moved elisp function from header to Emacs config

The project is now dependent on my Spacemacs layer `conlanging'
https://labs.phundrak.fr/phundrak/conlang-layer
This commit is contained in:
Phuntsok Drak-pa 2019-09-15 15:25:51 +02:00
parent 5b6b1ecff9
commit 5f01ed0628
6 changed files with 17 additions and 79 deletions

View File

@ -685,7 +685,6 @@
#+NAME: vow-dot
#+BEGIN_SRC emacs-lisp :noweb yes :exports none :eval yes :cache yes
<<tree-dot>>
(setq-local eittlandic-vowels
'("vowels"
("[high]"
@ -706,10 +705,10 @@
("[low]" ("/æ/"))
("{low}" ("/e/")))
("{tense}" ("/ɑ/"))))))
(tree-to-dot eittlandic-vowels)
(conlanging/tree-to-dot eittlandic-vowels)
#+END_SRC
#+RESULTS[5d8b0c4772f3a9108690df7c578138d3eb4206af]: vow-dot
#+RESULTS[b7b678da629a411fee0918a5634d09a825f51e14]: vow-dot
: graph{node[shape=plaintext];graph[bgcolor="transparent"];0[label="vowels"];1[label="[high]"];0 -- 1;11[label="[rnd]"];1 -- 11;111[label="[front]"];11 -- 111;1111[label="/y/"];111 -- 1111;112[label="{front}"];11 -- 112;1121[label="/u/"];112 -- 1121;12[label="{rnd}"];1 -- 12;121[label="/i/"];12 -- 121;2[label="{high}"];0 -- 2;21[label="[rnd]"];2 -- 21;211[label="[tense]"];21 -- 211;2111[label="[front]"];211 -- 2111;21111[label="/ø/"];2111 -- 21111;2112[label="{front}"];211 -- 2112;21121[label="/o/"];2112 -- 21121;212[label="{tense}"];21 -- 212;2121[label="[front]"];212 -- 2121;21211[label="/œ/"];2121 -- 21211;2122[label="{front}"];212 -- 2122;21221[label="/ɔ/"];2122 -- 21221;22[label="{rnd}"];2 -- 22;221[label="[tense]"];22 -- 221;2211[label="[low]"];221 -- 2211;22111[label="/æ/"];2211 -- 22111;2212[label="{low}"];221 -- 2212;22121[label="/e/"];2212 -- 22121;222[label="{tense}"];22 -- 222;2221[label="/ɑ/"];222 -- 2221;}
#+BEGIN_SRC dot :file img/eittlanda/vowel-feature-tree.png :var input=vow-dot :exports results :cache yes
@ -907,7 +906,6 @@
#+NAME: cons-dot
#+BEGIN_SRC emacs-lisp :noweb yes :exports none :eval yes :cache yes
<<tree-dot>>
(setq-local eittlandic-consonants
'("consonants"
("[occ]"
@ -946,7 +944,7 @@
("[rnd]" ("/w/"))
("{rnd}" ("/j/")))
("{dor}" ("/h/"))))))
(tree-to-dot eittlandic-consonants)
(conlanging/tree-to-dot eittlandic-consonants)
#+END_SRC
#+RESULTS[c1e5eb5b47dfd5f34797276fc1515955532b2d14]: cons-dot

View File

@ -9,61 +9,6 @@
#+OPTIONS: H:4 broken_links:mark email:t ^:{} tex:dvisvgm
#+KEYWORDS: conlang idéolangue langue langues linguistique phundrak drakpa
# ### CODE #####################################################################
#+NAME: tree-dot
#+BEGIN_SRC emacs-lisp :noweb yes :exports none :eval yes
(defun declare-node (node-text node-generation)
"Declares a node in the graphviz source code. The nodes identifier will be
~node-generation~, and it will bear the label ~node-text~."
(concat (number-to-string node-generation)
"[label=\""
node-text
"\"];"))
(defun 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 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.
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"
(cond
((null tree) "")
((atom (car tree)) ;; '("text" () () ())
(concat (declare-node (car tree) current-generation)
(make-link previous-generation current-generation)
(tree-to-dot-helper (cdr tree)
(+ 1 (* 10 current-generation))
current-generation)))
((listp (car tree)) ;; '(() () ())
(concat (tree-to-dot-helper (car tree) ;; child of current node
current-generation
previous-generation)
(tree-to-dot-helper (cdr tree)
(+ 1 current-generation)
previous-generation)))))
(defun tree-to-dot (tree)
"Returns a graphvizs dot compatible string representing an Elisp tree"
(if (null tree) ""
(concat
"graph{node[shape=plaintext];graph[bgcolor=\"transparent\"];"
(declare-node (car tree) 0)
(tree-to-dot-helper (cdr tree) 1 0)
"}")))
#+END_SRC
# ### LaTeX ####################################################################
#+LATEX_CLASS: conlang

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -188,7 +188,6 @@
#+NAME: cons-tree
#+BEGIN_SRC emacs-lisp :noweb yes :exports none :eval yes :cache yes
<<tree-dot>>
(setq-local nyqy-consonants
'("[cons]"
("[son]"
@ -213,7 +212,7 @@
("{voice}"
("[cor]")
("{cor}"))))))
(tree-to-dot nyqy-consonants)
(conlanging/tree-to-dot nyqy-consonants)
#+END_SRC
#+BEGIN_SRC dot :file img/nyqy/consonant-feature-tree.png :var input=cons-tree :exports results :eval yes :cache yes
@ -308,7 +307,6 @@
#+NAME: vow-tree
#+BEGIN_SRC emacs-lisp :noweb yes :exports none :eval yes :cache yes
<<tree-dot>>
(setq-local nyqy-vowels
'("[vowel]"
("[back]"
@ -325,7 +323,7 @@
("{tense}"
("[high]" ("i"))
("{high}" ("e"))))))
(tree-to-dot nyqy-vowels)
(conlanging/tree-to-dot nyqy-vowels)
#+END_SRC
#+BEGIN_SRC dot :file img/nyqy/vowel-feature-tree.png :var input=vow-tree :exports results :eval yes :cache yes
@ -704,7 +702,6 @@
#+NAME: basic-syntax-tree
#+BEGIN_SRC emacs-lisp :noweb yes :exports none :eval yes :cache yes
<<tree-dot>>
(setq-local nyqy-syntax-tree
'("S"
("Obl")
@ -726,7 +723,7 @@
("Tense")
("V")
("Neg")))))))
(tree-to-dot nyqy-syntax-tree)
(conlanging/tree-to-dot nyqy-syntax-tree)
#+END_SRC
#+BEGIN_SRC dot :file img/nyqy/basic-syntax.png :var input=basic-syntax-tree :exports results :eval yes :cache yes

View File

@ -421,7 +421,6 @@
#+NAME: vow-tree
#+BEGIN_SRC emacs-lisp :noweb yes :exports none :eval yes :cache yes
<<tree-dot>>
(setq-local nyqy-vowels
'("[vowel]"
("[back]"
@ -438,7 +437,7 @@
("{tense}"
("[high]" ("i"))
("{high}" ("e"))))))
(tree-to-dot nyqy-vowels)
(conlanging/tree-to-dot nyqy-vowels)
#+END_SRC
#+BEGIN_SRC dot :file img/nyqy/vowel-feature-tree.png :var input=vow-tree :exports results :eval yes :cache yes
@ -457,7 +456,6 @@
:END:
#+NAME: cons-tree
#+BEGIN_SRC emacs-lisp :noweb yes :exports none :eval yes :cache yes
<<tree-dot>>
(setq-local nyqy-consonants
'("[cons]"
("[son]"
@ -482,7 +480,7 @@
("{voice}"
("[cor]")
("{cor}"))))))
(tree-to-dot nyqy-consonants)
(conlanging/tree-to-dot nyqy-consonants)
#+END_SRC
#+BEGIN_SRC dot :file img/nyqy/consonant-feature-tree.png :var input=cons-tree :exports results :eval yes :cache yes
@ -624,9 +622,9 @@
| d͡ʒ | ɮ | | | s | x |
| w | l | | | z | ɣ |
Ainsi, la phrase {{{nyqy(ňe pom qy)}}} ne se prononce pas *{{{phon(ɴɛ pɔm
qy)}}}, et la phrase {{{nyqy(qi bú pim mo coq)}}} se ne prononce pas
*{{{phon(qɪ bʊ pɪm mɔ t͡ʃɔq)}}}.
Ainsi, la phrase {{{nyqy(ňe pom qy)}}} ne se prononce pas *{{{phon(ɴɛ pɔm
qy)}}}, et la phrase {{{nyqy(qi bú pim mo coq)}}} se ne prononce pas
*{{{phon(qɪ bʊ pɪm mɔ t͡ʃɔq)}}}.
** Structure des mots
:PROPERTIES:
@ -762,7 +760,6 @@
#+NAME: basic-syntax-tree
#+BEGIN_SRC emacs-lisp :noweb yes :exports none :eval yes :cache yes
<<tree-dot>>
(setq-local nyqy-syntax-tree
'("S"
("Obl")
@ -784,9 +781,12 @@
("Tense")
("V")
("Neg")))))))
(tree-to-dot nyqy-syntax-tree)
(conlanging/tree-to-dot nyqy-syntax-tree)
#+END_SRC
#+RESULTS[24286e618306da25dc9283fdc01819e3b5d77394]: basic-syntax-tree
: graph{node[shape=plaintext];graph[bgcolor="transparent"];0[label="S"];1[label="Obl"];0 -- 1;2[label="S'"];0 -- 2;21[label="NPerg"];2 -- 21;211[label="NP"];21 -- 211;22[label="VP"];2 -- 22;221[label="NPdat"];22 -- 221;2211[label="NP"];221 -- 2211;222[label="VP'"];22 -- 222;2221[label="NPabs"];222 -- 2221;22211[label="NP"];2221 -- 22211;222111[label="S"];22211 -- 222111;222112[label="NP'"];22211 -- 222112;2221121[label="Adj"];222112 -- 2221121;2221122[label="N"];222112 -- 2221122;2222[label="V'"];222 -- 2222;22221[label="Mood"];2222 -- 22221;22222[label="Tense"];2222 -- 22222;22223[label="V"];2222 -- 22223;22224[label="Neg"];2222 -- 22224;}
#+BEGIN_SRC dot :file img/nyqy/basic-syntax.png :var input=basic-syntax-tree :exports results :eval yes :cache yes
$input
#+END_SRC

View File

@ -169,7 +169,6 @@
#+NAME: vowel-tree
#+BEGIN_SRC emacs-lisp :noweb yes :exports none :eval yes :cache yes
<<tree-dot>>
(setq-local taso-vowels
'("vowel"
("[high]"
@ -198,7 +197,7 @@
("{frnt}"
("[tense]" ("ɤ"))
("{tense}" ("a")))))))
(tree-to-dot taso-vowels)
(conlanging/tree-to-dot taso-vowels)
#+END_SRC
#+BEGIN_SRC dot :file img/taso/vowel-feature-tree.png :var input=vowel-tree :exports results :eval yes :cache yes
@ -226,7 +225,6 @@
:END:
#+NAME: cons-tree
#+BEGIN_SRC emacs-lisp :noweb yes :exports none :eval yes :cache yes
<<tree-dot>>
(setq-local taso-consonants
'("consonant"
("[son]"
@ -277,7 +275,7 @@
("{cont}"
("[voice]" ("b"))
("{voice}" ("p"))))))))
(tree-to-dot taso-consonants)
(conlanging/tree-to-dot taso-consonants)
#+END_SRC
#+BEGIN_SRC dot :file img/taso/consonant-feature-tree.png :var input=cons-tree :exports results :eval yes :cache yes