Compare commits

...

19 Commits

Author SHA1 Message Date
6a182b2085 Remove keybindings fro opening files 2020-12-27 15:14:46 +01:00
15ae526299 Proto-Ñyqy orthography change 2020-11-10 15:50:18 +01:00
ea8d089e80 Fix formatting of documentation 2020-10-01 09:57:41 +02:00
f1a938cfc9 Updated Proto-Ñyqy phonetics 2020-08-22 13:05:37 +02:00
103d096091 Updated the Eittlandic runic alphabet 2020-08-22 13:04:51 +02:00
9d29817ef1 beginning litterate programming 2020-06-01 18:00:31 +02:00
b00e7f839a Updated keybindings, file headers and updated README 2020-05-29 17:53:01 +02:00
955843d903 updated keybindings 2020-05-19 13:25:05 +02:00
cd94dc0011 Separated phonetics generation and org formatting 2020-05-01 22:58:33 +02:00
b9fff85970 Deleted conlanging//find-elem-in-list
Removed unused function
2020-03-25 12:27:56 +01:00
3e27453523 Code simplification
Simplified some code and calls, less `setq-local` delegated to `let*`
2020-03-25 12:27:07 +01:00
ea9637ff5a Updated naming convention
Arguments are now preceded by the prefix `t-`
2020-03-25 12:21:20 +01:00
81fc628935 updated keybindings for Eittlandic 2020-03-15 12:26:11 +01:00
557725ac74 removed debug help 2020-01-30 00:15:21 +01:00
72da663163 Variables documentation 2020-01-29 22:01:38 +01:00
6f26d36bae Simplified tree-to-dot 2020-01-29 21:49:21 +01:00
a14464f407 Now a proper variable with documentation 2020-01-29 21:48:56 +01:00
f65d603f8e Fixed issue with Ñyqy conversion function
Function used to ask for a mutated consonant if the initial word began
with a vowel. Also merged helper function with original function.
2020-01-29 21:17:55 +01:00
89d053b722 clearer HTML formatting 2020-01-15 12:44:40 +01:00
3 changed files with 393 additions and 338 deletions

View File

