moved elements around
Eittlandic variables now with Eittlandic functions, same for Mattér
This commit is contained in:
parent
927d9f9eb3
commit
8fa7818b70
163
funcs.el
163
funcs.el
@ -9,7 +9,53 @@
|
|||||||
;;
|
;;
|
||||||
;;; License: GPLv3
|
;;; License: GPLv3
|
||||||
|
|
||||||
; Mattér ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; 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))
|
||||||
|
(end (region-end))
|
||||||
|
(boundary-word (bounds-of-thing-at-point 'word)))
|
||||||
|
(if (= beg end)
|
||||||
|
boundary-word
|
||||||
|
(cons beg end))))
|
||||||
|
|
||||||
|
(defun conlanging//replace-char-by-table (correspondance-table)
|
||||||
|
"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))
|
||||||
|
(end (cdr cur-boundary)))
|
||||||
|
(setq-local regionp
|
||||||
|
(buffer-substring-no-properties beg end))
|
||||||
|
(setq-local regionp
|
||||||
|
(conlanging//replace-string-by-char regionp
|
||||||
|
correspondance-table))
|
||||||
|
(delete-region beg end)
|
||||||
|
(goto-char beg)
|
||||||
|
(insert regionp)))
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; Mattér ;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
(setq conlanging//matter-latin-to-runes '((", *" . "᛬")
|
(setq conlanging//matter-latin-to-runes '((", *" . "᛬")
|
||||||
("\\. *" . "᛭")
|
("\\. *" . "᛭")
|
||||||
(" +" . "᛫")
|
(" +" . "᛫")
|
||||||
@ -48,6 +94,7 @@
|
|||||||
("é" . "ᛟ")
|
("é" . "ᛟ")
|
||||||
("a" . "ᚪ")
|
("a" . "ᚪ")
|
||||||
("y" . "ᚣ")))
|
("y" . "ᚣ")))
|
||||||
|
|
||||||
(setq conlanging//matter-latin-to-native '((" +" . " ")
|
(setq conlanging//matter-latin-to-native '((" +" . " ")
|
||||||
("ch" . "ċ")
|
("ch" . "ċ")
|
||||||
("ae" . "æ")
|
("ae" . "æ")
|
||||||
@ -57,6 +104,7 @@
|
|||||||
("z" . "ð")
|
("z" . "ð")
|
||||||
("w" . "ƿ")
|
("w" . "ƿ")
|
||||||
("j" . "i")))
|
("j" . "i")))
|
||||||
|
|
||||||
(setq conlanging//matter-latin-to-latex '((", *" . ":")
|
(setq conlanging//matter-latin-to-latex '((", *" . ":")
|
||||||
("\\. *" . "*")
|
("\\. *" . "*")
|
||||||
(" +" . ".")
|
(" +" . ".")
|
||||||
@ -73,7 +121,36 @@
|
|||||||
("v" . "\\\\ng")
|
("v" . "\\\\ng")
|
||||||
("é " . "\\\\oe")))
|
("é " . "\\\\oe")))
|
||||||
|
|
||||||
; Eittlandic ;;;;;;;;;;;;;;;;;;;;;;;;;;
|
(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))
|
||||||
|
|
||||||
|
(defun conlanging/matter-org-export-runes (text)
|
||||||
|
"Replaces transliterated Mattér 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 text conlanging//matter-latin-to-runes)))
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; Eittlanda ;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
(setq conlanging//eittlanda-latin-to-latex '((", *" . "\\\\tripledot")
|
(setq conlanging//eittlanda-latin-to-latex '((", *" . "\\\\tripledot")
|
||||||
("\\. *" . "\\\\tripledot")
|
("\\. *" . "\\\\tripledot")
|
||||||
(" +" . ":")
|
(" +" . ":")
|
||||||
@ -83,6 +160,7 @@
|
|||||||
("v" . "w")
|
("v" . "w")
|
||||||
("ó" . "v")
|
("ó" . "v")
|
||||||
("ń" . "\\\\ndot")))
|
("ń" . "\\\\ndot")))
|
||||||
|
|
||||||
(setq conlanging//eittlanda-latin-to-runes '((", *" . "⁝")
|
(setq conlanging//eittlanda-latin-to-runes '((", *" . "⁝")
|
||||||
("\\. *" . "⁝")
|
("\\. *" . "⁝")
|
||||||
(" +" . "᛬")
|
(" +" . "᛬")
|
||||||
@ -116,83 +194,6 @@
|
|||||||
("r" . "ᚱ")
|
("r" . "ᚱ")
|
||||||
("l" . "ᛚ")))
|
("l" . "ᛚ")))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; 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))
|
|
||||||
(end (region-end))
|
|
||||||
(boundary-word (bounds-of-thing-at-point 'word)))
|
|
||||||
(if (= beg end)
|
|
||||||
boundary-word
|
|
||||||
(cons beg end))))
|
|
||||||
|
|
||||||
(defun conlanging//replace-char-by-table (correspondance-table)
|
|
||||||
"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))
|
|
||||||
(end (cdr cur-boundary)))
|
|
||||||
(setq regionp (buffer-substring-no-properties beg end))
|
|
||||||
(setq regionp (conlanging//replace-string-by-char regionp
|
|
||||||
correspondance-table))
|
|
||||||
(delete-region beg end)
|
|
||||||
(goto-char beg)
|
|
||||||
(insert regionp)))
|
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; Mattér ;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
(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))
|
|
||||||
|
|
||||||
(defun conlanging/matter-org-export-runes (text)
|
|
||||||
"Replaces transliterated Mattér 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 text conlanging//matter-latin-to-runes)))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; Eittlanda ;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
(defun conlanging/eittlanda-to-runes ()
|
(defun conlanging/eittlanda-to-runes ()
|
||||||
"Replaces transliterated Eittlandic with its runic writing system"
|
"Replaces transliterated Eittlandic with its runic writing system"
|
||||||
(interactive)
|
(interactive)
|
||||||
@ -204,8 +205,8 @@ export"
|
|||||||
(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 (text)
|
||||||
"Replaces transliterated Eittlandic with its corresponding runes during
|
"Replaces transliterated Eittlandic with its corresponding
|
||||||
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)
|
||||||
|
Reference in New Issue
Block a user