Compare commits

...
3 Commits
Author SHA1 Message Date
phundrak 72da663163 Variables documentation 2020-01-29 22:01:38 +01:00
phundrak 6f26d36bae Simplified tree-to-dot 2020-01-29 21:49:21 +01:00
phundrak a14464f407 Now a proper variable with documentation 2020-01-29 21:48:56 +01:00
+157 -148
View File
@@ -15,52 +15,43 @@
(defun conlanging//declare-node (node-text node-generation)
"Declares a node in the graphviz source code. The node’s identifier will be
~node-generation~, and it will bear the label ~node-text~."
(concat (number-to-string node-generation)
"[label=\""
node-text
"\"];"))
(format "%d[label=\"%s\"];\n" node-generation
node-text))
(defun conlanging//make-link (previous-node current-node)
"This creates a link in the graphviz source code between the two nodes
bearing ~previous-node~ and ~current-node~ respectively as their node
identifier."
(concat (number-to-string previous-node) " -- "
(number-to-string current-node) ";"))
(defun conlanging//tree-to-dot-helper (tree current-generation previous-generation)
"Helper to ~tree-to-dot~ that translates an Elisp tree with any number of
children per node to a corresponding graphviz file that can be executed from
dot.
(defun conlanging/tree-to-dot (tree &optional current-generation previous-generation)
"Translates an Elisp tree with any number of children per node
to a corresponding graphviz file that can be executed from dot.
Arguments:
- tree :: tree-to-convert
- current-generation :: Generation number, incremented when changing from a node
to another node from the same generation, multiplied by 10 when going from
a node to one of its children.
- previous-generation :: generation number from previous named node"
- `tree': tree to convert
- `current-generation': generation number, incremented when
changing from a node to another node from the same generation,
multiplied by 10 when going from a node to one of its children.
- `previous-generation': generation number from previous named
node"
(cond
((null tree) "")
((atom (car tree)) ;; '("text" () () ())
(concat (conlanging//declare-node (car tree) current-generation)
(conlanging//make-link previous-generation current-generation)
(conlanging//tree-to-dot-helper (cdr tree)
(+ 1 (* 10 current-generation))
current-generation)))
((listp (car tree)) ;; '(() () ())
(concat (conlanging//tree-to-dot-helper (car tree) ;; child of current node
current-generation
previous-generation)
(conlanging//tree-to-dot-helper (cdr tree)
(+ 1 current-generation)
previous-generation)))))
(defun conlanging/tree-to-dot (tree)
"Returns a graphviz’s dot compatible string representing an Elisp tree"
(if (null tree) ""
(concat
"graph{graph[dpi=300];node[shape=plaintext];graph[bgcolor=\"transparent\"];"
(conlanging//declare-node (car tree) 0)
(conlanging//tree-to-dot-helper (cdr tree) 1 0)
"}")))
((null previous-generation) ;; first call
(concat "graph{graph[dpi=300];node[shape=plaintext];graph[bgcolor=\"transparent\"];\n"
(conlanging//declare-node (car tree) 0)
(conlanging/tree-to-dot (cdr tree) 1 0)
"}"))
((null tree) "") ;; last call in this branch
((atom (car tree)) ;; '("text" () () ()) manage the label
(concat (conlanging//declare-node (car tree)
current-generation)
;; make link
(concat (number-to-string previous-generation) " -- "
(number-to-string current-generation) ";\n")
(conlanging/tree-to-dot (cdr tree)
(+ 1
(* 10 current-generation))
current-generation)))
((listp (car tree)) ;; '(() () ()) manage the branches
(concat (conlanging/tree-to-dot (car tree) ;; child of current node
current-generation
previous-generation)
(conlanging/tree-to-dot (cdr tree)
(+ 1 current-generation)
previous-generation)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Common ;
@@ -120,70 +111,81 @@ whose first element equals `elem'"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Mattér ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq conlanging//matter-latin-to-runes '((", *" . "᛬")
("\\. *" . "᛭")
(" +" . "᛫")
("ċ" . "ᛇ")
("ch" . "ᛇ")
("ae" . "ᚫ")
("æ" . "ᚫ")
("dh" . "ᛋ")
("z" . "ᛋ")
("ð" . "ᛋ")
("th" . "ᚦ")
("s" . "ᚦ")
("þ" . "ᚦ")
("w" . "ᚹ")
("ƿ" . "ᚹ")
("g" . "ᚷ")
("ᵹ" . "ᚷ")
("ea" . "ᛠ")
("f" . "ᚠ")
("u" . "ᚢ")
("o" . "ᚩ")
("r" . "ᚱ")
("c" . "ᚳ")
("h" . "ᚻ")
("n" . "ᚾ")
("i" . "ᛁ")
("j" . "ᛄ")
("p" . "ᛈ")
("v" . "ᛝ")
("t" . "ᛏ")
("b" . "ᛒ")
("e" . "ᛖ")
("m" . "ᛗ")
("l" . "ᛚ")
("d" . "ᛞ")
("é" . "ᛟ")
("a" . "ᚪ")
("y" . "ᚣ")))
(defvar conlanging//matter-latin-to-runes '((", *" . "᛬")
("\\. *" . "᛭")
(" +" . "᛫")
("ċ" . "ᛇ")
("ch" . "ᛇ")
("ae" . "ᚫ")
("æ" . "ᚫ")
("dh" . "ᛋ")
("z" . "ᛋ")
("ð" . "ᛋ")
("th" . "ᚦ")
("s" . "ᚦ")
("þ" . "ᚦ")
("w" . "ᚹ")
("ƿ" . "ᚹ")
("g" . "ᚷ")
("ᵹ" . "ᚷ")
("ea" . "ᛠ")
("f" . "ᚠ")
("u" . "ᚢ")
("o" . "ᚩ")
("r" . "ᚱ")
("c" . "ᚳ")
("h" . "ᚻ")
("n" . "ᚾ")
("i" . "ᛁ")
("j" . "ᛄ")
("p" . "ᛈ")
("v" . "ᛝ")
("t" . "ᛏ")
("b" . "ᛒ")
("e" . "ᛖ")
("m" . "ᛗ")
("l" . "ᛚ")
("d" . "ᛞ")
("é" . "ᛟ")
("a" . "ᚪ")
("y" . "ᚣ"))
"Equivalence between the Mattér orthography in the Latin script
and the Runic script. The first element of a pair is the Latin
script orthography, the second is the Runic equivalent.")
(setq conlanging//matter-latin-to-native '((" +" . " ")
("ch" . "ċ")
("ae" . "æ")
("th" . "þ")
("s" . "þ")
("dh" . "ð")
("z" . "ð")
("w" . "ƿ")
("j" . "i")))
(defvar conlanging//matter-latin-to-native '((" +" . " ")
("ch" . "ċ")
("ae" . "æ")
("th" . "þ")
("s" . "þ")
("dh" . "ð")
("z" . "ð")
("w" . "ƿ")
("j" . "i"))
"Equivalence between the Mattér orthography in its native Latin
script and the transliterated Mattér Latin script. The first
element of a pair is the transliterated Latin script orthography,
the second is the native Latin script equivalent.")
(setq conlanging//matter-latin-to-latex '((", *" . ":")
("\\. *" . "*")
(" +" . ".")
("ch" . "I")
("ċ" . "I")
("ae" . "æ")
("ea" . "\\\\ea")
("ƿ" . "w")
("dh" . "s")
("z" . "s")
("ð" . "s")
("th" . "þ")
("s" . "þ")
("v" . "\\\\ng")
("é " . "\\\\oe")))
(defvar conlanging//matter-latin-to-latex '((", *" . ":")
("\\. *" . "*")
(" +" . ".")
("ch" . "I")
("ċ" . "I")
("ae" . "æ")
("ea" . "\\\\ea")
("ƿ" . "w")
("dh" . "s")
("z" . "s")
("ð" . "s")
("th" . "þ")
("s" . "þ")
("v" . "\\\\ng")
("é " . "\\\\oe"))
"Equivalence between the Mattér orthography in the Latin script
and the LaTeX code for the Runic script. The first element of a
pair is the Latin script orthography, the second is the Runic
LaTeX code equivalent.")
(defun conlanging/matter-to-runes ()
"Replaces transliterated Mattér with its runic writing system"
@@ -202,8 +204,8 @@ latin writing system"
(conlanging//replace-char-by-table conlanging//matter-latin-to-latex))
(defun conlanging/matter-org-export-runes (text)
"Replaces transliterated Mattér with its corresponding runes during org-mode
export"
"Replaces the transliterated Mattér `text' with its
corresponding runes during org-mode export"
(interactive)
(if (org-export-derived-backend-p org-export-current-backend
'latex)
@@ -215,48 +217,55 @@ export"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Eittlanda ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq conlanging//eittlanda-latin-to-latex '((", *" . "\\\\tripledot")
("\\. *" . "\\\\tripledot")
(" +" . ":")
("hv" . "x")
("ø" . "\\\\o")
("œ" . "\\\\oO")
("v" . "w")
("ó" . "v")
("ń" . "\\\\ndot")))
(defvar conlanging//eittlanda-latin-to-latex '((", *" . "\\\\tripledot")
("\\. *" . "\\\\tripledot")
(" +" . ":")
("hv" . "x")
("ø" . "\\\\o")
("œ" . "\\\\oO")
("v" . "w")
("ó" . "v")
("ń" . "\\\\ndot"))
"Equivalence between the Eittlandic orthography in the Latin
script and the LaTeX code for the Runic script. The first element
of a pair is the Latin script orthography, the second is the
Runic LaTeX code equivalent.")
(setq conlanging//eittlanda-latin-to-runes '((", *" . "⁝")
("\\. *" . "⁝")
(" +" . "᛬")
(":" . "᛬")
("hv" . "ᛪ")
("i" . "ᛁ")
("y" . "ᛦ")
("u" . "ᚢ")
("e" . "ᛂ")
("ø" . "ᚯ")
("o" . "ᚮ")
("œ" . "ᚰ")
("ó" . "ᚤ")
("æ" . "ᛅ")
("a" . "ᛆ")
("m" . "ᛘ")
("n" . "ᚾ")
("ń" . "ᛀ")
("p" . "ᛔ")
("b" . "ᛒ")
("t" . "ᛐ")
("d" . "ᛑ")
("k" . "ᚴ")
("g" . "ᚵ")
("f" . "ᚠ")
("þ" . "ᚦ")
("ð" . "ᚧ")
("s" . "ᛋ")
("h" . "ᚼ")
("v" . "ᚥ")
("r" . "ᚱ")
("l" . "ᛚ")))
(defvar conlanging//eittlanda-latin-to-runes '((", *" . "⁝")
("\\. *" . "⁝")
(" +" . "᛬")
(":" . "᛬")
("hv" . "ᛪ")
("i" . "ᛁ")
("y" . "ᛦ")
("u" . "ᚢ")
("e" . "ᛂ")
("ø" . "ᚯ")
("o" . "ᚮ")
("œ" . "ᚰ")
("ó" . "ᚤ")
("æ" . "ᛅ")
("a" . "ᛆ")
("m" . "ᛘ")
("n" . "ᚾ")
("ń" . "ᛀ")
("p" . "ᛔ")
("b" . "ᛒ")
("t" . "ᛐ")
("d" . "ᛑ")
("k" . "ᚴ")
("g" . "ᚵ")
("f" . "ᚠ")
("þ" . "ᚦ")
("ð" . "ᚧ")
("s" . "ᛋ")
("h" . "ᚼ")
("v" . "ᚥ")
("r" . "ᚱ")
("l" . "ᛚ"))
"Equivalence between the Eittlandic orthography in the Latin
script and the Runic script. The first element of a pair is the
Latin script orthography, the second is the Runic equivalent.")
(defun conlanging/eittlanda-to-runes ()
"Replaces transliterated Eittlandic with its runic writing system"