yatex

view yatexmth.el @ 449:c2c547e147c7

YaTeX-math-other-env-alist-* for additional math-environments
author HIROSE Yuuji <yuuji@gentei.org>
date Tue, 17 Jan 2017 22:38:37 +0900
parents 7a9d30752353
children 8871fe9f563b
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 Jan 17 22:33:52 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 ("mt" "mathtt" "\\mathtt{}")
325 ("ms" "mathsf" "\\mathsf{}")
326 ("mc" "mathcal" "\\mathcal{}")
327 ("mn" "mathnormal" "\\mathnormal{}")
328 )
329 "Default LaTeX-math-command alist.")
331 (defvar YaTeX-math-sign-alist-private nil
332 "*User definable key vs LaTeX-math-command alist.")
334 (defvar YaTeX-math-quit-with-strict-match nil
335 "*T for quitting completion as soon as strict-match is found.")
336 (defvar YaTeX-math-sign-alist
337 (append YaTeX-math-sign-alist-private YaTeX-math-sign-alist-default))
339 ;;(defun YaTeX-math-alist2array (alist array)
340 ;; (set array
341 ;; (let ((array (make-vector (length alist) "")) (list alist) (i 0))
342 ;; (while list
343 ;; (aset array i (car (car list)))
344 ;; (setq i (1+ i) list (cdr list)))
345 ;; array))
346 ;;)
348 (defvar YaTeX-greek-key-alist-default
349 '(
350 ("a" "alpha" ("a" "α"))
351 ("b" "beta" ("|>\n|>\n|" "β"))
352 ("g" "gamma" ("~r" "γ"))
353 ("G" "Gamma" ("|~" "Γ"))
354 ("d" "delta" ("<~\n<>" "δ"))
355 ("D" "Delta" ("/\\\n~~" "Δ"))
356 ("e" "epsilon" "<\n<~")
357 ("e-" "varepsilon" ("(\n(~" "ε"))
358 ("z" "zeta" ("(~\n >" "ζ"))
359 ("et" "eta" ("n\n/" "η"))
360 ("th" "theta" ("8" "θ"))
361 ("Th" "Theta" ("(8)" "Θ"))
362 ("th-" "vartheta" ("-8" "-θ"))
363 ("i" "iota" ("i\n\\_/" "ι"))
364 ("k" "kappa" ("k" "κ"))
365 ("l" "lambda" ("\\n/\\" "λ"))
366 ("L" "Lambda" ("/\\" "Λ"))
367 ("m" "mu" (" u_\n/" "μ"))
368 ("n" "nu" ("|/" "ν"))
369 ("x" "xi" ("E\n >" "ξ"))
370 ("X" "Xi" ("---\n -\n---" "Ξ"))
371 ("p" "pi" ("__\n)(" "π"))
372 ("P" "Pi" ("__\n||" "Π"))
373 ("p-" "varpi" ("_\nw" "__\nω"))
374 ("r" "rho" ("/O" "ρ"))
375 ("r-" "varrho" ("/O\n~~" "ρ\n~~"))
376 ("s" "sigma" ("o~" "σ"))
377 ("S" "Sigma" ("\\-+\n >\n/-+" "Σ"))
378 ("s-" "varsigma" "(~~ \n>")
379 ("t" "tau" ("__\n(" "τ"))
380 ("u" "upsilon" ("~v" "υ"))
381 ("y" "upsilon" ("~v" "υ"))
382 ("U" "Upsilon" ("~Y~" "Υ"))
383 ("Y" "Upsilon" ("~Y~" "Υ"))
384 ("ph" "phi" (" /\n(/)\n/" "φ"))
385 ("Ph" "Phi" (" _\n(|)\n ~" "Φ"))
386 ("ph-" "varphi" "\\O\n|")
387 ("c" "chi" ("x" "χ"))
388 ("ps" "psi" ("\\|/\\n |" "ψ"))
389 ("Ps" "Psi" (" ~\n\\|/\\n |" "Ψ"))
390 ("o" "omega" ("w" "ω"))
391 ("w" "omega" ("w" "ω"))
392 ("O" "Omega" ("(~)\n~ ~" "Ω"))
393 ("W" "Omega" ("(~)\n~ ~" "Ω"))
394 ("f" "foo")
395 )
396 "Default LaTeX-math-command alist.")
398 (defvar YaTeX-greek-key-alist-private nil
399 "*User definable key vs LaTeX-math-command alist.")
401 (defvar YaTeX-greek-key-alist
402 (append YaTeX-greek-key-alist-private YaTeX-greek-key-alist-default))
404 ;;(mapcar (function (lambda (x) (YaTeX-math-alist2array x)))
405 ;; YaTeX-math-key-list)
407 (defvar YaTeX-math-indicator "KEY\tLaTeX sequence\t\tsign")
409 (defvar YaTeX-math-need-image t
410 "*T for displaying pseudo image momentarily.")
411 (defvar YaTeX-math-max-key 8)
412 (defvar YaTeX-math-max-seq
413 (* 8 (1+ (/ (length "\\longleftrightarrow") 8))))
414 (defvar YaTeX-math-max-sign 5)
415 (defvar YaTeX-math-sign-width
416 (+ YaTeX-math-max-key YaTeX-math-max-seq YaTeX-math-max-sign))
417 (defvar YaTeX-math-display-width
418 (* 8 (1+ (/ YaTeX-math-sign-width 8))))
419 (defvar YaTeX-math-menu-map nil
420 "Keymap used in YaTeX mathematical sign menu mode.")
422 (if YaTeX-math-menu-map nil
423 (setq YaTeX-math-menu-map (make-sparse-keymap))
424 (define-key YaTeX-math-menu-map "n" 'next-line)
425 (define-key YaTeX-math-menu-map "p" 'previous-line)
426 (define-key YaTeX-math-menu-map "f" 'YaTeX-math-forward)
427 (define-key YaTeX-math-menu-map "b" 'YaTeX-math-backward)
428 (define-key YaTeX-math-menu-map "v" 'scroll-up)
429 (define-key YaTeX-math-menu-map " " 'scroll-up)
430 (define-key YaTeX-math-menu-map "c" 'scroll-up)
431 (define-key YaTeX-math-menu-map "V" 'scroll-down)
432 (define-key YaTeX-math-menu-map "r" 'scroll-down)
433 (define-key YaTeX-math-menu-map "\^h" 'scroll-down)
434 (define-key YaTeX-math-menu-map "<" 'beginning-of-buffer)
435 (define-key YaTeX-math-menu-map ">" 'end-of-buffer)
436 (define-key YaTeX-math-menu-map "\^m" 'exit-recursive-edit)
437 (define-key YaTeX-math-menu-map "q" 'abort-recursive-edit))
439 (defvar YaTeX-math-exit-key "\e"
440 "*Key sequence after prefix key of YaTeX-math-mode to exit from math-mode.")
442 (defmacro YaTeX-math-japanese-sign (list)
443 (list 'nth 1 list))
445 (defvar YaTeX-math-cmd-regexp (concat (regexp-quote YaTeX-ec) "[A-z|]"))
447 ;;; alltt goes into YaTeX-verbatim-environments 2011/3/16
448 ;;(defvar YaTeX-math-verbatim-environments
449 ;; '("alltt")
450 ;; "*List of environments in which LaTeX math mode is disabled.
451 ;;This value is appended with YaTeX-verbatim-environments.")
453 ;;;
454 ;;YaTeX math-mode functions
455 ;;;
456 ;;;###autoload
457 (defun YaTeX-toggle-math-mode (&optional arg)
458 (interactive "P")
459 (or (memq 'YaTeX-math-mode mode-line-format) nil
460 (setq mode-line-format
461 (append (list "" 'YaTeX-math-mode) mode-line-format)))
462 (if YaTeX-auto-math-mode nil ;Only effective on manual mode.
463 (if (or arg (null YaTeX-math-mode))
464 (let (keys)
465 (setq YaTeX-math-mode "math:")
466 (message "Turn on math mode. Prefix keys are %s"
467 (mapconcat 'car YaTeX-math-key-list " "))
468 (sit-for 3)
469 (message
470 (concat "To exit from math-mode, type `ESC' after prefix, "
471 "or type `"
472 (key-description
473 (car
474 (where-is-internal
475 'YaTeX-switch-mode-menu YaTeX-mode-map)))
476 " $'")))
477 (setq YaTeX-math-mode nil)
478 (message "Exit from math mode."))
479 (set-buffer-modified-p (buffer-modified-p))))
481 (defun YaTeX-math-forward (arg)
482 (interactive "p")
483 (re-search-forward YaTeX-math-cmd-regexp nil t arg))
485 (defun YaTeX-math-backward (arg)
486 (interactive "p")
487 (re-search-backward YaTeX-math-cmd-regexp nil t arg))
489 (defun YaTeX-math-gets (sign)
490 (cond
491 ((null sign) nil)
492 ((listp sign)
493 (setq sign
494 (cond
495 (YaTeX-japan (YaTeX-math-japanese-sign sign))
496 (t (car sign))))
497 (YaTeX-math-gets sign))
498 ((symbolp sign)
499 (YaTeX-math-gets (symbol-value sign)))
500 (t sign)))
502 (defun YaTeX-math-get-sign (list)
503 (YaTeX-math-gets (car (cdr-safe (cdr-safe list)))))
505 (defvar YaTeX-math-section-type-regexp
506 "eqn\\\\\\sw+\\b"
507 "*Regexp of section-type math-mode macro")
509 (defun YaTeX-in-math-mode-p ()
510 "If current position is supposed to be in LaTeX-math-mode, return t.
511 This function refers a local variable `source-window' in YaTeX-make-section."
512 (save-excursion
513 (and (boundp 'source-window) source-window
514 (set-buffer (window-buffer source-window)))
515 (or (YaTeX-quick-in-environment-p
516 (append
517 '("math" "eqnarray" "equation" "eqnarray*" "displaymath") ;LaTeX
518 (if YaTeX-use-AMS-LaTeX
519 ;; And math modes of AMS-LaTeX
520 ;;'("align" "align*" "split" "multline" "multline*" "gather"
521 ;; "gather*" "aligned*" "gathered" "gathered*" "alignat"
522 ;; "equation*" "cases" "flalign" "flalign*"
523 ;; "alignat*" "xalignat" "xalignat*" "xxalignat" "xxalignat*"
524 YaTeX-math-begin-list
525 )
526 YaTeX-math-other-env-alist))
527 (let*((p (point)) (nest 0) me0 r firstp dollar
528 (delim (concat YaTeX-sectioning-regexp "\\|^$\\|^\C-l"))
529 (boundary
530 (save-excursion
531 (if (looking-at delim)
532 (goto-char (max (point-min) (1- (point)))))
533 (re-search-backward delim nil 1)
534 (point))))
535 (save-excursion
536 (cond
537 ((catch 'open
538 (save-excursion
539 (while (and (>= nest 0)
540 (re-search-backward
541 (concat YaTeX-ec-regexp ;\
542 "\\([()]\\|[][]\\)") boundary t))
543 (setq me0 (match-end 0))
544 (if (or (YaTeX-on-comment-p)
545 (YaTeX-literal-p)) nil
546 (if (or (= (char-after (1- me0)) ?\))
547 (= (char-after (1- me0)) ?\]))
548 (setq nest (1+ nest))
549 (if (= (preceding-char) ?\\ ) nil ;;\\[5pt]
550 (setq nest (1- nest))))))
551 (if (< nest 0)
552 (throw 'open (cons (YaTeX-match-string 0) (point)))))))
553 ((and (setq r (YaTeX-on-section-command-p
554 YaTeX-math-section-type-regexp))
555 (numberp r)
556 (> r 0))
557 t)
558 (t (catch 'dollar
559 (while ;(search-backward "$" boundary t);little bit fast.
560 (YaTeX-re-search-active-backward ;;;;;; Too slow???
561 "\\$" (concat "[^\\\\]" YaTeX-comment-prefix) boundary t)
562 (setq dollar "$")
563 (cond
564 ((equal (char-after (1- (point))) ?$) ; $$ equation $$
565 (setq dollar "$$")
566 (backward-char 1)
567 (setq nest (1+ nest)))
568 ((YaTeX-literal-p)
569 nil)
570 ((and (equal (char-after (1- (point))) ?\\ )
571 (not (equal (char-after (- (point) 3)) ?\\ )))
572 nil) ;\$
573 (t (setq nest (1+ nest))))
574 (if (and (= nest 1) (null firstp))
575 (setq firstp (cons dollar (point)))))
576 (if (= (% nest 2) 1)
577 (throw 'dollar firstp))))))))))
579 (defun YaTeX-mark-mathenv ()
580 "Mark current mathematic environment."
581 (interactive)
582 (let ((mmp (YaTeX-in-math-mode-p)) type bpt)
583 (if (or (null mmp) (not (stringp (setq type (car mmp)))))
584 nil ;if nil or not string, do nothing
585 (setq bpt (cdr mmp))
586 (goto-char bpt)
587 (cond
588 ((string-match "\\$" type)
589 (set-mark-command nil)
590 (skip-chars-forward "$")
591 (YaTeX-search-active-forward
592 type YaTeX-comment-prefix nil) ;if it cause error, obey it
593 (goto-char (match-end 0)))
594 ;;
595 ((string-match "^\\\\[\\[(]" type)
596 (set-mark-command nil)
597 (YaTeX-goto-corresponding-leftright)
598 (skip-chars-forward "])\\\\"))
599 ;;
600 ((string-match "^[a-z]" type) ; \begin\end type math
601 (set-mark-command nil)
602 (YaTeX-goto-corresponding-environment)
603 (goto-char (match-end 0)))))))
605 (defun YaTeX-math-display-list (list cols)
606 (goto-char (point-max))
607 (if (= cols 0) (if (not (eolp)) (newline 1))
608 (forward-line -1)
609 (while (looking-at "[ \t\n]") (forward-line -1)))
610 (end-of-line)
611 (let ((indent (* YaTeX-math-display-width cols)) sign str to)
612 (indent-to indent)
613 (insert (car list))
614 (indent-to (setq indent (+ indent YaTeX-math-max-key)))
615 (insert "\\" (car (cdr list)))
616 (setq indent (+ indent YaTeX-math-max-seq))
617 (setq sign (YaTeX-math-get-sign list))
618 (while (and sign (not (string= "" sign)))
619 (setq to (string-match "\n" sign)
620 str (if to (substring sign 0 to) sign))
621 (end-of-line)
622 (indent-to indent)
623 (insert str)
624 (cond ((eobp) (newline 1))
625 ((> cols 0) (forward-line 1)))
626 (setq sign (if to (substring sign (1+ to)) "")))))
628 (defvar YaTeX-math-menu-buffer "*math-mode-signs*")
630 (defun YaTeX-math-show-menu (match-str)
631 (save-window-excursion
632 (YaTeX-showup-buffer YaTeX-math-menu-buffer nil t)
633 (let ((maxcols (max 1 (/ (YaTeX-screen-width) YaTeX-math-sign-width)))
634 (case-fold-search nil)
635 (cols 0) (list alist) command)
636 (erase-buffer)
637 (insert
638 "Candidates of sign. [n:next p:prev f:forw b:back q:quit RET:select]\n")
639 (insert YaTeX-math-indicator "\t")
640 (insert YaTeX-math-indicator)
641 (newline 1)
642 (insert-char ?- (1- (YaTeX-screen-width)))
643 (newline 1)
644 (while list
645 (if (string-match match-str (car (car list)))
646 (progn (YaTeX-math-display-list (car list) cols)
647 (setq cols (% (1+ cols) maxcols))))
648 (setq list (cdr list)))
649 (goto-char (point-min)) (forward-line 3)
650 (use-local-map YaTeX-math-menu-map)
651 (setq buffer-read-only t)
652 (unwind-protect
653 (recursive-edit)
654 (skip-chars-backward "^ \t\n")
655 (setq command
656 (if (re-search-forward YaTeX-math-cmd-regexp nil t)
657 (buffer-substring
658 (match-beginning 0)
659 (prog2 (skip-chars-forward "^ \t\n") (point)))
660 nil))
661 (kill-buffer YaTeX-math-menu-buffer))
662 command)))
664 (defun YaTeX-math-show-image (image &optional exit-char)
665 "Momentarily display IMAGE at the beginning of the next line;
666 erase it on the next keystroke. The window is recentered if necessary
667 to make the whole string visible. If the window isn't large enough,
668 at least you get to read the beginning."
669 (if (and image (not (string= image "")))
670 (let ((buffer-read-only nil)
671 (modified (buffer-modified-p))
672 (name buffer-file-name)
673 insert-start
674 insert-end)
675 (unwind-protect
676 (progn
677 (save-excursion
678 ;; defeat file locking... don't try this at home, kids!
679 (setq buffer-file-name nil)
680 (forward-line 1)
681 (setq insert-start (point))
682 (if (eobp) (newline))
683 (insert image)
684 (setq insert-end (point)))
685 ; make sure the whole string is visible
686 (if (not (pos-visible-in-window-p insert-end))
687 (recenter (max 0
688 (- (window-height)
689 (count-lines insert-start insert-end)
690 2))))
691 (let ((char (read-char)))
692 (or (eq char exit-char)
693 (if (boundp 'unread-command-events)
694 (setq unread-command-events (list char))
695 (setq unread-command-char char)))))
696 (if insert-end
697 (save-excursion
698 (delete-region insert-start insert-end)))
699 (setq buffer-file-name name)
700 (set-buffer-modified-p modified)))))
702 (defun YaTeX-math-insert-sequence (&optional force initial)
703 "Insert math-mode sequence with image completion."
704 (interactive "P")
705 (let*((key (or initial "")) regkey str last-char list i
706 (case-fold-search nil) match sign
707 (this-key (char-to-string (YaTeX-last-key)))
708 (alistsym (cdr (assoc this-key YaTeX-math-key-list)))
709 (alistname (symbol-name alistsym))
710 (alist (symbol-value alistsym))
711 (n (length alist)) (beg (point)) result)
712 (if initial (insert YaTeX-ec (car (cdr (assoc initial alist)))))
713 (if (string-match "^YaTeX-" alistname)
714 (setq alistname (substring alistname (length "YaTeX-"))))
715 (setq alistname (substring alistname 0 (string-match "-" alistname)))
716 (setq result
717 (catch 'complete
718 (if (and (not force)
719 (if YaTeX-auto-math-mode
720 (not (YaTeX-in-math-mode-p))
721 (not YaTeX-math-mode)))
722 (throw 'complete 'escape));this tag should be exit, but...
723 (while t
724 (message "%ssequence%s: %s"
725 (if YaTeX-simple-messages "" (concat alistname " "))
726 (if YaTeX-simple-messages "" "(TAB for menu)") key)
727 (setq last-char (read-char)
728 key (concat key (char-to-string last-char))
729 i 0)
730 (cond
731 ((string= key this-key) ;;invoke key itself
732 (throw 'complete 'escape))
733 ((string= key YaTeX-math-exit-key) ;;exit from math-mode
734 (throw 'complete 'exit))
735 ((string-match "\r" key) ;;RET = kakutei
736 (throw 'complete 'select))
737 ((string-match "[\C-g\C-c]" key) ;;C-g = abort
738 (throw 'complete 'abort))
739 ((string-match "[\t\n]" key) ;;TAB, LFD = menu
740 (throw 'complete 'menu))
741 ((string-match "[\C-h\C-?]" key) ;;BS, DEL = BS
742 (if (< (length key) 2) (throw 'complete 'abort))
743 (setq key (substring key 0 -2))))
745 (setq regkey (concat "^" (regexp-quote key)))
746 (message "Sequence%s: %s"
747 (if YaTeX-simple-messages "" "(TAB for menu)") key)
748 (if
749 (catch 'found
750 ;;(1)input string strictly matches with alist
751 (setq match (assoc key alist))
752 ;;remember previous match
754 ;;(2)search partial match into alist
755 (setq list alist)
756 (while (< i n)
757 (if (string-match
758 regkey
759 ;;(aref array i)
760 ;;(car (nth i alist))
761 (car (car list)))
762 (progn
763 (or match
764 ;;(setq match (nth i alist))
765 (setq match (car list)))
766 (throw 'found t)))
767 (setq i (1+ i) list (cdr list)))) ;catch 'found
768 nil ;;if any match, continue reading
769 ;;else reading of sequence has been done.
770 (message "complete.")
771 (throw 'complete t))
773 (if match
774 (progn (delete-region beg (point))
775 (setq YaTeX-single-command (car (cdr match)))
776 (insert YaTeX-ec YaTeX-single-command)
777 (if (and YaTeX-math-need-image
778 (setq sign (YaTeX-math-get-sign match)))
779 (YaTeX-math-show-image (concat sign "\n")))
780 )
781 nil)
782 )))
783 (delete-region beg (point))
784 (cond
785 ((memq result '(t select))
786 (if (eq result t)
787 (if (boundp 'unread-command-events)
788 (setq unread-command-events (list last-char))
789 (setq unread-command-char last-char))
790 (message "Done."))
791 (if (assoc YaTeX-single-command section-table)
792 (YaTeX-make-section nil nil nil YaTeX-single-command)
793 (setq YaTeX-current-completion-type 'maketitle)
794 (YaTeX-make-singlecmd YaTeX-single-command)))
795 ((eq result 'abort)
796 (message "Abort."))
797 ((eq result 'escape)
798 (call-interactively (lookup-key global-map this-key)))
799 ((eq result 'exit)
800 (YaTeX-toggle-math-mode))
801 ((eq result 'menu)
802 (setq key (concat "^" (regexp-quote (substring key 0 -1))))
803 (insert (YaTeX-math-show-menu key))))))
805 ;; ----- Change image completion types -----
806 (defun YaTeX-math-member-p (item)
807 "Check if ITEM is a member of image completion.
808 If so return the cons of its invocation key and image-string."
809 (let ((lists YaTeX-math-key-list) list)
810 (catch 'found
811 (while lists
812 (setq list (symbol-value (cdr (car lists))))
813 (while list
814 (if (string= item (nth 1 (car list)))
815 (throw 'found (cons (car (car lists)) (nth 0 (car list)))))
816 (setq list (cdr list)))
817 (setq lists (cdr lists))))))
819 ;;; ----- for AMS LaTeX (by matsu<at>math.s.chiba-u.ac.jp) -----
820 (defvar YaTeX-ams-paren-modifier
821 '(("Biggl" . "Biggr") ("biggl" . "biggr")
822 ("Bigl" . "Bigr") ("bigl" . "bigr")
823 ("left" . "right") ("" . ""))
824 "Alist of modifier of parentheses.")
826 (defvar YaTeX-left-paren "(\\|\\[\\|\\\\{")
827 (defvar YaTeX-right-paren ")\\|\\]\\|\\\\}")
828 (defvar YaTeX-paren
829 (concat YaTeX-left-paren "\\|" YaTeX-right-paren))
831 (defun YaTeX-on-parenthesis-p ()
832 "If cursor is on an (AMS-LaTeX) parenthesis, return the parenthesis."
833 (interactive)
834 (let* ((list YaTeX-ams-paren-modifier)
835 (longest 0) ;; the longest length of parenthesis command strings
836 (flag t) ;; flag for whether on braces not following \
837 (point (point))
838 (move 0)
839 (paren))
840 (while list
841 (setq longest
842 (max longest (length (car (car list))) (length (cdr (car list)))))
843 (setq list (cdr list)))
844 (save-excursion
845 ;; search {} and, if it does not follow `\', set flag nil.
846 ;; if it is right after `\', set flag t and move to the position of \.
847 ;; mmmmm.
848 (if (looking-at "{\\|}")
849 (if (not (equal (char-after (1- (point))) 92))
850 (setq flag nil)
851 (forward-char -1)))
852 ;; if flag is nil, do nothing.
853 (if (and flag (re-search-forward YaTeX-paren
854 (+ (point) 3 longest) t))
855 (progn
856 (setq move (- (point) point))
857 (setq paren (YaTeX-match-string 0))
858 (setq list YaTeX-ams-paren-modifier)
859 ;; criterion for whether on [] () \{\} or not.
860 (if (string-match YaTeX-left-paren paren)
861 (while (and list flag)
862 (let* ((mod (car (car list)))
863 (mod-length 0) ;; length of modifier
864 paren-regexp ;; regexp of paren.
865 mod-regexp) ;; regexp of modifier.
866 (if (> (length mod) 0)
867 (setq mod-regexp (concat "\\\\" mod)
868 mod-length (1+ (length mod))))
869 (cond ((string= paren "\\{")
870 (setq paren-regexp (concat "\\" paren)))
871 ((string= paren "[")
872 (setq paren-regexp "\\["))
873 (t (setq paren-regexp paren)))
874 (save-excursion
875 (if (and (>= (- (point) (point-min))
876 (+ mod-length (length paren)))
877 (not (forward-char
878 (- 0 mod-length (length paren))))
879 (looking-at (concat "\\(" mod-regexp "\\)\\("
880 paren-regexp "\\)")))
881 (setq flag nil)))
882 (setq list (cdr list))))
883 (while (and list flag)
884 (let* ((mod (cdr (car list)))
885 (mod-length 0)
886 paren-regexp
887 mod-regexp)
888 (if (> (length mod) 0)
889 (setq mod-regexp (concat "\\\\" mod)
890 mod-length (1+ (length mod))))
891 (cond ((string= paren "\\}")
892 (setq paren-regexp (concat "\\" paren)))
893 ((string= paren "]")
894 (setq paren-regexp "\\]"))
895 (t (setq paren-regexp paren)))
896 (save-excursion
897 (if (and (>= (- (point) (point-min))
898 (+ mod-length (length paren)))
899 (not (forward-char
900 (- 0 mod-length (length paren))))
901 (looking-at (concat "\\(" mod-regexp "\\)\\("
902 paren-regexp "\\)")))
903 (setq flag nil)))
904 (setq list (cdr list)))))
905 (if (<= move (length (YaTeX-match-string 0)))
906 (YaTeX-match-string 0)))))))
908 (defun YaTeX-goto-open-paren (&optional jumpto-co)
909 "Jump to the exact position of open parenthesis.
910 If optional argument JUMPTO-CO is non-nil, goto corresponding parentheses."
911 (interactive)
912 (let ((paren)
913 (backslash-syntax (char-to-string (char-syntax ?\\))))
914 (if (setq paren (YaTeX-on-parenthesis-p))
915 (if (string-match "(\\|{\\|\\[" paren (1- (length paren)))
916 (progn
917 (re-search-forward "(\\|{\\|\\[" (+ (point) (length paren)) t)
918 (backward-char)
919 (if jumpto-co
920 (unwind-protect
921 (progn
922 (modify-syntax-entry ?\\ " ")
923 (forward-list)
924 (backward-char))
925 (modify-syntax-entry ?\\ backslash-syntax)))
926 (point))
927 (re-search-forward ")\\|}\\|\\]" (+ (point) (length paren)) t)
928 (unwind-protect
929 (progn
930 (modify-syntax-entry ?\\ " ")
931 (backward-list)
932 (point))
933 (modify-syntax-entry ?\\ backslash-syntax))))))
935 ;;;###autoload
936 (defun YaTeX-goto-corresponding-paren ()
937 "Go to corresponding mathematical parentheses."
938 (if (YaTeX-on-parenthesis-p)
939 (YaTeX-goto-open-paren t)
940 nil))
942 (defun YaTeX-change-parentheses ()
943 "Change the size of parentheses, braces, and brackets of AMS-LaTeX."
944 (interactive)
945 (if (not (and YaTeX-use-AMS-LaTeX (YaTeX-on-parenthesis-p)))
946 nil
947 (let* ((mod (YaTeX-match-string 1)) ;; modifier
948 (paren (if mod (YaTeX-match-string 2) (YaTeX-match-string 0))) ;; paren
949 (mod-length (if (or (string= mod "\\left") (string= mod "\\right"))
950 5 ;; 5 in case left or right
951 (length mod))) ;; length of modifier
952 (paren-length (length paren)) ;; length of paren
953 (length (+ mod-length paren-length)) ;; length of whole string
954 (big-p t) ;; flag whether new modifier is "[Bb]ig+" or not.
955 size ;; left, big, Big etc.
956 type ;; parentheses type
957 lr ;; "l" or "r".
958 char newsize newsize-length
959 (backslash-syntax (char-to-string (char-syntax ?\\)))
960 (case-fold-search))
961 ;; decide lr and size from mod and paren.
962 (cond ((string-match "\\(\\\\[Bb]ig+\\)[lr]" mod)
963 (setq size (substring mod 1 (match-end 1))
964 lr (substring mod (match-end 1) (match-end 0))))
965 ((string-match "\\\\left" mod)
966 (setq size "left-right" lr "l"))
967 ((string-match "\\\\right" mod)
968 (setq size "left-right" lr "r"))
969 ((string-match "(\\|\\[\\|\\\\{" paren)
970 (setq size "null" lr "l"))
971 ((string-match ")\\|\\]\\|\\\\}" paren)
972 (setq size "null" lr "r"))
973 (t
974 (setq size nil lr nil)))
975 (while (not newsize)
976 (message (format (concat "Change from %s: "
977 "l(big) L(Big) h(bigg) H(Bigg) "
978 "r(left-right) n(NONE) ( { [") size))
979 (setq char (read-char)
980 newsize (cond ((char-equal char ?l) "\\big")
981 ((char-equal char ?L) "\\Big")
982 ((char-equal char ?h) "\\bigg")
983 ((char-equal char ?H) "\\Bigg")
984 ((char-equal char ?r)
985 (setq big-p nil) "\\left")
986 ((memq char '(?\( ?\)))
987 (setq big-p nil type '("(" . ")")) "")
988 ((memq char '(?\{ ?\}))
989 (setq big-p nil type '("\\{" . "\\}")) "")
990 ((memq char '(?\[ ?\]))
991 (setq big-p nil type '("[" . "]")) "")
992 ((char-equal char ?n)
993 (setq big-p nil) "")
994 (t nil))
995 newsize-length (length newsize)))
996 (YaTeX-goto-open-paren)
997 (forward-char)
998 (cond
999 (type
1000 (delete-region (point) (- (point) paren-length))
1001 (save-excursion (insert (car type))))
1002 (t
1003 (delete-region (- (point) length) (- (point) paren-length))
1004 (backward-char paren-length)))
1005 (insert-string newsize)
1006 (if big-p (insert ?l))
1007 (unwind-protect
1008 (progn
1009 (modify-syntax-entry ?\\ " ")
1010 (forward-list)
1011 (if (string= size "left-right") (setq length (1+ length)))
1012 (if (eq char ?r) (setq newsize "\\right"))
1013 (cond
1014 (type
1015 (delete-region (point) (- (point) paren-length))
1016 (insert (cdr type)))
1017 (t
1018 (delete-region (- (point) length) (- (point) paren-length))
1019 (backward-char paren-length)
1020 (insert-string newsize)
1021 (if big-p (insert ?r))
1022 (forward-char paren-length)))
1023 (if (string= lr "l") (backward-list)))
1024 (modify-syntax-entry ?\\ backslash-syntax))
1025 t)))
1027 (defun YaTeX-insert-amsparens-region (beg end char)
1028 (interactive "r\ncWhich one ? l(big) L(Big) h(bigg) H(Bigg): ")
1029 (let* ((case-fold-search)
1030 (st (cond ((char-equal char ?l) "big")
1031 ((char-equal char ?L) "Big")
1032 ((char-equal char ?h) "bigg")
1033 ((char-equal char ?H) "Bigg"))))
1034 (if st
1035 (YaTeX-insert-braces-region
1036 beg end (concat "\\" st "l(") (concat "\\" st "r)"))
1037 (YaTeX-insert-braces-region beg end "(" ")"))))
1039 (defun YaTeX-insert-amsbraces-region (beg end char)
1040 (interactive "r\ncWhich one ? l(big) L(Big) h(bigg) H(Bigg): ")
1041 (let* ((case-fold-search)
1042 (st (cond ((char-equal char ?l) "big")
1043 ((char-equal char ?L) "Big")
1044 ((char-equal char ?h) "bigg")
1045 ((char-equal char ?H) "Bigg"))))
1046 (if st
1047 (YaTeX-insert-braces-region
1048 beg end (concat "\\" st "l\\{") (concat "\\" st "r\\}"))
1049 (YaTeX-insert-braces-region beg end "\\{" "\\}"))))
1051 (defun YaTeX-insert-amsbrackets-region (beg end char)
1052 (interactive "r\ncWhich one ? l(big) L(Big) h(bigg) H(Bigg): ")
1053 (let* ((case-fold-search)
1054 (st (cond ((char-equal char ?l) "big")
1055 ((char-equal char ?L) "Big")
1056 ((char-equal char ?h) "bigg")
1057 ((char-equal char ?H) "Bigg"))))
1058 (if st
1059 (YaTeX-insert-braces-region
1060 beg end (concat "\\" st "l[") (concat "\\" st "r]"))
1061 (YaTeX-insert-braces-region beg end "[" "]"))))
1064 ;;
1065 (provide 'yatexmth)
1067 ; Local variables:
1068 ; fill-prefix: ";;; "
1069 ; paragraph-start: "^$\\| \\|;;;$"
1070 ; paragraph-separate: "^$\\| \\|;;;$"
1071 ; End: