2019-07-21 14:48:11 +00:00
|
|
|
|
;;; funcs.el --- Conlanging Layer functions File for Spacemacs
|
|
|
|
|
;;
|
2020-05-29 15:53:01 +00:00
|
|
|
|
;; Copyright (c) 2018-2020 Lucien Cartier-Tilet
|
2019-07-21 14:48:11 +00:00
|
|
|
|
;;
|
2020-05-29 15:53:01 +00:00
|
|
|
|
;; Author: Lucien Cartier-Tilet <lucien@phundrak.com>
|
|
|
|
|
;; URL: https://labs.phundrak.com/phundrak/conlang-layer
|
2019-07-21 14:48:11 +00:00
|
|
|
|
;;
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
;;
|
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
2019-09-16 13:30:02 +00:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
; Tree ;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(defun conlanging//declare-node (t-node-text t-node-generation)
|
2019-09-16 13:30:02 +00:00
|
|
|
|
"Declares a node in the graphviz source code. The node’s identifier will be
|
2020-10-01 07:57:41 +00:00
|
|
|
|
`node-generation', and it will bear the label `node-text'."
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(format "%d[label=\"%s\"];" t-node-generation
|
|
|
|
|
t-node-text))
|
2019-09-16 13:30:02 +00:00
|
|
|
|
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(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
|
2020-01-29 20:49:21 +00:00
|
|
|
|
to a corresponding graphviz file that can be executed from dot.
|
2019-09-16 13:30:02 +00:00
|
|
|
|
Arguments:
|
2020-03-25 11:21:20 +00:00
|
|
|
|
- `t-tree': t-tree to convert
|
|
|
|
|
- `t-current-generation': generation number, incremented when
|
2020-01-29 20:49:21 +00:00
|
|
|
|
changing from a node to another node from the same generation,
|
|
|
|
|
multiplied by 10 when going from a node to one of its children.
|
2020-03-25 11:21:20 +00:00
|
|
|
|
- `t-previous-generation': generation number from previous named
|
2020-01-29 20:49:21 +00:00
|
|
|
|
node"
|
2019-09-16 13:30:02 +00:00
|
|
|
|
(cond
|
2020-03-25 11:21:20 +00:00
|
|
|
|
((null t-previous-generation) ;; first call
|
2020-01-29 23:15:21 +00:00
|
|
|
|
(concat "graph{graph[dpi=300];node[shape=plaintext];graph[bgcolor=\"transparent\"];"
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(conlanging//declare-node (car t-tree) 0)
|
|
|
|
|
(conlanging/tree-to-dot (cdr t-tree) 1 0)
|
2020-01-29 20:49:21 +00:00
|
|
|
|
"}"))
|
2020-03-25 11:21:20 +00:00
|
|
|
|
((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)
|
2020-01-29 20:49:21 +00:00
|
|
|
|
;; make link
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(concat (number-to-string t-previous-generation) " -- "
|
|
|
|
|
(number-to-string t-current-generation) ";")
|
|
|
|
|
(conlanging/tree-to-dot (cdr t-tree)
|
2020-01-29 20:49:21 +00:00
|
|
|
|
(+ 1
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(* 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)))))
|
2019-09-16 13:30:02 +00:00
|
|
|
|
|
2019-09-15 01:57:52 +00:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
; Common ;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
(defun conlanging//replace-string-by-char (t-string t-correspondance-table)
|
|
|
|
|
"Return a copy of t-string converted with the correspondance
|
|
|
|
|
table"
|
|
|
|
|
(interactive)
|
|
|
|
|
(while t-correspondance-table
|
|
|
|
|
(let ((cur-from-char (car (car t-correspondance-table)))
|
|
|
|
|
(cur-to-char (cdr (car t-correspondance-table))))
|
|
|
|
|
(setq t-string (replace-regexp-in-string cur-from-char cur-to-char
|
|
|
|
|
t-string))
|
|
|
|
|
(setq t-correspondance-table (cdr t-correspondance-table))))
|
|
|
|
|
t-string)
|
|
|
|
|
|
|
|
|
|
(defun conlanging//get-boundary ()
|
|
|
|
|
"Get the boundary of either the selected region, or if there is
|
|
|
|
|
none the word the cursor is over"
|
|
|
|
|
(interactive)
|
|
|
|
|
(let* ((beg (region-beginning))
|
2020-03-25 11:27:07 +00:00
|
|
|
|
(end (region-end)))
|
2019-09-15 01:57:52 +00:00
|
|
|
|
(if (= beg end)
|
2020-03-25 11:27:07 +00:00
|
|
|
|
(bounds-of-thing-at-point 'word)
|
2019-09-15 01:57:52 +00:00
|
|
|
|
(cons beg end))))
|
|
|
|
|
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(defun conlanging//replace-char-by-table (t-correspondance-table)
|
2019-09-15 01:57:52 +00:00
|
|
|
|
"Replaces selected text’s 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
|
|
|
|
|
second element of the pair the string it has to be replaced
|
|
|
|
|
with."
|
|
|
|
|
(let* ((cur-boundary (conlanging//get-boundary))
|
|
|
|
|
(beg (car cur-boundary))
|
2020-03-25 11:27:07 +00:00
|
|
|
|
(end (cdr cur-boundary))
|
|
|
|
|
(regionp (buffer-substring-no-properties beg end))
|
|
|
|
|
(new-regionp (conlanging//replace-string-by-char regionp
|
|
|
|
|
t-correspondance-table)))
|
2019-09-15 01:57:52 +00:00
|
|
|
|
(delete-region beg end)
|
|
|
|
|
(goto-char beg)
|
2020-03-25 11:27:56 +00:00
|
|
|
|
(insert new-regionp)))
|
2019-09-16 13:29:43 +00:00
|
|
|
|
|
2019-09-15 01:57:52 +00:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
; Mattér ;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2020-01-29 21:01:38 +00:00
|
|
|
|
(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.")
|
2019-09-15 01:57:52 +00:00
|
|
|
|
|
2020-01-29 21:01:38 +00:00
|
|
|
|
(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.")
|
2019-09-15 01:57:52 +00:00
|
|
|
|
|
2020-01-29 21:01:38 +00:00
|
|
|
|
(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.")
|
2019-08-12 23:52:51 +00:00
|
|
|
|
|
2019-09-15 01:57:52 +00:00
|
|
|
|
(defun conlanging/matter-to-runes ()
|
|
|
|
|
"Replaces transliterated Mattér with its runic writing system"
|
|
|
|
|
(interactive)
|
|
|
|
|
(conlanging//replace-char-by-table conlanging//matter-latin-to-runes))
|
|
|
|
|
|
|
|
|
|
(defun conlanging/matter-to-native-latin ()
|
|
|
|
|
"Replaces transliterated Mattér with its corresponding native
|
|
|
|
|
latin writing system"
|
|
|
|
|
(interactive)
|
|
|
|
|
(conlanging//replace-char-by-table conlanging//matter-latin-to-native))
|
|
|
|
|
|
|
|
|
|
(defun conlanging/matter-to-latex ()
|
|
|
|
|
"Replaces transliterated Mattér with its corresponding runes"
|
|
|
|
|
(interactive)
|
|
|
|
|
(conlanging//replace-char-by-table conlanging//matter-latin-to-latex))
|
|
|
|
|
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(defun conlanging/matter-org-export-runes (t-text)
|
|
|
|
|
"Replaces the transliterated Mattér `t-text' with its
|
2020-01-29 21:01:38 +00:00
|
|
|
|
corresponding runes during org-mode export"
|
2019-09-15 01:57:52 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(if (org-export-derived-backend-p org-export-current-backend
|
|
|
|
|
'latex)
|
|
|
|
|
(concat "\\textarm{"
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(conlanging//replace-string-by-char t-text conlanging//matter-latin-to-latex)
|
2019-09-15 01:57:52 +00:00
|
|
|
|
"}")
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(conlanging//replace-string-by-char t-text conlanging//matter-latin-to-runes)))
|
2019-09-15 01:57:52 +00:00
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2020-08-22 11:04:51 +00:00
|
|
|
|
; Eittlandic ;
|
2019-09-15 01:57:52 +00:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2020-08-22 11:04:51 +00:00
|
|
|
|
(defvar conlanging//eittlandic-latin-to-latex '((", *\\|\\. *" . "\\\\tripledot")
|
|
|
|
|
(" +" . ":")
|
|
|
|
|
("hv" . "x")
|
|
|
|
|
("í" . "i")
|
|
|
|
|
("é" . "\\\\e")
|
|
|
|
|
("ę\\|æ" . "æ")
|
|
|
|
|
("ý" . "y")
|
|
|
|
|
("œ" . "ø")
|
|
|
|
|
("ú" . "u")
|
|
|
|
|
("ó" . "o")
|
|
|
|
|
("á\\|ǫ" . "a")
|
|
|
|
|
("j" . "i"))
|
2020-01-29 21:01:38 +00:00
|
|
|
|
"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.")
|
2019-09-15 01:57:52 +00:00
|
|
|
|
|
2020-08-22 11:04:51 +00:00
|
|
|
|
(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" . "ᛚ"))
|
2020-01-29 20:48:56 +00:00
|
|
|
|
"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.")
|
2019-07-21 14:48:11 +00:00
|
|
|
|
|
2020-08-22 11:04:51 +00:00
|
|
|
|
(defun conlanging/eittlandic-to-runes ()
|
2019-08-21 12:57:03 +00:00
|
|
|
|
"Replaces transliterated Eittlandic with its runic writing system"
|
2019-08-12 23:52:51 +00:00
|
|
|
|
(interactive)
|
2020-08-22 11:04:51 +00:00
|
|
|
|
(conlanging//replace-char-by-table conlanging//eittlandic-latin-to-runes))
|
2019-07-21 14:48:11 +00:00
|
|
|
|
|
2020-08-22 11:04:51 +00:00
|
|
|
|
(defun conlanging/eittlandic-to-latex ()
|
2019-08-21 12:57:03 +00:00
|
|
|
|
"Replaces transliterated Eittlandic with its corresponding runes"
|
2019-08-13 14:39:23 +00:00
|
|
|
|
(interactive)
|
2020-08-22 11:04:51 +00:00
|
|
|
|
(conlanging//replace-char-by-table conlanging//eittlandic-latin-to-latex))
|
2019-08-13 14:39:23 +00:00
|
|
|
|
|
2020-08-22 11:04:51 +00:00
|
|
|
|
(defun conlanging/eittlandic-org-export-runes (t-text)
|
2019-09-15 01:57:52 +00:00
|
|
|
|
"Replaces transliterated Eittlandic with its corresponding
|
|
|
|
|
runes during org-mode export"
|
2019-07-21 14:48:11 +00:00
|
|
|
|
(interactive)
|
2019-08-13 14:39:23 +00:00
|
|
|
|
(if (org-export-derived-backend-p org-export-current-backend
|
|
|
|
|
'latex)
|
|
|
|
|
(concat "\\textarm{"
|
2020-08-22 11:04:51 +00:00
|
|
|
|
(conlanging//replace-string-by-char t-text conlanging//eittlandic-latin-to-latex)
|
2019-08-13 14:39:23 +00:00
|
|
|
|
"}")
|
2020-08-22 11:04:51 +00:00
|
|
|
|
(conlanging//replace-string-by-char t-text conlanging//eittlandic-latin-to-runes)))
|
2019-09-15 01:58:20 +00:00
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-09-26 14:53:14 +00:00
|
|
|
|
; Ñyqy ;
|
2019-09-15 01:58:20 +00:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2020-01-29 20:17:55 +00:00
|
|
|
|
(defvar conlanging//nyqy-phonetics '(("q" t t "q" "ħ")
|
|
|
|
|
("g" t t "ɢ" "ʢ")
|
|
|
|
|
("ñ" t t "ɴ" "m")
|
2020-08-22 11:05:37 +00:00
|
|
|
|
("c" t t "c" "ɬ")
|
|
|
|
|
("j" t t "ɟ" "ɮ")
|
2020-01-29 20:17:55 +00:00
|
|
|
|
("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 "ʊ")
|
2020-11-10 14:50:18 +00:00
|
|
|
|
("ø" nil "ø")
|
|
|
|
|
("œ" nil "ɤ")
|
2020-01-29 20:17:55 +00:00
|
|
|
|
("e" nil "ɛ")
|
|
|
|
|
("o" nil "ɔ")
|
|
|
|
|
(" " nil " ")
|
|
|
|
|
("," nil " ")
|
|
|
|
|
(";" nil " ")
|
|
|
|
|
("." nil " "))
|
|
|
|
|
"List of Ñyqy characters and their phonetics equivalent.
|
|
|
|
|
|
|
|
|
|
The first value is the translitteration of a sound in Ñyqy. The
|
|
|
|
|
second is whether or not it represents a consonant.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
If it is not a consonant, then the third value is its
|
|
|
|
|
pronunciation already.")
|
2019-09-15 01:58:20 +00:00
|
|
|
|
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(defun conlanging//nyqy-is-consonant (t-elem)
|
|
|
|
|
(nth 1 t-elem))
|
2019-09-15 01:58:20 +00:00
|
|
|
|
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(defun conlanging//nyqy-is-dorsal (t-elem)
|
|
|
|
|
(nth 2 t-elem))
|
2019-09-15 01:58:20 +00:00
|
|
|
|
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(defun conlanging//nyqy-get-phoneme (t-phoneme &optional t-is-consonant t-is-dorsal)
|
|
|
|
|
"Extracts a phoneme from `t-phoneme'.
|
2019-09-15 01:58:20 +00:00
|
|
|
|
|
2020-01-29 20:17:55 +00:00
|
|
|
|
Arguments:
|
2020-03-25 11:21:20 +00:00
|
|
|
|
- `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)))
|
2019-09-15 01:58:20 +00:00
|
|
|
|
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(defun conlanging/nyqy-to-phonetics (t-text &optional t-nyqy t-phonetics t-met-consonant
|
|
|
|
|
t-dorsal)
|
2020-05-01 20:58:33 +00:00
|
|
|
|
"Returns the phonetics equivalent of the Ñyqy `t-text'.
|
2019-09-15 01:58:20 +00:00
|
|
|
|
|
|
|
|
|
Arguments:
|
2020-03-25 11:21:20 +00:00
|
|
|
|
- `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"
|
2019-09-15 01:58:20 +00:00
|
|
|
|
(interactive)
|
2020-01-29 20:17:55 +00:00
|
|
|
|
(cond
|
2020-05-01 20:58:33 +00:00
|
|
|
|
|
|
|
|
|
;; first call to the function
|
|
|
|
|
((eq nil t-phonetics)
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(conlanging/nyqy-to-phonetics t-text
|
2020-05-01 20:58:33 +00:00
|
|
|
|
(split-string (downcase t-text) "" t)
|
2020-01-29 20:17:55 +00:00
|
|
|
|
""))
|
2020-05-01 20:58:33 +00:00
|
|
|
|
|
|
|
|
|
;; no more to convert
|
|
|
|
|
((eq nil t-nyqy)
|
|
|
|
|
t-phonetics)
|
|
|
|
|
|
|
|
|
|
;; default option
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(t (let* ((cur-char (car t-nyqy)) ;; default option
|
2020-01-29 20:17:55 +00:00
|
|
|
|
(cur-phon (seq-find (lambda (elt)
|
|
|
|
|
(string= (car elt)
|
|
|
|
|
cur-char))
|
|
|
|
|
conlanging//nyqy-phonetics))
|
|
|
|
|
(is-consonant (conlanging//nyqy-is-consonant cur-phon))
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(t-dorsal (if (or t-met-consonant
|
|
|
|
|
(not is-consonant))
|
|
|
|
|
t-dorsal
|
|
|
|
|
(conlanging//nyqy-is-dorsal cur-phon))))
|
2020-01-29 20:17:55 +00:00
|
|
|
|
(if is-consonant
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(conlanging/nyqy-to-phonetics t-text
|
|
|
|
|
(cdr t-nyqy)
|
|
|
|
|
(concat t-phonetics
|
|
|
|
|
(conlanging//nyqy-get-phoneme cur-phon t t-dorsal))
|
2020-01-29 20:17:55 +00:00
|
|
|
|
t
|
2020-03-25 11:21:20 +00:00
|
|
|
|
(not t-dorsal))
|
|
|
|
|
(conlanging/nyqy-to-phonetics t-text
|
|
|
|
|
(cdr t-nyqy)
|
|
|
|
|
(concat t-phonetics
|
2020-01-29 20:17:55 +00:00
|
|
|
|
(conlanging//nyqy-get-phoneme cur-phon nil))
|
2020-03-25 11:21:20 +00:00
|
|
|
|
t-met-consonant
|
|
|
|
|
t-dorsal))))))
|
2020-05-01 20:58:33 +00:00
|
|
|
|
|
|
|
|
|
(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)))
|