yatex

view yatexmth.el @ 456:7bf780961390

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