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