@@ -1,7 +1,9 @@
[[file:https://cdn.rawgit.com/syl20bnr/spacemacs/442d025779da2f62fc86c2082703697714db6514/assets/spacemacs-badge.svg]]
#+TITLE: Conlanging layer
#+author: Lucien “Pundrak” Cartier-Tilet
#+AUTHOR: Lucien “Pundrak” Cartier-Tilet
#+PROPERTY: header-args :noweb yes :exports code
#+PROPERTY: header-args:dot :tangle no :exports code
[[img/conlang_flag.png]]
@@ -10,16 +12,19 @@
- [[#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 support for conlanging.
This layer adds features for conlanging.
** Features
- Generate graphviz trees based on Elisp trees
- Replace some text by its runic equivalent (supports the Mattér and
Eittlandic languages)
- Adds phonetics to Ňyqy text
- Adds phonetics to Proto-Ñyqy text
- Provides custom shortcuts
** Graphviz trees
@@ -65,9 +70,9 @@
[[file:img/vowels-example.png]]
This example tree is only a binary tree, but a single node can have up to ten
children. See some examples in the [[https://labs.phundrak.fr/phundrak/langue-phundrak-fr/blob/master/nyqy.org][Ňyqy source file]].
children. See some examples in the [[https://labs.phundrak.com/phundrak/langue-phundrak-fr/blob/master/proto-nyqy.org][Ñyqy source file]].
It is planned to merge [[https://labs.phundrak.fr/phundrak/distinctive-features-chooser][this project]] into this layer in order to facilitate
It is planned to merge [[https://labs.phundrak.com/phundrak/distinctive-features-chooser][this project]] into this layer in order to facilitate
the creation of trees based on distinctive features.
* Install
@@ -83,18 +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 l e l~ | (org-mode only) Translate Einnlandish transliteration into native latin |
| ~SPC l e r~ | (org-mode only) Translate Einnlandish transliteration into runes |
| ~SPC l m L~ | (org-mode only) Translate Mattér transliteration into LaTeX runes |
| ~SPC l m l~ | (org-mode only) Translate Mattér transliteration into native latin |
| ~SPC 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 Ňyqy file |
| ~SPC o l o~ | Open the conlanging directory |
| ~SPC o l t o~ | Open 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, lets simply describe
the ~layer.el~ file.
#+BEGIN_SRC emacs-lisp :tangle layers.el
(configuration-layer/declare-layer 'conlanging)
#+END_SRC
And thats 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, its 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 nodes 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. Lets 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

549
funcs.el
View File

@@ -1,9 +1,9 @@
;;; funcs.el --- Conlanging Layer functions File for Spacemacs
;;
;; Copyright (c) 2019-2020 Lucien Cartier-Tilet
;; Copyright (c) 2018-2020 Lucien Cartier-Tilet
;;
;; Author: Lucien Cartier-Tilet <phundrak@phundrak.fr>
;; URL: https://github.com/syl20bnr/spacemacs
;; Author: Lucien Cartier-Tilet <lucien@phundrak.com>
;; URL: https://labs.phundrak.com/phundrak/conlang-layer
;;
;; This file is not part of GNU Emacs.
;;
@@ -12,55 +12,46 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Tree ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun conlanging//declare-node (node-text node-generation)
(defun conlanging//declare-node (t-node-text t-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
"\"];"))
`node-generation', and it will bear the label `node-text'."
(format "%d[label=\"%s\"];" t-node-generation
t-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 (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:
- 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"
- `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 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 graphvizs 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 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)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Common ;
@@ -82,13 +73,12 @@ table"
none the word the cursor is over"
(interactive)
(let* ((beg (region-beginning))
(end (region-end))
(boundary-word (bounds-of-thing-at-point 'word)))
(end (region-end)))
(if (= beg end)
boundary-word
(bounds-of-thing-at-point 'word)
(cons beg end))))
(defun conlanging//replace-char-by-table (correspondance-table)
(defun conlanging//replace-char-by-table (t-correspondance-table)
"Replaces selected texts strings according to the table passed
as argument. The table is a list of pairs, the first element of
the pair is a regex to be searched in the selected text and the
@@ -96,94 +86,92 @@ second element of the pair the string it has to be replaced
with."
(let* ((cur-boundary (conlanging//get-boundary))
(beg (car cur-boundary))
(end (cdr cur-boundary)))
(setq-local regionp
(buffer-substring-no-properties beg end))
(setq-local regionp
(conlanging//replace-string-by-char regionp
correspondance-table))
(end (cdr cur-boundary))
(regionp (buffer-substring-no-properties beg end))
(new-regionp (conlanging//replace-string-by-char regionp
t-correspondance-table)))
(delete-region beg end)
(goto-char beg)
(insert regionp)))
(defun conlanging//find-elem-in-list (elem list)
"In a list containing lists, returns the element of `list'
whose first element equals `elem'"
(if list
(if (string= (caar list)
elem)
(car list)
(conlanging//find-elem-in-list elem
(cdr list)))
nil))
(insert new-regionp)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 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"
@@ -201,162 +189,211 @@ latin writing system"
(interactive)
(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"
(defun conlanging/matter-org-export-runes (t-text)
"Replaces the transliterated Mattér `t-text' 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 text conlanging//matter-latin-to-latex)
(conlanging//replace-string-by-char t-text conlanging//matter-latin-to-latex)
"}")
(conlanging//replace-string-by-char text conlanging//matter-latin-to-runes)))
(conlanging//replace-string-by-char t-text conlanging//matter-latin-to-runes)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Eittlanda ;
; Eittlandic ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq 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.")
(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//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 (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 text conlanging//eittlanda-latin-to-latex)
(conlanging//replace-string-by-char t-text conlanging//eittlandic-latin-to-latex)
"}")
(conlanging//replace-string-by-char text conlanging//eittlanda-latin-to-runes)))
(conlanging//replace-string-by-char t-text conlanging//eittlandic-latin-to-runes)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Ñyqy ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq conlanging//nyqy-phonetics '(("q" t t "q" "ħ")
("g" t t "ɢ" "ʢ")
("ñ" t t "ɴ" "m")
("c" t t "t͡ʃ" "ɬ")
("j" t t "d͡ʒ" "ɮ")
("w" t t "w" "l")
("p" t nil "p" "χ")
("b" t nil "b" "ʁ")
("m" t nil "m" "ʀ")
("n" t nil "n" "j")
("s" t nil "s" "x")
("z" t nil "z" "ɣ")
("y" nil nil "y")
("ú" nil nil "u")
("i" nil nil "ɪ")
("u" nil nil "ʊ")
("é" nil nil "ø")
("ó" nil nil "ɤ")
("e" nil nil "ɛ")
("o" nil nil "ɔ")
(" " nil nil " ")
("," nil nil " ")
(";" nil nil " ")
("." nil nil " ")))
(defvar conlanging//nyqy-phonetics '(("q" t t "q" "ħ")
("g" t t "ɢ" "ʢ")
("ñ" t t "ɴ" "m")
("c" t t "c" "ɬ")
("j" t t "ɟ" "ɮ")
("w" t t "w" "l")
("p" t nil "χ" "p")
("b" t nil "ʁ" "b")
("m" t nil "ʀ" "m")
("n" t nil "j" "n")
("s" t nil "x" "s")
("z" t nil "ɣ" "z")
("y" nil "y")
("ú" nil "u")
("i" nil "ɪ")
("u" nil "ʊ")
("ø" nil "ø")
("œ" nil "ɤ")
("e" nil "ɛ")
("o" nil "ɔ")
(" " nil " ")
("," nil " ")
(";" nil " ")
("." nil " "))
"List of Ñyqy characters and their phonetics equivalent.
(defun conlanging//nyqy-is-consonant (elem)
(nth 1 elem))
The first value is the translitteration of a sound in Ñyqy. The
second is whether or not it represents a consonant.
(defun conlanging//nyqy-is-dorsal (elem)
(nth 2 elem))
If it is a consonant, then the third value is whether it is a
dorsal consonant by default or not. Then we have the consonant's
dorsal prononciation and its non-dorsal pronunciation.
(defun conlanging//nyqy-get-phoneme (consonant phon need-dorsal is-dorsal)
(nth (if (or (eq need-dorsal 2)
(not consonant))
3
(if (eq is-dorsal need-dorsal)
3
4))
phon))
If it is not a consonant, then the third value is its
pronunciation already.")
(defun conlanging//nyqy-convert (text phonetics need-dorsal)
"
need-dorsal: initial = 2, sinon t ou nil
"
(if (null text)
(mapconcat 'identity phonetics "")
(let* ((curr-char (car text))
(curr-phon-list (conlanging//find-elem-in-list curr-char conlanging//nyqy-phonetics))
(consonant (conlanging//nyqy-is-consonant curr-phon-list))
(dorsal (conlanging//nyqy-is-dorsal curr-phon-list))
(phon (conlanging//nyqy-get-phoneme consonant curr-phon-list
need-dorsal dorsal)))
(if (eq need-dorsal 2)
(setq-local need-dorsal dorsal))
(conlanging//nyqy-convert (cdr text)
(append phonetics
(list phon))
(if consonant
(not need-dorsal)
need-dorsal)))))
(defun conlanging//nyqy-is-consonant (t-elem)
(nth 1 t-elem))
(defun conlanging/nyqy-to-phonetics (text)
"Adds to Ñyqy text its phonetics equivalent, either as a
tooltip in HTML or as plain text appended in LaTeX.
(defun conlanging//nyqy-is-dorsal (t-elem)
(nth 2 t-elem))
(defun conlanging//nyqy-get-phoneme (t-phoneme &optional t-is-consonant t-is-dorsal)
"Extracts a phoneme from `t-phoneme'.
Arguments:
- text: text to convert to phonetics"
- `t-phoneme': array from `conlanging//nyqy-phonetics'
- `t-is-consonant': whether `t-phoneme' represents a
consonant (default: `nil')
- `t-is-dorsal': whether `t-phoneme' should be a dorsal
consonant (default: `nil')"
(if t-is-consonant
(if t-is-dorsal
(nth 3 t-phoneme)
(nth 4 t-phoneme))
(nth 2 t-phoneme)))
(defun conlanging/nyqy-to-phonetics (t-text &optional t-nyqy t-phonetics t-met-consonant
t-dorsal)
"Returns the phonetics equivalent of the Ñyqy `t-text'.
Arguments:
- `t-text': text to convert to phonetics
- `t-nyqy': for internal use only, `t-text' argument but as a
list of characters
- `t-phonetics': for internal use only, result phonetics, array
- `t-met-consonant': for internal use only, `t' if a consonant
has been met previously, `nil' otherwise
- `t-dorsal': for internal use only, `t' if the current consonant
is required to be dorsal, `nil' otherwise"
(interactive)
(setq-local phonetics
(conlanging//nyqy-convert (split-string (downcase text)
""
t)
()
2))
(concat "@@html:<span class=\"tooltip\"><i>"
text "</i><span class=\"tooltiptext\"> /" phonetics
"/</span></span>@@@@latex:\\textit{" text
"} (/" phonetics "/)@@"))
(cond
;; first call to the function
((eq nil t-phonetics)
(conlanging/nyqy-to-phonetics t-text
(split-string (downcase t-text) "" t)
""))
;; no more to convert
((eq nil t-nyqy)
t-phonetics)
;; default option
(t (let* ((cur-char (car t-nyqy)) ;; default option
(cur-phon (seq-find (lambda (elt)
(string= (car elt)
cur-char))
conlanging//nyqy-phonetics))
(is-consonant (conlanging//nyqy-is-consonant cur-phon))
(t-dorsal (if (or t-met-consonant
(not is-consonant))
t-dorsal
(conlanging//nyqy-is-dorsal cur-phon))))
(if is-consonant
(conlanging/nyqy-to-phonetics t-text
(cdr t-nyqy)
(concat t-phonetics
(conlanging//nyqy-get-phoneme cur-phon t t-dorsal))
t
(not t-dorsal))
(conlanging/nyqy-to-phonetics t-text
(cdr t-nyqy)
(concat t-phonetics
(conlanging//nyqy-get-phoneme cur-phon nil))
t-met-consonant
t-dorsal))))))
(defun conlanging/nyqy-to-org (t-text)
"Returns the phonetics equivalent of the Ñygy `t-text' properly
formatted for org so it gets exported as a tooltip in HTML or as
LaTeX code for LaTeX exports.
Arguments:
- `t-text': text to convert to phonetics"
(let ((phonetics (conlanging/nyqy-to-phonetics t-text))
(text t-text))
(format (concat "@@html:<span class=\"tooltip\"><i>%s</i><span class=\"tooltiptext\">/%s/</span></span>@@"
"@@latex:\\textit{%s} (/%s/)@@")
text
phonetics
text
phonetics)))

View File

@@ -1,72 +1,19 @@
;;; packages.el --- conlanging layer packages file for Spacemacs.
;;; keybindings.el --- conlanging layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;; Copyright (c) 2018-2020 Lucien Cartier-Tilet
;;
;; Author: Lucien Cartier-Tilet <phundrak@phundrak.fr>
;; URL: https://github.com/syl20bnr/spacemacs
;; Author: Lucien Cartier-Tilet <lucien@phundrak.com>
;; URL: https://labs.phundrak.com/phundrak/conlang-layer
;;
;; This file is not part of GNU Emacs.
;;
;;; 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" "Einnlanda")
(spacemacs/declare-prefix "oleo" "eittlanda.org")
(spacemacs/declare-prefix "oln" "Ñyqy")
(spacemacs/declare-prefix "olno" "nyqy.org")
(spacemacs/declare-prefix "olne" "nyqy.org (English)")
(spacemacs/declare-prefix "olo" "Conlang directory")
(spacemacs/declare-prefix "olO" "Conlang root directory")
(spacemacs/declare-prefix "olt" "Tãso")
(spacemacs/declare-prefix "olto" "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/web/eittlanda.org"))
"olho"
(lambda ()
(interactive)
(find-file "~/Documents/conlanging/web/hjelp.org"))
"olmo"
(lambda ()
(interactive)
(find-file "~/Documents/conlanging/web/matter.org"))
"olno"
(lambda ()
(interactive)
(find-file "~/Documents/conlanging/web/nyqy.org"))
"olne"
(lambda ()
(interactive)
(find-file "~/Documents/conlanging/web/en/nyqy.org"))
"olO"
(lambda ()
(interactive)
(dired "~/Documents/conlanging"))
"olo"
(lambda ()
(interactive)
(dired "~/Documents/conlanging/web"))
"olto"
(lambda ()
(interactive)
(find-file "~/Documents/conlanging/web/taso.org")))
(spacemacs/set-leader-keys-for-major-mode
'org-mode "ler" 'conlanging/eittlanda-to-runes
"lel" 'conlanging/eittlanda-to-latex "lmr"
'conlanging/matter-to-runes "lml" 'conlanging/matter-to-native-latin
(spacemacs/set-leader-keys-for-major-mode 'org-mode
"ler" 'conlanging/eittlanda-to-runes
"lel" 'conlanging/eittlanda-to-latex
"lmr" 'conlanging/matter-to-runes
"lml" 'conlanging/matter-to-native-latin
"lmL" 'conlanging/matter-to-latex)
;;; keybindings.el ends here