yatex

view yatexmth.el @ 460:1790e0d35156

Capitalized varGREEK with amssymb, added
author HIROSE Yuuji <yuuji@gentei.org>
date Tue, 23 May 2017 11:34:14 +0859
parents 7bf780961390
children 9db0e1522847
line source
1 ;;; yatexmth.el --- YaTeX math-mode-specific functions -*- coding: sjis -*-
2 ;;;
3 ;;; (c)1993-2017 by HIROSE Yuuji [yuuji@yatex.org]
4 ;;; Last modified Tue May 23 11:32:21 2017 on firestorm
5 ;;; $Id$
7 ;;; Commentary:
8 ;;; [Customization guide]
9 ;;;
10 ;;; By default, you can use two completion groups in YaTeX math
11 ;;; mode, `;' for mathematical signs and `:' for greek letters. But
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
15 ;;; completion as follows(prefix key is `,'):
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 ;;;
27 ;;; Typing `s' after `,' makes `\sin', `hs' after `,' makes `\sinh'
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
41 ;;; '(("," . YaTeX-math-funcs-list)
42 ;;; ("'" . Other-List-if-any)))
43 ;;;
44 ;;; Put these expressions into your ~/.emacs, and you can use this
45 ;;; completion in the math-mode.
46 ;;;
47 ;;; And you can add your favorite completion sequences to the
48 ;;; default completion list invoked with `;', by defining those lists
49 ;;; into variable YaTeX-math-sign-alist-private.
51 ;;; 【イメージ補完の追加方法】
52 ;;;
53 ;;; 標準のイメージ補完では、「;」で始まる数式記号補完と、「:」で始
54 ;;; まるギリシャ文字補完が使用可能ですが、これ以外の文字で始まる補完
55 ;;; シリーズも定義することができます。例えば、「,」で始まる次のよう
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 ;;;
68 ;;; 「,」のあとに s を押すと \sin が、hs を押すと \sinh が入力されま
69 ;;; す。このような補完リストの登録は以下のようにします(変数名は任意)。
70 ;;;
71 ;;; (setq YaTeX-math-funcs-list
72 ;;; '(("s" "sin")
73 ;;; ("S" "arcsin")
74 ;;; :
75 ;;; ("hs" "sinh")))
76 ;;;
77 ;;; さらに、「,」を押した時にイメージ補完が始まるよう次の変数に、起動キー
78 ;;; と上で定義した補完用変数の登録を行ないます。
79 ;;;
80 ;;; (setq YaTeX-math-key-list-private
81 ;;; '(("," . YaTeX-math-funcs-list)
82 ;;; ("'" . ほかに定義したいシリーズがあれば…)))
83 ;;;
84 ;;; これらを ~/.emacs に書いておけば、math-mode で自分専用のイメージ
85 ;;; 補完が利用できます。
87 ;;; Code:
88 (defvar YaTeX-jisold
89 (and (boundp 'dos-machine-type)
90 (eq dos-machine-type 'pc98)))
92 (defmacro YaTeX-setq-math-sym (sym old new)
93 (list 'setq sym (list 'if 'YaTeX-jisold old new)))
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" "♭")
110 (YaTeX-setq-math-sym YaTeX-image-sqrt "" "√")
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  ̄"))
117 (defvar
118 YaTeX-math-sign-alist-default
119 '(
120 ;frequently used
121 ("||" "|" ("||" "‖"))
122 ("sum" "sum" ("\\-+\n >\n/-+" "Σ"))
123 ("sigma" "sum" ("\\-+\n >\n/-+" "Σ"))
124 ("integral" "int" (" /\\\n \\\n\\/" YaTeX-image-int))
125 ("ointegral" "oint" " /\\\n(\\)\n\\/")
126 ("sqrt" "sqrt" (" __\n,/" YaTeX-image-sqrt))
127 ("root" "sqrt" (" __\n,/" YaTeX-image-sqrt))
128 ("A" "forall" "|_|\nV")
129 ("E" "exists" "-+\n-+\n-+")
130 ("!" "neg" ("--+\n |" YaTeX-image-neg))
131 ("oo" "infty" ("oo" "∞"))
132 ("\\" "backslash" ("\\" "\"))
133 ("..." "cdots" ("..." "…"))
135 ;;binary operators
136 ("+-" "pm" ("+\n-" "±"))
137 ("-+" "mp" "-\n+")
138 ("x" "times" ("x" "×"))
139 ("/" "div" (",\n-\n'" "÷"))
140 ("f" "frac" "xxx\n---\nyyy" "÷")
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" "<>")
156 ("/\\-" "bigtriangleup" ("/\\\n~~" "△"))
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")
170 ("t" "dagger" ("+\n|" YaTeX-image-dagger))
171 ("tt" "ddagger" ("+\n+\n|" YaTeX-image-ddagger))
172 ("II" "amalg" "II")
173 ; :
174 ;;relational operators
175 ("<" "leq" ("<\n-" "<\n-"))
176 ("=<" "leqq" ("<\n=" "≦"))
177 (">" "geq" (">\n-" ">\n-"))
178 (">=" "geqq" (">\n=" "≧"))
179 ("=:" "fallingdotseq" (".\n==\n ." "≒"))
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))
187 ("[" "sqsubset" "[")
188 ("[-" "sqsubseteq" "[\n~")
189 ("]" "sqsupset" "]")
190 ("]-" "sqsupseteq" "]\n~")
191 ("{" "in" ("(-" YaTeX-image-in))
192 ("}" "ni" ("-)" YaTeX-image-ni))
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" ("<<" "《"))
214 ("<<" "lll" "<<<")
215 (">>" "gg" (">>" "》"))
216 (">>>" "ggg" ">>>")
217 ; :
218 ;;arrows
219 ("<-" "leftarrow" ("<-" "←"))
220 ("\C-b" "leftarrow" ("<-" "←"))
221 ("<--" "longleftarrow" ("<--" "←--"))
222 ("<=" "Leftarrow" "<=")
223 ("<==" "Longleftarrow" "<==")
224 ("->" "rightarrow" ("->" "→"))
225 ("\C-f" "rightarrow" ("->" "→"))
226 ("-->" "longrightarrow" ("-->" "--→"))
227 ("=>" "Rightarrow" "=>")
228 ("==>" "Longrightarrow" "==>")
229 ("<->" "leftrightarrow" ("<->" "←→"))
230 ("<-->" "longleftrightarrow" ("<---->" "←--→"))
231 ("<=>" "Leftrightarrow" "<=>")
232 ("<==>" "Longleftrightarrow" "<==>")
233 ("^|" "uparrow" ("^\n|" "↑"))
234 ("\C-p" "uparrow" ("^\n|" "↑"))
235 ("^||" "Uparrow" "/\\\n||")
236 ("\C-n" "downarrow" ("|\nv" "↓"))
237 ("v|" "downarrow" ("|\nv" "↓"))
238 ("v||" "Downarrow" "||\n\\/")
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)
251 ("|->" "mapsto" ("|->" "|→"))
252 ("<-)" "hookleftarrow" (" ,\n<--+" " ヽ\n<--/"))
253 ("(->" "hookrightarrow" ("`\n+-->" "/\n\-->"))
254 ("/-" "leftharpoonup" "/\n~~~")
255 ("\\-" "leftharpoondown" "__\n\\")
256 ("-/" "rightharpoondown" "__\n/")
257 ("-\\" "rightharpoonup" "~~\n\\")
258 ;;left and right
259 ("left" "left" "(leftmark)")
260 ("right" "right" "(rightmark)")
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
286 ("angle" "angle" ("/\n~" "∠"))
287 ("/_" "angle" ("/\n~" "∠"))
288 ("Z" "aleph" "|\\|")
289 ("|\\|" "aleph" "|\\|")
290 ("h-" "hbar" "_\nh")
291 ; ("i" "imath" "i") ;These chars are appeared only
292 ; ("j" "jmath" "j") ;as section-type arguments
293 ("l" "ell" "l")
294 ("wp" "wp" "???")
295 ("R" "Re" ")R")
296 ("Im" "Im" "???")
297 ("mho" "mho" "~|_|~")
298 ("'" "prime" "'")
299 ("0" "emptyset" "0")
300 ("nabla" "nabla" ("___\n\\\\/" YaTeX-image-nabla))
301 ("\\/" "surd" "-\\/")
302 ("surd" "surd" "-\\/")
303 ("top" "top" "T")
304 ("bot" "bot" ("_|_" YaTeX-image-bot))
305 ("b" "flat" ("b" YaTeX-image-flat))
306 ("LT" "natural" "|\nLT\n |")
307 ("6" "partial" (" -+\n+-+\n+-+" YaTeX-image-partial))
308 ("partial" "partial" (" -+\n+-+\n+-+" YaTeX-image-partial))
309 ("round" "partial" (" -+\n+-+\n+-+" YaTeX-image-partial))
310 ("[]" "Box" "[]")
311 ("no" "notag" "\\notag")
312 (":" "colon" ":")
313 (".'." "therefore" (".'." "∴"))
314 ("'.'" "because" ("'.'" "∵"))
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 /\\")
321 ("mi" "mathit" "\\mathit{}")
322 ("mr" "mathrm" "\\mathrm{}")
323 ("mb" "mathbf" "\\mathbf{}")
324 ("mB" "mathbb" "\\mathbb{}")
325 ("mt" "mathtt" "\\mathtt{}")
326 ("ms" "mathsf" "\\mathsf{}")
327 ("mc" "mathcal" "\\mathcal{}")
328 ("mn" "mathnormal" "\\mathnormal{}")
329 )
330 "Default LaTeX-math-command alist.")
332 (defvar YaTeX-math-sign-alist-private nil
333 "*User definable key vs LaTeX-math-command alist.")
335 (defvar YaTeX-math-quit-with-strict-match nil
336 "*T for quitting completion as soon as strict-match is found.")
337 (defvar YaTeX-math-sign-alist
338 (append YaTeX-math-sign-alist-private YaTeX-math-sign-alist-default))
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 ;;)
349 (defvar YaTeX-greek-key-alist-default
350 (append
351 '(
352 ("a" "alpha" ("a" "α"))
353 ("b" "beta" ("|>\n|>\n|" "β"))
354 ("g" "gamma" ("~r" "γ"))
355 ("G" "Gamma" ("|~" "Γ"))
356 ("d" "delta" ("<~\n<>" "δ"))
357 ("D" "Delta" ("/\\\n~~" "Δ"))
358 ("e" "epsilon" "<\n<~")
359 ("e-" "varepsilon" " <\n<~")
360 ("e-" "varepsilon" ("(\n(~" "ε"))
361 ("z" "zeta" ("(~\n >" "ζ"))
362 ("et" "eta" ("n\n/" "η"))
363 ("th" "theta" ("8" "θ"))
364 ("th-" "vartheta" (" o\no" "θ"))
365 ("Th" "Theta" ("(8)" "Θ"))
366 ("th-" "vartheta" ("-8" "-θ"))
367 ("i" "iota" ("i\n\\_/" "ι"))
368 ("k" "kappa" ("k" "κ"))
369 ("l" "lambda" ("\\n/\\" "λ"))
370 ("L" "Lambda" ("/\\" "Λ"))
371 ("m" "mu" (" u_\n/" "μ"))
372 ("n" "nu" ("|/" "ν"))
373 ("x" "xi" ("E\n >" "ξ"))
374 ("X" "Xi" ("---\n -\n---" "Ξ"))
375 ("p" "pi" ("__\n)(" "π"))
376 ("p-" "varpi" (" __\n)(" "π"))
377 ("P" "Pi" ("__\n||" "Π"))
378 ("p-" "varpi" ("_\nw" "__\nω"))
379 ("r" "rho" ("/O" "ρ"))
380 ("r-" "varrho" ("~O" "ρ"))
381 ("r-" "varrho" ("/O\n~~" "ρ\n~~"))
382 ("s" "sigma" ("o~" "σ"))
383 ("s-" "varsigma" ("o~~" "σ"))
384 ("S" "Sigma" ("\\-+\n >\n/-+" "Σ"))
385 ("s-" "varsigma" "(~~ \n>")
386 ("t" "tau" ("__\n(" "τ"))
387 ("u" "upsilon" ("~v" "υ"))
388 ("y" "upsilon" ("~v" "υ"))
389 ("U" "Upsilon" ("~Y~" "Υ"))
390 ("Y" "Upsilon" ("~Y~" "Υ"))
391 ("ph" "phi" (" /\n(/)\n/" "φ"))
392 ("ph-" "varphi" (" /\n(/)\n/" "φ"))
393 ("Ph" "Phi" (" _\n(|)\n ~" "Φ"))
394 ("ph-" "varphi" "\\O\n|")
395 ("c" "chi" ("x" "χ"))
396 ("ps" "psi" ("\\|/\\n |" "ψ"))
397 ("Ps" "Psi" (" ~\n\\|/\\n |" "Ψ"))
398 ("o" "omega" ("w" "ω"))
399 ("w" "omega" ("w" "ω"))
400 ("O" "Omega" ("(~)\n~ ~" "Ω"))
401 ("W" "Omega" ("(~)\n~ ~" "Ω"))
402 ("f" "foo")
403 )
404 (if YaTeX-use-AMS-LaTeX
405 '(
406 ("G-" "varGamma" ("/~" "_Γ"))
407 ("D-" "varDelta" ("/|\n~~" "_Δ"))
408 ("Th-" "varTheta" ("/8/" "_Θ"))
409 ("L-" "varLambda" ("/|" "_Λ"))
410 ("X-" "varXi" (" --\n -\n-- " "_Ξ"))
411 ("S-" "varSigma" (" \\-+\n >\n/-+" "_Σ"))
412 ("U-" "varUpsilon" ("~~Y~" "_Υ"))
413 ("Ph-" "varPhi" (" _\n(|)\n~" "_Φ"))
414 ("Ps-" "varPsi" (" ~\n\\//\\n /" "Ψ"))
415 ("O-" "varOmega" ("/~/\n~ ~" "_Ω")))))
416 "Default LaTeX-math-command alist.")
418 (defvar YaTeX-greek-key-alist-private nil
419 "*User definable key vs LaTeX-math-command alist.")
421 (defvar YaTeX-greek-key-alist
422 (append YaTeX-greek-key-alist-private YaTeX-greek-key-alist-default))
424 ;;(mapcar (function (lambda (x) (YaTeX-math-alist2array x)))
425 ;; YaTeX-math-key-list)
427 (defvar YaTeX-math-indicator "KEY\tLaTeX sequence\t\tsign")
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
440 "Keymap used in YaTeX mathematical sign menu mode.")
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))
459 (defvar YaTeX-math-exit-key "\e"
460 "*Key sequence after prefix key of YaTeX-math-mode to exit from math-mode.")
462 (defmacro YaTeX-math-japanese-sign (list)
463 (list 'nth 1 list))
465 (defvar YaTeX-math-cmd-regexp (concat (regexp-quote YaTeX-ec) "[A-z|]"))
467 ;;; alltt goes into YaTeX-verbatim-environments 2011/3/16
468 ;;(defvar YaTeX-math-verbatim-environments
469 ;; '("alltt")
470 ;; "*List of environments in which LaTeX math mode is disabled.
471 ;;This value is appended with YaTeX-verbatim-environments.")
473 ;;;
474 ;;YaTeX math-mode functions
475 ;;;
476 ;;;###autoload
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)))
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."))
499 (set-buffer-modified-p (buffer-modified-p))))
501 (defun YaTeX-math-forward (arg)
502 (interactive "p")
503 (re-search-forward YaTeX-math-cmd-regexp nil t arg))
505 (defun YaTeX-math-backward (arg)
506 (interactive "p")
507 (re-search-backward YaTeX-math-cmd-regexp nil t arg))
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)))
520 (t sign)))
522 (defun YaTeX-math-get-sign (list)
523 (YaTeX-math-gets (car (cdr-safe (cdr-safe list)))))
525 (defvar YaTeX-math-section-type-regexp
526 "eqn\\\\\\sw+\\b"
527 "*Regexp of section-type math-mode macro")
529 (defun YaTeX-in-math-mode-p ()
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
545 )
546 YaTeX-math-other-env-list))
547 (let*((p (point)) (nest 0) me0 r firstp dollar
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))))))
571 (if (< nest 0)
572 (throw 'open (cons (YaTeX-match-string 0) (point)))))))
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)
582 (setq dollar "$")
583 (cond
584 ((equal (char-after (1- (point))) ?$) ; $$ equation $$
585 (setq dollar "$$")
586 (backward-char 1)
587 (setq nest (1+ nest)))
588 ((YaTeX-literal-p)
589 nil)
590 ((and (equal (char-after (1- (point))) ?\\ )
591 (not (equal (char-after (- (point) 3)) ?\\ )))
592 nil) ;\$
593 (t (setq nest (1+ nest))))
594 (if (and (= nest 1) (null firstp))
595 (setq firstp (cons dollar (point)))))
596 (if (= (% nest 2) 1)
597 (throw 'dollar firstp))))))))))
599 (defun YaTeX-mark-mathenv ()
600 "Mark current mathematic environment."
601 (interactive)
602 (let ((mmp (YaTeX-in-math-mode-p)) type bpt)
603 (if (or (null mmp) (not (stringp (setq type (car mmp)))))
604 nil ;if nil or not string, do nothing
605 (setq bpt (cdr mmp))
606 (goto-char bpt)
607 (cond
608 ((string-match "\\$" type)
609 (set-mark-command nil)
610 (skip-chars-forward "$")
611 (YaTeX-search-active-forward
612 type YaTeX-comment-prefix nil) ;if it cause error, obey it
613 (goto-char (match-end 0)))
614 ;;
615 ((string-match "^\\\\[\\[(]" type)
616 (set-mark-command nil)
617 (YaTeX-goto-corresponding-leftright)
618 (skip-chars-forward "])\\\\"))
619 ;;
620 ((string-match "^[a-z]" type) ; \begin\end type math
621 (set-mark-command nil)
622 (YaTeX-goto-corresponding-environment)
623 (goto-char (match-end 0)))))))
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))
638 (while (and sign (not (string= "" sign)))
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)) "")))))
648 (defvar YaTeX-math-menu-buffer "*math-mode-signs*")
650 (defun YaTeX-math-show-menu (match-str)
651 (save-window-excursion
652 (YaTeX-showup-buffer YaTeX-math-menu-buffer nil t)
653 (let ((maxcols (max 1 (/ (YaTeX-screen-width) YaTeX-math-sign-width)))
654 (case-fold-search nil)
655 (cols 0) (list alist) command)
656 (erase-buffer)
657 (insert
658 "Candidates of sign. [n:next p:prev f:forw b:back q:quit RET:select]\n")
659 (insert YaTeX-math-indicator "\t")
660 (insert YaTeX-math-indicator)
661 (newline 1)
662 (insert-char ?- (1- (YaTeX-screen-width)))
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)))
669 (goto-char (point-min)) (forward-line 3)
670 (use-local-map YaTeX-math-menu-map)
671 (setq buffer-read-only t)
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))
682 command)))
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."
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)
713 (if (boundp 'unread-command-events)
714 (setq unread-command-events (list char))
715 (setq unread-command-char char)))))
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)))))
722 (defun YaTeX-math-insert-sequence (&optional force initial)
723 "Insert math-mode sequence with image completion."
724 (interactive "P")
725 (let*((key (or initial "")) regkey str last-char list i
726 (case-fold-search nil) match sign
727 (this-key (char-to-string (YaTeX-last-key)))
728 (alistsym (cdr (assoc this-key YaTeX-math-key-list)))
729 (alistname (symbol-name alistsym))
730 (alist (symbol-value alistsym))
731 (n (length alist)) (beg (point)) result)
732 (if initial (insert YaTeX-ec (car (cdr (assoc initial alist)))))
733 (if (string-match "^YaTeX-" alistname)
734 (setq alistname (substring alistname (length "YaTeX-"))))
735 (setq alistname (substring alistname 0 (string-match "-" alistname)))
736 (setq result
737 (catch 'complete
738 (if (and (not force)
739 (if YaTeX-auto-math-mode
740 (not (YaTeX-in-math-mode-p))
741 (not YaTeX-math-mode)))
742 (throw 'complete 'escape));this tag should be exit, but...
743 (while t
744 (message "%ssequence%s: %s"
745 (if YaTeX-simple-messages "" (concat alistname " "))
746 (if YaTeX-simple-messages "" "(TAB for menu)") key)
747 (setq last-char (read-char)
748 key (concat key (char-to-string last-char))
749 i 0)
750 (cond
751 ((string= key this-key) ;;invoke key itself
752 (throw 'complete 'escape))
753 ((string= key YaTeX-math-exit-key) ;;exit from math-mode
754 (throw 'complete 'exit))
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))
763 (setq key (substring key 0 -2))))
765 (setq regkey (concat "^" (regexp-quote key)))
766 (message "Sequence%s: %s"
767 (if YaTeX-simple-messages "" "(TAB for menu)") key)
768 (if
769 (catch 'found
770 ;;(1)input string strictly matches with alist
771 (setq match (assoc key alist))
772 ;;remember previous match
774 ;;(2)search partial match into alist
775 (setq list alist)
776 (while (< i n)
777 (if (string-match
778 regkey
779 ;;(aref array i)
780 ;;(car (nth i alist))
781 (car (car list)))
782 (progn
783 (or match
784 ;;(setq match (nth i alist))
785 (setq match (car list)))
786 (throw 'found t)))
787 (setq i (1+ i) list (cdr list)))) ;catch 'found
788 nil ;;if any match, continue reading
789 ;;else reading of sequence has been done.
790 (message "complete.")
791 (throw 'complete t))
793 (if match
794 (progn (delete-region beg (point))
795 (setq YaTeX-single-command (car (cdr match)))
796 (insert YaTeX-ec YaTeX-single-command)
797 (if (and YaTeX-math-need-image
798 (setq sign (YaTeX-math-get-sign match)))
799 (YaTeX-math-show-image (concat sign "\n")))
800 )
801 nil)
802 )))
803 (delete-region beg (point))
804 (cond
805 ((memq result '(t select))
806 (if (eq result t)
807 (if (boundp 'unread-command-events)
808 (setq unread-command-events (list last-char))
809 (setq unread-command-char last-char))
810 (message "Done."))
811 (if (assoc YaTeX-single-command section-table)
812 (YaTeX-make-section nil nil nil YaTeX-single-command)
813 (setq YaTeX-current-completion-type 'maketitle)
814 (YaTeX-make-singlecmd YaTeX-single-command)))
815 ((eq result 'abort)
816 (message "Abort."))
817 ((eq result 'escape)
818 (call-interactively (lookup-key global-map this-key)))
819 ((eq result 'exit)
820 (YaTeX-toggle-math-mode))
821 ((eq result 'menu)
822 (setq key (concat "^" (regexp-quote (substring key 0 -1))))
823 (insert (YaTeX-math-show-menu key))))))
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))))))
839 ;;; ----- for AMS LaTeX (by matsu<at>math.s.chiba-u.ac.jp) -----
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.")
846 (defvar YaTeX-left-paren "(\\|\\[\\|\\\\{")
847 (defvar YaTeX-right-paren ")\\|\\]\\|\\\\}")
848 (defvar YaTeX-paren
849 (concat YaTeX-left-paren "\\|" YaTeX-right-paren))
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))
877 (setq paren (YaTeX-match-string 0))
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)))))
925 (if (<= move (length (YaTeX-match-string 0)))
926 (YaTeX-match-string 0)))))))
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."
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)
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))
947 (re-search-forward ")\\|}\\|\\]" (+ (point) (length paren)) t)
948 (unwind-protect
949 (progn
950 (modify-syntax-entry ?\\ " ")
951 (backward-list)
952 (point))
953 (modify-syntax-entry ?\\ backslash-syntax))))))
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))
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
967 (let* ((mod (YaTeX-match-string 1)) ;; modifier
968 (paren (if mod (YaTeX-match-string 2) (YaTeX-match-string 0))) ;; paren
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.
976 type ;; parentheses type
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) "
998 "r(left-right) n(NONE) ( { [") size))
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")
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 '("[" . "]")) "")
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)
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)))
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"))
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)))
1043 (if (string= lr "l") (backward-list)))
1044 (modify-syntax-entry ?\\ backslash-syntax))
1045 t)))
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 "(" ")"))))
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 "\\{" "\\}"))))
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 "[" "]"))))
1084 ;;
1085 (provide 'yatexmth)
1087 ; Local variables:
1088 ; fill-prefix: ";;; "
1089 ; paragraph-start: "^$\\| \\|;;;$"
1090 ; paragraph-separate: "^$\\| \\|;;;$"
1091 ; End: