yatex

view yatexmth.el @ 143:c9da37260ca9

fallingdotseq
author yuuji@gentei.org
date Sat, 11 Sep 2010 16:02:24 +0900
parents 94a1370956a4
children 9c5a764a871f
line source
1 ;;; -*- Emacs-Lisp -*-
2 ;;; YaTeX math-mode-specific functions.
3 ;;; yatexmth.el
4 ;;; (c)1993-2010 by HIROSE Yuuji [yuuji@yatex.org]
5 ;;; Last modified Sat Sep 11 15:51:37 2010 on firestorm
6 ;;; $Id$
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 (defvar YaTeX-jisold
88 (and (boundp 'dos-machine-type)
89 (eq dos-machine-type 'pc98)))
91 (defmacro YaTeX-setq-math-sym (sym old new)
92 (list 'setq sym (list 'if 'YaTeX-jisold old new)))
94 (YaTeX-setq-math-sym YaTeX-image-in "E" "∈")
95 (YaTeX-setq-math-sym YaTeX-image-ni "ヨ" "∋")
96 (YaTeX-setq-math-sym YaTeX-image-subset " _\n(\n ~" "⊂")
97 (YaTeX-setq-math-sym YaTeX-image-subseteq " _\n(_\n ~" "⊆")
98 (YaTeX-setq-math-sym YaTeX-image-supset "_\n )\n~" "⊃")
99 (YaTeX-setq-math-sym YaTeX-image-supseteq "_\n_)\n~" "⊇")
100 (YaTeX-setq-math-sym YaTeX-image-nabla "___\n\\\\/" "∇")
101 (YaTeX-setq-math-sym YaTeX-image-partial " -+\n+-+\n+-+" "∂")
102 (YaTeX-setq-math-sym YaTeX-image-dagger "+\n|" "†")
103 (YaTeX-setq-math-sym YaTeX-image-ddagger "+\n+\n|" "‡")
104 (YaTeX-setq-math-sym YaTeX-image-equiv "=\n ̄" "≡")
105 (YaTeX-setq-math-sym YaTeX-image-int " /\\\n \\\n\\/" "∫")
106 (YaTeX-setq-math-sym YaTeX-image-bot "|\n ̄" "⊥")
107 (YaTeX-setq-math-sym YaTeX-image-neg "イ" "¬")
108 (YaTeX-setq-math-sym YaTeX-image-flat "b" "♭")
109 (YaTeX-setq-math-sym YaTeX-image-sqrt "" "√")
110 (defvar YaTeX-image-nearrow '("__\n /|\n/" " _\n /|\n/" ))
111 (defvar YaTeX-image-nwarrow '(" __\n|\\\n \\" " _\n|\\n \"))
112 (defvar YaTeX-image-searrow '("\\\n \\|\n--`" "\\n \|\n  ̄"))
113 (defvar YaTeX-image-swarrow '(" /\n|/\n'~~" " /\n|/\n  ̄"))
116 (defvar
117 YaTeX-math-sign-alist-default
118 '(
119 ;frequently used
120 ("||" "|" ("||" "‖"))
121 ("sum" "sum" ("\\-+\n >\n/-+" "Σ"))
122 ("sigma" "sum" ("\\-+\n >\n/-+" "Σ"))
123 ("integral" "int" (" /\\\n \\\n\\/" YaTeX-image-int))
124 ("ointegral" "oint" " /\\\n(\\)\n\\/")
125 ("sqrt" "sqrt" (" __\n,/" YaTeX-image-sqrt))
126 ("root" "sqrt" (" __\n,/" YaTeX-image-sqrt))
127 ("A" "forall" "|_|\nV")
128 ("E" "exists" "-+\n-+\n-+")
129 ("!" "neg" ("--+\n |" YaTeX-image-neg))
130 ("oo" "infty" ("oo" "∞"))
131 ("\\" "backslash" ("\\" "\"))
132 ("..." "cdots" ("..." "…"))
134 ;;binary operators
135 ("+-" "pm" ("+\n-" "±"))
136 ("-+" "mp" "-\n+")
137 ("x" "times" ("x" "×"))
138 ("/" "div" (",\n-\n'" "÷"))
139 ("f" "frac" "xxx\n---\nyyy" "÷")
140 ("*" "ast" "*")
141 ("#" "star" ("_/\\_\n\\ /\n//\\\\" "★"))
142 ("o" "circ" "o")
143 ("o*" "bullet" " _\n(*)\n ~")
144 ("." "cdot" ".")
145 ("cap" "cap" "/-\\\n| |")
146 ("cup" "cup" "| |\n\\-/")
147 ("u+" "uplus" "|+|\n\\-/")
148 ("|~|" "sqcap" "|~|")
149 ("|_|" "sqcup" "|_|")
150 ("v" "vee" "v")
151 ("^" "wedge" "^")
152 ("\\\\" "setminus" "\\")
153 (")(" "wr" " )\n(")
154 ("<>" "diamond" "<>")
155 ("/\\-" "bigtriangleup" ("/\\\n~~" "△"))
156 ("-\\/" "bigtriangledown" ("__\n\\/" "▽"))
157 ("<|" "triangleleft" "<|")
158 ("|>" "triangleright" "|>")
159 ("<||" "lhd" "/|\n\\|")
160 ("||>" "rhd" "|\\\n|/")
161 ("<|-" "unlhd" "<|\n~~")
162 ("|>-" "unrhd" "|>\n~~")
163 ("o+" "oplus" " _\n(+)\n ~")
164 ("o-" "ominus" " _\n(-)\n ~")
165 ("ox" "otimes" " _\n(x)\n ~")
166 ("o/" "oslash" " _\n(/)\n ~")
167 ("o." "odot" "(.)")
168 ("O" "bigcirc" "O")
169 ("t" "dagger" ("+\n|" YaTeX-image-dagger))
170 ("tt" "ddagger" ("+\n+\n|" YaTeX-image-ddagger))
171 ("II" "amalg" "II")
172 ; :
173 ;;relational operators
174 ("<" "leq" ("<\n-" "<\n-"))
175 ("=<" "leqq" ("<\n=" "≦"))
176 (">" "geq" (">\n-" ">\n-"))
177 (">=" "geqq" (">\n=" "≧"))
178 ("=:" "fallingdotseq" (".\n==\n ." "≒"))
179 ("-=" "equiv" ("=\n-" YaTeX-image-equiv))
180 ("=-" "equiv" ("=\n-" YaTeX-image-equiv))
181 ("---" "equiv" ("=\n-" YaTeX-image-equiv))
182 ("(" "subset" (" _\n(\n ~" YaTeX-image-subset))
183 ("(-" "subseteq" (" _\n(_\n ~" YaTeX-image-subseteq))
184 (")" "supset" ("_\n )\n~" YaTeX-image-supset))
185 (")-" "supseteq" ("_\n_)\n~" YaTeX-image-supseteq))
186 ("[" "sqsubset" "[")
187 ("[-" "sqsubseteq" "[\n~")
188 ("]" "sqsupset" "]")
189 ("]-" "sqsupseteq" "]\n~")
190 ("{" "in" ("(-" YaTeX-image-in))
191 ("}" "ni" ("-)" YaTeX-image-ni))
192 ("|-" "vdash" "|-")
193 ("-|" "dashv" "-|")
194 ("~" "sim" "~(tild)")
195 ("~-" "simeq" "~\n-")
196 ("asymp" "asymp" "v\n^")
197 ("~~" "approx" "~\n~")
198 ("~=" "cong" "~\n=")
199 ("=/" "neq" ("=/=" "≠"))
200 (".=" "doteq" ".\n=")
201 ("o<" "propto" "o<")
202 ("|=" "models" "|=")
203 ("_|_" "perp" "_|_")
204 ("|" "mid" "|")
205 ("||" "parallel" "||")
206 ("bowtie" "bowtie" "|><|(wide)")
207 ("|><|" "join" "|><|")
208 ("\\_/" "smile" "\\_/")
209 ("/~\\" "frown" "/~~\\")
210 ("-<" "prec" ("-<" "く"))
211 ("-<=" "preceq" ("-<\n-" "く\n="))
212 ("<<" "ll" ("<<" "《"))
213 ("<<" "lll" "<<<")
214 (">>" "gg" (">>" "》"))
215 (">>>" "ggg" ">>>")
216 ; :
217 ;;arrows
218 ("<-" "leftarrow" ("<-" "←"))
219 ("\C-b" "leftarrow" ("<-" "←"))
220 ("<--" "longleftarrow" ("<--" "←--"))
221 ("<=" "Leftarrow" "<=")
222 ("<==" "Longleftarrow" "<==")
223 ("->" "rightarrow" ("->" "→"))
224 ("\C-f" "rightarrow" ("->" "→"))
225 ("-->" "longrightarrow" ("-->" "--→"))
226 ("=>" "Rightarrow" "=>")
227 ("==>" "Longrightarrow" "==>")
228 ("<->" "leftrightarrow" ("<->" "←→"))
229 ("<-->" "longleftrightarrow" ("<---->" "←--→"))
230 ("<=>" "Leftrightarrow" "<=>")
231 ("<==>" "Longleftrightarrow" "<==>")
232 ("^|" "uparrow" ("^\n|" "↑"))
233 ("\C-p" "uparrow" ("^\n|" "↑"))
234 ("^||" "Uparrow" "/\\\n||")
235 ("\C-n" "downarrow" ("|\nv" "↓"))
236 ("v|" "downarrow" ("|\nv" "↓"))
237 ("v||" "Downarrow" "||\n\\/")
238 ("\C-p\C-f" "nearrow" YaTeX-image-nearrow)
239 ("\C-f\C-p" "nearrow" YaTeX-image-nearrow)
240 ("ne" "nearrow" YaTeX-image-nearrow)
241 ("\C-p\C-b" "nwarrow" YaTeX-image-nwarrow)
242 ("\C-b\C-p" "nwarrow" YaTeX-image-nwarrow)
243 ("nw" "nwarrow" YaTeX-image-nwarrow)
244 ("\C-n\C-f" "searrow" YaTeX-image-searrow)
245 ("\C-f\C-n" "searrow" YaTeX-image-searrow)
246 ("se" "searrow" YaTeX-image-searrow)
247 ("\C-n\C-b" "swarrow" YaTeX-image-swarrow)
248 ("\C-b\C-n" "swarrow" YaTeX-image-swarrow)
249 ("sw" "swarrow" YaTeX-image-swarrow)
250 ("|->" "mapsto" ("|->" "|→"))
251 ("<-)" "hookleftarrow" (" ,\n<--+" " ヽ\n<--/"))
252 ("(->" "hookrightarrow" ("`\n+-->" "/\n\-->"))
253 ("/-" "leftharpoonup" "/\n~~~")
254 ("\\-" "leftharpoondown" "__\n\\")
255 ("-/" "rightharpoondown" "__\n/")
256 ("-\\" "rightharpoonup" "~~\n\\")
257 ;;left and right
258 ("left" "left" "(leftmark)")
259 ("right" "right" "(rightmark)")
260 ;;accent marks
261 ("tilde" "tilde" "~\n?")
262 ("T" "tilde" "~\n?")
263 ("wtilde" "widetilde" "~\n?")
264 ("hat" "hat" "^\n?")
265 ("what" "widehat" "/\\\n??")
266 ("w^" "widehat" "/\\\n?")
267 ("check" "check" "v\n?")
268 ("bar" "bar" "_\n?")
269 ("overline" "overline" "_\n?")
270 ("wbar" "overline" "--\n??")
271 ("dot" "dot" ".\n?")
272 ("ddot" "ddot" "..\n??")
273 ("vec" "vec" ("->\n??" "→\n??"))
274 ("~>" "overrightarrow" ("-->\nAB" "→\nAB"))
275 ("VEC" "overrightarrow" ("-->\nAB" "→\nAB"))
276 ;;rage-aware stuffs
277 ("prod" "prod" ("-+--+-\n | |" "Π"))
278 ("CUP" "bigcup" "|~~|\n| |\n| |")
279 ("union" "bigcup" "|~~|\n| |\n| |")
280 ("CAP" "bigcap" "| |\n| |\n|__|")
281 ("isc" "bigcap" "| |\n| |\n|__|")
282 ("O+" "bigoplus" "/~~~\\\n| + |\n\\___/")
283 ("Ox" "bigotimes" "/~~~\\\n| X |\n\\___/")
284 ;;other marks
285 ("angle" "angle" ("/\n~" "∠"))
286 ("/_" "angle" ("/\n~" "∠"))
287 ("Z" "aleph" "|\\|")
288 ("|\\|" "aleph" "|\\|")
289 ("h-" "hbar" "_\nh")
290 ; ("i" "imath" "i") ;These chars are appeared only
291 ; ("j" "jmath" "j") ;as section-type arguments
292 ("l" "ell" "l")
293 ("wp" "wp" "???")
294 ("R" "Re" ")R")
295 ("Im" "Im" "???")
296 ("mho" "mho" "~|_|~")
297 ("'" "prime" "'")
298 ("0" "emptyset" "0")
299 ("nabla" "nabla" ("___\n\\\\/" YaTeX-image-nabla))
300 ("\\/" "surd" "-\\/")
301 ("surd" "surd" "-\\/")
302 ("top" "top" "T")
303 ("bot" "bot" ("_|_" YaTeX-image-bot))
304 ("b" "flat" ("b" YaTeX-image-flat))
305 ("LT" "natural" "|\nLT\n |")
306 ("6" "partial" (" -+\n+-+\n+-+" YaTeX-image-partial))
307 ("partial" "partial" (" -+\n+-+\n+-+" YaTeX-image-partial))
308 ("round" "partial" (" -+\n+-+\n+-+" YaTeX-image-partial))
309 ("[]" "Box" "[]")
310 ("no" "notag" "\\notag")
311 (":" "colon" ":")
312 ("Diamond" "Diamond" "/\\\n\\/")
313 ("3" "triangle" "/\\\n~~")
314 ("C" "clubsuit" " o\no+o\n |")
315 ("D" "diamondsuit" "/\\\n\\/")
316 ("H" "heartsuit" "<^^>\n \\/")
317 ("S" "spadesuit" " /\\\n<++>\n /\\")
318 )
319 "Default LaTeX-math-command alist.")
321 (defvar YaTeX-math-sign-alist-private nil
322 "*User definable key vs LaTeX-math-command alist.")
324 (defvar YaTeX-math-quit-with-strict-match nil
325 "*T for quitting completion as soon as strict-match is found.")
326 (defvar YaTeX-math-sign-alist
327 (append YaTeX-math-sign-alist-private YaTeX-math-sign-alist-default))
329 ;;(defun YaTeX-math-alist2array (alist array)
330 ;; (set array
331 ;; (let ((array (make-vector (length alist) "")) (list alist) (i 0))
332 ;; (while list
333 ;; (aset array i (car (car list)))
334 ;; (setq i (1+ i) list (cdr list)))
335 ;; array))
336 ;;)
338 (defvar YaTeX-greek-key-alist-default
339 '(
340 ("a" "alpha" ("a" "α"))
341 ("b" "beta" ("|>\n|>\n|" "β"))
342 ("g" "gamma" ("~r" "γ"))
343 ("G" "Gamma" ("|~" "Γ"))
344 ("d" "delta" ("<~\n<>" "δ"))
345 ("D" "Delta" ("/\\\n~~" "Δ"))
346 ("e" "epsilon" "<\n<~")
347 ("e-" "varepsilon" ("(\n(~" "ε"))
348 ("z" "zeta" ("(~\n >" "ζ"))
349 ("et" "eta" ("n\n/" "η"))
350 ("th" "theta" ("8" "θ"))
351 ("Th" "Theta" ("(8)" "Θ"))
352 ("th-" "vartheta" ("-8" "-θ"))
353 ("i" "iota" ("i\n\\_/" "ι"))
354 ("k" "kappa" ("k" "κ"))
355 ("l" "lambda" ("\\n/\\" "λ"))
356 ("L" "Lambda" ("/\\" "Λ"))
357 ("m" "mu" (" u_\n/" "μ"))
358 ("n" "nu" ("|/" "ν"))
359 ("x" "xi" ("E\n >" "ξ"))
360 ("X" "Xi" ("---\n -\n---" "Ξ"))
361 ("p" "pi" ("__\n)(" "π"))
362 ("P" "Pi" ("__\n||" "Π"))
363 ("p-" "varpi" ("_\nw" "__\nω"))
364 ("r" "rho" ("/O" "ρ"))
365 ("r-" "varrho" ("/O\n~~" "ρ\n~~"))
366 ("s" "sigma" ("o~" "σ"))
367 ("S" "Sigma" ("\\-+\n >\n/-+" "Σ"))
368 ("s-" "varsigma" "(~~ \n>")
369 ("t" "tau" ("__\n(" "τ"))
370 ("u" "upsilon" ("~v" "υ"))
371 ("y" "upsilon" ("~v" "υ"))
372 ("U" "Upsilon" ("~Y~" "Υ"))
373 ("Y" "Upsilon" ("~Y~" "Υ"))
374 ("ph" "phi" (" /\n(/)\n/" "φ"))
375 ("Ph" "Phi" (" _\n(|)\n ~" "Φ"))
376 ("ph-" "varphi" "\\O\n|")
377 ("c" "chi" ("x" "χ"))
378 ("ps" "psi" ("\\|/\\n |" "ψ"))
379 ("Ps" "Psi" (" ~\n\\|/\\n |" "Ψ"))
380 ("o" "omega" ("w" "ω"))
381 ("w" "omega" ("w" "ω"))
382 ("O" "Omega" ("(~)\n~ ~" "Ω"))
383 ("W" "Omega" ("(~)\n~ ~" "Ω"))
384 ("f" "foo")
385 )
386 "Default LaTeX-math-command alist.")
388 (defvar YaTeX-greek-key-alist-private nil
389 "*User definable key vs LaTeX-math-command alist.")
391 (defvar YaTeX-greek-key-alist
392 (append YaTeX-greek-key-alist-private YaTeX-greek-key-alist-default))
394 ;;(mapcar (function (lambda (x) (YaTeX-math-alist2array x)))
395 ;; YaTeX-math-key-list)
397 (defvar YaTeX-math-indicator "KEY\tLaTeX sequence\t\tsign")
399 (defvar YaTeX-math-need-image t
400 "*T for displaying pseudo image momentarily.")
401 (defvar YaTeX-math-max-key 8)
402 (defvar YaTeX-math-max-seq
403 (* 8 (1+ (/ (length "\\longleftrightarrow") 8))))
404 (defvar YaTeX-math-max-sign 5)
405 (defvar YaTeX-math-sign-width
406 (+ YaTeX-math-max-key YaTeX-math-max-seq YaTeX-math-max-sign))
407 (defvar YaTeX-math-display-width
408 (* 8 (1+ (/ YaTeX-math-sign-width 8))))
409 (defvar YaTeX-math-menu-map nil
410 "Keymap used in YaTeX mathematical sign menu mode.")
412 (if YaTeX-math-menu-map nil
413 (setq YaTeX-math-menu-map (make-sparse-keymap))
414 (define-key YaTeX-math-menu-map "n" 'next-line)
415 (define-key YaTeX-math-menu-map "p" 'previous-line)
416 (define-key YaTeX-math-menu-map "f" 'YaTeX-math-forward)
417 (define-key YaTeX-math-menu-map "b" 'YaTeX-math-backward)
418 (define-key YaTeX-math-menu-map "v" 'scroll-up)
419 (define-key YaTeX-math-menu-map " " 'scroll-up)
420 (define-key YaTeX-math-menu-map "c" 'scroll-up)
421 (define-key YaTeX-math-menu-map "V" 'scroll-down)
422 (define-key YaTeX-math-menu-map "r" 'scroll-down)
423 (define-key YaTeX-math-menu-map "\^h" 'scroll-down)
424 (define-key YaTeX-math-menu-map "<" 'beginning-of-buffer)
425 (define-key YaTeX-math-menu-map ">" 'end-of-buffer)
426 (define-key YaTeX-math-menu-map "\^m" 'exit-recursive-edit)
427 (define-key YaTeX-math-menu-map "q" 'abort-recursive-edit))
429 (defvar YaTeX-math-exit-key "\e"
430 "*Key sequence after prefix key of YaTeX-math-mode to exit from math-mode.")
432 (defmacro YaTeX-math-japanese-sign (list)
433 (list 'nth 1 list))
435 (defvar YaTeX-math-cmd-regexp (concat (regexp-quote YaTeX-ec) "[A-z|]"))
436 (defvar YaTeX-math-verbatim-environments
437 '("alltt")
438 "*List of environments in which LaTeX math mode is disabled.
439 This value is appended with YaTeX-verbatim-environments.")
441 ;;;
442 ;;YaTeX math-mode functions
443 ;;;
444 ;;;###autoload from yatex.el
445 (defun YaTeX-toggle-math-mode (&optional arg)
446 (interactive "P")
447 (or (memq 'YaTeX-math-mode mode-line-format) nil
448 (setq mode-line-format
449 (append (list "" 'YaTeX-math-mode) mode-line-format)))
450 (if YaTeX-auto-math-mode nil ;Only effective on manual mode.
451 (if (or arg (null YaTeX-math-mode))
452 (let (keys)
453 (setq YaTeX-math-mode "math:")
454 (message "Turn on math mode. Prefix keys are %s"
455 (mapconcat 'car YaTeX-math-key-list " "))
456 (sit-for 3)
457 (message
458 (concat "To exit from math-mode, type `ESC' after prefix, "
459 "or type `"
460 (key-description
461 (car
462 (where-is-internal
463 'YaTeX-switch-mode-menu YaTeX-mode-map)))
464 " $'")))
465 (setq YaTeX-math-mode nil)
466 (message "Exit from math mode."))
467 (set-buffer-modified-p (buffer-modified-p))))
469 (defun YaTeX-math-forward (arg)
470 (interactive "p")
471 (re-search-forward YaTeX-math-cmd-regexp nil t arg))
473 (defun YaTeX-math-backward (arg)
474 (interactive "p")
475 (re-search-backward YaTeX-math-cmd-regexp nil t arg))
477 (defun YaTeX-math-gets (sign)
478 (cond
479 ((null sign) nil)
480 ((listp sign)
481 (setq sign
482 (cond
483 (YaTeX-japan (YaTeX-math-japanese-sign sign))
484 (t (car sign))))
485 (YaTeX-math-gets sign))
486 ((symbolp sign)
487 (YaTeX-math-gets (symbol-value sign)))
488 (t sign)))
490 (defun YaTeX-math-get-sign (list)
491 (YaTeX-math-gets (car (cdr-safe (cdr-safe list)))))
493 (defvar YaTeX-math-section-type-regexp
494 "eqn\\\\\\sw+\\b"
495 "*Regexp of section-type math-mode macro")
497 (defun YaTeX-in-math-mode-p ()
498 "If current position is supposed to be in LaTeX-math-mode, return t.
499 This function refers a local variable `source-window' in YaTeX-make-section."
500 (save-excursion
501 (and (boundp 'source-window) source-window
502 (set-buffer (window-buffer source-window)))
503 (or (YaTeX-quick-in-environment-p
504 (append
505 '("math" "eqnarray" "equation" "eqnarray*" "displaymath") ;LaTeX
506 (if YaTeX-use-AMS-LaTeX
507 ;; And math modes of AMS-LaTeX
508 ;;'("align" "align*" "split" "multline" "multline*" "gather"
509 ;; "gather*" "aligned*" "gathered" "gathered*" "alignat"
510 ;; "equation*" "cases" "flalign" "flalign*"
511 ;; "alignat*" "xalignat" "xalignat*" "xxalignat" "xxalignat*"
512 YaTeX-math-begin-list
513 )))
514 (let*((p (point)) (nest 0) me0 r firstp dollar
515 (delim (concat YaTeX-sectioning-regexp "\\|^$\\|^\C-l"))
516 (boundary
517 (save-excursion
518 (if (looking-at delim)
519 (goto-char (max (point-min) (1- (point)))))
520 (re-search-backward delim nil 1)
521 (point))))
522 (save-excursion
523 (cond
524 ((catch 'open
525 (save-excursion
526 (while (and (>= nest 0)
527 (re-search-backward
528 (concat YaTeX-ec-regexp ;\
529 "\\([()]\\|[][]\\)") boundary t))
530 (setq me0 (match-end 0))
531 (if (or (YaTeX-on-comment-p)
532 (YaTeX-literal-p)) nil
533 (if (or (= (char-after (1- me0)) ?\))
534 (= (char-after (1- me0)) ?\]))
535 (setq nest (1+ nest))
536 (if (= (preceding-char) ?\\ ) nil ;;\\[5pt]
537 (setq nest (1- nest))))))
538 (if (< nest 0)
539 (throw 'open (cons (YaTeX-match-string 0) (point)))))))
540 ((and (setq r (YaTeX-on-section-command-p
541 YaTeX-math-section-type-regexp))
542 (numberp r)
543 (> r 0))
544 t)
545 (t (catch 'dollar
546 (while ;(search-backward "$" boundary t);little bit fast.
547 (YaTeX-re-search-active-backward ;;;;;; Too slow???
548 "\\$" (concat "[^\\\\]" YaTeX-comment-prefix) boundary t)
549 (setq dollar "$")
550 (cond
551 ((equal (char-after (1- (point))) ?$) ; $$ equation $$
552 (setq dollar "$$")
553 (backward-char 1)
554 (setq nest (1+ nest)))
555 ((let ((YaTeX-verbatim-environments
556 (append YaTeX-math-verbatim-environments
557 YaTeX-verbatim-environments)))
558 (YaTeX-literal-p))
559 nil)
560 ((and (equal (char-after (1- (point))) ?\\ )
561 (not (equal (char-after (- (point) 3)) ?\\ )))
562 nil) ;\$
563 (t (setq nest (1+ nest))))
564 (if (and (= nest 1) (null firstp))
565 (setq firstp (cons dollar (point)))))
566 (if (= (% nest 2) 1)
567 (throw 'dollar firstp))))))))))
569 (defun YaTeX-mark-mathenv ()
570 "Mark current mathematic environment."
571 (interactive)
572 (let ((mmp (YaTeX-in-math-mode-p)) type bpt)
573 (if (or (null mmp) (not (stringp (setq type (car mmp)))))
574 nil ;if nil or not string, do nothing
575 (setq bpt (cdr mmp))
576 (goto-char bpt)
577 (cond
578 ((string-match "\\$" type)
579 (set-mark-command nil)
580 (skip-chars-forward "$")
581 (YaTeX-search-active-forward
582 type YaTeX-comment-prefix nil) ;if it cause error, obey it
583 (goto-char (match-end 0)))
584 ;;
585 ((string-match "^\\\\[\\[(]" type)
586 (set-mark-command nil)
587 (YaTeX-goto-corresponding-leftright)
588 (skip-chars-forward "])\\\\"))
589 ;;
590 ((string-match "^[a-z]" type) ; \begin\end type math
591 (set-mark-command nil)
592 (YaTeX-goto-corresponding-environment)
593 (goto-char (match-end 0)))))))
595 (defun YaTeX-math-display-list (list cols)
596 (goto-char (point-max))
597 (if (= cols 0) (if (not (eolp)) (newline 1))
598 (forward-line -1)
599 (while (looking-at "[ \t\n]") (forward-line -1)))
600 (end-of-line)
601 (let ((indent (* YaTeX-math-display-width cols)) sign str to)
602 (indent-to indent)
603 (insert (car list))
604 (indent-to (setq indent (+ indent YaTeX-math-max-key)))
605 (insert "\\" (car (cdr list)))
606 (setq indent (+ indent YaTeX-math-max-seq))
607 (setq sign (YaTeX-math-get-sign list))
608 (while (and sign (not (string= "" sign)))
609 (setq to (string-match "\n" sign)
610 str (if to (substring sign 0 to) sign))
611 (end-of-line)
612 (indent-to indent)
613 (insert str)
614 (cond ((eobp) (newline 1))
615 ((> cols 0) (forward-line 1)))
616 (setq sign (if to (substring sign (1+ to)) "")))))
618 (defvar YaTeX-math-menu-buffer "*math-mode-signs*")
620 (defun YaTeX-math-show-menu (match-str)
621 (save-window-excursion
622 (YaTeX-showup-buffer YaTeX-math-menu-buffer nil t)
623 (let ((maxcols (max 1 (/ (YaTeX-screen-width) YaTeX-math-sign-width)))
624 (case-fold-search nil)
625 (cols 0) (list alist) command)
626 (erase-buffer)
627 (insert
628 "Candidates of sign. [n:next p:prev f:forw b:back q:quit RET:select]\n")
629 (insert YaTeX-math-indicator "\t")
630 (insert YaTeX-math-indicator)
631 (newline 1)
632 (insert-char ?- (1- (YaTeX-screen-width)))
633 (newline 1)
634 (while list
635 (if (string-match match-str (car (car list)))
636 (progn (YaTeX-math-display-list (car list) cols)
637 (setq cols (% (1+ cols) maxcols))))
638 (setq list (cdr list)))
639 (goto-line 4)
640 (use-local-map YaTeX-math-menu-map)
641 (setq buffer-read-only t)
642 (unwind-protect
643 (recursive-edit)
644 (skip-chars-backward "^ \t\n")
645 (setq command
646 (if (re-search-forward YaTeX-math-cmd-regexp nil t)
647 (buffer-substring
648 (match-beginning 0)
649 (prog2 (skip-chars-forward "^ \t\n") (point)))
650 nil))
651 (kill-buffer YaTeX-math-menu-buffer))
652 command)))
654 ;
655 (defun YaTeX-math-show-image (image &optional exit-char)
656 "Momentarily display IMAGE at the beginning of the next line;
657 erase it on the next keystroke. The window is recentered if necessary
658 to make the whole string visible. If the window isn't large enough,
659 at least you get to read the beginning."
660 (if (and image (not (string= image "")))
661 (let ((buffer-read-only nil)
662 (modified (buffer-modified-p))
663 (name buffer-file-name)
664 insert-start
665 insert-end)
666 (unwind-protect
667 (progn
668 (save-excursion
669 ;; defeat file locking... don't try this at home, kids!
670 (setq buffer-file-name nil)
671 (forward-line 1)
672 (setq insert-start (point))
673 (if (eobp) (newline))
674 (insert image)
675 (setq insert-end (point)))
676 ; make sure the whole string is visible
677 (if (not (pos-visible-in-window-p insert-end))
678 (recenter (max 0
679 (- (window-height)
680 (count-lines insert-start insert-end)
681 2))))
682 (let ((char (read-char)))
683 (or (eq char exit-char)
684 (setq unread-command-char char))))
685 (if insert-end
686 (save-excursion
687 (delete-region insert-start insert-end)))
688 (setq buffer-file-name name)
689 (set-buffer-modified-p modified)))))
691 (defun YaTeX-math-insert-sequence (&optional force initial)
692 "Insert math-mode sequence with image completion."
693 (interactive "P")
694 (let*((key (or initial "")) regkey str last-char list i
695 (case-fold-search nil) match sign
696 (this-key (char-to-string last-command-char))
697 (alistsym (cdr (assoc this-key YaTeX-math-key-list)))
698 (alistname (symbol-name alistsym))
699 (alist (symbol-value alistsym))
700 (n (length alist)) (beg (point)) result)
701 (if initial (insert YaTeX-ec (car (cdr (assoc initial alist)))))
702 (if (string-match "^YaTeX-" alistname)
703 (setq alistname (substring alistname (length "YaTeX-"))))
704 (setq alistname (substring alistname 0 (string-match "-" alistname)))
705 (setq result
706 (catch 'complete
707 (if (and (not force)
708 (if YaTeX-auto-math-mode
709 (not (YaTeX-in-math-mode-p))
710 (not YaTeX-math-mode)))
711 (throw 'complete 'escape));this tag should be exit, but...
712 (while t
713 (message "%ssequence%s: %s"
714 (if YaTeX-simple-messages "" (concat alistname " "))
715 (if YaTeX-simple-messages "" "(TAB for menu)") key)
716 (setq last-char (read-char)
717 key (concat key (char-to-string last-char))
718 i 0)
719 (cond
720 ((string= key this-key) ;;invoke key itself
721 (throw 'complete 'escape))
722 ((string= key YaTeX-math-exit-key) ;;exit from math-mode
723 (throw 'complete 'exit))
724 ((string-match "\r" key) ;;RET = kakutei
725 (throw 'complete 'select))
726 ((string-match "[\C-g\C-c]" key) ;;C-g = abort
727 (throw 'complete 'abort))
728 ((string-match "[\t\n]" key) ;;TAB, LFD = menu
729 (throw 'complete 'menu))
730 ((string-match "[\C-h\C-?]" key) ;;BS, DEL = BS
731 (if (< (length key) 2) (throw 'complete 'abort))
732 (setq key (substring key 0 -2))))
734 (setq regkey (concat "^" (regexp-quote key)))
735 (message "Sequence%s: %s"
736 (if YaTeX-simple-messages "" "(TAB for menu)") key)
737 (if
738 (catch 'found
739 ;;(1)input string strictly matches with alist
740 (setq match (assoc key alist))
741 ;;remember previous match
743 ;;(2)search partial match into alist
744 (setq list alist)
745 (while (< i n)
746 (if (string-match
747 regkey
748 ;;(aref array i)
749 ;;(car (nth i alist))
750 (car (car list)))
751 (progn
752 (or match
753 ;;(setq match (nth i alist))
754 (setq match (car list)))
755 (throw 'found t)))
756 (setq i (1+ i) list (cdr list)))) ;catch 'found
757 nil ;;if any match, continue reading
758 ;;else reading of sequence has been done.
759 (message "complete.")
760 (throw 'complete t))
762 (if match
763 (progn (delete-region beg (point))
764 (setq YaTeX-single-command (car (cdr match)))
765 (insert YaTeX-ec YaTeX-single-command)
766 (if (and YaTeX-math-need-image
767 (setq sign (YaTeX-math-get-sign match)))
768 (YaTeX-math-show-image (concat sign "\n")))
769 )
770 nil)
771 )))
772 (delete-region beg (point))
773 (cond
774 ((memq result '(t select))
775 (if (eq result t)
776 (setq unread-command-char last-char)
777 (message "Done."))
778 (if (assoc YaTeX-single-command section-table)
779 (YaTeX-make-section nil nil nil YaTeX-single-command)
780 (setq YaTeX-current-completion-type 'maketitle)
781 (YaTeX-make-singlecmd YaTeX-single-command)))
782 ((eq result 'abort)
783 (message "Abort."))
784 ((eq result 'escape)
785 (call-interactively (lookup-key global-map this-key)))
786 ((eq result 'exit)
787 (YaTeX-toggle-math-mode))
788 ((eq result 'menu)
789 (setq key (concat "^" (regexp-quote (substring key 0 -1))))
790 (insert (YaTeX-math-show-menu key))))))
792 ;; ----- Change image completion types -----
793 (defun YaTeX-math-member-p (item)
794 "Check if ITEM is a member of image completion.
795 If so return the cons of its invocation key and image-string."
796 (let ((lists YaTeX-math-key-list) list)
797 (catch 'found
798 (while lists
799 (setq list (symbol-value (cdr (car lists))))
800 (while list
801 (if (string= item (nth 1 (car list)))
802 (throw 'found (cons (car (car lists)) (nth 0 (car list)))))
803 (setq list (cdr list)))
804 (setq lists (cdr lists))))))
806 ;;; ----- for AMS LaTeX (by matsu@math.s.chiba-u.ac.jp) -----
807 (defvar YaTeX-ams-paren-modifier
808 '(("Biggl" . "Biggr") ("biggl" . "biggr")
809 ("Bigl" . "Bigr") ("bigl" . "bigr")
810 ("left" . "right") ("" . ""))
811 "Alist of modifier of parentheses.")
813 (defvar YaTeX-left-paren "(\\|\\[\\|\\\\{")
814 (defvar YaTeX-right-paren ")\\|\\]\\|\\\\}")
815 (defvar YaTeX-paren
816 (concat YaTeX-left-paren "\\|" YaTeX-right-paren))
818 (defun YaTeX-on-parenthesis-p ()
819 "If cursor is on an (AMS-LaTeX) parenthesis, return the parenthesis."
820 (interactive)
821 (let* ((list YaTeX-ams-paren-modifier)
822 (longest 0) ;; the longest length of parenthesis command strings
823 (flag t) ;; flag for whether on braces not following \
824 (point (point))
825 (move 0)
826 (paren))
827 (while list
828 (setq longest
829 (max longest (length (car (car list))) (length (cdr (car list)))))
830 (setq list (cdr list)))
831 (save-excursion
832 ;; search {} and, if it does not follow `\', set flag nil.
833 ;; if it is right after `\', set flag t and move to the position of \.
834 ;; mmmmm.
835 (if (looking-at "{\\|}")
836 (if (not (equal (char-after (1- (point))) 92))
837 (setq flag nil)
838 (forward-char -1)))
839 ;; if flag is nil, do nothing.
840 (if (and flag (re-search-forward YaTeX-paren
841 (+ (point) 3 longest) t))
842 (progn
843 (setq move (- (point) point))
844 (setq paren (YaTeX-match-string 0))
845 (setq list YaTeX-ams-paren-modifier)
846 ;; criterion for whether on [] () \{\} or not.
847 (if (string-match YaTeX-left-paren paren)
848 (while (and list flag)
849 (let* ((mod (car (car list)))
850 (mod-length 0) ;; length of modifier
851 paren-regexp ;; regexp of paren.
852 mod-regexp) ;; regexp of modifier.
853 (if (> (length mod) 0)
854 (setq mod-regexp (concat "\\\\" mod)
855 mod-length (1+ (length mod))))
856 (cond ((string= paren "\\{")
857 (setq paren-regexp (concat "\\" paren)))
858 ((string= paren "[")
859 (setq paren-regexp "\\["))
860 (t (setq paren-regexp paren)))
861 (save-excursion
862 (if (and (>= (- (point) (point-min))
863 (+ mod-length (length paren)))
864 (not (forward-char
865 (- 0 mod-length (length paren))))
866 (looking-at (concat "\\(" mod-regexp "\\)\\("
867 paren-regexp "\\)")))
868 (setq flag nil)))
869 (setq list (cdr list))))
870 (while (and list flag)
871 (let* ((mod (cdr (car list)))
872 (mod-length 0)
873 paren-regexp
874 mod-regexp)
875 (if (> (length mod) 0)
876 (setq mod-regexp (concat "\\\\" mod)
877 mod-length (1+ (length mod))))
878 (cond ((string= paren "\\}")
879 (setq paren-regexp (concat "\\" paren)))
880 ((string= paren "]")
881 (setq paren-regexp "\\]"))
882 (t (setq paren-regexp paren)))
883 (save-excursion
884 (if (and (>= (- (point) (point-min))
885 (+ mod-length (length paren)))
886 (not (forward-char
887 (- 0 mod-length (length paren))))
888 (looking-at (concat "\\(" mod-regexp "\\)\\("
889 paren-regexp "\\)")))
890 (setq flag nil)))
891 (setq list (cdr list)))))
892 (if (<= move (length (YaTeX-match-string 0)))
893 (YaTeX-match-string 0)))))))
895 (defun YaTeX-goto-open-paren (&optional jumpto-co)
896 "Jump to the exact position of open parenthesis.
897 If optional argument JUMPTO-CO is non-nil, goto corresponding parentheses."
898 (interactive)
899 (let ((paren)
900 (backslash-syntax (char-to-string (char-syntax ?\\))))
901 (if (setq paren (YaTeX-on-parenthesis-p))
902 (if (string-match "(\\|{\\|\\[" paren (1- (length paren)))
903 (progn
904 (re-search-forward "(\\|{\\|\\[" (+ (point) (length paren)) t)
905 (backward-char)
906 (if jumpto-co
907 (unwind-protect
908 (progn
909 (modify-syntax-entry ?\\ " ")
910 (forward-list)
911 (backward-char))
912 (modify-syntax-entry ?\\ backslash-syntax)))
913 (point))
914 (re-search-forward ")\\|}\\|\\]" (+ (point) (length paren)) t)
915 (unwind-protect
916 (progn
917 (modify-syntax-entry ?\\ " ")
918 (backward-list)
919 (point))
920 (modify-syntax-entry ?\\ backslash-syntax))))))
922 ;;;###autoload
923 (defun YaTeX-goto-corresponding-paren ()
924 "Go to corresponding mathematical parentheses."
925 (if (YaTeX-on-parenthesis-p)
926 (YaTeX-goto-open-paren t)
927 nil))
929 (defun YaTeX-change-parentheses ()
930 "Change the size of parentheses, braces, and brackets of AMS-LaTeX."
931 (interactive)
932 (if (not (and YaTeX-use-AMS-LaTeX (YaTeX-on-parenthesis-p)))
933 nil
934 (let* ((mod (YaTeX-match-string 1)) ;; modifier
935 (paren (if mod (YaTeX-match-string 2) (YaTeX-match-string 0))) ;; paren
936 (mod-length (if (or (string= mod "\\left") (string= mod "\\right"))
937 5 ;; 5 in case left or right
938 (length mod))) ;; length of modifier
939 (paren-length (length paren)) ;; length of paren
940 (length (+ mod-length paren-length)) ;; length of whole string
941 (big-p t) ;; flag whether new modifier is "[Bb]ig+" or not.
942 size ;; left, big, Big etc.
943 type ;; parentheses type
944 lr ;; "l" or "r".
945 char newsize newsize-length
946 (backslash-syntax (char-to-string (char-syntax ?\\)))
947 (case-fold-search))
948 ;; decide lr and size from mod and paren.
949 (cond ((string-match "\\(\\\\[Bb]ig+\\)[lr]" mod)
950 (setq size (substring mod 1 (match-end 1))
951 lr (substring mod (match-end 1) (match-end 0))))
952 ((string-match "\\\\left" mod)
953 (setq size "left-right" lr "l"))
954 ((string-match "\\\\right" mod)
955 (setq size "left-right" lr "r"))
956 ((string-match "(\\|\\[\\|\\\\{" paren)
957 (setq size "null" lr "l"))
958 ((string-match ")\\|\\]\\|\\\\}" paren)
959 (setq size "null" lr "r"))
960 (t
961 (setq size nil lr nil)))
962 (while (not newsize)
963 (message (format (concat "Change from %s: "
964 "l(big) L(Big) h(bigg) H(Bigg) "
965 "r(left-right) n(NONE) ( { [") size))
966 (setq char (read-char)
967 newsize (cond ((char-equal char ?l) "\\big")
968 ((char-equal char ?L) "\\Big")
969 ((char-equal char ?h) "\\bigg")
970 ((char-equal char ?H) "\\Bigg")
971 ((char-equal char ?r)
972 (setq big-p nil) "\\left")
973 ((memq char '(?\( ?\)))
974 (setq big-p nil type '("(" . ")")) "")
975 ((memq char '(?\{ ?\}))
976 (setq big-p nil type '("\\{" . "\\}")) "")
977 ((memq char '(?\[ ?\]))
978 (setq big-p nil type '("[" . "]")) "")
979 ((char-equal char ?n)
980 (setq big-p nil) "")
981 (t nil))
982 newsize-length (length newsize)))
983 (YaTeX-goto-open-paren)
984 (forward-char)
985 (cond
986 (type
987 (delete-region (point) (- (point) paren-length))
988 (save-excursion (insert (car type))))
989 (t
990 (delete-region (- (point) length) (- (point) paren-length))
991 (backward-char paren-length)))
992 (insert-string newsize)
993 (if big-p (insert ?l))
994 (unwind-protect
995 (progn
996 (modify-syntax-entry ?\\ " ")
997 (forward-list)
998 (if (string= size "left-right") (setq length (1+ length)))
999 (if (eq char ?r) (setq newsize "\\right"))
1000 (cond
1001 (type
1002 (delete-region (point) (- (point) paren-length))
1003 (insert (cdr type)))
1004 (t
1005 (delete-region (- (point) length) (- (point) paren-length))
1006 (backward-char paren-length)
1007 (insert-string newsize)
1008 (if big-p (insert ?r))
1009 (forward-char paren-length)))
1010 (if (string= lr "l") (backward-list)))
1011 (modify-syntax-entry ?\\ backslash-syntax))
1012 t)))
1014 (defun YaTeX-insert-amsparens-region (beg end char)
1015 (interactive "r\ncWhich one ? l(big) L(Big) h(bigg) H(Bigg): ")
1016 (let* ((case-fold-search)
1017 (st (cond ((char-equal char ?l) "big")
1018 ((char-equal char ?L) "Big")
1019 ((char-equal char ?h) "bigg")
1020 ((char-equal char ?H) "Bigg"))))
1021 (if st
1022 (YaTeX-insert-braces-region
1023 beg end (concat "\\" st "l(") (concat "\\" st "r)"))
1024 (YaTeX-insert-braces-region beg end "(" ")"))))
1026 (defun YaTeX-insert-amsbraces-region (beg end char)
1027 (interactive "r\ncWhich one ? l(big) L(Big) h(bigg) H(Bigg): ")
1028 (let* ((case-fold-search)
1029 (st (cond ((char-equal char ?l) "big")
1030 ((char-equal char ?L) "Big")
1031 ((char-equal char ?h) "bigg")
1032 ((char-equal char ?H) "Bigg"))))
1033 (if st
1034 (YaTeX-insert-braces-region
1035 beg end (concat "\\" st "l\\{") (concat "\\" st "r\\}"))
1036 (YaTeX-insert-braces-region beg end "\\{" "\\}"))))
1038 (defun YaTeX-insert-amsbrackets-region (beg end char)
1039 (interactive "r\ncWhich one ? l(big) L(Big) h(bigg) H(Bigg): ")
1040 (let* ((case-fold-search)
1041 (st (cond ((char-equal char ?l) "big")
1042 ((char-equal char ?L) "Big")
1043 ((char-equal char ?h) "bigg")
1044 ((char-equal char ?H) "Bigg"))))
1045 (if st
1046 (YaTeX-insert-braces-region
1047 beg end (concat "\\" st "l[") (concat "\\" st "r]"))
1048 (YaTeX-insert-braces-region beg end "[" "]"))))
1051 ;;
1052 (provide 'yatexmth)
1054 ; Local variables:
1055 ; fill-prefix: ";;; "
1056 ; paragraph-start: "^$\\| \\|;;;$"
1057 ; paragraph-separate: "^$\\| \\|;;;$"
1058 ; End: