2019-07-21 14:48:11 +00:00
|
|
|
|
;;; funcs.el --- Conlanging Layer functions File for Spacemacs
|
|
|
|
|
;;
|
|
|
|
|
;; Copyright (c) 2019-2020 Lucien Cartier-Tilet
|
|
|
|
|
;;
|
|
|
|
|
;; Author: Lucien Cartier-Tilet <phundrak@phundrak.fr>
|
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
|
;;
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
;;
|
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
2019-08-22 18:29:04 +00:00
|
|
|
|
; Mattér ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-08-13 14:39:23 +00:00
|
|
|
|
(setq conlanging//matter-latin-to-runes '((", *" . "᛬")
|
2019-08-12 23:52:51 +00:00
|
|
|
|
("\\. *" . "᛭")
|
2019-08-13 14:39:23 +00:00
|
|
|
|
(" +" . "᛫")
|
|
|
|
|
("ċ" . "ᛇ")
|
|
|
|
|
("ch" . "ᛇ")
|
|
|
|
|
("ae" . "ᚫ")
|
|
|
|
|
("æ" . "ᚫ")
|
|
|
|
|
("dh" . "ᛋ")
|
|
|
|
|
("z" . "ᛋ")
|
|
|
|
|
("ð" . "ᛋ")
|
|
|
|
|
("th" . "ᚦ")
|
|
|
|
|
("s" . "ᚦ")
|
|
|
|
|
("þ" . "ᚦ")
|
2019-08-22 18:29:04 +00:00
|
|
|
|
("w" . "ᚹ")
|
2019-08-13 14:39:23 +00:00
|
|
|
|
("ƿ" . "ᚹ")
|
|
|
|
|
("g" . "ᚷ")
|
|
|
|
|
("ᵹ" . "ᚷ")
|
|
|
|
|
("ea" . "ᛠ")
|
|
|
|
|
("f" . "ᚠ")
|
|
|
|
|
("u" . "ᚢ")
|
|
|
|
|
("o" . "ᚩ")
|
|
|
|
|
("r" . "ᚱ")
|
|
|
|
|
("c" . "ᚳ")
|
|
|
|
|
("h" . "ᚻ")
|
|
|
|
|
("n" . "ᚾ")
|
|
|
|
|
("i" . "ᛁ")
|
2019-08-22 18:29:04 +00:00
|
|
|
|
("j" . "ᛄ")
|
2019-08-13 14:39:23 +00:00
|
|
|
|
("p" . "ᛈ")
|
2019-08-22 18:29:04 +00:00
|
|
|
|
("v" . "ᛝ")
|
2019-08-13 14:39:23 +00:00
|
|
|
|
("t" . "ᛏ")
|
|
|
|
|
("b" . "ᛒ")
|
|
|
|
|
("e" . "ᛖ")
|
|
|
|
|
("m" . "ᛗ")
|
|
|
|
|
("l" . "ᛚ")
|
|
|
|
|
("d" . "ᛞ")
|
|
|
|
|
("é" . "ᛟ")
|
|
|
|
|
("a" . "ᚪ")
|
|
|
|
|
("y" . "ᚣ")))
|
2019-08-12 23:52:51 +00:00
|
|
|
|
(setq conlanging//matter-latin-to-native '((" +" . " ")
|
|
|
|
|
("ch" . "ċ")
|
|
|
|
|
("ae" . "æ")
|
|
|
|
|
("th" . "þ")
|
2019-08-13 14:39:23 +00:00
|
|
|
|
("s" . "þ")
|
2019-08-12 23:52:51 +00:00
|
|
|
|
("dh" . "ð")
|
2019-08-13 14:39:23 +00:00
|
|
|
|
("z" . "ð")
|
|
|
|
|
("w" . "ƿ")
|
|
|
|
|
("j" . "i")))
|
|
|
|
|
(setq conlanging//matter-latin-to-latex '((", *" . ":")
|
|
|
|
|
("\\. *" . "*")
|
|
|
|
|
(" +" . ".")
|
|
|
|
|
("ch" . "I")
|
|
|
|
|
("ċ" . "I")
|
|
|
|
|
("ae" . "æ")
|
|
|
|
|
("ea" . "\\\\ea")
|
|
|
|
|
("ƿ" . "w")
|
|
|
|
|
("dh" . "s")
|
|
|
|
|
("z" . "s")
|
|
|
|
|
("ð" . "s")
|
|
|
|
|
("th" . "þ")
|
|
|
|
|
("s" . "þ")
|
|
|
|
|
("v" . "\\\\ng")
|
|
|
|
|
("é " . "\\\\oe")))
|
2019-08-12 23:52:51 +00:00
|
|
|
|
|
2019-08-22 18:29:04 +00:00
|
|
|
|
; Eittlandic ;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-08-21 12:57:03 +00:00
|
|
|
|
(setq conlanging//eittlanda-latin-to-latex '((", *" . "\\\\tripledot")
|
2019-08-12 23:52:51 +00:00
|
|
|
|
("\\. *" . "\\\\tripledot")
|
2019-08-13 14:39:23 +00:00
|
|
|
|
(" +" . ":")
|
|
|
|
|
("hw" . "x")
|
|
|
|
|
("ø" . "\\\\o")
|
|
|
|
|
("ö" . "\\\\oO")
|
|
|
|
|
("ó" . "v")
|
|
|
|
|
("ń" . "\\\\ndot")
|
2019-08-22 18:29:04 +00:00
|
|
|
|
("v" . "w")))
|
2019-08-21 12:57:03 +00:00
|
|
|
|
(setq conlanging//eittlanda-latin-to-runes '((", *" . "⁝")
|
2019-08-12 23:52:51 +00:00
|
|
|
|
("\\. *" . "⁝")
|
2019-08-13 14:39:23 +00:00
|
|
|
|
(" +" . "᛬")
|
2019-08-23 11:45:26 +00:00
|
|
|
|
(":" . "᛬")
|
2019-08-13 14:39:23 +00:00
|
|
|
|
("hw" . "ᛪ")
|
|
|
|
|
("i" . "ᛁ")
|
|
|
|
|
("y" . "ᛦ")
|
|
|
|
|
("u" . "ᚢ")
|
|
|
|
|
("e" . "ᛂ")
|
|
|
|
|
("ø" . "ᚯ")
|
|
|
|
|
("o" . "ᚮ")
|
|
|
|
|
("ö" . "ᚰ")
|
|
|
|
|
("ó" . "ᚤ")
|
|
|
|
|
("æ" . "ᛅ")
|
|
|
|
|
("a" . "ᛆ")
|
|
|
|
|
("m" . "ᛘ")
|
|
|
|
|
("n" . "ᚾ")
|
|
|
|
|
("ń" . "ᛀ")
|
|
|
|
|
("p" . "ᛔ")
|
|
|
|
|
("b" . "ᛒ")
|
|
|
|
|
("t" . "ᛐ")
|
|
|
|
|
("d" . "ᛑ")
|
|
|
|
|
("k" . "ᚴ")
|
|
|
|
|
("g" . "ᚵ")
|
|
|
|
|
("f" . "ᚠ")
|
|
|
|
|
("þ" . "ᚦ")
|
|
|
|
|
("ð" . "ᚧ")
|
|
|
|
|
("s" . "ᛋ")
|
|
|
|
|
("h" . "ᚼ")
|
2019-08-22 18:29:04 +00:00
|
|
|
|
("v" . "ᚥ")
|
2019-08-13 14:39:23 +00:00
|
|
|
|
("r" . "ᚱ")
|
|
|
|
|
("l" . "ᛚ")))
|
2019-07-21 14:48:11 +00:00
|
|
|
|
|
2019-08-21 12:57:03 +00:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
; Common ;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
2019-07-21 14:48:11 +00:00
|
|
|
|
(defun conlanging//replace-string-by-char (t-string t-correspondance-table)
|
2019-07-21 15:24:46 +00:00
|
|
|
|
"Return a copy of t-string converted with the correspondance
|
|
|
|
|
table"
|
2019-08-12 23:52:51 +00:00
|
|
|
|
(interactive)
|
2019-07-21 14:48:11 +00:00
|
|
|
|
(while t-correspondance-table
|
|
|
|
|
(let ((cur-from-char (car (car t-correspondance-table)))
|
|
|
|
|
(cur-to-char (cdr (car t-correspondance-table))))
|
2019-08-12 23:52:51 +00:00
|
|
|
|
(setq t-string (replace-regexp-in-string cur-from-char cur-to-char
|
2019-07-21 14:48:11 +00:00
|
|
|
|
t-string))
|
|
|
|
|
(setq t-correspondance-table (cdr t-correspondance-table))))
|
|
|
|
|
t-string)
|
|
|
|
|
|
|
|
|
|
(defun conlanging//get-boundary ()
|
2019-07-21 15:24:46 +00:00
|
|
|
|
"Get the boundary of either the selected region, or if there is
|
|
|
|
|
none the word the cursor is over"
|
2019-07-21 14:48:11 +00:00
|
|
|
|
(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)
|
2019-07-21 15:24:46 +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."
|
2019-07-21 14:48:11 +00:00
|
|
|
|
(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)))
|
|
|
|
|
|
|
|
|
|
|
2019-08-12 23:52:51 +00:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
; Mattér ;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-07-21 14:48:11 +00:00
|
|
|
|
(defun conlanging/matter-to-runes ()
|
2019-08-13 14:39:23 +00:00
|
|
|
|
"Replaces transliterated Mattér with its runic writing system"
|
2019-07-21 14:48:11 +00:00
|
|
|
|
(interactive)
|
2019-08-12 23:52:51 +00:00
|
|
|
|
(conlanging//replace-char-by-table conlanging//matter-latin-to-runes))
|
2019-07-21 14:48:11 +00:00
|
|
|
|
|
|
|
|
|
(defun conlanging/matter-to-native-latin ()
|
2019-08-13 14:39:23 +00:00
|
|
|
|
"Replaces transliterated Mattér with its corresponding native
|
2019-07-21 15:24:46 +00:00
|
|
|
|
latin writing system"
|
2019-07-21 14:48:11 +00:00
|
|
|
|
(interactive)
|
2019-08-12 23:52:51 +00:00
|
|
|
|
(conlanging//replace-char-by-table conlanging//matter-latin-to-native))
|
|
|
|
|
|
|
|
|
|
(defun conlanging/matter-to-latex ()
|
2019-08-13 14:39:23 +00:00
|
|
|
|
"Replaces transliterated Mattér with its corresponding runes"
|
2019-08-12 23:52:51 +00:00
|
|
|
|
(interactive)
|
2019-08-13 14:39:23 +00:00
|
|
|
|
(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)))
|
2019-08-12 23:52:51 +00:00
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-08-21 12:57:03 +00:00
|
|
|
|
; Eittlanda ;
|
2019-08-12 23:52:51 +00:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-08-21 12:57:03 +00:00
|
|
|
|
(defun conlanging/eittlanda-to-runes ()
|
|
|
|
|
"Replaces transliterated Eittlandic with its runic writing system"
|
2019-08-12 23:52:51 +00:00
|
|
|
|
(interactive)
|
2019-08-21 12:57:03 +00:00
|
|
|
|
(conlanging//replace-char-by-table conlanging//eittlanda-latin-to-runes))
|
2019-07-21 14:48:11 +00:00
|
|
|
|
|
2019-08-21 12:57:03 +00:00
|
|
|
|
(defun conlanging/eittlanda-to-latex ()
|
|
|
|
|
"Replaces transliterated Eittlandic with its corresponding runes"
|
2019-08-13 14:39:23 +00:00
|
|
|
|
(interactive)
|
2019-08-21 12:57:03 +00:00
|
|
|
|
(conlanging//replace-char-by-table conlanging//eittlanda-latin-to-latex))
|
2019-08-13 14:39:23 +00:00
|
|
|
|
|
2019-08-21 12:57:03 +00:00
|
|
|
|
(defun conlanging/eittlanda-org-export-runes (text)
|
|
|
|
|
"Replaces transliterated Eittlandic with its corresponding runes during
|
2019-08-13 14:39:23 +00:00
|
|
|
|
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{"
|
2019-08-21 12:57:03 +00:00
|
|
|
|
(conlanging//replace-string-by-char text conlanging//eittlanda-latin-to-latex)
|
2019-08-13 14:39:23 +00:00
|
|
|
|
"}")
|
2019-08-21 12:57:03 +00:00
|
|
|
|
(conlanging//replace-string-by-char text conlanging//eittlanda-latin-to-runes)))
|