Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexmth.el @ 460:1790e0d35156 dev
Capitalized varGREEK with amssymb, added
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Tue, 23 May 2017 11:34:14 +0859 |
parents | 7bf780961390 |
children | 9db0e1522847 |
rev | line source |
---|---|
395 | 1 ;;; yatexmth.el --- YaTeX math-mode-specific functions -*- coding: sjis -*- |
287 | 2 ;;; |
443 | 3 ;;; (c)1993-2017 by HIROSE Yuuji [yuuji@yatex.org] |
460
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
4 ;;; Last modified Tue May 23 11:32:21 2017 on firestorm |
368 | 5 ;;; $Id$ |
11 | 6 |
287 | 7 ;;; Commentary: |
13 | 8 ;;; [Customization guide] |
9 ;;; | |
10 ;;; By default, you can use two completion groups in YaTeX math | |
52 | 11 ;;; mode, `;' for mathematical signs and `:' for greek letters. But |
13 | 12 ;;; you can add other completion groups by defining the alist of |
13 ;;; `prefix key' vs `completion list' into the variable | |
14 ;;; YaTeX-math-key-list-private. If you wish to accomplish the | |
23 | 15 ;;; completion as follows(prefix key is `,'): |
13 | 16 ;;; |
17 ;;; KEY COMPLETION | |
18 ;;; s \sin | |
19 ;;; S \arcsin | |
20 ;;; c \cos | |
21 ;;; C \arccos | |
22 ;;; : | |
23 ;;; T \arctan | |
24 ;;; l \log | |
25 ;;; hs \sinh | |
26 ;;; | |
23 | 27 ;;; Typing `s' after `,' makes `\sin', `hs' after `,' makes `\sinh' |
13 | 28 ;;; and so on. First, you have to define list of key-completion |
29 ;;; pairs. Variable name(YaTeX-math-funcs-list) is arbitrary. | |
30 ;;; | |
31 ;;; (setq YaTeX-math-funcs-list | |
32 ;;; '(("s" "sin") | |
33 ;;; ("S" "arcsin") | |
34 ;;; : | |
35 ;;; ("hs" "sinh"))) | |
36 ;;; | |
37 ;;; Next, define the list of prefix-key vs completion list(defined | |
38 ;;; above) into the variable YaTeX-math-key-list-private. | |
39 ;;; | |
40 ;;; (setq YaTeX-math-key-list-private | |
23 | 41 ;;; '(("," . YaTeX-math-funcs-list) |
13 | 42 ;;; ("'" . Other-List-if-any))) |
43 ;;; | |
44 ;;; Put these expressions into your ~/.emacs, and you can use this | |
51 | 45 ;;; completion in the math-mode. |
13 | 46 ;;; |
47 ;;; And you can add your favorite completion sequences to the | |
23 | 48 ;;; default completion list invoked with `;', by defining those lists |
13 | 49 ;;; into variable YaTeX-math-sign-alist-private. |
50 | |
51 ;;; 【イメージ補完の追加方法】 | |
52 ;;; | |
52 | 53 ;;; 標準のイメージ補完では、「;」で始まる数式記号補完と、「:」で始 |
13 | 54 ;;; まるギリシャ文字補完が使用可能ですが、これ以外の文字で始まる補完 |
23 | 55 ;;; シリーズも定義することができます。例えば、「,」で始まる次のよう |
13 | 56 ;;; な補完シリーズを定義する場合を考えてみます。 |
57 ;;; | |
58 ;;; 補完キー 補完結果 | |
59 ;;; s \sin | |
60 ;;; S \arcsin | |
61 ;;; c \cos | |
62 ;;; C \arccos | |
63 ;;; : | |
64 ;;; T \arctan | |
65 ;;; l \log | |
66 ;;; hs \sinh | |
67 ;;; | |
23 | 68 ;;; 「,」のあとに s を押すと \sin が、hs を押すと \sinh が入力されま |
13 | 69 ;;; す。このような補完リストの登録は以下のようにします(変数名は任意)。 |
70 ;;; | |
71 ;;; (setq YaTeX-math-funcs-list | |
72 ;;; '(("s" "sin") | |
73 ;;; ("S" "arcsin") | |
74 ;;; : | |
75 ;;; ("hs" "sinh"))) | |
76 ;;; | |
23 | 77 ;;; さらに、「,」を押した時にイメージ補完が始まるよう次の変数に、起動キー |
13 | 78 ;;; と上で定義した補完用変数の登録を行ないます。 |
79 ;;; | |
80 ;;; (setq YaTeX-math-key-list-private | |
23 | 81 ;;; '(("," . YaTeX-math-funcs-list) |
13 | 82 ;;; ("'" . ほかに定義したいシリーズがあれば…))) |
83 ;;; | |
51 | 84 ;;; これらを ~/.emacs に書いておけば、math-mode で自分専用のイメージ |
85 ;;; 補完が利用できます。 | |
13 | 86 |
287 | 87 ;;; Code: |
13 | 88 (defvar YaTeX-jisold |
89 (and (boundp 'dos-machine-type) | |
90 (eq dos-machine-type 'pc98))) | |
91 | |
92 (defmacro YaTeX-setq-math-sym (sym old new) | |
93 (list 'setq sym (list 'if 'YaTeX-jisold old new))) | |
94 | |
95 (YaTeX-setq-math-sym YaTeX-image-in "E" "∈") | |
96 (YaTeX-setq-math-sym YaTeX-image-ni "ヨ" "∋") | |
97 (YaTeX-setq-math-sym YaTeX-image-subset " _\n(\n ~" "⊂") | |
98 (YaTeX-setq-math-sym YaTeX-image-subseteq " _\n(_\n ~" "⊆") | |
99 (YaTeX-setq-math-sym YaTeX-image-supset "_\n )\n~" "⊃") | |
100 (YaTeX-setq-math-sym YaTeX-image-supseteq "_\n_)\n~" "⊇") | |
101 (YaTeX-setq-math-sym YaTeX-image-nabla "___\n\\\\/" "∇") | |
102 (YaTeX-setq-math-sym YaTeX-image-partial " -+\n+-+\n+-+" "∂") | |
103 (YaTeX-setq-math-sym YaTeX-image-dagger "+\n|" "†") | |
104 (YaTeX-setq-math-sym YaTeX-image-ddagger "+\n+\n|" "‡") | |
105 (YaTeX-setq-math-sym YaTeX-image-equiv "=\n ̄" "≡") | |
106 (YaTeX-setq-math-sym YaTeX-image-int " /\\\n \\\n\\/" "∫") | |
107 (YaTeX-setq-math-sym YaTeX-image-bot "|\n ̄" "⊥") | |
108 (YaTeX-setq-math-sym YaTeX-image-neg "イ" "¬") | |
109 (YaTeX-setq-math-sym YaTeX-image-flat "b" "♭") | |
23 | 110 (YaTeX-setq-math-sym YaTeX-image-sqrt "" "√") |
80 | 111 (defvar YaTeX-image-nearrow '("__\n /|\n/" " _\n /|\n/" )) |
112 (defvar YaTeX-image-nwarrow '(" __\n|\\\n \\" " _\n|\\n \")) | |
113 (defvar YaTeX-image-searrow '("\\\n \\|\n--`" "\\n \|\n  ̄")) | |
114 (defvar YaTeX-image-swarrow '(" /\n|/\n'~~" " /\n|/\n  ̄")) | |
115 | |
13 | 116 |
52 | 117 (defvar |
13 | 118 YaTeX-math-sign-alist-default |
11 | 119 '( |
120 ;frequently used | |
121 ("||" "|" ("||" "‖")) | |
122 ("sum" "sum" ("\\-+\n >\n/-+" "Σ")) | |
123 ("sigma" "sum" ("\\-+\n >\n/-+" "Σ")) | |
13 | 124 ("integral" "int" (" /\\\n \\\n\\/" YaTeX-image-int)) |
11 | 125 ("ointegral" "oint" " /\\\n(\\)\n\\/") |
23 | 126 ("sqrt" "sqrt" (" __\n,/" YaTeX-image-sqrt)) |
127 ("root" "sqrt" (" __\n,/" YaTeX-image-sqrt)) | |
11 | 128 ("A" "forall" "|_|\nV") |
129 ("E" "exists" "-+\n-+\n-+") | |
13 | 130 ("!" "neg" ("--+\n |" YaTeX-image-neg)) |
11 | 131 ("oo" "infty" ("oo" "∞")) |
132 ("\\" "backslash" ("\\" "\")) | |
68 | 133 ("..." "cdots" ("..." "…")) |
11 | 134 |
135 ;;binary operators | |
136 ("+-" "pm" ("+\n-" "±")) | |
137 ("-+" "mp" "-\n+") | |
138 ("x" "times" ("x" "×")) | |
139 ("/" "div" (",\n-\n'" "÷")) | |
23 | 140 ("f" "frac" "xxx\n---\nyyy" "÷") |
11 | 141 ("*" "ast" "*") |
142 ("#" "star" ("_/\\_\n\\ /\n//\\\\" "★")) | |
143 ("o" "circ" "o") | |
144 ("o*" "bullet" " _\n(*)\n ~") | |
145 ("." "cdot" ".") | |
146 ("cap" "cap" "/-\\\n| |") | |
147 ("cup" "cup" "| |\n\\-/") | |
148 ("u+" "uplus" "|+|\n\\-/") | |
149 ("|~|" "sqcap" "|~|") | |
150 ("|_|" "sqcup" "|_|") | |
151 ("v" "vee" "v") | |
152 ("^" "wedge" "^") | |
153 ("\\\\" "setminus" "\\") | |
154 (")(" "wr" " )\n(") | |
155 ("<>" "diamond" "<>") | |
128 | 156 ("/\\-" "bigtriangleup" ("/\\\n~~" "△")) |
11 | 157 ("-\\/" "bigtriangledown" ("__\n\\/" "▽")) |
158 ("<|" "triangleleft" "<|") | |
159 ("|>" "triangleright" "|>") | |
160 ("<||" "lhd" "/|\n\\|") | |
161 ("||>" "rhd" "|\\\n|/") | |
162 ("<|-" "unlhd" "<|\n~~") | |
163 ("|>-" "unrhd" "|>\n~~") | |
164 ("o+" "oplus" " _\n(+)\n ~") | |
165 ("o-" "ominus" " _\n(-)\n ~") | |
166 ("ox" "otimes" " _\n(x)\n ~") | |
167 ("o/" "oslash" " _\n(/)\n ~") | |
168 ("o." "odot" "(.)") | |
169 ("O" "bigcirc" "O") | |
13 | 170 ("t" "dagger" ("+\n|" YaTeX-image-dagger)) |
171 ("tt" "ddagger" ("+\n+\n|" YaTeX-image-ddagger)) | |
11 | 172 ("II" "amalg" "II") |
173 ; : | |
174 ;;relational operators | |
134 | 175 ("<" "leq" ("<\n-" "<\n-")) |
176 ("=<" "leqq" ("<\n=" "≦")) | |
177 (">" "geq" (">\n-" ">\n-")) | |
178 (">=" "geqq" (">\n=" "≧")) | |
143 | 179 ("=:" "fallingdotseq" (".\n==\n ." "≒")) |
13 | 180 ("-=" "equiv" ("=\n-" YaTeX-image-equiv)) |
181 ("=-" "equiv" ("=\n-" YaTeX-image-equiv)) | |
182 ("---" "equiv" ("=\n-" YaTeX-image-equiv)) | |
183 ("(" "subset" (" _\n(\n ~" YaTeX-image-subset)) | |
184 ("(-" "subseteq" (" _\n(_\n ~" YaTeX-image-subseteq)) | |
185 (")" "supset" ("_\n )\n~" YaTeX-image-supset)) | |
186 (")-" "supseteq" ("_\n_)\n~" YaTeX-image-supseteq)) | |
11 | 187 ("[" "sqsubset" "[") |
188 ("[-" "sqsubseteq" "[\n~") | |
189 ("]" "sqsupset" "]") | |
190 ("]-" "sqsupseteq" "]\n~") | |
13 | 191 ("{" "in" ("(-" YaTeX-image-in)) |
192 ("}" "ni" ("-)" YaTeX-image-ni)) | |
11 | 193 ("|-" "vdash" "|-") |
194 ("-|" "dashv" "-|") | |
195 ("~" "sim" "~(tild)") | |
196 ("~-" "simeq" "~\n-") | |
197 ("asymp" "asymp" "v\n^") | |
198 ("~~" "approx" "~\n~") | |
199 ("~=" "cong" "~\n=") | |
200 ("=/" "neq" ("=/=" "≠")) | |
201 (".=" "doteq" ".\n=") | |
202 ("o<" "propto" "o<") | |
203 ("|=" "models" "|=") | |
204 ("_|_" "perp" "_|_") | |
205 ("|" "mid" "|") | |
206 ("||" "parallel" "||") | |
207 ("bowtie" "bowtie" "|><|(wide)") | |
208 ("|><|" "join" "|><|") | |
209 ("\\_/" "smile" "\\_/") | |
210 ("/~\\" "frown" "/~~\\") | |
211 ("-<" "prec" ("-<" "く")) | |
212 ("-<=" "preceq" ("-<\n-" "く\n=")) | |
213 ("<<" "ll" ("<<" "《")) | |
134 | 214 ("<<" "lll" "<<<") |
80 | 215 (">>" "gg" (">>" "》")) |
134 | 216 (">>>" "ggg" ">>>") |
11 | 217 ; : |
218 ;;arrows | |
219 ("<-" "leftarrow" ("<-" "←")) | |
13 | 220 ("\C-b" "leftarrow" ("<-" "←")) |
221 ("<--" "longleftarrow" ("<--" "←--")) | |
11 | 222 ("<=" "Leftarrow" "<=") |
223 ("<==" "Longleftarrow" "<==") | |
224 ("->" "rightarrow" ("->" "→")) | |
13 | 225 ("\C-f" "rightarrow" ("->" "→")) |
11 | 226 ("-->" "longrightarrow" ("-->" "--→")) |
64 | 227 ("=>" "Rightarrow" "=>") |
11 | 228 ("==>" "Longrightarrow" "==>") |
229 ("<->" "leftrightarrow" ("<->" "←→")) | |
230 ("<-->" "longleftrightarrow" ("<---->" "←--→")) | |
47 | 231 ("<=>" "Leftrightarrow" "<=>") |
11 | 232 ("<==>" "Longleftrightarrow" "<==>") |
233 ("^|" "uparrow" ("^\n|" "↑")) | |
13 | 234 ("\C-p" "uparrow" ("^\n|" "↑")) |
11 | 235 ("^||" "Uparrow" "/\\\n||") |
236 ("\C-n" "downarrow" ("|\nv" "↓")) | |
13 | 237 ("v|" "downarrow" ("|\nv" "↓")) |
238 ("v||" "Downarrow" "||\n\\/") | |
80 | 239 ("\C-p\C-f" "nearrow" YaTeX-image-nearrow) |
240 ("\C-f\C-p" "nearrow" YaTeX-image-nearrow) | |
241 ("ne" "nearrow" YaTeX-image-nearrow) | |
242 ("\C-p\C-b" "nwarrow" YaTeX-image-nwarrow) | |
243 ("\C-b\C-p" "nwarrow" YaTeX-image-nwarrow) | |
244 ("nw" "nwarrow" YaTeX-image-nwarrow) | |
245 ("\C-n\C-f" "searrow" YaTeX-image-searrow) | |
246 ("\C-f\C-n" "searrow" YaTeX-image-searrow) | |
247 ("se" "searrow" YaTeX-image-searrow) | |
248 ("\C-n\C-b" "swarrow" YaTeX-image-swarrow) | |
249 ("\C-b\C-n" "swarrow" YaTeX-image-swarrow) | |
250 ("sw" "swarrow" YaTeX-image-swarrow) | |
11 | 251 ("|->" "mapsto" ("|->" "|→")) |
252 ("<-)" "hookleftarrow" (" ,\n<--+" " ヽ\n<--/")) | |
69 | 253 ("(->" "hookrightarrow" ("`\n+-->" "/\n\-->")) |
11 | 254 ("/-" "leftharpoonup" "/\n~~~") |
255 ("\\-" "leftharpoondown" "__\n\\") | |
256 ("-/" "rightharpoondown" "__\n/") | |
257 ("-\\" "rightharpoonup" "~~\n\\") | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
258 ;;left and right |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
259 ("left" "left" "(leftmark)") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
260 ("right" "right" "(rightmark)") |
68 | 261 ;;accent marks |
262 ("tilde" "tilde" "~\n?") | |
263 ("T" "tilde" "~\n?") | |
264 ("wtilde" "widetilde" "~\n?") | |
265 ("hat" "hat" "^\n?") | |
266 ("what" "widehat" "/\\\n??") | |
267 ("w^" "widehat" "/\\\n?") | |
268 ("check" "check" "v\n?") | |
269 ("bar" "bar" "_\n?") | |
270 ("overline" "overline" "_\n?") | |
271 ("wbar" "overline" "--\n??") | |
272 ("dot" "dot" ".\n?") | |
273 ("ddot" "ddot" "..\n??") | |
274 ("vec" "vec" ("->\n??" "→\n??")) | |
275 ("~>" "overrightarrow" ("-->\nAB" "→\nAB")) | |
276 ("VEC" "overrightarrow" ("-->\nAB" "→\nAB")) | |
277 ;;rage-aware stuffs | |
278 ("prod" "prod" ("-+--+-\n | |" "Π")) | |
279 ("CUP" "bigcup" "|~~|\n| |\n| |") | |
280 ("union" "bigcup" "|~~|\n| |\n| |") | |
281 ("CAP" "bigcap" "| |\n| |\n|__|") | |
282 ("isc" "bigcap" "| |\n| |\n|__|") | |
283 ("O+" "bigoplus" "/~~~\\\n| + |\n\\___/") | |
284 ("Ox" "bigotimes" "/~~~\\\n| X |\n\\___/") | |
285 ;;other marks | |
80 | 286 ("angle" "angle" ("/\n~" "∠")) |
287 ("/_" "angle" ("/\n~" "∠")) | |
11 | 288 ("Z" "aleph" "|\\|") |
289 ("|\\|" "aleph" "|\\|") | |
290 ("h-" "hbar" "_\nh") | |
68 | 291 ; ("i" "imath" "i") ;These chars are appeared only |
292 ; ("j" "jmath" "j") ;as section-type arguments | |
11 | 293 ("l" "ell" "l") |
294 ("wp" "wp" "???") | |
295 ("R" "Re" ")R") | |
296 ("Im" "Im" "???") | |
297 ("mho" "mho" "~|_|~") | |
298 ("'" "prime" "'") | |
299 ("0" "emptyset" "0") | |
13 | 300 ("nabla" "nabla" ("___\n\\\\/" YaTeX-image-nabla)) |
11 | 301 ("\\/" "surd" "-\\/") |
302 ("surd" "surd" "-\\/") | |
303 ("top" "top" "T") | |
13 | 304 ("bot" "bot" ("_|_" YaTeX-image-bot)) |
305 ("b" "flat" ("b" YaTeX-image-flat)) | |
11 | 306 ("LT" "natural" "|\nLT\n |") |
13 | 307 ("6" "partial" (" -+\n+-+\n+-+" YaTeX-image-partial)) |
308 ("partial" "partial" (" -+\n+-+\n+-+" YaTeX-image-partial)) | |
309 ("round" "partial" (" -+\n+-+\n+-+" YaTeX-image-partial)) | |
59 | 310 ("[]" "Box" "[]") |
80 | 311 ("no" "notag" "\\notag") |
312 (":" "colon" ":") | |
305
53709ee88448
Add \because and \therefore to math-image completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
313 (".'." "therefore" (".'." "∴")) |
53709ee88448
Add \because and \therefore to math-image completion.
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
314 ("'.'" "because" ("'.'" "∵")) |
11 | 315 ("Diamond" "Diamond" "/\\\n\\/") |
316 ("3" "triangle" "/\\\n~~") | |
317 ("C" "clubsuit" " o\no+o\n |") | |
318 ("D" "diamondsuit" "/\\\n\\/") | |
319 ("H" "heartsuit" "<^^>\n \\/") | |
320 ("S" "spadesuit" " /\\\n<++>\n /\\") | |
229 | 321 ("mi" "mathit" "\\mathit{}") |
322 ("mr" "mathrm" "\\mathrm{}") | |
323 ("mb" "mathbf" "\\mathbf{}") | |
456 | 324 ("mB" "mathbb" "\\mathbb{}") |
229 | 325 ("mt" "mathtt" "\\mathtt{}") |
326 ("ms" "mathsf" "\\mathsf{}") | |
327 ("mc" "mathcal" "\\mathcal{}") | |
328 ("mn" "mathnormal" "\\mathnormal{}") | |
52 | 329 ) |
330 "Default LaTeX-math-command alist.") | |
11 | 331 |
13 | 332 (defvar YaTeX-math-sign-alist-private nil |
11 | 333 "*User definable key vs LaTeX-math-command alist.") |
334 | |
335 (defvar YaTeX-math-quit-with-strict-match nil | |
336 "*T for quitting completion as soon as strict-match is found.") | |
52 | 337 (defvar YaTeX-math-sign-alist |
13 | 338 (append YaTeX-math-sign-alist-private YaTeX-math-sign-alist-default)) |
339 | |
340 ;;(defun YaTeX-math-alist2array (alist array) | |
341 ;; (set array | |
342 ;; (let ((array (make-vector (length alist) "")) (list alist) (i 0)) | |
343 ;; (while list | |
344 ;; (aset array i (car (car list))) | |
345 ;; (setq i (1+ i) list (cdr list))) | |
346 ;; array)) | |
347 ;;) | |
11 | 348 |
52 | 349 (defvar YaTeX-greek-key-alist-default |
460
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
350 (append |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
351 '( |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
352 ("a" "alpha" ("a" "α")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
353 ("b" "beta" ("|>\n|>\n|" "β")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
354 ("g" "gamma" ("~r" "γ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
355 ("G" "Gamma" ("|~" "Γ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
356 ("d" "delta" ("<~\n<>" "δ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
357 ("D" "Delta" ("/\\\n~~" "Δ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
358 ("e" "epsilon" "<\n<~") |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
359 ("e-" "varepsilon" " <\n<~") |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
360 ("e-" "varepsilon" ("(\n(~" "ε")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
361 ("z" "zeta" ("(~\n >" "ζ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
362 ("et" "eta" ("n\n/" "η")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
363 ("th" "theta" ("8" "θ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
364 ("th-" "vartheta" (" o\no" "θ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
365 ("Th" "Theta" ("(8)" "Θ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
366 ("th-" "vartheta" ("-8" "-θ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
367 ("i" "iota" ("i\n\\_/" "ι")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
368 ("k" "kappa" ("k" "κ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
369 ("l" "lambda" ("\\n/\\" "λ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
370 ("L" "Lambda" ("/\\" "Λ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
371 ("m" "mu" (" u_\n/" "μ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
372 ("n" "nu" ("|/" "ν")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
373 ("x" "xi" ("E\n >" "ξ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
374 ("X" "Xi" ("---\n -\n---" "Ξ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
375 ("p" "pi" ("__\n)(" "π")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
376 ("p-" "varpi" (" __\n)(" "π")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
377 ("P" "Pi" ("__\n||" "Π")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
378 ("p-" "varpi" ("_\nw" "__\nω")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
379 ("r" "rho" ("/O" "ρ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
380 ("r-" "varrho" ("~O" "ρ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
381 ("r-" "varrho" ("/O\n~~" "ρ\n~~")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
382 ("s" "sigma" ("o~" "σ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
383 ("s-" "varsigma" ("o~~" "σ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
384 ("S" "Sigma" ("\\-+\n >\n/-+" "Σ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
385 ("s-" "varsigma" "(~~ \n>") |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
386 ("t" "tau" ("__\n(" "τ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
387 ("u" "upsilon" ("~v" "υ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
388 ("y" "upsilon" ("~v" "υ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
389 ("U" "Upsilon" ("~Y~" "Υ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
390 ("Y" "Upsilon" ("~Y~" "Υ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
391 ("ph" "phi" (" /\n(/)\n/" "φ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
392 ("ph-" "varphi" (" /\n(/)\n/" "φ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
393 ("Ph" "Phi" (" _\n(|)\n ~" "Φ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
394 ("ph-" "varphi" "\\O\n|") |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
395 ("c" "chi" ("x" "χ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
396 ("ps" "psi" ("\\|/\\n |" "ψ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
397 ("Ps" "Psi" (" ~\n\\|/\\n |" "Ψ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
398 ("o" "omega" ("w" "ω")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
399 ("w" "omega" ("w" "ω")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
400 ("O" "Omega" ("(~)\n~ ~" "Ω")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
401 ("W" "Omega" ("(~)\n~ ~" "Ω")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
402 ("f" "foo") |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
403 ) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
404 (if YaTeX-use-AMS-LaTeX |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
405 '( |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
406 ("G-" "varGamma" ("/~" "_Γ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
407 ("D-" "varDelta" ("/|\n~~" "_Δ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
408 ("Th-" "varTheta" ("/8/" "_Θ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
409 ("L-" "varLambda" ("/|" "_Λ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
410 ("X-" "varXi" (" --\n -\n-- " "_Ξ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
411 ("S-" "varSigma" (" \\-+\n >\n/-+" "_Σ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
412 ("U-" "varUpsilon" ("~~Y~" "_Υ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
413 ("Ph-" "varPhi" (" _\n(|)\n~" "_Φ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
414 ("Ps-" "varPsi" (" ~\n\\//\\n /" "Ψ")) |
1790e0d35156
Capitalized varGREEK with amssymb, added
HIROSE Yuuji <yuuji@gentei.org>
parents:
456
diff
changeset
|
415 ("O-" "varOmega" ("/~/\n~ ~" "_Ω"))))) |
52 | 416 "Default LaTeX-math-command alist.") |
11 | 417 |
13 | 418 (defvar YaTeX-greek-key-alist-private nil |
419 "*User definable key vs LaTeX-math-command alist.") | |
420 | |
52 | 421 (defvar YaTeX-greek-key-alist |
13 | 422 (append YaTeX-greek-key-alist-private YaTeX-greek-key-alist-default)) |
423 | |
424 ;;(mapcar (function (lambda (x) (YaTeX-math-alist2array x))) | |
425 ;; YaTeX-math-key-list) | |
426 | |
52 | 427 (defvar YaTeX-math-indicator "KEY\tLaTeX sequence\t\tsign") |
11 | 428 |
429 (defvar YaTeX-math-need-image t | |
430 "*T for displaying pseudo image momentarily.") | |
431 (defvar YaTeX-math-max-key 8) | |
432 (defvar YaTeX-math-max-seq | |
433 (* 8 (1+ (/ (length "\\longleftrightarrow") 8)))) | |
434 (defvar YaTeX-math-max-sign 5) | |
435 (defvar YaTeX-math-sign-width | |
436 (+ YaTeX-math-max-key YaTeX-math-max-seq YaTeX-math-max-sign)) | |
437 (defvar YaTeX-math-display-width | |
438 (* 8 (1+ (/ YaTeX-math-sign-width 8)))) | |
439 (defvar YaTeX-math-menu-map nil | |
80 | 440 "Keymap used in YaTeX mathematical sign menu mode.") |
441 | |
11 | 442 (if YaTeX-math-menu-map nil |
443 (setq YaTeX-math-menu-map (make-sparse-keymap)) | |
444 (define-key YaTeX-math-menu-map "n" 'next-line) | |
445 (define-key YaTeX-math-menu-map "p" 'previous-line) | |
446 (define-key YaTeX-math-menu-map "f" 'YaTeX-math-forward) | |
447 (define-key YaTeX-math-menu-map "b" 'YaTeX-math-backward) | |
448 (define-key YaTeX-math-menu-map "v" 'scroll-up) | |
449 (define-key YaTeX-math-menu-map " " 'scroll-up) | |
450 (define-key YaTeX-math-menu-map "c" 'scroll-up) | |
451 (define-key YaTeX-math-menu-map "V" 'scroll-down) | |
452 (define-key YaTeX-math-menu-map "r" 'scroll-down) | |
453 (define-key YaTeX-math-menu-map "\^h" 'scroll-down) | |
454 (define-key YaTeX-math-menu-map "<" 'beginning-of-buffer) | |
455 (define-key YaTeX-math-menu-map ">" 'end-of-buffer) | |
456 (define-key YaTeX-math-menu-map "\^m" 'exit-recursive-edit) | |
457 (define-key YaTeX-math-menu-map "q" 'abort-recursive-edit)) | |
458 | |
13 | 459 (defvar YaTeX-math-exit-key "\e" |
80 | 460 "*Key sequence after prefix key of YaTeX-math-mode to exit from math-mode.") |
13 | 461 |
11 | 462 (defmacro YaTeX-math-japanese-sign (list) |
463 (list 'nth 1 list)) | |
464 | |
72 | 465 (defvar YaTeX-math-cmd-regexp (concat (regexp-quote YaTeX-ec) "[A-z|]")) |
177
9c5a764a871f
Treat `alltt' in YaTeX-verbatim-environments.
yuuji@gentei.org
parents:
143
diff
changeset
|
466 |
9c5a764a871f
Treat `alltt' in YaTeX-verbatim-environments.
yuuji@gentei.org
parents:
143
diff
changeset
|
467 ;;; alltt goes into YaTeX-verbatim-environments 2011/3/16 |
9c5a764a871f
Treat `alltt' in YaTeX-verbatim-environments.
yuuji@gentei.org
parents:
143
diff
changeset
|
468 ;;(defvar YaTeX-math-verbatim-environments |
9c5a764a871f
Treat `alltt' in YaTeX-verbatim-environments.
yuuji@gentei.org
parents:
143
diff
changeset
|
469 ;; '("alltt") |
9c5a764a871f
Treat `alltt' in YaTeX-verbatim-environments.
yuuji@gentei.org
parents:
143
diff
changeset
|
470 ;; "*List of environments in which LaTeX math mode is disabled. |
9c5a764a871f
Treat `alltt' in YaTeX-verbatim-environments.
yuuji@gentei.org
parents:
143
diff
changeset
|
471 ;;This value is appended with YaTeX-verbatim-environments.") |
11 | 472 |
13 | 473 ;;; |
474 ;;YaTeX math-mode functions | |
475 ;;; | |
417
1ab1b9ba8698
Remove superfluous string in autoload line
HIROSE Yuuji <yuuji@gentei.org>
parents:
401
diff
changeset
|
476 ;;;###autoload |
13 | 477 (defun YaTeX-toggle-math-mode (&optional arg) |
478 (interactive "P") | |
479 (or (memq 'YaTeX-math-mode mode-line-format) nil | |
480 (setq mode-line-format | |
481 (append (list "" 'YaTeX-math-mode) mode-line-format))) | |
23 | 482 (if YaTeX-auto-math-mode nil ;Only effective on manual mode. |
483 (if (or arg (null YaTeX-math-mode)) | |
484 (let (keys) | |
485 (setq YaTeX-math-mode "math:") | |
486 (message "Turn on math mode. Prefix keys are %s" | |
487 (mapconcat 'car YaTeX-math-key-list " ")) | |
488 (sit-for 3) | |
489 (message | |
490 (concat "To exit from math-mode, type `ESC' after prefix, " | |
491 "or type `" | |
492 (key-description | |
493 (car | |
494 (where-is-internal | |
495 'YaTeX-switch-mode-menu YaTeX-mode-map))) | |
496 " $'"))) | |
497 (setq YaTeX-math-mode nil) | |
498 (message "Exit from math mode.")) | |
80 | 499 (set-buffer-modified-p (buffer-modified-p)))) |
13 | 500 |
11 | 501 (defun YaTeX-math-forward (arg) |
502 (interactive "p") | |
503 (re-search-forward YaTeX-math-cmd-regexp nil t arg)) | |
504 | |
505 (defun YaTeX-math-backward (arg) | |
506 (interactive "p") | |
507 (re-search-backward YaTeX-math-cmd-regexp nil t arg)) | |
508 | |
13 | 509 (defun YaTeX-math-gets (sign) |
510 (cond | |
511 ((null sign) nil) | |
512 ((listp sign) | |
513 (setq sign | |
514 (cond | |
515 (YaTeX-japan (YaTeX-math-japanese-sign sign)) | |
516 (t (car sign)))) | |
517 (YaTeX-math-gets sign)) | |
518 ((symbolp sign) | |
519 (YaTeX-math-gets (symbol-value sign))) | |
80 | 520 (t sign))) |
13 | 521 |
11 | 522 (defun YaTeX-math-get-sign (list) |
80 | 523 (YaTeX-math-gets (car (cdr-safe (cdr-safe list))))) |
524 | |
77 | 525 (defvar YaTeX-math-section-type-regexp |
526 "eqn\\\\\\sw+\\b" | |
527 "*Regexp of section-type math-mode macro") | |
528 | |
23 | 529 (defun YaTeX-in-math-mode-p () |
80 | 530 "If current position is supposed to be in LaTeX-math-mode, return t. |
531 This function refers a local variable `source-window' in YaTeX-make-section." | |
532 (save-excursion | |
533 (and (boundp 'source-window) source-window | |
534 (set-buffer (window-buffer source-window))) | |
535 (or (YaTeX-quick-in-environment-p | |
536 (append | |
537 '("math" "eqnarray" "equation" "eqnarray*" "displaymath") ;LaTeX | |
538 (if YaTeX-use-AMS-LaTeX | |
539 ;; And math modes of AMS-LaTeX | |
540 ;;'("align" "align*" "split" "multline" "multline*" "gather" | |
541 ;; "gather*" "aligned*" "gathered" "gathered*" "alignat" | |
542 ;; "equation*" "cases" "flalign" "flalign*" | |
543 ;; "alignat*" "xalignat" "xalignat*" "xxalignat" "xxalignat*" | |
544 YaTeX-math-begin-list | |
449
c2c547e147c7
YaTeX-math-other-env-alist-* for additional math-environments
HIROSE Yuuji <yuuji@gentei.org>
parents:
443
diff
changeset
|
545 ) |
450
8871fe9f563b
YaTeX-math-other-env-alist should have list form
HIROSE Yuuji <yuuji@gentei.org>
parents:
449
diff
changeset
|
546 YaTeX-math-other-env-list)) |
130
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
547 (let*((p (point)) (nest 0) me0 r firstp dollar |
80 | 548 (delim (concat YaTeX-sectioning-regexp "\\|^$\\|^\C-l")) |
549 (boundary | |
550 (save-excursion | |
551 (if (looking-at delim) | |
552 (goto-char (max (point-min) (1- (point))))) | |
553 (re-search-backward delim nil 1) | |
554 (point)))) | |
555 (save-excursion | |
556 (cond | |
557 ((catch 'open | |
558 (save-excursion | |
559 (while (and (>= nest 0) | |
560 (re-search-backward | |
561 (concat YaTeX-ec-regexp ;\ | |
562 "\\([()]\\|[][]\\)") boundary t)) | |
563 (setq me0 (match-end 0)) | |
564 (if (or (YaTeX-on-comment-p) | |
565 (YaTeX-literal-p)) nil | |
566 (if (or (= (char-after (1- me0)) ?\)) | |
567 (= (char-after (1- me0)) ?\])) | |
568 (setq nest (1+ nest)) | |
569 (if (= (preceding-char) ?\\ ) nil ;;\\[5pt] | |
570 (setq nest (1- nest)))))) | |
130
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
571 (if (< nest 0) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
572 (throw 'open (cons (YaTeX-match-string 0) (point))))))) |
80 | 573 ((and (setq r (YaTeX-on-section-command-p |
574 YaTeX-math-section-type-regexp)) | |
575 (numberp r) | |
576 (> r 0)) | |
577 t) | |
578 (t (catch 'dollar | |
579 (while ;(search-backward "$" boundary t);little bit fast. | |
580 (YaTeX-re-search-active-backward ;;;;;; Too slow??? | |
581 "\\$" (concat "[^\\\\]" YaTeX-comment-prefix) boundary t) | |
130
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
582 (setq dollar "$") |
80 | 583 (cond |
584 ((equal (char-after (1- (point))) ?$) ; $$ equation $$ | |
130
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
585 (setq dollar "$$") |
80 | 586 (backward-char 1) |
587 (setq nest (1+ nest))) | |
177
9c5a764a871f
Treat `alltt' in YaTeX-verbatim-environments.
yuuji@gentei.org
parents:
143
diff
changeset
|
588 ((YaTeX-literal-p) |
80 | 589 nil) |
590 ((and (equal (char-after (1- (point))) ?\\ ) | |
591 (not (equal (char-after (- (point) 3)) ?\\ ))) | |
592 nil) ;\$ | |
130
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
593 (t (setq nest (1+ nest)))) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
594 (if (and (= nest 1) (null firstp)) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
595 (setq firstp (cons dollar (point))))) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
596 (if (= (% nest 2) 1) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
597 (throw 'dollar firstp)))))))))) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
598 |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
599 (defun YaTeX-mark-mathenv () |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
600 "Mark current mathematic environment." |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
601 (interactive) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
602 (let ((mmp (YaTeX-in-math-mode-p)) type bpt) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
603 (if (or (null mmp) (not (stringp (setq type (car mmp))))) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
604 nil ;if nil or not string, do nothing |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
605 (setq bpt (cdr mmp)) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
606 (goto-char bpt) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
607 (cond |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
608 ((string-match "\\$" type) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
609 (set-mark-command nil) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
610 (skip-chars-forward "$") |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
611 (YaTeX-search-active-forward |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
612 type YaTeX-comment-prefix nil) ;if it cause error, obey it |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
613 (goto-char (match-end 0))) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
614 ;; |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
615 ((string-match "^\\\\[\\[(]" type) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
616 (set-mark-command nil) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
617 (YaTeX-goto-corresponding-leftright) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
618 (skip-chars-forward "])\\\\")) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
619 ;; |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
620 ((string-match "^[a-z]" type) ; \begin\end type math |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
621 (set-mark-command nil) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
622 (YaTeX-goto-corresponding-environment) |
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
128
diff
changeset
|
623 (goto-char (match-end 0))))))) |
23 | 624 |
11 | 625 (defun YaTeX-math-display-list (list cols) |
626 (goto-char (point-max)) | |
627 (if (= cols 0) (if (not (eolp)) (newline 1)) | |
628 (forward-line -1) | |
629 (while (looking-at "[ \t\n]") (forward-line -1))) | |
630 (end-of-line) | |
631 (let ((indent (* YaTeX-math-display-width cols)) sign str to) | |
632 (indent-to indent) | |
633 (insert (car list)) | |
634 (indent-to (setq indent (+ indent YaTeX-math-max-key))) | |
635 (insert "\\" (car (cdr list))) | |
636 (setq indent (+ indent YaTeX-math-max-seq)) | |
637 (setq sign (YaTeX-math-get-sign list)) | |
13 | 638 (while (and sign (not (string= "" sign))) |
11 | 639 (setq to (string-match "\n" sign) |
640 str (if to (substring sign 0 to) sign)) | |
641 (end-of-line) | |
642 (indent-to indent) | |
643 (insert str) | |
644 (cond ((eobp) (newline 1)) | |
645 ((> cols 0) (forward-line 1))) | |
646 (setq sign (if to (substring sign (1+ to)) ""))))) | |
647 | |
648 (defvar YaTeX-math-menu-buffer "*math-mode-signs*") | |
649 | |
650 (defun YaTeX-math-show-menu (match-str) | |
651 (save-window-excursion | |
59 | 652 (YaTeX-showup-buffer YaTeX-math-menu-buffer nil t) |
70 | 653 (let ((maxcols (max 1 (/ (YaTeX-screen-width) YaTeX-math-sign-width))) |
11 | 654 (case-fold-search nil) |
13 | 655 (cols 0) (list alist) command) |
11 | 656 (erase-buffer) |
13 | 657 (insert |
658 "Candidates of sign. [n:next p:prev f:forw b:back q:quit RET:select]\n") | |
11 | 659 (insert YaTeX-math-indicator "\t") |
660 (insert YaTeX-math-indicator) | |
661 (newline 1) | |
70 | 662 (insert-char ?- (1- (YaTeX-screen-width))) |
11 | 663 (newline 1) |
664 (while list | |
665 (if (string-match match-str (car (car list))) | |
666 (progn (YaTeX-math-display-list (car list) cols) | |
667 (setq cols (% (1+ cols) maxcols)))) | |
668 (setq list (cdr list))) | |
178 | 669 (goto-char (point-min)) (forward-line 3) |
11 | 670 (use-local-map YaTeX-math-menu-map) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
671 (setq buffer-read-only t) |
11 | 672 (unwind-protect |
673 (recursive-edit) | |
674 (skip-chars-backward "^ \t\n") | |
675 (setq command | |
676 (if (re-search-forward YaTeX-math-cmd-regexp nil t) | |
677 (buffer-substring | |
678 (match-beginning 0) | |
679 (prog2 (skip-chars-forward "^ \t\n") (point))) | |
680 nil)) | |
681 (kill-buffer YaTeX-math-menu-buffer)) | |
80 | 682 command))) |
11 | 683 |
684 (defun YaTeX-math-show-image (image &optional exit-char) | |
685 "Momentarily display IMAGE at the beginning of the next line; | |
686 erase it on the next keystroke. The window is recentered if necessary | |
687 to make the whole string visible. If the window isn't large enough, | |
688 at least you get to read the beginning." | |
13 | 689 (if (and image (not (string= image ""))) |
690 (let ((buffer-read-only nil) | |
691 (modified (buffer-modified-p)) | |
692 (name buffer-file-name) | |
693 insert-start | |
694 insert-end) | |
695 (unwind-protect | |
696 (progn | |
697 (save-excursion | |
698 ;; defeat file locking... don't try this at home, kids! | |
699 (setq buffer-file-name nil) | |
700 (forward-line 1) | |
701 (setq insert-start (point)) | |
702 (if (eobp) (newline)) | |
703 (insert image) | |
704 (setq insert-end (point))) | |
705 ; make sure the whole string is visible | |
706 (if (not (pos-visible-in-window-p insert-end)) | |
707 (recenter (max 0 | |
708 (- (window-height) | |
709 (count-lines insert-start insert-end) | |
710 2)))) | |
711 (let ((char (read-char))) | |
712 (or (eq char exit-char) | |
292
e1c1616c4f07
Use unread-command-events when bound.
HIROSE Yuuji <yuuji@gentei.org>
parents:
290
diff
changeset
|
713 (if (boundp 'unread-command-events) |
e1c1616c4f07
Use unread-command-events when bound.
HIROSE Yuuji <yuuji@gentei.org>
parents:
290
diff
changeset
|
714 (setq unread-command-events (list char)) |
e1c1616c4f07
Use unread-command-events when bound.
HIROSE Yuuji <yuuji@gentei.org>
parents:
290
diff
changeset
|
715 (setq unread-command-char char))))) |
13 | 716 (if insert-end |
717 (save-excursion | |
718 (delete-region insert-start insert-end))) | |
719 (setq buffer-file-name name) | |
720 (set-buffer-modified-p modified))))) | |
11 | 721 |
52 | 722 (defun YaTeX-math-insert-sequence (&optional force initial) |
23 | 723 "Insert math-mode sequence with image completion." |
724 (interactive "P") | |
52 | 725 (let*((key (or initial "")) regkey str last-char list i |
13 | 726 (case-fold-search nil) match sign |
290
1a4332ecc58b
For emacs-24.3+ and NEmacs(last-command-{char,event} handling)
HIROSE Yuuji <yuuji@gentei.org>
parents:
287
diff
changeset
|
727 (this-key (char-to-string (YaTeX-last-key))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
728 (alistsym (cdr (assoc this-key YaTeX-math-key-list))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
729 (alistname (symbol-name alistsym)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
730 (alist (symbol-value alistsym)) |
13 | 731 (n (length alist)) (beg (point)) result) |
52 | 732 (if initial (insert YaTeX-ec (car (cdr (assoc initial alist))))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
733 (if (string-match "^YaTeX-" alistname) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
734 (setq alistname (substring alistname (length "YaTeX-")))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
735 (setq alistname (substring alistname 0 (string-match "-" alistname))) |
11 | 736 (setq result |
737 (catch 'complete | |
23 | 738 (if (and (not force) |
51 | 739 (if YaTeX-auto-math-mode |
740 (not (YaTeX-in-math-mode-p)) | |
741 (not YaTeX-math-mode))) | |
23 | 742 (throw 'complete 'escape));this tag should be exit, but... |
11 | 743 (while t |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
744 (message "%ssequence%s: %s" |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
745 (if YaTeX-simple-messages "" (concat alistname " ")) |
56 | 746 (if YaTeX-simple-messages "" "(TAB for menu)") key) |
11 | 747 (setq last-char (read-char) |
748 key (concat key (char-to-string last-char)) | |
13 | 749 i 0) |
11 | 750 (cond |
13 | 751 ((string= key this-key) ;;invoke key itself |
11 | 752 (throw 'complete 'escape)) |
13 | 753 ((string= key YaTeX-math-exit-key) ;;exit from math-mode |
754 (throw 'complete 'exit)) | |
23 | 755 ((string-match "\r" key) ;;RET = kakutei |
756 (throw 'complete 'select)) | |
757 ((string-match "[\C-g\C-c]" key) ;;C-g = abort | |
758 (throw 'complete 'abort)) | |
759 ((string-match "[\t\n]" key) ;;TAB, LFD = menu | |
760 (throw 'complete 'menu)) | |
761 ((string-match "[\C-h\C-?]" key) ;;BS, DEL = BS | |
762 (if (< (length key) 2) (throw 'complete 'abort)) | |
13 | 763 (setq key (substring key 0 -2)))) |
764 | |
765 (setq regkey (concat "^" (regexp-quote key))) | |
56 | 766 (message "Sequence%s: %s" |
767 (if YaTeX-simple-messages "" "(TAB for menu)") key) | |
11 | 768 (if |
769 (catch 'found | |
770 ;;(1)input string strictly matches with alist | |
23 | 771 (setq match (assoc key alist)) |
772 ;;remember previous match | |
773 | |
11 | 774 ;;(2)search partial match into alist |
13 | 775 (setq list alist) |
11 | 776 (while (< i n) |
777 (if (string-match | |
13 | 778 regkey |
779 ;;(aref array i) | |
780 ;;(car (nth i alist)) | |
23 | 781 (car (car list))) |
11 | 782 (progn |
783 (or match | |
13 | 784 ;;(setq match (nth i alist)) |
785 (setq match (car list))) | |
11 | 786 (throw 'found t))) |
13 | 787 (setq i (1+ i) list (cdr list)))) ;catch 'found |
11 | 788 nil ;;if any match, continue reading |
789 ;;else reading of sequence has been done. | |
790 (message "complete.") | |
23 | 791 (throw 'complete t)) |
792 | |
11 | 793 (if match |
794 (progn (delete-region beg (point)) | |
80 | 795 (setq YaTeX-single-command (car (cdr match))) |
796 (insert YaTeX-ec YaTeX-single-command) | |
13 | 797 (if (and YaTeX-math-need-image |
798 (setq sign (YaTeX-math-get-sign match))) | |
799 (YaTeX-math-show-image (concat sign "\n"))) | |
11 | 800 ) |
801 nil) | |
802 ))) | |
68 | 803 (delete-region beg (point)) |
11 | 804 (cond |
68 | 805 ((memq result '(t select)) |
806 (if (eq result t) | |
292
e1c1616c4f07
Use unread-command-events when bound.
HIROSE Yuuji <yuuji@gentei.org>
parents:
290
diff
changeset
|
807 (if (boundp 'unread-command-events) |
e1c1616c4f07
Use unread-command-events when bound.
HIROSE Yuuji <yuuji@gentei.org>
parents:
290
diff
changeset
|
808 (setq unread-command-events (list last-char)) |
e1c1616c4f07
Use unread-command-events when bound.
HIROSE Yuuji <yuuji@gentei.org>
parents:
290
diff
changeset
|
809 (setq unread-command-char last-char)) |
68 | 810 (message "Done.")) |
80 | 811 (if (assoc YaTeX-single-command section-table) |
812 (YaTeX-make-section nil nil nil YaTeX-single-command) | |
68 | 813 (setq YaTeX-current-completion-type 'maketitle) |
80 | 814 (YaTeX-make-singlecmd YaTeX-single-command))) |
11 | 815 ((eq result 'abort) |
816 (message "Abort.")) | |
817 ((eq result 'escape) | |
80 | 818 (call-interactively (lookup-key global-map this-key))) |
13 | 819 ((eq result 'exit) |
820 (YaTeX-toggle-math-mode)) | |
11 | 821 ((eq result 'menu) |
822 (setq key (concat "^" (regexp-quote (substring key 0 -1)))) | |
68 | 823 (insert (YaTeX-math-show-menu key)))))) |
52 | 824 |
825 ;; ----- Change image completion types ----- | |
826 (defun YaTeX-math-member-p (item) | |
827 "Check if ITEM is a member of image completion. | |
828 If so return the cons of its invocation key and image-string." | |
829 (let ((lists YaTeX-math-key-list) list) | |
830 (catch 'found | |
831 (while lists | |
832 (setq list (symbol-value (cdr (car lists)))) | |
833 (while list | |
834 (if (string= item (nth 1 (car list))) | |
835 (throw 'found (cons (car (car lists)) (nth 0 (car list))))) | |
836 (setq list (cdr list))) | |
837 (setq lists (cdr lists)))))) | |
838 | |
193 | 839 ;;; ----- for AMS LaTeX (by matsu<at>math.s.chiba-u.ac.jp) ----- |
69 | 840 (defvar YaTeX-ams-paren-modifier |
841 '(("Biggl" . "Biggr") ("biggl" . "biggr") | |
842 ("Bigl" . "Bigr") ("bigl" . "bigr") | |
843 ("left" . "right") ("" . "")) | |
844 "Alist of modifier of parentheses.") | |
845 | |
846 (defvar YaTeX-left-paren "(\\|\\[\\|\\\\{") | |
847 (defvar YaTeX-right-paren ")\\|\\]\\|\\\\}") | |
848 (defvar YaTeX-paren | |
849 (concat YaTeX-left-paren "\\|" YaTeX-right-paren)) | |
850 | |
851 (defun YaTeX-on-parenthesis-p () | |
852 "If cursor is on an (AMS-LaTeX) parenthesis, return the parenthesis." | |
853 (interactive) | |
854 (let* ((list YaTeX-ams-paren-modifier) | |
855 (longest 0) ;; the longest length of parenthesis command strings | |
856 (flag t) ;; flag for whether on braces not following \ | |
857 (point (point)) | |
858 (move 0) | |
859 (paren)) | |
860 (while list | |
861 (setq longest | |
862 (max longest (length (car (car list))) (length (cdr (car list))))) | |
863 (setq list (cdr list))) | |
864 (save-excursion | |
865 ;; search {} and, if it does not follow `\', set flag nil. | |
866 ;; if it is right after `\', set flag t and move to the position of \. | |
867 ;; mmmmm. | |
868 (if (looking-at "{\\|}") | |
869 (if (not (equal (char-after (1- (point))) 92)) | |
870 (setq flag nil) | |
871 (forward-char -1))) | |
872 ;; if flag is nil, do nothing. | |
873 (if (and flag (re-search-forward YaTeX-paren | |
874 (+ (point) 3 longest) t)) | |
875 (progn | |
876 (setq move (- (point) point)) | |
80 | 877 (setq paren (YaTeX-match-string 0)) |
69 | 878 (setq list YaTeX-ams-paren-modifier) |
879 ;; criterion for whether on [] () \{\} or not. | |
880 (if (string-match YaTeX-left-paren paren) | |
881 (while (and list flag) | |
882 (let* ((mod (car (car list))) | |
883 (mod-length 0) ;; length of modifier | |
884 paren-regexp ;; regexp of paren. | |
885 mod-regexp) ;; regexp of modifier. | |
886 (if (> (length mod) 0) | |
887 (setq mod-regexp (concat "\\\\" mod) | |
888 mod-length (1+ (length mod)))) | |
889 (cond ((string= paren "\\{") | |
890 (setq paren-regexp (concat "\\" paren))) | |
891 ((string= paren "[") | |
892 (setq paren-regexp "\\[")) | |
893 (t (setq paren-regexp paren))) | |
894 (save-excursion | |
895 (if (and (>= (- (point) (point-min)) | |
896 (+ mod-length (length paren))) | |
897 (not (forward-char | |
898 (- 0 mod-length (length paren)))) | |
899 (looking-at (concat "\\(" mod-regexp "\\)\\(" | |
900 paren-regexp "\\)"))) | |
901 (setq flag nil))) | |
902 (setq list (cdr list)))) | |
903 (while (and list flag) | |
904 (let* ((mod (cdr (car list))) | |
905 (mod-length 0) | |
906 paren-regexp | |
907 mod-regexp) | |
908 (if (> (length mod) 0) | |
909 (setq mod-regexp (concat "\\\\" mod) | |
910 mod-length (1+ (length mod)))) | |
911 (cond ((string= paren "\\}") | |
912 (setq paren-regexp (concat "\\" paren))) | |
913 ((string= paren "]") | |
914 (setq paren-regexp "\\]")) | |
915 (t (setq paren-regexp paren))) | |
916 (save-excursion | |
917 (if (and (>= (- (point) (point-min)) | |
918 (+ mod-length (length paren))) | |
919 (not (forward-char | |
920 (- 0 mod-length (length paren)))) | |
921 (looking-at (concat "\\(" mod-regexp "\\)\\(" | |
922 paren-regexp "\\)"))) | |
923 (setq flag nil))) | |
924 (setq list (cdr list))))) | |
80 | 925 (if (<= move (length (YaTeX-match-string 0))) |
926 (YaTeX-match-string 0))))))) | |
69 | 927 |
77 | 928 (defun YaTeX-goto-open-paren (&optional jumpto-co) |
929 "Jump to the exact position of open parenthesis. | |
930 If optional argument JUMPTO-CO is non-nil, goto corresponding parentheses." | |
69 | 931 (interactive) |
932 (let ((paren) | |
933 (backslash-syntax (char-to-string (char-syntax ?\\)))) | |
934 (if (setq paren (YaTeX-on-parenthesis-p)) | |
935 (if (string-match "(\\|{\\|\\[" paren (1- (length paren))) | |
936 (progn | |
937 (re-search-forward "(\\|{\\|\\[" (+ (point) (length paren)) t) | |
77 | 938 (backward-char) |
939 (if jumpto-co | |
940 (unwind-protect | |
941 (progn | |
942 (modify-syntax-entry ?\\ " ") | |
943 (forward-list) | |
944 (backward-char)) | |
945 (modify-syntax-entry ?\\ backslash-syntax))) | |
946 (point)) | |
69 | 947 (re-search-forward ")\\|}\\|\\]" (+ (point) (length paren)) t) |
948 (unwind-protect | |
949 (progn | |
950 (modify-syntax-entry ?\\ " ") | |
77 | 951 (backward-list) |
952 (point)) | |
69 | 953 (modify-syntax-entry ?\\ backslash-syntax)))))) |
954 | |
77 | 955 ;;;###autoload |
956 (defun YaTeX-goto-corresponding-paren () | |
957 "Go to corresponding mathematical parentheses." | |
958 (if (YaTeX-on-parenthesis-p) | |
959 (YaTeX-goto-open-paren t) | |
960 nil)) | |
961 | |
69 | 962 (defun YaTeX-change-parentheses () |
963 "Change the size of parentheses, braces, and brackets of AMS-LaTeX." | |
964 (interactive) | |
965 (if (not (and YaTeX-use-AMS-LaTeX (YaTeX-on-parenthesis-p))) | |
966 nil | |
80 | 967 (let* ((mod (YaTeX-match-string 1)) ;; modifier |
968 (paren (if mod (YaTeX-match-string 2) (YaTeX-match-string 0))) ;; paren | |
69 | 969 (mod-length (if (or (string= mod "\\left") (string= mod "\\right")) |
970 5 ;; 5 in case left or right | |
971 (length mod))) ;; length of modifier | |
972 (paren-length (length paren)) ;; length of paren | |
973 (length (+ mod-length paren-length)) ;; length of whole string | |
974 (big-p t) ;; flag whether new modifier is "[Bb]ig+" or not. | |
975 size ;; left, big, Big etc. | |
77 | 976 type ;; parentheses type |
69 | 977 lr ;; "l" or "r". |
978 char newsize newsize-length | |
979 (backslash-syntax (char-to-string (char-syntax ?\\))) | |
980 (case-fold-search)) | |
981 ;; decide lr and size from mod and paren. | |
982 (cond ((string-match "\\(\\\\[Bb]ig+\\)[lr]" mod) | |
983 (setq size (substring mod 1 (match-end 1)) | |
984 lr (substring mod (match-end 1) (match-end 0)))) | |
985 ((string-match "\\\\left" mod) | |
986 (setq size "left-right" lr "l")) | |
987 ((string-match "\\\\right" mod) | |
988 (setq size "left-right" lr "r")) | |
989 ((string-match "(\\|\\[\\|\\\\{" paren) | |
990 (setq size "null" lr "l")) | |
991 ((string-match ")\\|\\]\\|\\\\}" paren) | |
992 (setq size "null" lr "r")) | |
993 (t | |
994 (setq size nil lr nil))) | |
995 (while (not newsize) | |
996 (message (format (concat "Change from %s: " | |
997 "l(big) L(Big) h(bigg) H(Bigg) " | |
77 | 998 "r(left-right) n(NONE) ( { [") size)) |
69 | 999 (setq char (read-char) |
1000 newsize (cond ((char-equal char ?l) "\\big") | |
1001 ((char-equal char ?L) "\\Big") | |
1002 ((char-equal char ?h) "\\bigg") | |
1003 ((char-equal char ?H) "\\Bigg") | |
1004 ((char-equal char ?r) | |
1005 (setq big-p nil) "\\left") | |
77 | 1006 ((memq char '(?\( ?\))) |
1007 (setq big-p nil type '("(" . ")")) "") | |
1008 ((memq char '(?\{ ?\})) | |
1009 (setq big-p nil type '("\\{" . "\\}")) "") | |
1010 ((memq char '(?\[ ?\])) | |
1011 (setq big-p nil type '("[" . "]")) "") | |
69 | 1012 ((char-equal char ?n) |
1013 (setq big-p nil) "") | |
1014 (t nil)) | |
1015 newsize-length (length newsize))) | |
1016 (YaTeX-goto-open-paren) | |
1017 (forward-char) | |
77 | 1018 (cond |
1019 (type | |
1020 (delete-region (point) (- (point) paren-length)) | |
1021 (save-excursion (insert (car type)))) | |
1022 (t | |
1023 (delete-region (- (point) length) (- (point) paren-length)) | |
1024 (backward-char paren-length))) | |
69 | 1025 (insert-string newsize) |
1026 (if big-p (insert ?l)) | |
1027 (unwind-protect | |
1028 (progn | |
1029 (modify-syntax-entry ?\\ " ") | |
1030 (forward-list) | |
1031 (if (string= size "left-right") (setq length (1+ length))) | |
1032 (if (eq char ?r) (setq newsize "\\right")) | |
77 | 1033 (cond |
1034 (type | |
1035 (delete-region (point) (- (point) paren-length)) | |
1036 (insert (cdr type))) | |
1037 (t | |
1038 (delete-region (- (point) length) (- (point) paren-length)) | |
1039 (backward-char paren-length) | |
1040 (insert-string newsize) | |
1041 (if big-p (insert ?r)) | |
1042 (forward-char paren-length))) | |
69 | 1043 (if (string= lr "l") (backward-list))) |
1044 (modify-syntax-entry ?\\ backslash-syntax)) | |
1045 t))) | |
1046 | |
1047 (defun YaTeX-insert-amsparens-region (beg end char) | |
1048 (interactive "r\ncWhich one ? l(big) L(Big) h(bigg) H(Bigg): ") | |
1049 (let* ((case-fold-search) | |
1050 (st (cond ((char-equal char ?l) "big") | |
1051 ((char-equal char ?L) "Big") | |
1052 ((char-equal char ?h) "bigg") | |
1053 ((char-equal char ?H) "Bigg")))) | |
1054 (if st | |
1055 (YaTeX-insert-braces-region | |
1056 beg end (concat "\\" st "l(") (concat "\\" st "r)")) | |
1057 (YaTeX-insert-braces-region beg end "(" ")")))) | |
1058 | |
1059 (defun YaTeX-insert-amsbraces-region (beg end char) | |
1060 (interactive "r\ncWhich one ? l(big) L(Big) h(bigg) H(Bigg): ") | |
1061 (let* ((case-fold-search) | |
1062 (st (cond ((char-equal char ?l) "big") | |
1063 ((char-equal char ?L) "Big") | |
1064 ((char-equal char ?h) "bigg") | |
1065 ((char-equal char ?H) "Bigg")))) | |
1066 (if st | |
1067 (YaTeX-insert-braces-region | |
1068 beg end (concat "\\" st "l\\{") (concat "\\" st "r\\}")) | |
1069 (YaTeX-insert-braces-region beg end "\\{" "\\}")))) | |
1070 | |
1071 (defun YaTeX-insert-amsbrackets-region (beg end char) | |
1072 (interactive "r\ncWhich one ? l(big) L(Big) h(bigg) H(Bigg): ") | |
1073 (let* ((case-fold-search) | |
1074 (st (cond ((char-equal char ?l) "big") | |
1075 ((char-equal char ?L) "Big") | |
1076 ((char-equal char ?h) "bigg") | |
1077 ((char-equal char ?H) "Bigg")))) | |
1078 (if st | |
1079 (YaTeX-insert-braces-region | |
1080 beg end (concat "\\" st "l[") (concat "\\" st "r]")) | |
1081 (YaTeX-insert-braces-region beg end "[" "]")))) | |
1082 | |
1083 | |
11 | 1084 ;; |
1085 (provide 'yatexmth) | |
13 | 1086 |
1087 ; Local variables: | |
1088 ; fill-prefix: ";;; " | |
1089 ; paragraph-start: "^$\\|\\|;;;$" | |
1090 ; paragraph-separate: "^$\\|\\|;;;$" | |
1091 ; End: |