Compare commits
6 Commits
b00e7f839a
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
6a182b2085
|
|||
|
15ae526299
|
|||
|
ea8d089e80
|
|||
|
f1a938cfc9
|
|||
|
103d096091
|
|||
|
9d29817ef1
|
104
README.org
104
README.org
@@ -1,7 +1,9 @@
|
||||
[[file:https://cdn.rawgit.com/syl20bnr/spacemacs/442d025779da2f62fc86c2082703697714db6514/assets/spacemacs-badge.svg]]
|
||||
|
||||
#+TITLE: Conlanging layer
|
||||
#+author: Lucien “P’undrak” Cartier-Tilet
|
||||
#+AUTHOR: Lucien “P’undrak” Cartier-Tilet
|
||||
#+PROPERTY: header-args :noweb yes :exports code
|
||||
#+PROPERTY: header-args:dot :tangle no :exports code
|
||||
|
||||
[[img/conlang_flag.png]]
|
||||
|
||||
@@ -10,7 +12,10 @@
|
||||
- [[#features][Features]]
|
||||
- [[#graphviz-trees][Graphviz trees]]
|
||||
- [[#install][Install]]
|
||||
- [[#key-bindings][Key bindings]]
|
||||
- [[#licence][Licence]]
|
||||
- [[#documentation][Documentation]]
|
||||
- [[#functionalities][Functionalities]]
|
||||
- [[#graphviz-trees-generation][Graphviz trees generation]]
|
||||
|
||||
* Description
|
||||
This layer adds features for conlanging.
|
||||
@@ -83,19 +88,84 @@
|
||||
You can then reload your configuration file with ~SPC f e R~, or restart Emacs
|
||||
with ~SPC q r~ or ~SPC q R~.
|
||||
|
||||
* Key bindings
|
||||
* Licence
|
||||
All the code included in this repository is licensed under the GPLv3 license.
|
||||
See [[file:LICENCE]].
|
||||
|
||||
| Key Binding | Description |
|
||||
|---------------+-----------------------------------------------------------------------|
|
||||
| ~SPC m l e l~ | (org-mode only) Translate Eittlandic transliteration into LaTeX runes |
|
||||
| ~SPC m l e r~ | (org-mode only) Translate Eittlandic transliteration into runes |
|
||||
| ~SPC m l m L~ | (org-mode only) Translate Mattér transliteration into LaTeX runes |
|
||||
| ~SPC m l m l~ | (org-mode only) Translate Mattér transliteration into native latin |
|
||||
| ~SPC m l m r~ | (org-mode only) Translate Mattér transliteration into runes |
|
||||
| ~SPC o l e o~ | Open Eittlandic file |
|
||||
| ~SPC o l h o~ | Open Hjelp file |
|
||||
| ~SPC o l m o~ | Open Mattér file |
|
||||
| ~SPC o l n o~ | Open Proto-Ñyqy file |
|
||||
| ~SPC o l o~ | Open the working conlanging directory |
|
||||
| ~SPC o l O~ | Open the root conlanging directory |
|
||||
| ~SPC o l t o~ | Open Proto-Tãso file |
|
||||
* Documentation
|
||||
The following is the documentation of the source code of the ~conlanging~
|
||||
layer. It is divided in two main parts, describing the two main files of the
|
||||
layer: ~funcs.el~ and ~keybindings.el~. First of all, let’s simply describe
|
||||
the ~layer.el~ file.
|
||||
#+BEGIN_SRC emacs-lisp :tangle layers.el
|
||||
(configuration-layer/declare-layer 'conlanging)
|
||||
#+END_SRC
|
||||
|
||||
And that’s enough for the ~layer.el~ file! Now, onto the ~funcs.el~ file.
|
||||
|
||||
** Functionalities
|
||||
:PROPERTIES:
|
||||
:HEADER-ARGS: :tangle funcs.el
|
||||
:END:
|
||||
Here will be detailed the functionalities of the ~conlanging~ layer. It can
|
||||
be divided in several parts.
|
||||
|
||||
*** Graphviz trees generation
|
||||
As described above, it is possible to create graphviz trees from Elisp trees
|
||||
made from lists. This feature is coded in two functions: one that creates
|
||||
the tree itself, and one that generates nodes. The first one that generates
|
||||
nodes is declared as a private function (actually, it’s just prefixed with
|
||||
~conlanging//~ following Spacemacs’ [[https://www.spacemacs.org/doc/CONVENTIONS.html#spacemacs-core-and-layer][naming convention]]).
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun conlanging//declare-node (t-node-text t-node-generation)
|
||||
"Declares a node in the graphviz source code. The node’s identifier will be
|
||||
`t-node-generation', and it will bear the label `t-node-text'."
|
||||
(format "%d[label=\"%s\"];" t-node-generation
|
||||
t-node-text))
|
||||
#+END_SRC
|
||||
|
||||
This can result in a graphviz node declared like so:
|
||||
#+BEGIN_SRC dot
|
||||
231[label="This is a label"];
|
||||
#+END_SRC
|
||||
|
||||
All nodes generated by the function have a unique identifier in the form of
|
||||
a number, and its content is only defined by its label. By default, the tree
|
||||
created from the graphviz code gives a tree from top to bottom with the
|
||||
label not surrounded by anything. Let’s declare our whole function:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun conlanging/tree-to-dot (t-tree &optional t-current-generation t-previous-generation)
|
||||
"Translates an Elisp t-tree with any number of children per node
|
||||
to a corresponding graphviz file that can be executed from dot.
|
||||
Arguments:
|
||||
- `t-tree': t-tree to convert
|
||||
- `t-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.
|
||||
- `t-previous-generation': generation number from previous named
|
||||
node"
|
||||
(cond
|
||||
((null t-previous-generation) ;; first call
|
||||
(concat "graph{graph[dpi=300];node[shape=plaintext];graph[bgcolor=\"transparent\"];"
|
||||
(conlanging//declare-node (car t-tree) 0)
|
||||
(conlanging/tree-to-dot (cdr t-tree) 1 0)
|
||||
"}"))
|
||||
((null t-tree) "") ;; last call in this branch
|
||||
((atom (car t-tree)) ;; '("text" () () ()) manage the label
|
||||
(concat (conlanging//declare-node (car t-tree)
|
||||
t-current-generation)
|
||||
;; make link
|
||||
(concat (number-to-string t-previous-generation) " -- "
|
||||
(number-to-string t-current-generation) ";")
|
||||
(conlanging/tree-to-dot (cdr t-tree)
|
||||
(+ 1
|
||||
(* 10 t-current-generation))
|
||||
t-current-generation)))
|
||||
((listp (car t-tree)) ;; '(() () ()) manage the branches
|
||||
(concat (conlanging/tree-to-dot (car t-tree) ;; child of current node
|
||||
t-current-generation
|
||||
t-previous-generation)
|
||||
(conlanging/tree-to-dot (cdr t-tree)
|
||||
(+ 1 t-current-generation)
|
||||
t-previous-generation)))))
|
||||
#+END_SRC
|
||||
|
||||
105
funcs.el
105
funcs.el
@@ -14,7 +14,7 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(defun conlanging//declare-node (t-node-text t-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~."
|
||||
`node-generation', and it will bear the label `node-text'."
|
||||
(format "%d[label=\"%s\"];" t-node-generation
|
||||
t-node-text))
|
||||
|
||||
@@ -201,78 +201,75 @@ corresponding runes during org-mode export"
|
||||
(conlanging//replace-string-by-char t-text conlanging//matter-latin-to-runes)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Eittlanda ;
|
||||
; Eittlandic ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(defvar conlanging//eittlanda-latin-to-latex '((", *" . "\\\\tripledot")
|
||||
("\\. *" . "\\\\tripledot")
|
||||
(" +" . ":")
|
||||
("hv" . "x")
|
||||
("ø" . "\\\\o")
|
||||
("œ" . "\\\\oO")
|
||||
("v" . "w")
|
||||
("ó" . "v")
|
||||
("ń" . "\\\\ndot"))
|
||||
(defvar conlanging//eittlandic-latin-to-latex '((", *\\|\\. *" . "\\\\tripledot")
|
||||
(" +" . ":")
|
||||
("hv" . "x")
|
||||
("í" . "i")
|
||||
("é" . "\\\\e")
|
||||
("ę\\|æ" . "æ")
|
||||
("ý" . "y")
|
||||
("œ" . "ø")
|
||||
("ú" . "u")
|
||||
("ó" . "o")
|
||||
("á\\|ǫ" . "a")
|
||||
("j" . "i"))
|
||||
"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.")
|
||||
|
||||
(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" . "ᛚ"))
|
||||
(defvar conlanging//eittlandic-latin-to-runes '((", *\\|\\. *" . "⁝")
|
||||
(" +\\|:" . "᛬")
|
||||
("hv" . "ᛪ")
|
||||
("i\\|í\\|j" . "ᛁ")
|
||||
("é" . "ᛂ")
|
||||
("e\\|ę\\|æ" . "ᛅ")
|
||||
("y\\|ý" . "ᛦ")
|
||||
("ø\\|œ" . "ᚯ")
|
||||
("u\\|ú\\|v\\|w" . "ᚢ")
|
||||
("o\\|ó" . "ᚮ")
|
||||
("a\\|á\\|ǫ" . "ᛆ")
|
||||
("p" . "ᛔ")
|
||||
("b" . "ᛒ")
|
||||
("f" . "ᚠ")
|
||||
("t" . "ᛐ")
|
||||
("d" . "ᛑ")
|
||||
("þ" . "ᚦ")
|
||||
("ð" . "ᚧ")
|
||||
("s" . "ᛋ")
|
||||
("k" . "ᚴ")
|
||||
("g" . "ᚵ")
|
||||
("h" . "ᚼ")
|
||||
("m" . "ᛘ")
|
||||
("n" . "ᚿ")
|
||||
("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 ()
|
||||
(defun conlanging/eittlandic-to-runes ()
|
||||
"Replaces transliterated Eittlandic with its runic writing system"
|
||||
(interactive)
|
||||
(conlanging//replace-char-by-table conlanging//eittlanda-latin-to-runes))
|
||||
(conlanging//replace-char-by-table conlanging//eittlandic-latin-to-runes))
|
||||
|
||||
(defun conlanging/eittlanda-to-latex ()
|
||||
(defun conlanging/eittlandic-to-latex ()
|
||||
"Replaces transliterated Eittlandic with its corresponding runes"
|
||||
(interactive)
|
||||
(conlanging//replace-char-by-table conlanging//eittlanda-latin-to-latex))
|
||||
(conlanging//replace-char-by-table conlanging//eittlandic-latin-to-latex))
|
||||
|
||||
(defun conlanging/eittlanda-org-export-runes (t-text)
|
||||
(defun conlanging/eittlandic-org-export-runes (t-text)
|
||||
"Replaces transliterated Eittlandic with its corresponding
|
||||
runes during org-mode export"
|
||||
(interactive)
|
||||
(if (org-export-derived-backend-p org-export-current-backend
|
||||
'latex)
|
||||
(concat "\\textarm{"
|
||||
(conlanging//replace-string-by-char t-text conlanging//eittlanda-latin-to-latex)
|
||||
(conlanging//replace-string-by-char t-text conlanging//eittlandic-latin-to-latex)
|
||||
"}")
|
||||
(conlanging//replace-string-by-char t-text conlanging//eittlanda-latin-to-runes)))
|
||||
(conlanging//replace-string-by-char t-text conlanging//eittlandic-latin-to-runes)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Ñyqy ;
|
||||
@@ -280,8 +277,8 @@ runes during org-mode export"
|
||||
(defvar conlanging//nyqy-phonetics '(("q" t t "q" "ħ")
|
||||
("g" t t "ɢ" "ʢ")
|
||||
("ñ" t t "ɴ" "m")
|
||||
("c" t t "t͡ʃ" "ɬ")
|
||||
("j" t t "d͡ʒ" "ɮ")
|
||||
("c" t t "c" "ɬ")
|
||||
("j" t t "ɟ" "ɮ")
|
||||
("w" t t "w" "l")
|
||||
("p" t nil "χ" "p")
|
||||
("b" t nil "ʁ" "b")
|
||||
@@ -293,8 +290,8 @@ runes during org-mode export"
|
||||
("ú" nil "u")
|
||||
("i" nil "ɪ")
|
||||
("u" nil "ʊ")
|
||||
("é" nil "ø")
|
||||
("ó" nil "ɤ")
|
||||
("ø" nil "ø")
|
||||
("œ" nil "ɤ")
|
||||
("e" nil "ɛ")
|
||||
("o" nil "ɔ")
|
||||
(" " nil " ")
|
||||
|
||||
@@ -9,53 +9,6 @@
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(spacemacs/declare-prefix "ol" "conlanging")
|
||||
(spacemacs/declare-prefix "olh" "Hjelp")
|
||||
(spacemacs/declare-prefix "olho" "hjelp.org")
|
||||
(spacemacs/declare-prefix "olm" "Mattér")
|
||||
(spacemacs/declare-prefix "olmo" "matter.org")
|
||||
(spacemacs/declare-prefix "ole" "Eittlandic")
|
||||
(spacemacs/declare-prefix "oleo" "eittland.org")
|
||||
(spacemacs/declare-prefix "oln" "Proto-Ñyqy")
|
||||
(spacemacs/declare-prefix "olno" "proto-nyqy.org")
|
||||
(spacemacs/declare-prefix "olne" "nyqy.org (English)")
|
||||
(spacemacs/declare-prefix "olo" "Conlang root directory")
|
||||
(spacemacs/declare-prefix "olo" "Conlang directory")
|
||||
(spacemacs/declare-prefix "olt" "Proto-Tãso")
|
||||
(spacemacs/declare-prefix "olto" "proto-taso.org")
|
||||
(spacemacs/declare-prefix-for-mode 'org-mode
|
||||
"ml" "conlanging")
|
||||
(spacemacs/declare-prefix-for-mode 'org-mode
|
||||
"mle" "Eittlanda")
|
||||
(spacemacs/declare-prefix-for-mode 'org-mode
|
||||
"mlm" "Mattér")
|
||||
|
||||
(spacemacs/set-leader-keys
|
||||
"oleo" (lambda ()
|
||||
(interactive)
|
||||
(find-file "~/Documents/conlanging/content/eittland.org"))
|
||||
"olho" (lambda ()
|
||||
(interactive)
|
||||
(find-file "~/Documents/conlanging/content/hjelp.org"))
|
||||
"olmo" (lambda ()
|
||||
(interactive)
|
||||
(find-file "~/Documents/conlanging/content/matter.org"))
|
||||
"olno" (lambda ()
|
||||
(interactive)
|
||||
(find-file "~/Documents/conlanging/content/proto-nyqy.org"))
|
||||
"olne" (lambda ()
|
||||
(interactive)
|
||||
(find-file "~/Documents/conlanging/content/en/nyqy.org"))
|
||||
"olO" (lambda ()
|
||||
(interactive)
|
||||
(dired "~/Documents/conlanging/"))
|
||||
"olo" (lambda ()
|
||||
(interactive)
|
||||
(dired "~/Documents/conlanging/content"))
|
||||
"olto" (lambda ()
|
||||
(interactive)
|
||||
(find-file "~/Documents/conlanging/content/proto-taso.org")))
|
||||
|
||||
(spacemacs/set-leader-keys-for-major-mode 'org-mode
|
||||
"ler" 'conlanging/eittlanda-to-runes
|
||||
"lel" 'conlanging/eittlanda-to-latex
|
||||
|
||||
Reference in New Issue
Block a user