Updated naming convention
Arguments are now preceded by the prefix `t-`
This commit is contained in:
parent
81fc628935
commit
ea9637ff5a
192
funcs.el
192
funcs.el
@ -12,46 +12,46 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; Tree ;
|
; 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 node’s identifier will be
|
"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\"];" node-generation
|
(format "%d[label=\"%s\"];" t-node-generation
|
||||||
node-text))
|
t-node-text))
|
||||||
|
|
||||||
(defun conlanging/tree-to-dot (tree &optional current-generation previous-generation)
|
(defun conlanging/tree-to-dot (t-tree &optional t-current-generation t-previous-generation)
|
||||||
"Translates an Elisp tree with any number of children per node
|
"Translates an Elisp t-tree with any number of children per node
|
||||||
to a corresponding graphviz file that can be executed from dot.
|
to a corresponding graphviz file that can be executed from dot.
|
||||||
Arguments:
|
Arguments:
|
||||||
- `tree': tree to convert
|
- `t-tree': t-tree to convert
|
||||||
- `current-generation': generation number, incremented when
|
- `t-current-generation': generation number, incremented when
|
||||||
changing from a node to another node from the same generation,
|
changing from a node to another node from the same generation,
|
||||||
multiplied by 10 when going from a node to one of its children.
|
multiplied by 10 when going from a node to one of its children.
|
||||||
- `previous-generation': generation number from previous named
|
- `t-previous-generation': generation number from previous named
|
||||||
node"
|
node"
|
||||||
(cond
|
(cond
|
||||||
((null previous-generation) ;; first call
|
((null t-previous-generation) ;; first call
|
||||||
(concat "graph{graph[dpi=300];node[shape=plaintext];graph[bgcolor=\"transparent\"];"
|
(concat "graph{graph[dpi=300];node[shape=plaintext];graph[bgcolor=\"transparent\"];"
|
||||||
(conlanging//declare-node (car tree) 0)
|
(conlanging//declare-node (car t-tree) 0)
|
||||||
(conlanging/tree-to-dot (cdr tree) 1 0)
|
(conlanging/tree-to-dot (cdr t-tree) 1 0)
|
||||||
"}"))
|
"}"))
|
||||||
((null tree) "") ;; last call in this branch
|
((null t-tree) "") ;; last call in this branch
|
||||||
((atom (car tree)) ;; '("text" () () ()) manage the label
|
((atom (car t-tree)) ;; '("text" () () ()) manage the label
|
||||||
(concat (conlanging//declare-node (car tree)
|
(concat (conlanging//declare-node (car t-tree)
|
||||||
current-generation)
|
t-current-generation)
|
||||||
;; make link
|
;; make link
|
||||||
(concat (number-to-string previous-generation) " -- "
|
(concat (number-to-string t-previous-generation) " -- "
|
||||||
(number-to-string current-generation) ";")
|
(number-to-string t-current-generation) ";")
|
||||||
(conlanging/tree-to-dot (cdr tree)
|
(conlanging/tree-to-dot (cdr t-tree)
|
||||||
(+ 1
|
(+ 1
|
||||||
(* 10 current-generation))
|
(* 10 t-current-generation))
|
||||||
current-generation)))
|
t-current-generation)))
|
||||||
((listp (car tree)) ;; '(() () ()) manage the branches
|
((listp (car t-tree)) ;; '(() () ()) manage the branches
|
||||||
(concat (conlanging/tree-to-dot (car tree) ;; child of current node
|
(concat (conlanging/tree-to-dot (car t-tree) ;; child of current node
|
||||||
current-generation
|
t-current-generation
|
||||||
previous-generation)
|
t-previous-generation)
|
||||||
(conlanging/tree-to-dot (cdr tree)
|
(conlanging/tree-to-dot (cdr t-tree)
|
||||||
(+ 1 current-generation)
|
(+ 1 t-current-generation)
|
||||||
previous-generation)))))
|
t-previous-generation)))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; Common ;
|
; Common ;
|
||||||
@ -79,7 +79,7 @@ none the word the cursor is over"
|
|||||||
boundary-word
|
boundary-word
|
||||||
(cons beg end))))
|
(cons beg end))))
|
||||||
|
|
||||||
(defun conlanging//replace-char-by-table (correspondance-table)
|
(defun conlanging//replace-char-by-table (t-correspondance-table)
|
||||||
"Replaces selected text’s strings according to the table passed
|
"Replaces selected text’s strings according to the table passed
|
||||||
as argument. The table is a list of pairs, the first element of
|
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
|
the pair is a regex to be searched in the selected text and the
|
||||||
@ -92,20 +92,20 @@ with."
|
|||||||
(buffer-substring-no-properties beg end))
|
(buffer-substring-no-properties beg end))
|
||||||
(setq-local regionp
|
(setq-local regionp
|
||||||
(conlanging//replace-string-by-char regionp
|
(conlanging//replace-string-by-char regionp
|
||||||
correspondance-table))
|
t-correspondance-table))
|
||||||
(delete-region beg end)
|
(delete-region beg end)
|
||||||
(goto-char beg)
|
(goto-char beg)
|
||||||
(insert regionp)))
|
(insert regionp)))
|
||||||
|
|
||||||
(defun conlanging//find-elem-in-list (elem list)
|
(defun conlanging//find-elem-in-list (t-elem t-list)
|
||||||
"In a list containing lists, returns the element of `list'
|
"In a t-list containing lists, returns the element of `t-list'
|
||||||
whose first element equals `elem'"
|
whose first element equals `t-elem'"
|
||||||
(if list
|
(if t-list
|
||||||
(if (string= (caar list)
|
(if (string= (caar t-list)
|
||||||
elem)
|
t-elem)
|
||||||
(car list)
|
(car t-list)
|
||||||
(conlanging//find-elem-in-list elem
|
(conlanging//find-elem-in-list t-elem
|
||||||
(cdr list)))
|
(cdr t-list)))
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
@ -203,16 +203,16 @@ latin writing system"
|
|||||||
(interactive)
|
(interactive)
|
||||||
(conlanging//replace-char-by-table conlanging//matter-latin-to-latex))
|
(conlanging//replace-char-by-table conlanging//matter-latin-to-latex))
|
||||||
|
|
||||||
(defun conlanging/matter-org-export-runes (text)
|
(defun conlanging/matter-org-export-runes (t-text)
|
||||||
"Replaces the transliterated Mattér `text' with its
|
"Replaces the transliterated Mattér `t-text' with its
|
||||||
corresponding runes during org-mode export"
|
corresponding runes during org-mode export"
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (org-export-derived-backend-p org-export-current-backend
|
(if (org-export-derived-backend-p org-export-current-backend
|
||||||
'latex)
|
'latex)
|
||||||
(concat "\\textarm{"
|
(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 ;
|
; Eittlanda ;
|
||||||
@ -277,16 +277,16 @@ Runic LaTeX code equivalent.")
|
|||||||
(interactive)
|
(interactive)
|
||||||
(conlanging//replace-char-by-table conlanging//eittlanda-latin-to-latex))
|
(conlanging//replace-char-by-table conlanging//eittlanda-latin-to-latex))
|
||||||
|
|
||||||
(defun conlanging/eittlanda-org-export-runes (text)
|
(defun conlanging/eittlanda-org-export-runes (t-text)
|
||||||
"Replaces transliterated Eittlandic with its corresponding
|
"Replaces transliterated Eittlandic with its corresponding
|
||||||
runes during org-mode export"
|
runes during org-mode export"
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (org-export-derived-backend-p org-export-current-backend
|
(if (org-export-derived-backend-p org-export-current-backend
|
||||||
'latex)
|
'latex)
|
||||||
(concat "\\textarm{"
|
(concat "\\textarm{"
|
||||||
(conlanging//replace-string-by-char text conlanging//eittlanda-latin-to-latex)
|
(conlanging//replace-string-by-char t-text conlanging//eittlanda-latin-to-latex)
|
||||||
"}")
|
"}")
|
||||||
(conlanging//replace-string-by-char text conlanging//eittlanda-latin-to-runes)))
|
(conlanging//replace-string-by-char t-text conlanging//eittlanda-latin-to-runes)))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; Ñyqy ;
|
; Ñyqy ;
|
||||||
@ -327,77 +327,77 @@ dorsal prononciation and its non-dorsal pronunciation.
|
|||||||
If it is not a consonant, then the third value is its
|
If it is not a consonant, then the third value is its
|
||||||
pronunciation already.")
|
pronunciation already.")
|
||||||
|
|
||||||
(defun conlanging//nyqy-is-consonant (elem)
|
(defun conlanging//nyqy-is-consonant (t-elem)
|
||||||
(nth 1 elem))
|
(nth 1 t-elem))
|
||||||
|
|
||||||
(defun conlanging//nyqy-is-dorsal (elem)
|
(defun conlanging//nyqy-is-dorsal (t-elem)
|
||||||
(nth 2 elem))
|
(nth 2 t-elem))
|
||||||
|
|
||||||
(defun conlanging//nyqy-get-phoneme (phoneme &optional is-consonant is-dorsal)
|
(defun conlanging//nyqy-get-phoneme (t-phoneme &optional t-is-consonant t-is-dorsal)
|
||||||
"Extracts a phoneme from `phoneme'.
|
"Extracts a phoneme from `t-phoneme'.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
- phoneme: array from `conlanging//nyqy-phonetics'
|
- `t-phoneme': array from `conlanging//nyqy-phonetics'
|
||||||
- is-consonant: whether `phoneme' represents a
|
- `t-is-consonant': whether `t-phoneme' represents a
|
||||||
consonant (default: nil)
|
consonant (default: `nil')
|
||||||
- is-dorsal: whether `phoneme' should be a dorsal
|
- `t-is-dorsal': whether `t-phoneme' should be a dorsal
|
||||||
consonant (default: nil)"
|
consonant (default: `nil')"
|
||||||
(if is-consonant
|
(if t-is-consonant
|
||||||
(if is-dorsal
|
(if t-is-dorsal
|
||||||
(nth 3 phoneme)
|
(nth 3 t-phoneme)
|
||||||
(nth 4 phoneme))
|
(nth 4 t-phoneme))
|
||||||
(nth 2 phoneme)))
|
(nth 2 t-phoneme)))
|
||||||
|
|
||||||
(defun conlanging/nyqy-to-phonetics (text &optional nyqy phonetics met-consonant
|
(defun conlanging/nyqy-to-phonetics (t-text &optional t-nyqy t-phonetics t-met-consonant
|
||||||
dorsal)
|
t-dorsal)
|
||||||
"Returns the phonetics equivalent of the Ñyqy `text', either as
|
"Returns the phonetics equivalent of the Ñyqy `t-text', either
|
||||||
a tooltip in HTML or plain text for LaTeX exports.
|
as a tooltip in HTML or plain text for LaTeX exports.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
- text: text to convert to phonetics
|
- `t-text': text to convert to phonetics
|
||||||
- nyqy: for internal use only, `text' argument but as a list of
|
- `t-nyqy': for internal use only, `t-text' argument but as a
|
||||||
characters
|
list of characters
|
||||||
- phonetics: for internal use only, result phonetics, array
|
- `t-phonetics': for internal use only, result phonetics, array
|
||||||
- met-consonant: for internal use only, `t' if a consonant has
|
- `t-met-consonant': for internal use only, `t' if a consonant
|
||||||
been met previously, `nil' otherwise
|
has been met previously, `nil' otherwise
|
||||||
- dorsal: for internal use only, `t' if the current consonant is
|
- `t-dorsal': for internal use only, `t' if the current consonant
|
||||||
required to be dorsal, `nil' otherwise"
|
is required to be dorsal, `nil' otherwise"
|
||||||
(interactive)
|
(interactive)
|
||||||
(cond
|
(cond
|
||||||
((eq nil phonetics) ;; first call to the function
|
((eq nil t-phonetics) ;; first call to the function
|
||||||
(conlanging/nyqy-to-phonetics text
|
(conlanging/nyqy-to-phonetics t-text
|
||||||
(split-string (downcase text)
|
(split-string (downcase t-text)
|
||||||
""
|
""
|
||||||
t)
|
t)
|
||||||
""))
|
""))
|
||||||
((eq nil nyqy) ;; no more to convert
|
((eq nil t-nyqy) ;; no more to convert
|
||||||
(progn
|
(progn
|
||||||
(format (concat "@@html:<span class=\"tooltip\"><i>%s</i><span class=\"tooltiptext\">/%s/</span></span>@@"
|
(format (concat "@@html:<span class=\"tooltip\"><i>%s</i><span class=\"tooltiptext\">/%s/</span></span>@@"
|
||||||
"@@latex:\\textit{%s} (/%s/)@@")
|
"@@latex:\\textit{%s} (/%s/)@@")
|
||||||
text
|
t-text
|
||||||
phonetics
|
t-phonetics
|
||||||
text
|
t-text
|
||||||
phonetics)))
|
t-phonetics)))
|
||||||
(t (let* ((cur-char (car nyqy)) ;; default option
|
(t (let* ((cur-char (car t-nyqy)) ;; default option
|
||||||
(cur-phon (seq-find (lambda (elt)
|
(cur-phon (seq-find (lambda (elt)
|
||||||
(string= (car elt)
|
(string= (car elt)
|
||||||
cur-char))
|
cur-char))
|
||||||
conlanging//nyqy-phonetics))
|
conlanging//nyqy-phonetics))
|
||||||
(is-consonant (conlanging//nyqy-is-consonant cur-phon))
|
(is-consonant (conlanging//nyqy-is-consonant cur-phon))
|
||||||
(dorsal (if (or met-consonant
|
(t-dorsal (if (or t-met-consonant
|
||||||
(not is-consonant))
|
(not is-consonant))
|
||||||
dorsal
|
t-dorsal
|
||||||
(conlanging//nyqy-is-dorsal cur-phon))))
|
(conlanging//nyqy-is-dorsal cur-phon))))
|
||||||
(if is-consonant
|
(if is-consonant
|
||||||
(conlanging/nyqy-to-phonetics text
|
(conlanging/nyqy-to-phonetics t-text
|
||||||
(cdr nyqy)
|
(cdr t-nyqy)
|
||||||
(concat phonetics
|
(concat t-phonetics
|
||||||
(conlanging//nyqy-get-phoneme cur-phon t dorsal))
|
(conlanging//nyqy-get-phoneme cur-phon t t-dorsal))
|
||||||
t
|
t
|
||||||
(not dorsal))
|
(not t-dorsal))
|
||||||
(conlanging/nyqy-to-phonetics text
|
(conlanging/nyqy-to-phonetics t-text
|
||||||
(cdr nyqy)
|
(cdr t-nyqy)
|
||||||
(concat phonetics
|
(concat t-phonetics
|
||||||
(conlanging//nyqy-get-phoneme cur-phon nil))
|
(conlanging//nyqy-get-phoneme cur-phon nil))
|
||||||
met-consonant
|
t-met-consonant
|
||||||
dorsal))))))
|
t-dorsal))))))
|
||||||
|
Reference in New Issue
Block a user