yatex

view yatexmth.el @ 566:2ef9f21dd13b

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