(require 'eev-glyphs)
(require 'eev-compose)
(if (not window-system)
(error "eev-math-glyphs.el is for X only"))
(defvar eev-math-glyphs-standard-display-table-backup nil
"A backup of standard-display-table (before adding user-defined glyphs)")
(if (not eev-math-glyphs-standard-display-table-backup)
(setq eev-math-glyphs-standard-display-table-backup
(copy-sequence standard-display-table)))
(defun eev-math-glyphs-reset ()
"Restore the standard-display-table and empties eev-composes-localmath."
(interactive)
(setq standard-display-table
(copy-sequence eev-math-glyphs-standard-display-table-backup))
(setq eev-composes-localmath nil)
(eev-composes-update))
(defun eev-glyphs-set-face (face fg bg)
(make-face face)
(set-face-foreground face fg)
(set-face-background face bg))
(eev-glyphs-set-face 'eev-glyph-face-Greek "orange" "gray20")
(eev-glyphs-set-face 'eev-glyph-face-greek "coral" "gray20")
(eev-glyphs-set-face 'eev-glyph-face-logical "SteelBlue1" "gray20")
(eev-glyphs-set-face 'eev-glyph-face-math "RoyalBlue2" "gray20")
(eev-glyphs-set-face 'eev-glyph-face-linear "PaleVioletRed" "gray20")
(eev-glyphs-set-face 'eev-glyph-face-graphic "red" "gray20")
(eev-glyphs-set-face 'eev-glyph-face-font "gold" "DarkOrange4")
(defvar eev-math-glyphs-name-to-char
'(("Theta" . 332664)
("Pi" . 332704)
("Sigma" . 332707)
("Omega" . 332713)
("delta" . 332724)
("epsilon" . 332725)
("theta" . 332728)
("lambda" . 343339)
("nu" . 332733)
("pi" . 332736)
("rho" . 332737)
("sigma" . 332739)
("tau" . 332740)
("omega" . 343541)
("top" . 343268)
("bot" . 343269)
("land" . 343111)
("lor" . 343112)
("supset" . 343235)
("forall" . 343072)
("exists" . 343075)
("box" . 299376)
("thin:" . 343126)
("in" . 343082)
("circ" . 343096)
("cap" . 343113)
("cup" . 343114)
("Int" . 343115)
("nabla" . 343079)
("infty" . 343102)
("ge" . 343205)
("^1" . 185)
("sqcap" . 343251)
("sqcup" . 343252)
("ud&" . 342827)
("oplus" . 343253)
("otimes" . 343259)
("to" . 342898)
("dotli" . 343375)
("nat" . 299502)
("seblock" . 299223)
("neblock" . 299229)
("b" . ?b)
("r" . ?r)
("t" . ?t)
("s" . ?s))
"An alist that translates char names\
(for mathematical glyphs) to char codes.")
(when (fboundp 'make-glyph-code)
(setq eev-math-glyphs-name-to-char
'(("Theta" . 920)
("Pi" . 928)
("Sigma" . 931)
("Omega" . 937)
("delta" . 948)
("epsilon" . 949)
("theta" . 952)
("lambda" . 955)
("nu" . 957)
("pi" . 960)
("rho" . 961)
("sigma" . 963)
("tau" . 964)
("omega" . 969)
("top" . 8868)
("bot" . 8869)
("land" . 8743)
("lor" . 8744)
("supset" . 8835)
("forall" . 8704)
("exists" . 8707)
("box" . 9744)
("thin:" . 8758)
("in" . 8712)
("circ" . 9675)
("cap" . 8745)
("cup" . 8746)
("Int" . 8747)
("nabla" . 8711)
("infty" . 8734)
("ge" . 8805)
("^1" . 185)
("sqcap" . 8851)
("sqcup" . 8852)
("ud&" . 8523)
("oplus" . 8853)
("otimes" . 8855)
("to" . 8594)
("lolli" . 8888)
("dotli" . 9480)
("nat" . 9838)
("seblock" . 9623)
("neblock" . 9629)
("b" . ?b)
("r" . ?r)
("t" . ?t)
("s" . ?s)
("ulcorn" . 8988)
("urcorn" . 8989))
)
)
' (progn (find-estring "")
(mapc (lambda (p) (insert (format "%c %s\n" (cdr p) (car p))))
eev-math-glyphs-name-to-char))
(defun ee-map-split (seq)
"Split with `ee-split' the strings in SEQ.
The original SEQ is not modified; this function returns a new list.
Example: (ee-map-split '(foo \"ab cd\" \"00 11\"))
==> (foo (\"ab\" \"cd\") (\"00\" \"11\"))"
(mapcar (lambda (x) (if (stringp x) (ee-split x) x)) seq))
(defun ee-map-nth (n seq)
"Substitute each list in SEQ by its N-th element.
The original SEQ is not modified; this function returns a new list.
(ee-map-nth 0 '(foo (a b c) (1 2) bar))
==> (foo a 1 bar)
(ee-map-nth 1 '(foo (a b c) (1 2) bar))
==> (foo b 2 bar)
(ee-map-nth 2 '(foo (a b c) (1 2) bar))
==> (foo c nil bar)"
(mapcar (lambda (x) (if (consp x) (nth n x) x)) seq))
(defun ee-chop1 (n bigseq)
"Return BIGSEQ split in N-element chunks.
Example: (ee-chop1 4 (number-sequence 1 10))
==> ((1 2 3 4) (5 6 7 8) (9 10))"
(setq bigseq (copy-sequence bigseq))
(let ((rest nil) (result nil))
(while bigseq
(setq rest (nthcdr n bigseq))
(if (nthcdr (- n 1) bigseq)
(setcdr (nthcdr (- n 1) bigseq) nil))
(setq result (cons bigseq result))
(setq bigseq rest))
(reverse result)))
(defun ee-chop2 (ref seq)
"Use `ee-map-nth' to return (length (nth REF SEQ)) \"sections\" of SEQ.
Examples:
(ee-chop2 1 '(foo (a b c) (1 2) bar))
==> ((foo a 1 bar) (foo b 2 bar) (foo c nil bar))
(ee-chop2 2 '(foo (a b c) (1 2) bar))
==> ((foo a 1 bar) (foo b 2 bar))"
(let ((ns (number-sequence 0 (- (length (nth ref seq)) 1))))
(mapcar (lambda (n) (ee-map-nth n seq)) ns)))
(defun ee-chop3 (n ref bigseq)
"Combine `ee-map-split', `ee-chop1', and `ee-chop2'.
Example:
(ee-chop3 4 1 '(Greek \"Pi Sigma Theta\" \"Pi Si Th\" (P S T)
greek \"delta epsilon\" \"dd ee\" (d e)))
==> ((Greek \"Pi\" \"Pi\" P)
(Greek \"Sigma\" \"Si\" S)
(Greek \"Theta\" \"Th\" T)
(greek \"delta\" \"dd\" d)
(greek \"epsilon\" \"ee\" e))"
(let* ((seqs (ee-chop1 n (ee-map-split bigseq)))
(columns (mapcar (lambda (seq) (ee-chop2 ref seq)) seqs)))
(apply 'append columns)))
(defun eev-math-glyphs-set (face names pairs chars &rest rest)
"This is hard to explain, but there's an example at:...
(find-efunction 'eev-math-glyphs-edrx)"
(setq names (split-string names " +"))
(setq pairs (split-string pairs " +"))
(setq chars (split-string chars " +"))
(while names
(let ((n (car names)) (p (car pairs)) (c (car chars)))
(if (= 1 (length c))
(let ((c (string-to-char c)))
(eev-set-glyph c (ee-aref eev-math-glyphs-name-to-char n) face)
(setq eev-composes-localmath
(lax-plist-put eev-composes-localmath p c)))))
(setq names (cdr names) pairs (cdr pairs) chars (cdr chars)))
(if rest (apply 'eev-math-glyphs-set rest)
(eev-composes-update)))
(defun eev-math-glyphs-edrx ()
"Sets up a certain set of mathematical glyphs for TeX, with compose pairs."
(interactive)
(eev-math-glyphs-set
'eev-glyph-face-Greek
"Theta Pi Sigma Omega"
"Th Pi Si Om "
"\336 \345 \306 \330 "
'eev-glyph-face-greek
"delta epsilon theta lambda nu pi rho sigma tau omega"
"dd ee te ll nu pi ro si tt ww "
"δ ε θ \360 \333 ρ σ τ \317 "
'eev-glyph-face-logical
"top bot land lor supset forall exists box thin: in circ"
"TT bt la lo im fa ex bo :: in oo "
"\247 \256 \264 ∨ \266 \375 \316 \361 \250 \335 \242 "
'eev-glyph-face-math
"cap cup Int nabla infty ge ^1"
"ca cu In na 88 >= -1"
"\314 \376 \305 \277 \202 \251 \263 "
'eev-glyph-face-linear
"sqcap sqcup ud& oplus otimes lolli"
"ka ku && o+ ox -o"
"⊓ \367 \321 \245 \244 \270 "
'eev-glyph-face-graphic
"dotli nat seblock neblock"
".. bq bl ^^ "
"(\367) \356 \255 \243 "
'eev-glyph-face-font
"b r t s "
"bf rm tx ss"
"\246 \257 \313 \320 "))
δεθρστ∨⊓
"
%*
% (ee-once (eelatex-bounded))
\catcode`\246=13 \def\246{\mathbf}
A natural transformation from $F:\246A \to \246B$ to $G:\246A \to \246B$ is...
%*
"
(provide 'eev-math-glyphs)