yatex

view yatexmth.el @ 611:e87c3271b8fd

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