rev |
line source |
yuuji@11
|
1 ;;; -*- Emacs-Lisp -*-
|
yuuji@11
|
2 ;;; YaTeX interface for math-mode.
|
yuuji@13
|
3 ;;; yatexmth.el rev.2
|
yuuji@13
|
4 ;;; (c )1993 by HIROSE Yuuji [yuuji@ae.keio.ac.jp]
|
yuuji@13
|
5 ;;; Last modified Sat Jan 29 16:55:03 1994 on gloria
|
yuuji@11
|
6 ;;; $Id$
|
yuuji@11
|
7
|
yuuji@13
|
8 ;;; [Customization guide]
|
yuuji@13
|
9 ;;;
|
yuuji@13
|
10 ;;; By default, you can use two completion groups in YaTeX math
|
yuuji@13
|
11 ;;; mode, `,' for mathematical signs and `/' for greek letters. But
|
yuuji@13
|
12 ;;; you can add other completion groups by defining the alist of
|
yuuji@13
|
13 ;;; `prefix key' vs `completion list' into the variable
|
yuuji@13
|
14 ;;; YaTeX-math-key-list-private. If you wish to accomplish the
|
yuuji@13
|
15 ;;; completion as follows(prefix key is `;'):
|
yuuji@13
|
16 ;;;
|
yuuji@13
|
17 ;;; KEY COMPLETION
|
yuuji@13
|
18 ;;; s \sin
|
yuuji@13
|
19 ;;; S \arcsin
|
yuuji@13
|
20 ;;; c \cos
|
yuuji@13
|
21 ;;; C \arccos
|
yuuji@13
|
22 ;;; :
|
yuuji@13
|
23 ;;; T \arctan
|
yuuji@13
|
24 ;;; l \log
|
yuuji@13
|
25 ;;; hs \sinh
|
yuuji@13
|
26 ;;;
|
yuuji@13
|
27 ;;; Typing `s' after `;' makes `\sin', `hs' after `;' makes `\sinh'
|
yuuji@13
|
28 ;;; and so on. First, you have to define list of key-completion
|
yuuji@13
|
29 ;;; pairs. Variable name(YaTeX-math-funcs-list) is arbitrary.
|
yuuji@13
|
30 ;;;
|
yuuji@13
|
31 ;;; (setq YaTeX-math-funcs-list
|
yuuji@13
|
32 ;;; '(("s" "sin")
|
yuuji@13
|
33 ;;; ("S" "arcsin")
|
yuuji@13
|
34 ;;; :
|
yuuji@13
|
35 ;;; ("hs" "sinh")))
|
yuuji@13
|
36 ;;;
|
yuuji@13
|
37 ;;; Next, define the list of prefix-key vs completion list(defined
|
yuuji@13
|
38 ;;; above) into the variable YaTeX-math-key-list-private.
|
yuuji@13
|
39 ;;;
|
yuuji@13
|
40 ;;; (setq YaTeX-math-key-list-private
|
yuuji@13
|
41 ;;; '((";" . YaTeX-math-funcs-list)
|
yuuji@13
|
42 ;;; ("'" . Other-List-if-any)))
|
yuuji@13
|
43 ;;;
|
yuuji@13
|
44 ;;; Put these expressions into your ~/.emacs, and you can use this
|
yuuji@13
|
45 ;;; completion in the YaTeX-math-mode.
|
yuuji@13
|
46 ;;;
|
yuuji@13
|
47 ;;; And you can add your favorite completion sequences to the
|
yuuji@13
|
48 ;;; default completion list invoked with `,', by defining those lists
|
yuuji@13
|
49 ;;; into variable YaTeX-math-sign-alist-private.
|
yuuji@13
|
50
|
yuuji@13
|
51 ;;; 【イメージ補完の追加方法】
|
yuuji@13
|
52 ;;;
|
yuuji@13
|
53 ;;; 標準のイメージ補完では、「,」で始まる数式記号補完と、「/」で始
|
yuuji@13
|
54 ;;; まるギリシャ文字補完が使用可能ですが、これ以外の文字で始まる補完
|
yuuji@13
|
55 ;;; シリーズも定義することができます。例えば、「;」で始まる次のよう
|
yuuji@13
|
56 ;;; な補完シリーズを定義する場合を考えてみます。
|
yuuji@13
|
57 ;;;
|
yuuji@13
|
58 ;;; 補完キー 補完結果
|
yuuji@13
|
59 ;;; s \sin
|
yuuji@13
|
60 ;;; S \arcsin
|
yuuji@13
|
61 ;;; c \cos
|
yuuji@13
|
62 ;;; C \arccos
|
yuuji@13
|
63 ;;; :
|
yuuji@13
|
64 ;;; T \arctan
|
yuuji@13
|
65 ;;; l \log
|
yuuji@13
|
66 ;;; hs \sinh
|
yuuji@13
|
67 ;;;
|
yuuji@13
|
68 ;;; 「;」のあとに s を押すと \sin が、hs を押すと \sinh が入力されま
|
yuuji@13
|
69 ;;; す。このような補完リストの登録は以下のようにします(変数名は任意)。
|
yuuji@13
|
70 ;;;
|
yuuji@13
|
71 ;;; (setq YaTeX-math-funcs-list
|
yuuji@13
|
72 ;;; '(("s" "sin")
|
yuuji@13
|
73 ;;; ("S" "arcsin")
|
yuuji@13
|
74 ;;; :
|
yuuji@13
|
75 ;;; ("hs" "sinh")))
|
yuuji@13
|
76 ;;;
|
yuuji@13
|
77 ;;; さらに、「;」を押した時にイメージ補完が始まるよう次の変数に、起動キー
|
yuuji@13
|
78 ;;; と上で定義した補完用変数の登録を行ないます。
|
yuuji@13
|
79 ;;;
|
yuuji@13
|
80 ;;; (setq YaTeX-math-key-list-private
|
yuuji@13
|
81 ;;; '((";" . YaTeX-math-funcs-list)
|
yuuji@13
|
82 ;;; ("'" . ほかに定義したいシリーズがあれば…)))
|
yuuji@13
|
83 ;;;
|
yuuji@13
|
84 ;;; これらを ~/.emacs に書いておけば、野鳥の math-mode で自分専用の
|
yuuji@13
|
85 ;;; イメージ補完が利用できます。
|
yuuji@13
|
86
|
yuuji@13
|
87 (defvar YaTeX-jisold
|
yuuji@13
|
88 (and (boundp 'dos-machine-type)
|
yuuji@13
|
89 (eq dos-machine-type 'pc98)))
|
yuuji@13
|
90
|
yuuji@13
|
91 (defmacro YaTeX-setq-math-sym (sym old new)
|
yuuji@13
|
92 (list 'setq sym (list 'if 'YaTeX-jisold old new)))
|
yuuji@13
|
93
|
yuuji@13
|
94 (YaTeX-setq-math-sym YaTeX-image-in "E" "∈")
|
yuuji@13
|
95 (YaTeX-setq-math-sym YaTeX-image-ni "ヨ" "∋")
|
yuuji@13
|
96 (YaTeX-setq-math-sym YaTeX-image-subset " _\n(\n ~" "⊂")
|
yuuji@13
|
97 (YaTeX-setq-math-sym YaTeX-image-subseteq " _\n(_\n ~" "⊆")
|
yuuji@13
|
98 (YaTeX-setq-math-sym YaTeX-image-supset "_\n )\n~" "⊃")
|
yuuji@13
|
99 (YaTeX-setq-math-sym YaTeX-image-supseteq "_\n_)\n~" "⊇")
|
yuuji@13
|
100 (YaTeX-setq-math-sym YaTeX-image-nabla "___\n\\\\/" "∇")
|
yuuji@13
|
101 (YaTeX-setq-math-sym YaTeX-image-partial " -+\n+-+\n+-+" "∂")
|
yuuji@13
|
102 (YaTeX-setq-math-sym YaTeX-image-dagger "+\n|" "†")
|
yuuji@13
|
103 (YaTeX-setq-math-sym YaTeX-image-ddagger "+\n+\n|" "‡")
|
yuuji@13
|
104 (YaTeX-setq-math-sym YaTeX-image-equiv "=\n ̄" "≡")
|
yuuji@13
|
105 (YaTeX-setq-math-sym YaTeX-image-int " /\\\n \\\n\\/" "∫")
|
yuuji@13
|
106 (YaTeX-setq-math-sym YaTeX-image-bot "|\n ̄" "⊥")
|
yuuji@13
|
107 (YaTeX-setq-math-sym YaTeX-image-neg "イ" "¬")
|
yuuji@13
|
108 (YaTeX-setq-math-sym YaTeX-image-flat "b" "♭")
|
yuuji@13
|
109
|
yuuji@11
|
110 (setq
|
yuuji@13
|
111 YaTeX-math-sign-alist-default
|
yuuji@11
|
112 '(
|
yuuji@11
|
113 ;frequently used
|
yuuji@11
|
114 ("||" "|" ("||" "‖"))
|
yuuji@11
|
115 ("sum" "sum" ("\\-+\n >\n/-+" "Σ"))
|
yuuji@11
|
116 ("sigma" "sum" ("\\-+\n >\n/-+" "Σ"))
|
yuuji@13
|
117 ("integral" "int" (" /\\\n \\\n\\/" YaTeX-image-int))
|
yuuji@11
|
118 ("ointegral" "oint" " /\\\n(\\)\n\\/")
|
yuuji@11
|
119 ("A" "forall" "|_|\nV")
|
yuuji@11
|
120 ("E" "exists" "-+\n-+\n-+")
|
yuuji@13
|
121 ("!" "neg" ("--+\n |" YaTeX-image-neg))
|
yuuji@11
|
122 ("oo" "infty" ("oo" "∞"))
|
yuuji@11
|
123 ("\\" "backslash" ("\\" "\"))
|
yuuji@11
|
124
|
yuuji@11
|
125 ;;binary operators
|
yuuji@11
|
126 ("+-" "pm" ("+\n-" "±"))
|
yuuji@11
|
127 ("-+" "mp" "-\n+")
|
yuuji@11
|
128 ("x" "times" ("x" "×"))
|
yuuji@11
|
129 ("/" "div" (",\n-\n'" "÷"))
|
yuuji@11
|
130 ("*" "ast" "*")
|
yuuji@11
|
131 ("#" "star" ("_/\\_\n\\ /\n//\\\\" "★"))
|
yuuji@11
|
132 ("o" "circ" "o")
|
yuuji@11
|
133 ("o*" "bullet" " _\n(*)\n ~")
|
yuuji@11
|
134 ("." "cdot" ".")
|
yuuji@11
|
135 ("cap" "cap" "/-\\\n| |")
|
yuuji@11
|
136 ("cup" "cup" "| |\n\\-/")
|
yuuji@11
|
137 ("u+" "uplus" "|+|\n\\-/")
|
yuuji@11
|
138 ("|~|" "sqcap" "|~|")
|
yuuji@11
|
139 ("|_|" "sqcup" "|_|")
|
yuuji@11
|
140 ("v" "vee" "v")
|
yuuji@11
|
141 ("^" "wedge" "^")
|
yuuji@11
|
142 ("\\\\" "setminus" "\\")
|
yuuji@11
|
143 (")(" "wr" " )\n(")
|
yuuji@11
|
144 ("<>" "diamond" "<>")
|
yuuji@11
|
145 ("/\-" "bigtriangleup" ("/\\\n~~" "△"))
|
yuuji@11
|
146 ("-\\/" "bigtriangledown" ("__\n\\/" "▽"))
|
yuuji@11
|
147 ("<|" "triangleleft" "<|")
|
yuuji@11
|
148 ("|>" "triangleright" "|>")
|
yuuji@11
|
149 ("<||" "lhd" "/|\n\\|")
|
yuuji@11
|
150 ("||>" "rhd" "|\\\n|/")
|
yuuji@11
|
151 ("<|-" "unlhd" "<|\n~~")
|
yuuji@11
|
152 ("|>-" "unrhd" "|>\n~~")
|
yuuji@11
|
153 ("o+" "oplus" " _\n(+)\n ~")
|
yuuji@11
|
154 ("o-" "ominus" " _\n(-)\n ~")
|
yuuji@11
|
155 ("ox" "otimes" " _\n(x)\n ~")
|
yuuji@11
|
156 ("o/" "oslash" " _\n(/)\n ~")
|
yuuji@11
|
157 ("o." "odot" "(.)")
|
yuuji@11
|
158 ("O" "bigcirc" "O")
|
yuuji@13
|
159 ("t" "dagger" ("+\n|" YaTeX-image-dagger))
|
yuuji@13
|
160 ("tt" "ddagger" ("+\n+\n|" YaTeX-image-ddagger))
|
yuuji@11
|
161 ("II" "amalg" "II")
|
yuuji@11
|
162 ; :
|
yuuji@11
|
163 ;;relational operators
|
yuuji@11
|
164 ("<" "leq" ("<\n-" "≦"))
|
yuuji@11
|
165 (">" "geq" (">\n-" "≧"))
|
yuuji@13
|
166 ("-=" "equiv" ("=\n-" YaTeX-image-equiv))
|
yuuji@13
|
167 ("=-" "equiv" ("=\n-" YaTeX-image-equiv))
|
yuuji@13
|
168 ("---" "equiv" ("=\n-" YaTeX-image-equiv))
|
yuuji@13
|
169 ("(" "subset" (" _\n(\n ~" YaTeX-image-subset))
|
yuuji@13
|
170 ("(-" "subseteq" (" _\n(_\n ~" YaTeX-image-subseteq))
|
yuuji@13
|
171 (")" "supset" ("_\n )\n~" YaTeX-image-supset))
|
yuuji@13
|
172 (")-" "supseteq" ("_\n_)\n~" YaTeX-image-supseteq))
|
yuuji@11
|
173 ("[" "sqsubset" "[")
|
yuuji@11
|
174 ("[-" "sqsubseteq" "[\n~")
|
yuuji@11
|
175 ("]" "sqsupset" "]")
|
yuuji@11
|
176 ("]-" "sqsupseteq" "]\n~")
|
yuuji@13
|
177 ("{" "in" ("(-" YaTeX-image-in))
|
yuuji@13
|
178 ("}" "ni" ("-)" YaTeX-image-ni))
|
yuuji@11
|
179 ("|-" "vdash" "|-")
|
yuuji@11
|
180 ("-|" "dashv" "-|")
|
yuuji@11
|
181 ("~" "sim" "~(tild)")
|
yuuji@11
|
182 ("~-" "simeq" "~\n-")
|
yuuji@11
|
183 ("asymp" "asymp" "v\n^")
|
yuuji@11
|
184 ("~~" "approx" "~\n~")
|
yuuji@11
|
185 ("~=" "cong" "~\n=")
|
yuuji@11
|
186 ("=/" "neq" ("=/=" "≠"))
|
yuuji@11
|
187 (".=" "doteq" ".\n=")
|
yuuji@11
|
188 ("o<" "propto" "o<")
|
yuuji@11
|
189 ("|=" "models" "|=")
|
yuuji@11
|
190 ("_|_" "perp" "_|_")
|
yuuji@11
|
191 ("|" "mid" "|")
|
yuuji@11
|
192 ("||" "parallel" "||")
|
yuuji@11
|
193 ("bowtie" "bowtie" "|><|(wide)")
|
yuuji@11
|
194 ("|><|" "join" "|><|")
|
yuuji@11
|
195 ("\\_/" "smile" "\\_/")
|
yuuji@11
|
196 ("/~\\" "frown" "/~~\\")
|
yuuji@11
|
197 ("-<" "prec" ("-<" "く"))
|
yuuji@11
|
198 ("-<=" "preceq" ("-<\n-" "く\n="))
|
yuuji@11
|
199 ("<<" "ll" ("<<" "《"))
|
yuuji@11
|
200 ; :
|
yuuji@11
|
201 ;;arrows
|
yuuji@11
|
202 ("<-" "leftarrow" ("<-" "←"))
|
yuuji@13
|
203 ("\C-b" "leftarrow" ("<-" "←"))
|
yuuji@13
|
204 ("<--" "longleftarrow" ("<--" "←--"))
|
yuuji@11
|
205 ("<=" "Leftarrow" "<=")
|
yuuji@11
|
206 ("<==" "Longleftarrow" "<==")
|
yuuji@11
|
207 ("->" "rightarrow" ("->" "→"))
|
yuuji@13
|
208 ("\C-f" "rightarrow" ("->" "→"))
|
yuuji@11
|
209 ("-->" "longrightarrow" ("-->" "--→"))
|
yuuji@11
|
210 ("==>" "Longrightarrow" "==>")
|
yuuji@11
|
211 ("<->" "leftrightarrow" ("<->" "←→"))
|
yuuji@11
|
212 ("<-->" "longleftrightarrow" ("<---->" "←--→"))
|
yuuji@11
|
213 ("<=>" "leftrightarrow" "<=>")
|
yuuji@11
|
214 ("<==>" "Longleftrightarrow" "<==>")
|
yuuji@11
|
215 ("^|" "uparrow" ("^\n|" "↑"))
|
yuuji@13
|
216 ("\C-p" "uparrow" ("^\n|" "↑"))
|
yuuji@11
|
217 ("^||" "Uparrow" "/\\\n||")
|
yuuji@11
|
218 ("\C-n" "downarrow" ("|\nv" "↓"))
|
yuuji@13
|
219 ("v|" "downarrow" ("|\nv" "↓"))
|
yuuji@13
|
220 ("v||" "Downarrow" "||\n\\/")
|
yuuji@11
|
221 ("|->" "mapsto" ("|->" "|→"))
|
yuuji@11
|
222 ("<-)" "hookleftarrow" (" ,\n<--+" " ヽ\n<--/"))
|
yuuji@11
|
223 ("/-" "leftharpoonup" "/\n~~~")
|
yuuji@11
|
224 ("\\-" "leftharpoondown" "__\n\\")
|
yuuji@11
|
225 ("-/" "rightharpoondown" "__\n/")
|
yuuji@11
|
226 ("-\\" "rightharpoonup" "~~\n\\")
|
yuuji@11
|
227 ;other marks
|
yuuji@11
|
228 ("Z" "aleph" "|\\|")
|
yuuji@11
|
229 ("|\\|" "aleph" "|\\|")
|
yuuji@11
|
230 ("h-" "hbar" "_\nh")
|
yuuji@11
|
231 ("i" "imath" "i")
|
yuuji@11
|
232 ("j" "jmath" "j")
|
yuuji@11
|
233 ("l" "ell" "l")
|
yuuji@11
|
234 ("wp" "wp" "???")
|
yuuji@11
|
235 ("R" "Re" ")R")
|
yuuji@11
|
236 ("Im" "Im" "???")
|
yuuji@11
|
237 ("mho" "mho" "~|_|~")
|
yuuji@11
|
238 ("'" "prime" "'")
|
yuuji@11
|
239 ("0" "emptyset" "0")
|
yuuji@13
|
240 ("nabla" "nabla" ("___\n\\\\/" YaTeX-image-nabla))
|
yuuji@11
|
241 ("\\/" "surd" "-\\/")
|
yuuji@11
|
242 ("surd" "surd" "-\\/")
|
yuuji@11
|
243 ("top" "top" "T")
|
yuuji@13
|
244 ("bot" "bot" ("_|_" YaTeX-image-bot))
|
yuuji@13
|
245 ("b" "flat" ("b" YaTeX-image-flat))
|
yuuji@11
|
246 ("LT" "natural" "|\nLT\n |")
|
yuuji@13
|
247 ("6" "partial" (" -+\n+-+\n+-+" YaTeX-image-partial))
|
yuuji@13
|
248 ("partial" "partial" (" -+\n+-+\n+-+" YaTeX-image-partial))
|
yuuji@13
|
249 ("round" "partial" (" -+\n+-+\n+-+" YaTeX-image-partial))
|
yuuji@11
|
250 ("[]" "box" "[]")
|
yuuji@11
|
251 ("Diamond" "Diamond" "/\\\n\\/")
|
yuuji@11
|
252 ("3" "triangle" "/\\\n~~")
|
yuuji@11
|
253 ("C" "clubsuit" " o\no+o\n |")
|
yuuji@11
|
254 ("D" "diamondsuit" "/\\\n\\/")
|
yuuji@11
|
255 ("H" "heartsuit" "<^^>\n \\/")
|
yuuji@11
|
256 ("S" "spadesuit" " /\\\n<++>\n /\\")
|
yuuji@11
|
257
|
yuuji@11
|
258 ))
|
yuuji@11
|
259
|
yuuji@13
|
260 (defvar YaTeX-math-sign-alist-private nil
|
yuuji@11
|
261 "*User definable key vs LaTeX-math-command alist.")
|
yuuji@11
|
262
|
yuuji@11
|
263 (defvar YaTeX-math-quit-with-strict-match nil
|
yuuji@11
|
264 "*T for quitting completion as soon as strict-match is found.")
|
yuuji@13
|
265 (setq YaTeX-math-sign-alist
|
yuuji@13
|
266 (append YaTeX-math-sign-alist-private YaTeX-math-sign-alist-default))
|
yuuji@11
|
267
|
yuuji@13
|
268 ;;(defun YaTeX-math-alist2array (alist array)
|
yuuji@13
|
269 ;; (set array
|
yuuji@13
|
270 ;; (let ((array (make-vector (length alist) "")) (list alist) (i 0))
|
yuuji@13
|
271 ;; (while list
|
yuuji@13
|
272 ;; (aset array i (car (car list)))
|
yuuji@13
|
273 ;; (setq i (1+ i) list (cdr list)))
|
yuuji@13
|
274 ;; array))
|
yuuji@13
|
275 ;;)
|
yuuji@11
|
276
|
yuuji@13
|
277 (setq YaTeX-greek-key-alist-default
|
yuuji@13
|
278 '(
|
yuuji@13
|
279 ("a" "alpha" ("a" "α"))
|
yuuji@13
|
280 ("b" "beta" ("|>\n|>\n|" "β"))
|
yuuji@13
|
281 ("g" "gamma" ("~r" "γ"))
|
yuuji@13
|
282 ("G" "Gamma" ("|~" "Γ"))
|
yuuji@13
|
283 ("d" "delta" ("<~\n<>" "δ"))
|
yuuji@13
|
284 ("D" "Delta" ("/\\\n~~" "Δ"))
|
yuuji@13
|
285 ("e" "epsilon" "<\n<~")
|
yuuji@13
|
286 ("e-" "varepsilon" ("(\n(~" "ε"))
|
yuuji@13
|
287 ("z" "zeta" ("(~\n >" "ζ"))
|
yuuji@13
|
288 ("et" "eta" ("n\n/" "η"))
|
yuuji@13
|
289 ("th" "theta" ("8" "θ"))
|
yuuji@13
|
290 ("Th" "Theta" ("(8)" "Θ"))
|
yuuji@13
|
291 ("th-" "vartheta" ("-8" "-θ"))
|
yuuji@13
|
292 ("i" "iota" ("i\n\\_/" "ι"))
|
yuuji@13
|
293 ("k" "kappa" ("k" "κ"))
|
yuuji@13
|
294 ("l" "lambda" ("\\n/\\" "λ"))
|
yuuji@13
|
295 ("L" "Lambda" ("/\\" "Λ"))
|
yuuji@13
|
296 ("m" "mu" (" u_\n/" "μ"))
|
yuuji@13
|
297 ("n" "nu" ("|/" "ν"))
|
yuuji@13
|
298 ("x" "xi" ("E\n >" "ξ"))
|
yuuji@13
|
299 ("X" "Xi" ("---\n -\n---" "Ξ"))
|
yuuji@13
|
300 ("p" "pi" ("__\n)(" "π"))
|
yuuji@13
|
301 ("P" "Pi" ("__\n||" "Π"))
|
yuuji@13
|
302 ("p-" "varpi" ("_\nw" "__\nω"))
|
yuuji@13
|
303 ("r" "rho" ("/O" "ρ"))
|
yuuji@13
|
304 ("r-" "varrho" ("/O\n~~" "ρ\n~~"))
|
yuuji@13
|
305 ("s" "sigma" ("o~" "σ"))
|
yuuji@13
|
306 ("S" "Sigma" ("\\-+\n >\n/-+" "Σ"))
|
yuuji@13
|
307 ("s-" "varsigma" "(~~ \n>")
|
yuuji@13
|
308 ("t" "tau" ("__\n(" "τ"))
|
yuuji@13
|
309 ("u" "upsilon" ("~v" "υ"))
|
yuuji@13
|
310 ("y" "upsilon" ("~v" "υ"))
|
yuuji@13
|
311 ("U" "Upsilon" ("~Y~" "Υ"))
|
yuuji@13
|
312 ("Y" "Upsilon" ("~Y~" "Υ"))
|
yuuji@13
|
313 ("ph" "phi" (" /\n(/)\n/" "φ"))
|
yuuji@13
|
314 ("Ph" "Phi" (" _\n(|)\n ~" "Φ"))
|
yuuji@13
|
315 ("ph-" "varphi" "\\O\n|")
|
yuuji@13
|
316 ("c" "chi" ("x" "χ"))
|
yuuji@13
|
317 ("ps" "psi" ("\\|/\\n |" "ψ"))
|
yuuji@13
|
318 ("Ps" "Psi" (" ~\n\\|/\\n |" "Ψ"))
|
yuuji@13
|
319 ("o" "omega" ("w" "ω"))
|
yuuji@13
|
320 ("w" "omega" ("w" "ω"))
|
yuuji@13
|
321 ("O" "Omega" ("(~)\n~ ~" "Ω"))
|
yuuji@13
|
322 ("W" "Omega" ("(~)\n~ ~" "Ω"))
|
yuuji@13
|
323 ("f" "foo")
|
yuuji@13
|
324 )
|
yuuji@13
|
325 )
|
yuuji@13
|
326
|
yuuji@13
|
327 (defvar YaTeX-greek-key-alist-private nil
|
yuuji@13
|
328 "*User definable key vs LaTeX-math-command alist.")
|
yuuji@13
|
329
|
yuuji@13
|
330 (setq YaTeX-greek-key-alist
|
yuuji@13
|
331 (append YaTeX-greek-key-alist-private YaTeX-greek-key-alist-default))
|
yuuji@13
|
332
|
yuuji@13
|
333 ;;(mapcar (function (lambda (x) (YaTeX-math-alist2array x)))
|
yuuji@13
|
334 ;; YaTeX-math-key-list)
|
yuuji@13
|
335
|
yuuji@11
|
336 (setq YaTeX-math-indicator
|
yuuji@11
|
337 "KEY\tLaTeX sequence\t\tsign")
|
yuuji@11
|
338
|
yuuji@11
|
339 (defvar YaTeX-math-need-image t
|
yuuji@11
|
340 "*T for displaying pseudo image momentarily.")
|
yuuji@11
|
341 (defvar YaTeX-math-max-key 8)
|
yuuji@11
|
342 (defvar YaTeX-math-max-seq
|
yuuji@11
|
343 (* 8 (1+ (/ (length "\\longleftrightarrow") 8))))
|
yuuji@11
|
344 (defvar YaTeX-math-max-sign 5)
|
yuuji@11
|
345 (defvar YaTeX-math-sign-width
|
yuuji@11
|
346 (+ YaTeX-math-max-key YaTeX-math-max-seq YaTeX-math-max-sign))
|
yuuji@11
|
347 (defvar YaTeX-math-display-width
|
yuuji@11
|
348 (* 8 (1+ (/ YaTeX-math-sign-width 8))))
|
yuuji@11
|
349 (defvar YaTeX-math-menu-map nil
|
yuuji@11
|
350 "Keymap used in YaTeX mathematical sign menu mode."
|
yuuji@11
|
351 )
|
yuuji@11
|
352 (if YaTeX-math-menu-map nil
|
yuuji@11
|
353 (setq YaTeX-math-menu-map (make-sparse-keymap))
|
yuuji@11
|
354 (define-key YaTeX-math-menu-map "n" 'next-line)
|
yuuji@11
|
355 (define-key YaTeX-math-menu-map "p" 'previous-line)
|
yuuji@11
|
356 (define-key YaTeX-math-menu-map "f" 'YaTeX-math-forward)
|
yuuji@11
|
357 (define-key YaTeX-math-menu-map "b" 'YaTeX-math-backward)
|
yuuji@11
|
358 (define-key YaTeX-math-menu-map "v" 'scroll-up)
|
yuuji@11
|
359 (define-key YaTeX-math-menu-map " " 'scroll-up)
|
yuuji@11
|
360 (define-key YaTeX-math-menu-map "c" 'scroll-up)
|
yuuji@11
|
361 (define-key YaTeX-math-menu-map "V" 'scroll-down)
|
yuuji@11
|
362 (define-key YaTeX-math-menu-map "r" 'scroll-down)
|
yuuji@11
|
363 (define-key YaTeX-math-menu-map "\^h" 'scroll-down)
|
yuuji@11
|
364 (define-key YaTeX-math-menu-map "<" 'beginning-of-buffer)
|
yuuji@11
|
365 (define-key YaTeX-math-menu-map ">" 'end-of-buffer)
|
yuuji@11
|
366 (define-key YaTeX-math-menu-map "\^m" 'exit-recursive-edit)
|
yuuji@11
|
367 (define-key YaTeX-math-menu-map "q" 'abort-recursive-edit))
|
yuuji@11
|
368
|
yuuji@13
|
369 (defvar YaTeX-math-key-list-default
|
yuuji@13
|
370 '(("," . YaTeX-math-sign-alist)
|
yuuji@13
|
371 ("/" . YaTeX-greek-key-alist))
|
yuuji@13
|
372 "Default key sequence to invoke math-mode's image completion."
|
yuuji@13
|
373 )
|
yuuji@13
|
374 (defvar YaTeX-math-key-list-private nil
|
yuuji@13
|
375 "*User defined alist, math-mode-prefix vs completion alist"
|
yuuji@13
|
376 )
|
yuuji@13
|
377 (defvar YaTeX-math-key-list
|
yuuji@13
|
378 (append YaTeX-math-key-list-private YaTeX-math-key-list-default)
|
yuuji@13
|
379 "Key sequence to invoke math-mode's image completion."
|
yuuji@13
|
380 )
|
yuuji@13
|
381 (defvar YaTeX-math-exit-key "\e"
|
yuuji@13
|
382 "*Key sequence after prefix key of YaTeX-math-mode to exit from math-mode."
|
yuuji@13
|
383 )
|
yuuji@13
|
384
|
yuuji@11
|
385 (defmacro YaTeX-math-japanese-sign (list)
|
yuuji@11
|
386 (list 'nth 1 list))
|
yuuji@11
|
387
|
yuuji@11
|
388 (defvar YaTeX-math-cmd-regexp (concat (regexp-quote YaTeX-ec) "[A-z]"))
|
yuuji@11
|
389
|
yuuji@13
|
390 ;;;
|
yuuji@13
|
391 ;;YaTeX math-mode functions
|
yuuji@13
|
392 ;;;
|
yuuji@13
|
393 ;##autoload from yatex.el
|
yuuji@13
|
394 (defun YaTeX-toggle-math-mode (&optional arg)
|
yuuji@13
|
395 (interactive "P")
|
yuuji@13
|
396 (require 'yatexmth)
|
yuuji@13
|
397 (or (memq 'YaTeX-math-mode mode-line-format) nil
|
yuuji@13
|
398 (setq mode-line-format
|
yuuji@13
|
399 (append (list "" 'YaTeX-math-mode) mode-line-format)))
|
yuuji@13
|
400 (if (or arg (null YaTeX-math-mode))
|
yuuji@13
|
401 (let ((keys ""))
|
yuuji@13
|
402 (setq YaTeX-math-mode "math:")
|
yuuji@13
|
403 (mapcar
|
yuuji@13
|
404 (function (lambda (x)
|
yuuji@13
|
405 (let ((key (car x)) (list (cdr x)))
|
yuuji@13
|
406 (setq keys (concat keys " " key))
|
yuuji@13
|
407 (put 'YaTeX-math-key-list list (key-binding key))
|
yuuji@13
|
408 (define-key YaTeX-mode-map key
|
yuuji@13
|
409 'YaTeX-math-insert-sequence))))
|
yuuji@13
|
410 YaTeX-math-key-list)
|
yuuji@13
|
411 (message "Turn on math mode. Prefix keys are %s" keys)
|
yuuji@13
|
412 (sit-for 3)
|
yuuji@13
|
413 (message
|
yuuji@13
|
414 (concat "To exit from math-mode, type `ESC' after prefix, "
|
yuuji@13
|
415 "or type `"
|
yuuji@13
|
416 (key-description
|
yuuji@13
|
417 (car
|
yuuji@13
|
418 (where-is-internal 'YaTeX-switch-mode-menu YaTeX-mode-map)))
|
yuuji@13
|
419 " $'")))
|
yuuji@13
|
420 (setq YaTeX-math-mode nil)
|
yuuji@13
|
421 (mapcar
|
yuuji@13
|
422 (function (lambda (x)
|
yuuji@13
|
423 (let ((key (car x)) (list (cdr x)))
|
yuuji@13
|
424 (define-key YaTeX-mode-map key
|
yuuji@13
|
425 (get 'YaTeX-math-key-list list)))))
|
yuuji@13
|
426 YaTeX-math-key-list)
|
yuuji@13
|
427 (setq YaTeX-math-mode nil)
|
yuuji@13
|
428 (message "Exit from math mode."))
|
yuuji@13
|
429 (set-buffer-modified-p (buffer-modified-p))
|
yuuji@13
|
430 )
|
yuuji@13
|
431
|
yuuji@11
|
432 (defun YaTeX-math-forward (arg)
|
yuuji@11
|
433 (interactive "p")
|
yuuji@11
|
434 (re-search-forward YaTeX-math-cmd-regexp nil t arg))
|
yuuji@11
|
435
|
yuuji@11
|
436 (defun YaTeX-math-backward (arg)
|
yuuji@11
|
437 (interactive "p")
|
yuuji@11
|
438 (re-search-backward YaTeX-math-cmd-regexp nil t arg))
|
yuuji@11
|
439
|
yuuji@13
|
440 (defun YaTeX-math-gets (sign)
|
yuuji@13
|
441 (cond
|
yuuji@13
|
442 ((null sign) nil)
|
yuuji@13
|
443 ((listp sign)
|
yuuji@13
|
444 (setq sign
|
yuuji@13
|
445 (cond
|
yuuji@13
|
446 (YaTeX-japan (YaTeX-math-japanese-sign sign))
|
yuuji@13
|
447 (t (car sign))))
|
yuuji@13
|
448 (YaTeX-math-gets sign))
|
yuuji@13
|
449 ((symbolp sign)
|
yuuji@13
|
450 (YaTeX-math-gets (symbol-value sign)))
|
yuuji@13
|
451 (t sign))
|
yuuji@13
|
452 )
|
yuuji@13
|
453
|
yuuji@11
|
454 (defun YaTeX-math-get-sign (list)
|
yuuji@13
|
455 (YaTeX-math-gets (car (cdr-safe (cdr-safe list))))
|
yuuji@11
|
456 )
|
yuuji@11
|
457
|
yuuji@11
|
458 (defun YaTeX-math-display-list (list cols)
|
yuuji@11
|
459 (goto-char (point-max))
|
yuuji@11
|
460 (if (= cols 0) (if (not (eolp)) (newline 1))
|
yuuji@11
|
461 (forward-line -1)
|
yuuji@11
|
462 (while (looking-at "[ \t\n]") (forward-line -1)))
|
yuuji@11
|
463 (end-of-line)
|
yuuji@11
|
464 (let ((indent (* YaTeX-math-display-width cols)) sign str to)
|
yuuji@11
|
465 (indent-to indent)
|
yuuji@11
|
466 (insert (car list))
|
yuuji@11
|
467 (indent-to (setq indent (+ indent YaTeX-math-max-key)))
|
yuuji@11
|
468 (insert "\\" (car (cdr list)))
|
yuuji@11
|
469 (setq indent (+ indent YaTeX-math-max-seq))
|
yuuji@11
|
470 (setq sign (YaTeX-math-get-sign list))
|
yuuji@13
|
471 (while (and sign (not (string= "" sign)))
|
yuuji@11
|
472 (setq to (string-match "\n" sign)
|
yuuji@11
|
473 str (if to (substring sign 0 to) sign))
|
yuuji@11
|
474 (end-of-line)
|
yuuji@11
|
475 (indent-to indent)
|
yuuji@11
|
476 (insert str)
|
yuuji@11
|
477 (cond ((eobp) (newline 1))
|
yuuji@11
|
478 ((> cols 0) (forward-line 1)))
|
yuuji@11
|
479 (setq sign (if to (substring sign (1+ to)) "")))))
|
yuuji@11
|
480
|
yuuji@11
|
481 (defvar YaTeX-math-menu-buffer "*math-mode-signs*")
|
yuuji@11
|
482
|
yuuji@11
|
483 (defun YaTeX-math-show-menu (match-str)
|
yuuji@11
|
484 (save-window-excursion
|
yuuji@11
|
485 (pop-to-buffer YaTeX-math-menu-buffer)
|
yuuji@11
|
486 (let ((maxcols (max 1 (/ (screen-width) YaTeX-math-sign-width)))
|
yuuji@11
|
487 (case-fold-search nil)
|
yuuji@13
|
488 (cols 0) (list alist) command)
|
yuuji@11
|
489 (erase-buffer)
|
yuuji@13
|
490 (insert
|
yuuji@13
|
491 "Candidates of sign. [n:next p:prev f:forw b:back q:quit RET:select]\n")
|
yuuji@11
|
492 (insert YaTeX-math-indicator "\t")
|
yuuji@11
|
493 (insert YaTeX-math-indicator)
|
yuuji@11
|
494 (newline 1)
|
yuuji@11
|
495 (insert-char ?- (1- (screen-width)))
|
yuuji@11
|
496 (newline 1)
|
yuuji@11
|
497 (while list
|
yuuji@11
|
498 (if (string-match match-str (car (car list)))
|
yuuji@11
|
499 (progn (YaTeX-math-display-list (car list) cols)
|
yuuji@11
|
500 (setq cols (% (1+ cols) maxcols))))
|
yuuji@11
|
501 (setq list (cdr list)))
|
yuuji@13
|
502 (goto-line 4)
|
yuuji@11
|
503 (use-local-map YaTeX-math-menu-map)
|
yuuji@11
|
504 (unwind-protect
|
yuuji@11
|
505 (recursive-edit)
|
yuuji@11
|
506 (skip-chars-backward "^ \t\n")
|
yuuji@11
|
507 (setq command
|
yuuji@11
|
508 (if (re-search-forward YaTeX-math-cmd-regexp nil t)
|
yuuji@11
|
509 (buffer-substring
|
yuuji@11
|
510 (match-beginning 0)
|
yuuji@11
|
511 (prog2 (skip-chars-forward "^ \t\n") (point)))
|
yuuji@11
|
512 nil))
|
yuuji@11
|
513 (kill-buffer YaTeX-math-menu-buffer))
|
yuuji@11
|
514 command))
|
yuuji@11
|
515 )
|
yuuji@11
|
516
|
yuuji@11
|
517 ;
|
yuuji@11
|
518 (defun YaTeX-math-show-image (image &optional exit-char)
|
yuuji@11
|
519 "Momentarily display IMAGE at the beginning of the next line;
|
yuuji@11
|
520 erase it on the next keystroke. The window is recentered if necessary
|
yuuji@11
|
521 to make the whole string visible. If the window isn't large enough,
|
yuuji@11
|
522 at least you get to read the beginning."
|
yuuji@13
|
523 (if (and image (not (string= image "")))
|
yuuji@13
|
524 (let ((buffer-read-only nil)
|
yuuji@13
|
525 (modified (buffer-modified-p))
|
yuuji@13
|
526 (name buffer-file-name)
|
yuuji@13
|
527 insert-start
|
yuuji@13
|
528 insert-end)
|
yuuji@13
|
529 (unwind-protect
|
yuuji@13
|
530 (progn
|
yuuji@13
|
531 (save-excursion
|
yuuji@13
|
532 ;; defeat file locking... don't try this at home, kids!
|
yuuji@13
|
533 (setq buffer-file-name nil)
|
yuuji@13
|
534 (forward-line 1)
|
yuuji@13
|
535 (setq insert-start (point))
|
yuuji@13
|
536 (if (eobp) (newline))
|
yuuji@13
|
537 (insert image)
|
yuuji@13
|
538 (setq insert-end (point)))
|
yuuji@13
|
539 ; make sure the whole string is visible
|
yuuji@13
|
540 (if (not (pos-visible-in-window-p insert-end))
|
yuuji@13
|
541 (recenter (max 0
|
yuuji@13
|
542 (- (window-height)
|
yuuji@13
|
543 (count-lines insert-start insert-end)
|
yuuji@13
|
544 2))))
|
yuuji@13
|
545 (let ((char (read-char)))
|
yuuji@13
|
546 (or (eq char exit-char)
|
yuuji@13
|
547 (setq unread-command-char char))))
|
yuuji@13
|
548 (if insert-end
|
yuuji@13
|
549 (save-excursion
|
yuuji@13
|
550 (delete-region insert-start insert-end)))
|
yuuji@13
|
551 (setq buffer-file-name name)
|
yuuji@13
|
552 (set-buffer-modified-p modified)))))
|
yuuji@11
|
553
|
yuuji@11
|
554 (defun YaTeX-math-insert-sequence ()
|
yuuji@11
|
555 (interactive)
|
yuuji@13
|
556 (let*((key "") regkey str last-char list i
|
yuuji@13
|
557 (case-fold-search nil) match sign
|
yuuji@13
|
558 (this-key (char-to-string last-command-char))
|
yuuji@13
|
559 (alist (symbol-value (cdr (assoc this-key YaTeX-math-key-list))))
|
yuuji@13
|
560 (n (length alist)) (beg (point)) result)
|
yuuji@11
|
561 (setq result
|
yuuji@11
|
562 (catch 'complete
|
yuuji@11
|
563 (while t
|
yuuji@13
|
564 (message "Sequence: %s" key)
|
yuuji@11
|
565 (setq last-char (read-char)
|
yuuji@11
|
566 key (concat key (char-to-string last-char))
|
yuuji@13
|
567 i 0)
|
yuuji@11
|
568 (cond
|
yuuji@13
|
569 ((string= key this-key) ;;invoke key itself
|
yuuji@11
|
570 (throw 'complete 'escape))
|
yuuji@13
|
571 ((string= key YaTeX-math-exit-key) ;;exit from math-mode
|
yuuji@13
|
572 (throw 'complete 'exit))
|
yuuji@11
|
573 ((string-match "[\C-g\C-c]" key) (throw 'complete 'abort))
|
yuuji@13
|
574 ((string-match "[\n\r]" key) (throw 'complete 'menu))
|
yuuji@13
|
575 ((string-match "[\C-h\C-?]" key)
|
yuuji@13
|
576 (if (string= key "") (throw 'complete 'abort))
|
yuuji@13
|
577 (setq key (substring key 0 -2))))
|
yuuji@13
|
578
|
yuuji@13
|
579 (setq regkey (concat "^" (regexp-quote key)))
|
yuuji@13
|
580 (message "Sequence: %s" key)
|
yuuji@11
|
581 (if
|
yuuji@11
|
582 (catch 'found
|
yuuji@11
|
583 ;;(1)input string strictly matches with alist
|
yuuji@11
|
584 (setq single-command (car (cdr match))
|
yuuji@11
|
585 ;;remember previous match
|
yuuji@13
|
586 match (assoc key alist))
|
yuuji@11
|
587 ;;(2)search partial match into alist
|
yuuji@13
|
588 (setq list alist)
|
yuuji@11
|
589 (while (< i n)
|
yuuji@11
|
590 (if (string-match
|
yuuji@13
|
591 regkey
|
yuuji@13
|
592 ;;(aref array i)
|
yuuji@13
|
593 ;;(car (nth i alist))
|
yuuji@13
|
594 (car (car list))
|
yuuji@13
|
595 )
|
yuuji@11
|
596 (progn
|
yuuji@11
|
597 (or match
|
yuuji@13
|
598 ;;(setq match (nth i alist))
|
yuuji@13
|
599 (setq match (car list)))
|
yuuji@11
|
600 (throw 'found t)))
|
yuuji@13
|
601 (setq i (1+ i) list (cdr list)))) ;catch 'found
|
yuuji@11
|
602 nil ;;if any match, continue reading
|
yuuji@11
|
603 ;;else reading of sequence has been done.
|
yuuji@11
|
604 (message "complete.")
|
yuuji@11
|
605 (throw 'complete t)
|
yuuji@11
|
606 )
|
yuuji@11
|
607 (if match
|
yuuji@11
|
608 (progn (delete-region beg (point))
|
yuuji@11
|
609 (insert YaTeX-ec (car (cdr match)))
|
yuuji@13
|
610 (if (and YaTeX-math-need-image
|
yuuji@13
|
611 (setq sign (YaTeX-math-get-sign match)))
|
yuuji@13
|
612 (YaTeX-math-show-image (concat sign "\n")))
|
yuuji@11
|
613 )
|
yuuji@11
|
614 nil)
|
yuuji@11
|
615 )))
|
yuuji@11
|
616 (cond
|
yuuji@11
|
617 ((eq result t)
|
yuuji@11
|
618 (setq YaTeX-current-completion-type 'maketitle)
|
yuuji@11
|
619 (if t nil
|
yuuji@11
|
620 (delete-region beg (point))
|
yuuji@11
|
621 (setq single-command (car (cdr match)))
|
yuuji@11
|
622 ;;(recursive-edit)
|
yuuji@11
|
623 (insert YaTeX-ec single-command)
|
yuuji@11
|
624 )
|
yuuji@13
|
625 ;;;(sit-for 1)
|
yuuji@11
|
626 (setq unread-command-char last-char)
|
yuuji@11
|
627 (insert (YaTeX-addin single-command)))
|
yuuji@11
|
628 ((eq result 'abort)
|
yuuji@11
|
629 (delete-region beg (point))
|
yuuji@11
|
630 (message "Abort."))
|
yuuji@11
|
631 ((eq result 'escape)
|
yuuji@11
|
632 (delete-region beg (point))
|
yuuji@13
|
633 (insert this-key))
|
yuuji@13
|
634 ((eq result 'exit)
|
yuuji@13
|
635 (delete-region beg (point))
|
yuuji@13
|
636 (YaTeX-toggle-math-mode))
|
yuuji@11
|
637 ((eq result 'menu)
|
yuuji@11
|
638 (delete-region beg (point))
|
yuuji@11
|
639 (setq key (concat "^" (regexp-quote (substring key 0 -1))))
|
yuuji@11
|
640 (insert (YaTeX-math-show-menu key)))))
|
yuuji@11
|
641 )
|
yuuji@11
|
642 ;;
|
yuuji@11
|
643 (provide 'yatexmth)
|
yuuji@13
|
644
|
yuuji@13
|
645 ; Local variables:
|
yuuji@13
|
646 ; fill-prefix: ";;; "
|
yuuji@13
|
647 ; paragraph-start: "^$\\|\\|;;;$"
|
yuuji@13
|
648 ; paragraph-separate: "^$\\|\\|;;;$"
|
yuuji@13
|
649 ; End:
|