Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexadd.el @ 287:5921f28ef77c dev
Change the first lines.
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 01 Sep 2012 08:14:41 +0900 |
parents | 388eaa8b695a |
children | 1a4332ecc58b |
rev | line source |
---|---|
287 | 1 ;;; yatexadd.el --- YaTeX add-in functions |
222 | 2 ;;; yatexadd.el rev.20 |
3 ;;; (c)1991-2012 by HIROSE Yuuji.[yuuji@yatex.org] | |
287 | 4 ;;; Last modified Sat Sep 1 08:08:21 2012 on firestorm |
141 | 5 ;;; $Id$ |
6 | 6 |
287 | 7 ;;; Code: |
6 | 8 ;;; |
9 ;;Sample functions for LaTeX environment. | |
10 ;;; | |
11 (defvar YaTeX:tabular-default-rule | |
12 "@{\\vrule width 1pt\\ }c|c|c@{\\ \\vrule width 1pt}" | |
69 | 13 "*Your favorite default rule format.") |
14 | |
23 | 15 (defvar YaTeX:tabular-thick-vrule "\\vrule width %s" |
69 | 16 "*Vertical thick line format (without @{}). %s'll be replaced by its width.") |
17 | |
23 | 18 (defvar YaTeX:tabular-thick-hrule "\\noalign{\\hrule height %s}" |
69 | 19 "*Horizontal thick line format. %s will be replaced by its width.") |
20 | |
6 | 21 (defun YaTeX:tabular () |
18 | 22 "YaTeX add-in function for tabular environment. |
23 Notice that this function refers the let-variable `env' in | |
24 YaTeX-make-begin-end." | |
23 | 25 (let ((width "") bars (rule "") (and "") (j 1) loc ans (hline "\\hline")) |
72 | 26 (if (string= YaTeX-env-name "tabular*") |
18 | 27 (setq width (concat "{" (read-string "Width: ") "}"))) |
28 (setq loc (YaTeX:read-position "tb") | |
23 | 29 bars (string-to-int |
30 (read-string "Number of columns(0 for default format): " "3"))) | |
31 (if (<= bars 0) | |
32 (setq ;if 0, simple format | |
33 rule YaTeX:tabular-default-rule | |
34 and "& &") | |
35 (while (< j bars) ;repeat bars-1 times | |
36 (setq rule (concat rule "c|") | |
37 and (concat and "& ") | |
38 j (1+ j))) | |
39 (setq rule (concat rule "c")) | |
40 (message "(N)ormal-frame or (T)hick frame? [nt]") | |
41 (setq ans (read-char)) | |
42 (cond | |
43 ((or (equal ans ?t) (equal ans ?T)) | |
44 (setq ans (read-string "Rule width: " "1pt") | |
45 rule (concat | |
46 "@{" (format YaTeX:tabular-thick-vrule ans) "}" | |
47 rule | |
48 "@{\\ " (format YaTeX:tabular-thick-vrule ans) "}") | |
49 hline (format YaTeX:tabular-thick-hrule ans))) | |
50 (t (setq rule (concat "|" rule "|") | |
51 hline "\\hline")))) | |
52 | |
6 | 53 (setq rule (read-string "rule format: " rule)) |
72 | 54 (setq YaTeX-single-command "hline") |
6 | 55 |
69 | 56 (format "%s%s{%s}" width loc rule))) |
57 | |
18 | 58 (fset 'YaTeX:tabular* 'YaTeX:tabular) |
80 | 59 (fset 'YaTeX:supertabular 'YaTeX:tabular) |
60 (defun YaTeX:alignat () | |
61 (concat "{" (read-string "Number of columns: ") "}")) | |
18 | 62 (defun YaTeX:array () |
63 (concat (YaTeX:read-position "tb") | |
69 | 64 "{" (read-string "Column format: ") "}")) |
80 | 65 (defun YaTeX:subequations () |
66 (message (if YaTeX-japan "分かりやすいコメントに変えるとref補完が楽よ" | |
67 "Changing comment string reduces effort at `ref' completion")) | |
68 (concat " " YaTeX-comment-prefix | |
69 (YaTeX::ref-default-label "%H:%M") | |
70 (if YaTeX-japan "の式群" "equations"))) | |
6 | 71 |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
72 (defun YaTeX:read-oneof (oneof &optional quick allow-dup) |
23 | 73 (let ((pos "") loc (guide "")) |
74 (and (boundp 'name) name (setq guide (format "%s " name))) | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
75 (catch 'quick |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
76 (while (not (string-match |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
77 (setq loc (read-key-sequence |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
78 (format "%s position (`%s') [%s]: " |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
79 guide oneof pos));name is in YaTeX-addin |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
80 loc (if (fboundp 'events-to-keys) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
81 (events-to-keys loc) loc)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
82 "\r\^g\n")) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
83 (cond |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
84 ((string-match loc oneof) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
85 (if (or allow-dup (not (string-match loc pos))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
86 (setq pos (concat pos loc))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
87 (if quick (throw 'quick t))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
88 ((and (string-match loc "\C-h\C-?") (> (length pos) 0)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
89 (setq pos (substring pos 0 (1- (length pos))))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
90 (t |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
91 (ding) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
92 (message "Please input one of `%s'." oneof) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
93 (sit-for 3))))) |
8 | 94 (message "") |
69 | 95 pos)) |
23 | 96 |
97 (defun YaTeX:read-position (oneof) | |
98 "Read a LaTeX (optional) position format such as `[htbp]'." | |
99 (let ((pos (YaTeX:read-oneof oneof))) | |
69 | 100 (if (string= pos "") "" (concat "[" pos "]")))) |
8 | 101 |
220
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
102 ;;; |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
103 ;; Functions for figure environemnt |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
104 ;;; |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
105 (defvar YaTeX:figure-caption-first nil |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
106 "Non-nil indicates put caption before figure.") |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
107 (defun YaTeX:figure (&optional type firstp) |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
108 "YaTeX add-in function for figure(*) environment." |
246
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
109 (setq YaTeX-section-name |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
110 (if YaTeX:figure-caption-first "caption" "includegraphics") |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
111 YaTeX-env-name "center") |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
112 (YaTeX:read-position "htbp")) |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
113 |
220
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
114 |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
115 (fset 'YaTeX:figure* 'YaTeX:figure) |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
116 |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
117 ;;; |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
118 ;; Functions for table environemnt |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
119 ;;; |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
120 (defvar YaTeX:table-caption-first t |
4bb77d7ee8f0
Modify YaTeX:table and YaTeX:figure.
yuuji@fusion.yk.gentei.org
parents:
219
diff
changeset
|
121 "*Non-nil indicates put caption before tabular.") |
8 | 122 (defun YaTeX:table () |
123 "YaTeX add-in function for table environment." | |
73 | 124 (cond |
125 ((eq major-mode 'yatex-mode) | |
246
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
126 (setq YaTeX-section-name |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
127 (if YaTeX:table-caption-first "caption" "label") |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
128 YaTeX-env-name "tabular") |
9105918e45a2
Abolish too-much guidance for table/figure.
yuuji@gentei.org
parents:
237
diff
changeset
|
129 (YaTeX:read-position "htbp")) |
73 | 130 ((eq major-mode 'texinfo-mode) |
131 (concat " " | |
132 (completing-read | |
133 "Highlights with: " | |
134 '(("@samp")("@kbd")("@code")("@asis")("@file")("@var")) | |
135 nil nil "@"))))) | |
219
ad4e0a008972
Add-in function for figure and refine table.
yuuji@fusion.yk.gentei.org
parents:
175
diff
changeset
|
136 (fset 'YaTeX:table* 'YaTeX:table) |
6 | 137 |
138 (defun YaTeX:description () | |
139 "Truly poor service:-)" | |
72 | 140 (setq YaTeX-single-command "item[]") |
69 | 141 "") |
6 | 142 |
143 (defun YaTeX:itemize () | |
144 "It's also poor service." | |
72 | 145 (setq YaTeX-single-command "item") |
69 | 146 "") |
6 | 147 |
249 | 148 (defun YaTeX:enumerate () |
149 (setq YaTeX-single-command "item" | |
150 YaTeX-section-name "label") | |
151 "") | |
8 | 152 |
11 | 153 (defun YaTeX:picture () |
154 "Ask the size of coordinates of picture environment." | |
155 (concat (YaTeX:read-coordinates "Picture size") | |
69 | 156 (YaTeX:read-coordinates "Initial position"))) |
11 | 157 |
12 | 158 (defun YaTeX:equation () |
59 | 159 (YaTeX-jmode-off) |
12 | 160 (if (fboundp 'YaTeX-toggle-math-mode) |
69 | 161 (YaTeX-toggle-math-mode t))) ;force math-mode ON. |
162 | |
59 | 163 (mapcar '(lambda (f) (fset f 'YaTeX:equation)) |
164 '(YaTeX:eqnarray YaTeX:eqnarray* YaTeX:align YaTeX:align* | |
165 YaTeX:split YaTeX:multline YaTeX:multline* YaTeX:gather YaTeX:gather* | |
166 YaTeX:aligned* YaTeX:gathered YaTeX:gathered* | |
167 YaTeX:alignat YaTeX:alignat* YaTeX:xalignat YaTeX:xalignat* | |
168 YaTeX:xxalignat YaTeX:xxalignat*)) | |
12 | 169 |
80 | 170 (defun YaTeX:alignat () |
171 (YaTeX:equation) | |
172 (concat "{" (read-string "Number of cols: ") "}")) | |
173 | |
174 | |
175 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
176 (defun YaTeX:list () |
69 | 177 "%\n{} %default label\n{} %formatting parameter") |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
178 |
18 | 179 (defun YaTeX:minipage () |
180 (concat (YaTeX:read-position "cbt") | |
69 | 181 "{" (read-string "Width: ") "}")) |
18 | 182 |
64 | 183 (defun YaTeX:thebibliography () |
72 | 184 (setq YaTeX-section-name "bibitem") |
77 | 185 (concat "{" (read-string "Longest label: ") "}")) |
64 | 186 |
80 | 187 (defun YaTeX:multicols () |
188 (concat "{" (read-string "Number of columns: ") "}")) | |
189 | |
8 | 190 ;;; |
191 ;;Sample functions for section-type command. | |
192 ;;; | |
193 (defun YaTeX:multiput () | |
194 (concat (YaTeX:read-coordinates "Pos") | |
195 (YaTeX:read-coordinates "Step") | |
69 | 196 "{" (read-string "How many times: ") "}")) |
8 | 197 |
198 (defun YaTeX:put () | |
69 | 199 (YaTeX:read-coordinates "Pos")) |
8 | 200 |
201 (defun YaTeX:makebox () | |
23 | 202 (cond |
203 ((YaTeX-in-environment-p "picture") | |
204 (concat (YaTeX:read-coordinates "Dimension") | |
80 | 205 (YaTeX:read-position "lsrtb"))) |
23 | 206 (t |
207 (let ((width (read-string "Width: "))) | |
208 (if (string< "" width) | |
209 (progn | |
210 (or (equal (aref width 0) ?\[) | |
211 (setq width (concat "[" width "]"))) | |
80 | 212 (concat width (YaTeX:read-position |
213 (if YaTeX-use-LaTeX2e "lrs" "lr"))))))))) | |
8 | 214 |
80 | 215 ;; (defun YaTeX:framebox () |
216 ;; (if (YaTeX-quick-in-environment-p "picture") | |
217 ;; (YaTeX:makebox))) | |
218 (fset 'YaTeX:framebox 'YaTeX:makebox) | |
219 | |
220 (defun YaTeX:parbox () | |
221 (YaTeX:read-position "tbc")) | |
104
47a11079cc56
Add add-in function for parbox (YaTeX::parbox).
yuuji@gentei.org
parents:
86
diff
changeset
|
222 (defun YaTeX::parbox (argp) |
47a11079cc56
Add add-in function for parbox (YaTeX::parbox).
yuuji@gentei.org
parents:
86
diff
changeset
|
223 (cond |
47a11079cc56
Add add-in function for parbox (YaTeX::parbox).
yuuji@gentei.org
parents:
86
diff
changeset
|
224 ((= argp 1) (read-string "Width: ")) |
47a11079cc56
Add add-in function for parbox (YaTeX::parbox).
yuuji@gentei.org
parents:
86
diff
changeset
|
225 ((= argp 2) (read-string "Text: ")))) |
8 | 226 |
105 | 227 (defun YaTeX::dashbox () |
8 | 228 (concat "{" (read-string "Dash dimension: ") "}" |
69 | 229 (YaTeX:read-coordinates "Dimension"))) |
8 | 230 |
105 | 231 (defun YaTeX::savebox (argp) |
80 | 232 (cond |
233 ((= argp 1) (read-string "Saved into name: " "\\")) | |
234 ((= argp 2) (read-string "Text: ")))) | |
235 | |
51 | 236 (defvar YaTeX-minibuffer-quick-map nil) |
237 (if YaTeX-minibuffer-quick-map nil | |
238 (setq YaTeX-minibuffer-quick-map | |
239 (copy-keymap minibuffer-local-completion-map)) | |
240 (let ((ch (1+ ? ))) | |
241 (while (< ch 127) | |
242 (define-key YaTeX-minibuffer-quick-map (char-to-string ch) | |
243 'YaTeX-minibuffer-quick-complete) | |
244 (setq ch (1+ ch))))) | |
245 | |
246 (defvar YaTeX:left-right-delimiters | |
247 '(("(" . ")") (")" . "(") ("[" . "]") ("]" . "[") | |
248 ("\\{" . "\\}") ("\\}" . "\\{") ("|") ("\\|") | |
249 ("\\lfloor" . "\\rfloor") ("\\lceil" . "\\rceil") | |
250 ("\\langle" . "\\rangle") ("/") (".") | |
251 ("\\rfloor" . "\\rfloor") ("\\rceil" . "\\lceil") | |
252 ("\\rangle" . "\\langle") ("\\backslash") | |
253 ("\\uparrow") ("\\downarrow") ("\\updownarrow") ("\\Updownarrow")) | |
254 "TeX math delimiter, which can be completed after \\right or \\left.") | |
255 | |
256 (defvar YaTeX:left-right-default nil "Default string of YaTeX:right.") | |
257 | |
23 | 258 (defun YaTeX:left () |
51 | 259 (let ((minibuffer-completion-table YaTeX:left-right-delimiters) |
72 | 260 delimiter (leftp (string= YaTeX-single-command "left"))) |
51 | 261 (setq delimiter |
262 (read-from-minibuffer | |
263 (format "Delimiter%s: " | |
264 (if YaTeX:left-right-default | |
265 (format "(default=`%s')" YaTeX:left-right-default) | |
266 "(SPC for menu)")) | |
267 nil YaTeX-minibuffer-quick-map)) | |
268 (if (string= "" delimiter) (setq delimiter YaTeX:left-right-default)) | |
72 | 269 (setq YaTeX-single-command (if leftp "right" "left") |
51 | 270 YaTeX:left-right-default |
271 (or (cdr (assoc delimiter YaTeX:left-right-delimiters)) delimiter)) | |
272 delimiter)) | |
273 | |
23 | 274 (fset 'YaTeX:right 'YaTeX:left) |
275 | |
80 | 276 (defun YaTeX:langle () |
277 (setq YaTeX-single-command "rangle") | |
278 nil) | |
279 | |
8 | 280 (defun YaTeX:read-coordinates (&optional mes varX varY) |
281 (concat | |
282 "(" | |
283 (read-string (format "%s %s: " (or mes "Dimension") (or varX "X"))) | |
284 "," | |
285 (read-string (format "%s %s: " (or mes "Dimension") (or varY "Y"))) | |
69 | 286 ")")) |
8 | 287 |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
288 (defun YaTeX:itembox () |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
289 (concat "{" (read-string "Item heading string: ") "}")) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
290 |
8 | 291 ;;; |
292 ;;Sample functions for maketitle-type command. | |
293 ;;; | |
294 (defun YaTeX:sum () | |
295 "Read range of summation." | |
296 (YaTeX:check-completion-type 'maketitle) | |
69 | 297 (concat (YaTeX:read-boundary "_") (YaTeX:read-boundary "^"))) |
8 | 298 |
299 (fset 'YaTeX:int 'YaTeX:sum) | |
300 | |
301 (defun YaTeX:lim () | |
302 "Insert limit notation of \\lim." | |
303 (YaTeX:check-completion-type 'maketitle) | |
304 (let ((var (read-string "Variable: ")) limit) | |
305 (if (string= "" var) "" | |
306 (setq limit (read-string "Limit ($ means infinity): ")) | |
307 (if (string= "$" limit) (setq limit "\\infty")) | |
69 | 308 (concat "_{" var " \\rightarrow " limit "}")))) |
8 | 309 |
310 (defun YaTeX:gcd () | |
311 "Add-in function for \\gcd(m,n)." | |
312 (YaTeX:check-completion-type 'maketitle) | |
69 | 313 (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)")) |
8 | 314 |
315 (defun YaTeX:read-boundary (ULchar) | |
316 "Read boundary usage by _ or ^. _ or ^ is indicated by argument ULchar." | |
11 | 317 (let ((bndry (read-string (concat ULchar "{???} ($ for infinity): ")))) |
8 | 318 (if (string= bndry "") "" |
11 | 319 (if (string= bndry "$") (setq bndry "\\infty")) |
69 | 320 (concat ULchar "{" bndry "}")))) |
8 | 321 |
14 | 322 (defun YaTeX:verb () |
323 "Enclose \\verb's contents with the same characters." | |
324 (let ((quote-char (read-string "Quoting char: " "|")) | |
325 (contents (read-string "Quoted contents: "))) | |
69 | 326 (concat quote-char contents quote-char))) |
327 | |
23 | 328 (fset 'YaTeX:verb* 'YaTeX:verb) |
14 | 329 |
43
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
330 (defun YaTeX:footnotemark () |
72 | 331 (setq YaTeX-section-name "footnotetext") |
69 | 332 nil) |
43
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
333 |
48 | 334 (defun YaTeX:cite () |
335 (let ((comment (read-string "Comment for citation: "))) | |
336 (if (string= comment "") "" | |
69 | 337 (concat "[" comment "]")))) |
48 | 338 |
339 (defun YaTeX:bibitem () | |
64 | 340 (let ((label (read-string "Citation label for bibitem: "))) |
48 | 341 (if (string= label "") "" |
69 | 342 (concat "[" label "]")))) |
48 | 343 |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
344 (defun YaTeX:item () |
73 | 345 (cond |
346 ((eq major-mode 'yatex-mode) | |
347 (YaTeX-indent-line) | |
348 (setq YaTeX-section-name "label")) | |
349 ((eq major-mode 'texinfo-mode) | |
350 (setq YaTeX-section-name "dots"))) ;?? | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
351 " ") |
52 | 352 (fset 'YaTeX:item\[\] 'YaTeX:item) |
353 (fset 'YaTeX:subitem 'YaTeX:item) | |
354 (fset 'YaTeX:subsubitem 'YaTeX:item) | |
355 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
356 (defun YaTeX:linebreak () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
357 (let (obl) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
358 (message "Break strength 0,1,2,3,4 (default: 4): ") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
359 (setq obl (char-to-string (read-char))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
360 (if (string-match "[0-4]" obl) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
361 (concat "[" obl "]") |
69 | 362 ""))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
363 (fset 'YaTeX:pagebreak 'YaTeX:linebreak) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
364 |
14 | 365 ;;; |
366 ;;Subroutine | |
367 ;;; | |
368 | |
8 | 369 (defun YaTeX:check-completion-type (type) |
370 "Check valid completion type." | |
371 (if (not (eq type YaTeX-current-completion-type)) | |
69 | 372 (error "This should be completed with %s-type completion." type))) |
11 | 373 |
374 | |
375 ;;; | |
376 ;;; [[Add-in functions for reading section arguments]] | |
377 ;;; | |
378 ;; All of add-in functions for reading sections arguments should | |
379 ;; take an argument ARGP that specify the argument position. | |
380 ;; If argument position is out of range, nil should be returned, | |
381 ;; else nil should NOT be returned. | |
13 | 382 |
383 ;; | |
384 ; Label selection | |
385 ;; | |
11 | 386 (defvar YaTeX-label-menu-other |
387 (if YaTeX-japan "':他のバッファのラベル\n" "':LABEL IN OTHER BUFFER.\n")) | |
23 | 388 (defvar YaTeX-label-menu-repeat |
389 (if YaTeX-japan ".:直前の\\refと同じ\n" "/:REPEAT LAST \ref{}\n")) | |
11 | 390 (defvar YaTeX-label-menu-any |
391 (if YaTeX-japan "*:任意の文字列\n" "*:ANY STRING.\n")) | |
392 (defvar YaTeX-label-buffer "*Label completions*") | |
393 (defvar YaTeX-label-guide-msg "Select label and hit RETURN.") | |
394 (defvar YaTeX-label-select-map nil | |
395 "Key map used in label selection buffer.") | |
396 (defun YaTeX::label-setup-key-map () | |
397 (if YaTeX-label-select-map nil | |
398 (message "Setting up label selection mode map...") | |
68 | 399 ;(setq YaTeX-label-select-map (copy-keymap global-map)) |
400 (setq YaTeX-label-select-map (make-keymap)) | |
11 | 401 (suppress-keymap YaTeX-label-select-map) |
402 (substitute-all-key-definition | |
403 'previous-line 'YaTeX::label-previous YaTeX-label-select-map) | |
404 (substitute-all-key-definition | |
405 'next-line 'YaTeX::label-next YaTeX-label-select-map) | |
406 (define-key YaTeX-label-select-map "\C-n" 'YaTeX::label-next) | |
407 (define-key YaTeX-label-select-map "\C-p" 'YaTeX::label-previous) | |
408 (define-key YaTeX-label-select-map "<" 'beginning-of-buffer) | |
409 (define-key YaTeX-label-select-map ">" 'end-of-buffer) | |
410 (define-key YaTeX-label-select-map "\C-m" 'exit-recursive-edit) | |
411 (define-key YaTeX-label-select-map "\C-j" 'exit-recursive-edit) | |
412 (define-key YaTeX-label-select-map " " 'exit-recursive-edit) | |
413 (define-key YaTeX-label-select-map "\C-g" 'abort-recursive-edit) | |
414 (define-key YaTeX-label-select-map "/" 'isearch-forward) | |
415 (define-key YaTeX-label-select-map "?" 'isearch-backward) | |
416 (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag) | |
23 | 417 (define-key YaTeX-label-select-map "." 'YaTeX::label-search-tag) |
11 | 418 (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag) |
419 (message "Setting up label selection mode map...Done") | |
420 (let ((key ?A)) | |
421 (while (<= key ?Z) | |
422 (define-key YaTeX-label-select-map (char-to-string key) | |
423 'YaTeX::label-search-tag) | |
424 (define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A))) | |
425 'YaTeX::label-search-tag) | |
69 | 426 (setq key (1+ key)))))) |
427 | |
11 | 428 (defun YaTeX::label-next () |
429 (interactive) (forward-line 1) (message YaTeX-label-guide-msg)) | |
430 (defun YaTeX::label-previous () | |
431 (interactive) (forward-line -1) (message YaTeX-label-guide-msg)) | |
432 (defun YaTeX::label-search-tag () | |
433 (interactive) | |
68 | 434 (let ((case-fold-search t) |
435 (tag (regexp-quote (char-to-string last-command-char)))) | |
11 | 436 (cond |
437 ((save-excursion | |
438 (forward-char 1) | |
23 | 439 (re-search-forward (concat "^" tag) nil t)) |
11 | 440 (goto-char (match-beginning 0))) |
441 ((save-excursion | |
442 (goto-char (point-min)) | |
23 | 443 (re-search-forward (concat "^" tag) nil t)) |
11 | 444 (goto-char (match-beginning 0)))) |
69 | 445 (message YaTeX-label-guide-msg))) |
446 | |
70 | 447 ; (defun YaTeX::ref (argp &optional labelcmd refcmd) |
448 ; (cond | |
449 ; ((= argp 1) | |
450 ; (let ((lnum 0) e0 label label-list (buf (current-buffer)) | |
451 ; (labelcmd (or labelcmd "label")) (refcmd (or refcmd "ref")) | |
452 ; (p (point)) initl line cf) | |
453 ; (message "Collecting labels...") | |
454 ; (save-window-excursion | |
455 ; (YaTeX-showup-buffer | |
456 ; YaTeX-label-buffer (function (lambda (x) (window-width x)))) | |
457 ; (if (fboundp 'select-frame) (setq cf (selected-frame))) | |
458 ; (if (eq (window-buffer (minibuffer-window)) buf) | |
459 ; (progn | |
460 ; (other-window 1) | |
461 ; (setq buf (current-buffer)) | |
462 ; (set-buffer buf) | |
463 ; ;(message "cb=%s" buf)(sit-for 3) | |
464 ; )) | |
465 ; (save-excursion | |
466 ; (set-buffer (get-buffer-create YaTeX-label-buffer)) | |
467 ; (setq buffer-read-only nil) | |
468 ; (erase-buffer)) | |
469 ; (save-excursion | |
470 ; (goto-char (point-min)) | |
471 ; (let ((standard-output (get-buffer YaTeX-label-buffer))) | |
472 ; (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf))) | |
473 ; (while (YaTeX-re-search-active-forward | |
474 ; (concat "\\\\" labelcmd "\\b") | |
475 ; (regexp-quote YaTeX-comment-prefix) nil t) | |
476 ; (goto-char (match-beginning 0)) | |
477 ; (skip-chars-forward "^{") | |
478 ; (setq label | |
479 ; (buffer-substring | |
480 ; (1+ (point)) | |
481 ; (prog2 (forward-list 1) (setq e0 (1- (point))))) | |
482 ; label-list (cons label label-list)) | |
483 ; (or initl | |
484 ; (if (< p (point)) (setq initl lnum))) | |
485 ; (beginning-of-line) | |
486 ; (skip-chars-forward " \t\n" nil) | |
487 ; (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label | |
488 ; (buffer-substring (point) (point-end-of-line)))) | |
489 ; (setq lnum (1+ lnum)) | |
490 ; (message "Collecting \\%s{}... %d" labelcmd lnum) | |
491 ; (goto-char e0)) | |
492 ; (princ YaTeX-label-menu-other) | |
493 ; (princ YaTeX-label-menu-repeat) | |
494 ; (princ YaTeX-label-menu-any) | |
495 ; );standard-output | |
496 ; (goto-char p) | |
497 ; (or initl (setq initl lnum)) | |
498 ; (message "Collecting %s...Done" labelcmd) | |
499 ; (if (fboundp 'select-frame) (select-frame cf)) | |
500 ; (YaTeX-showup-buffer YaTeX-label-buffer nil t) | |
501 ; (YaTeX::label-setup-key-map) | |
502 ; (setq truncate-lines t) | |
503 ; (setq buffer-read-only t) | |
504 ; (use-local-map YaTeX-label-select-map) | |
505 ; (message YaTeX-label-guide-msg) | |
506 ; (goto-line (1+ initl)) ;goto recently defined label line | |
507 ; (switch-to-buffer (current-buffer)) | |
508 ; (unwind-protect | |
509 ; (progn | |
510 ; (recursive-edit) | |
511 ; (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion | |
512 ; (beginning-of-line) | |
513 ; (setq line (1- (count-lines (point-min)(point)))) | |
514 ; (cond | |
515 ; ((= line -1) (setq label "")) | |
516 ; ((= line lnum) (setq label (YaTeX-label-other))) | |
517 ; ((= line (1+ lnum)) | |
518 ; (save-excursion | |
519 ; (switch-to-buffer buf) | |
520 ; (goto-char p) | |
521 ; (if (re-search-backward | |
522 ; (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t) | |
523 ; (setq label (YaTeX-match-string 1)) | |
524 ; (setq label "")))) | |
525 ; ((>= line (+ lnum 2)) | |
526 ; (setq label (read-string (format "\\%s{???}: " refcmd)))) | |
527 ; (t (setq label (nth (- lnum line 1) label-list))))) | |
528 ; (bury-buffer YaTeX-label-buffer))) | |
529 ; label))))) | |
530 | |
80 | 531 (defvar YaTeX-ref-default-label-string "%H%M%S_%d%b%y" |
532 "*Default \\ref time string format. | |
533 This format is like strftime(3) but allowed conversion char are as follows; | |
534 %y -> Last 2 digit of year, %b -> Month name, %m -> Monthe number(1-12), | |
535 %d -> Day, %H -> Hour, %M -> Minute, %S -> Second, | |
536 %qx -> alphabetical-decimal conversion of yymmdd. | |
537 %qX -> alphabetical-decimal conversion of HHMMSS. | |
538 Beware defualt label-string should be always unique. So this format string | |
539 should have both time part (%H+%M+%S or %qX) and date | |
540 part (%y+(%b|%m)+%d or %qx).") | |
541 | |
542 (defun YaTeX::ref-alphabex (n) | |
543 (let ((alphabex "")) | |
544 (while (> n 0) | |
545 (setq alphabex (concat (char-to-string (+ ?a (% n 26))) alphabex) | |
546 n (/ n 26))) | |
547 alphabex)) | |
548 | |
549 (defun YaTeX::ref-default-label (&optional format) | |
550 "Default auto-genarated label string." | |
551 ;; We do not use (format-time-string) for emacs-19 | |
552 (let*((ts (substring (current-time-string) 4)) | |
553 (y (substring ts -2)) | |
554 (b (substring ts 0 3)) | |
555 (d (format "%d" (string-to-int (substring ts 4 6)))) | |
556 (H (substring ts 7 9)) | |
557 (M (substring ts 10 12)) | |
558 (S (substring ts 13 15)) | |
559 (HMS (+ (* 10000 (string-to-int H)) | |
560 (* 100 (string-to-int M)) | |
561 (string-to-int S))) | |
562 (talphabex (YaTeX::ref-alphabex HMS)) | |
563 (mnames "JanFebMarAprMayJunJulAugSepOctNovDec") | |
564 (m (format "%02d" (/ (string-match b mnames) 3))) | |
565 (ymd (+ (* 10000 (string-to-int y)) | |
566 (* 100 (string-to-int m)) | |
567 (string-to-int d))) | |
568 (dalphabex (YaTeX::ref-alphabex ymd))) | |
569 (YaTeX-replace-formats | |
570 (or format YaTeX-ref-default-label-string) | |
571 (list (cons "y" y) | |
572 (cons "b" b) | |
573 (cons "m" m) | |
574 (cons "d" d) | |
575 (cons "H" H) | |
576 (cons "M" M) | |
577 (cons "S" S) | |
578 (cons "qX" talphabex) | |
579 (cons "qx" dalphabex))))) | |
580 | |
581 (defvar YaTeX-ref-generate-label-function 'YaTeX::ref-generate-label | |
582 "*Function to generate default label for unnamed \\label{}s. | |
583 The function pointed to this value should take two arguments. | |
584 First argument is LaTeX macro's name, second is macro's argument.") | |
585 | |
586 (defun YaTeX::ref-generate-label (command arg) | |
70 | 587 "Generate a label string which is unique in current buffer." |
80 | 588 (let ((default (condition-case nil |
589 (YaTeX::ref-default-label) | |
590 (error (substring (current-time-string) 4))))) | |
70 | 591 (read-string "Give a label for this line: " |
592 (if YaTeX-emacs-19 (cons default 1) default)))) | |
593 | |
80 | 594 (defun YaTeX::ref-getset-label (buffer point &optional noset) |
70 | 595 "Get label string in the BUFFER near the POINT. |
80 | 596 Make \\label{xx} if no label. |
597 If optional third argument NOSET is non-nil, do not generate new label." | |
73 | 598 ;;Here, we rewrite the LaTeX source. Therefore we should be careful |
599 ;;to decide the location suitable for \label. Do straightforward! | |
80 | 600 (let (boundary inspoint cc newlabel (labelholder "label") mathp exp1 env |
601 (r-escape (regexp-quote YaTeX-comment-prefix)) | |
602 command arg alreadysought foundpoint) | |
603 (set-buffer buffer) | |
70 | 604 (save-excursion |
605 (goto-char point) | |
606 (setq cc (current-column)) | |
607 (if (= (char-after (point)) ?\\) (forward-char 1)) | |
608 (cond | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
609 ;; In each codition, 'inspoint and 'boundary should be set |
70 | 610 ((looking-at YaTeX-sectioning-regexp) |
80 | 611 (setq command (YaTeX-match-string 0)) |
70 | 612 (skip-chars-forward "^{") |
80 | 613 (setq arg (buffer-substring |
614 (1+ (point)) | |
615 (progn (forward-list 1) (1- (point))))) | |
70 | 616 (skip-chars-forward " \t\n") |
73 | 617 ;(setq boundary "[^\\]") |
77 | 618 (setq inspoint (point)) |
73 | 619 (setq boundary |
620 (save-excursion | |
77 | 621 (if (YaTeX-re-search-active-forward |
622 (concat YaTeX-ec-regexp | |
623 "\\(" YaTeX-sectioning-regexp "\\|" | |
624 "begin\\|item\\)") | |
625 r-escape nil 1) | |
73 | 626 (match-beginning 0) |
627 (1- (point)))))) | |
70 | 628 ((looking-at "item\\s ") |
80 | 629 (setq command "item" |
630 cc (+ cc 6)) | |
73 | 631 ;(setq boundary (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b")) |
632 (setq boundary | |
633 (save-excursion | |
634 (if (YaTeX-re-search-active-forward | |
635 (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b") | |
636 r-escape nil 1) | |
637 (match-beginning 0) | |
77 | 638 (1- (point)))) |
639 inspoint boundary)) | |
70 | 640 ((looking-at "bibitem") |
80 | 641 (setq labelholder "bibitem" ; label holder is bibitem itself |
642 command "bibitem") | |
73 | 643 (setq boundary |
644 (save-excursion | |
645 (if (YaTeX-re-search-active-forward | |
646 (concat YaTeX-ec-regexp "\\(bibitem\\|end\\)\\b") | |
647 r-escape nil 1) | |
648 (match-beginning 0) | |
77 | 649 (1- (point)))) |
650 inspoint boundary)) | |
80 | 651 ((string-match YaTeX::ref-nestable-counter-regexp |
70 | 652 (setq env (or (YaTeX-inner-environment t) "document"))) |
80 | 653 (let ((curtop (get 'YaTeX-inner-environment 'point)) |
654 (end (point-max)) label) | |
655 (skip-chars-forward " \t\n") | |
656 (setq inspoint (point) ;initial candidate | |
657 cc (current-column) | |
658 command env | |
659 alreadysought t) | |
660 (if (condition-case nil | |
661 (progn | |
662 (goto-char curtop) | |
663 (YaTeX-goto-corresponding-environment)) | |
664 (error nil)) | |
665 (setq end (point))) | |
666 (goto-char inspoint) | |
667 (while (YaTeX-re-search-active-forward | |
668 (concat YaTeX-ec-regexp "label{\\([^}]+\\)}" ) | |
669 r-escape end t) | |
670 (setq label (YaTeX-match-string 1)) | |
671 (if (and (equal env (YaTeX-inner-environment t)) | |
672 (= curtop (get 'YaTeX-inner-environment 'point))) | |
673 ;;I found the label | |
674 (setq alreadysought label | |
675 foundpoint (match-end 0)))) | |
676 )) | |
677 ((string-match YaTeX::ref-mathenv-regexp env) ;env is set in above case | |
678 (setq command env | |
679 mathp t | |
680 exp1 (string-match YaTeX::ref-mathenv-exp1-regexp env)) | |
73 | 681 ;;(setq boundary (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)")) |
682 (setq boundary | |
683 (save-excursion | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
684 (or (catch 'bndry |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
685 (while (YaTeX-re-search-active-forward |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
686 (concat |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
687 YaTeX-ec-regexp "\\(" |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
688 (if exp1 "" "\\\\\\|") |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
689 "\\(end{" env "\\)}\\)") |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
690 r-escape nil 1) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
691 (setq foundpoint (match-beginning 0)) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
692 (if (or (match-beginning 2) ;end of outer math-env |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
693 (equal env (YaTeX-inner-environment t))) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
694 ;; YaTeX-inner-environment destroys match-data |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
695 (throw 'bndry foundpoint)))) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
696 (1- (point)))) |
77 | 697 inspoint boundary)) |
73 | 698 ((looking-at "footnote\\s *{") |
80 | 699 (setq command "footnote") |
73 | 700 (skip-chars-forward "^{") ;move onto `{' |
701 (setq boundary | |
702 (save-excursion | |
703 (condition-case err | |
704 (forward-list 1) | |
705 (error (error "\\\\footnote at point %s's brace not closed" | |
706 (point)))) | |
77 | 707 (1- (point))) |
708 inspoint boundary)) | |
70 | 709 ((looking-at "caption\\|\\(begin\\)") |
80 | 710 (setq command (YaTeX-match-string 0)) |
70 | 711 (skip-chars-forward "^{") |
77 | 712 ;;;;;;(if (match-beginning 1) (forward-list 1)) |
713 ;; caption can be treated as mathenv, is it right?? | |
80 | 714 (setq arg (buffer-substring |
715 (1+ (point)) | |
716 (progn (forward-list 1) (1- (point))))) | |
73 | 717 ;;(setq boundary (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b")) |
77 | 718 (setq inspoint (point)) |
73 | 719 (setq boundary |
720 (save-excursion | |
721 (if (YaTeX-re-search-active-forward | |
722 (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b") | |
723 r-escape nil 1) | |
724 (match-beginning 0) | |
725 (1- (point)))))) | |
70 | 726 (t )) |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
727 ;;cond by kind of labeling ends here. |
70 | 728 (if (save-excursion (skip-chars-forward " \t") (looking-at "%")) |
729 (forward-line 1)) | |
80 | 730 (cond |
731 ((stringp alreadysought) | |
732 (put 'YaTeX::ref-getset-label 'foundpoint foundpoint) ;ugly... | |
733 alreadysought) | |
734 ((and (null alreadysought) | |
735 (> boundary (point)) | |
736 (save-excursion | |
737 (YaTeX-re-search-active-forward | |
738 ;;(concat "\\(" labelholder "\\)\\|\\(" boundary "\\)") | |
739 labelholder | |
740 (regexp-quote YaTeX-comment-prefix) | |
741 boundary 1)) | |
742 (match-beginning 0)) | |
70 | 743 ;; if \label{hoge} found, return it |
80 | 744 (put 'YaTeX::ref-getset-label 'foundpoint (1- (match-beginning 0))) |
745 (buffer-substring | |
746 (progn | |
747 (goto-char (match-end 0)) | |
748 (skip-chars-forward "^{") (1+ (point))) | |
749 (progn | |
750 (forward-sexp 1) (1- (point))))) | |
70 | 751 ;;else make a label |
73 | 752 ;(goto-char (match-beginning 0)) |
80 | 753 (noset nil) ;do not set label if noset |
754 (t | |
77 | 755 (goto-char inspoint) |
70 | 756 (skip-chars-backward " \t\n") |
80 | 757 (save-excursion |
758 (setq newlabel | |
759 (funcall YaTeX-ref-generate-label-function command arg))) | |
70 | 760 (delete-region (point) (progn (skip-chars-backward " \t") (point))) |
761 (if mathp nil | |
762 (insert "\n") | |
763 (YaTeX-reindent cc)) | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
764 (put 'YaTeX::ref-getset-label 'foundpoint (point)) |
70 | 765 (insert (format "\\label{%s}" newlabel)) |
80 | 766 newlabel))))) |
70 | 767 |
80 | 768 (defvar YaTeX::ref-labeling-regexp-alist-default |
769 '(("\\\\begin{\\(java\\|program\\)}{\\([^}]+\\)}" . 2) | |
770 ("\\\\label{\\([^}]+\\)}" . 1)) | |
771 "Alist of labeling regexp vs. its group number points to label string. | |
772 This alist is used in \\ref's argument's completion.") | |
773 (defvar YaTeX::ref-labeling-regexp-alist-private nil | |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
774 "*Private extension to YaTeX::ref-labeling-regexp-alist. |
80 | 775 See the documetation of YaTeX::ref-labeling-regexp-alist.") |
70 | 776 (defvar YaTeX::ref-labeling-regexp-alist |
80 | 777 (append YaTeX::ref-labeling-regexp-alist-default |
778 YaTeX::ref-labeling-regexp-alist-private)) | |
70 | 779 (defvar YaTeX::ref-labeling-regexp |
780 (mapconcat 'car YaTeX::ref-labeling-regexp-alist "\\|")) | |
781 (defvar YaTeX::ref-mathenv-regexp | |
80 | 782 ;; See also YaTeX-ams-math-begin-alist in yatex.el |
783 ;; Define only envs which has counter.(without *) | |
784 "equation\\|eqnarray\\|align\\(at\\)?\\|flalign\\|gather\\|xx?alignat\\|multline") | |
785 (defvar YaTeX::ref-mathenv-exp1-regexp | |
786 "\\(equation\\|multline\\)\\b" | |
787 "*Regexp of math-envname which has only one math-expression.") | |
70 | 788 (defvar YaTeX::ref-enumerateenv-regexp |
789 "enumerate") | |
80 | 790 (defvar YaTeX::ref-nestable-counter-regexp |
791 "subequations") | |
70 | 792 |
793 (defvar YaTeX::ref-labeling-section-level 2 | |
72 | 794 "*ref補完で収集するセクショニングコマンドの下限レベル |
70 | 795 YaTeX-sectioning-levelの数値で指定.") |
796 | |
80 | 797 (defun YaTeX::ref (argp &optional labelcmd refcmd predf) |
70 | 798 (setplist 'YaTeX::ref-labeling-regexp nil) ;erase memory cache |
799 (require 'yatexsec) | |
11 | 800 (cond |
801 ((= argp 1) | |
80 | 802 (let*((lnum 0) m0 e0 x cmd label match-point point-list boundary |
70 | 803 (buf (current-buffer)) |
804 (llv YaTeX::ref-labeling-section-level) | |
80 | 805 (mathenvs YaTeX::ref-mathenv-regexp) envname endrx |
70 | 806 (enums YaTeX::ref-enumerateenv-regexp) |
807 (counter | |
808 (or labelcmd | |
809 (concat | |
810 YaTeX-ec-regexp "\\(\\(" | |
811 (mapconcat | |
812 'concat | |
813 (delq nil | |
814 (mapcar | |
72 | 815 (function |
816 (lambda (s) | |
817 (if (>= llv (cdr s)) | |
818 (car s)))) | |
70 | 819 YaTeX-sectioning-level)) |
820 "\\|") | |
77 | 821 "\\|caption\\(\\[[^]]+\\]\\)?\\|footnote\\){" |
80 | 822 "\\|\\(begin{\\(" mathenvs "\\|" enums "\\)}\\)" |
823 (if YaTeX-use-AMS-LaTeX | |
824 (concat | |
825 "\\|\\(begin{" | |
826 YaTeX::ref-nestable-counter-regexp "}\\)")) | |
827 "\\)"))) | |
70 | 828 (regexp (concat "\\(" counter |
829 "\\)\\|\\(" YaTeX::ref-labeling-regexp "\\)")) | |
830 (itemsep (concat YaTeX-ec-regexp | |
831 "\\(\\(bib\\)?item\\|begin\\|end\\)")) | |
86 | 832 (refcmd (or refcmd "\\(page\\)?ref")) |
70 | 833 (p (point)) initl line cf |
834 (percent (regexp-quote YaTeX-comment-prefix)) | |
835 (output | |
836 (function | |
837 (lambda (label p) | |
80 | 838 (while (setq x (string-match "[\n\t]" label)) |
70 | 839 (aset label x ? )) |
80 | 840 (while (setq x (string-match " +" label)) |
70 | 841 (setq label (concat |
842 (substring label 0 (1+ (match-beginning 0))) | |
843 (substring label (match-end 0))))) | |
844 (princ (format "%c: <<%s>>\n" (+ (% lnum 26) ?A) label)) | |
845 (setq point-list (cons p point-list)) | |
846 (message "Collecting labels... %d" lnum) | |
847 (setq lnum (1+ lnum))))) | |
80 | 848 (me (if (boundp 'me) me 'YaTeX::ref)) |
70 | 849 ) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
850 (message "Collecting labels...") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
851 (save-window-excursion |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
852 (YaTeX-showup-buffer |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
853 YaTeX-label-buffer (function (lambda (x) (window-width x)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
854 (if (fboundp 'select-frame) (setq cf (selected-frame))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
855 (if (eq (window-buffer (minibuffer-window)) buf) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
856 (progn |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
857 (other-window 1) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
858 (setq buf (current-buffer)) |
70 | 859 (set-buffer buf))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
860 (save-excursion |
69 | 861 (set-buffer (get-buffer-create YaTeX-label-buffer)) |
80 | 862 (condition-case () |
863 (if (and YaTeX-use-font-lock (fboundp 'font-lock-mode)) | |
864 (font-lock-mode 1)) | |
865 (error nil)) | |
69 | 866 (setq buffer-read-only nil) |
867 (erase-buffer)) | |
868 (save-excursion | |
70 | 869 (set-buffer buf) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
870 (goto-char (point-min)) |
80 | 871 (let ((standard-output (get-buffer YaTeX-label-buffer)) existlabel) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
872 (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf))) |
48 | 873 (while (YaTeX-re-search-active-forward |
70 | 874 regexp ;;counter |
875 percent nil t) | |
876 ;(goto-char (match-beginning 0)) | |
877 (setq e0 (match-end 0)) | |
878 (cond | |
80 | 879 ;; |
880 ;;2005/10/21 Skip it if predicate function returns nil | |
881 ((and predf | |
882 (let ((md (match-data))) | |
883 (prog1 | |
884 (condition-case nil | |
885 (not (funcall predf)) | |
886 (error nil)) | |
887 (store-match-data md))))) | |
73 | 888 ((YaTeX-literal-p) nil) |
72 | 889 ((YaTeX-match-string 1) |
70 | 890 ;;if standard counter commands found |
80 | 891 (setq cmd (YaTeX-match-string 2) |
892 m0 (match-beginning 0)) | |
70 | 893 (setq match-point (match-beginning 0)) |
894 (or initl | |
895 (if (< p (point)) (setq initl lnum))) | |
896 (cond | |
80 | 897 ;; In any case, variables e0 should be set |
898 ((and YaTeX-use-AMS-LaTeX | |
899 (string-match YaTeX::ref-nestable-counter-regexp cmd)) | |
900 (let (label) | |
901 (skip-chars-forward "}") | |
902 (setq label (buffer-substring | |
903 (point) (min (+ 80 (point)) (point-max)))) | |
904 ;; to skip (maybe)auto-generated comment | |
905 (skip-chars-forward " \t") | |
906 (if (looking-at YaTeX-comment-prefix) | |
907 (forward-line 1)) | |
908 (setq e0 (point)) | |
909 (skip-chars-forward " \t\n") | |
910 (if (looking-at "\\\\label{\\([^}]+\\)}") | |
911 (setq label (format "(labe:%s)" (YaTeX-match-string 1)) | |
912 e0 (match-end 1))) | |
913 (funcall output (format "--subequation--%s" label) e0))) | |
70 | 914 ((string-match mathenvs cmd) ;;if matches mathematical env |
80 | 915 (skip-chars-forward "}") |
916 (setq x (point) | |
917 envname (substring | |
918 cmd (match-beginning 0) (match-end 0))) | |
919 (save-restriction | |
920 (narrow-to-region | |
921 m0 | |
922 (save-excursion | |
923 (YaTeX-re-search-active-forward | |
924 (setq endrx (format "%send{%s}" YaTeX-ec-regexp | |
925 (regexp-quote envname))) | |
926 percent nil t))) | |
927 (catch 'scan | |
928 (while (YaTeX-re-search-active-forward | |
929 (concat | |
930 "\\\\end{\\(" (regexp-quote envname) "\\)";;(1) | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
931 "\\|\\\\\\(notag\\)" ;;2 |
80 | 932 (if (string-match |
933 YaTeX::ref-mathenv-exp1-regexp cmd) | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
934 "" "\\|\\(\\\\\\\\\\)$") ;;3 |
80 | 935 ) |
936 percent nil t) | |
937 (let*((quit (match-beginning 1)) | |
938 (notag (match-beginning 2)) | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
939 (newln (match-beginning 3)) |
80 | 940 (label ".......................") l2 |
941 (e (point)) (m0 (match-beginning 0)) | |
942 (ln (YaTeX-string-width label))) | |
943 (cond | |
944 (notag | |
945 (YaTeX-re-search-active-forward | |
946 "\\\\\\\\" percent nil 1) | |
259
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
947 (setq x (point))) ;use x as \label search bound |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
948 ((and newln ; `\\' found |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
949 (not (equal (YaTeX-inner-environment) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
950 envname))) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
951 (YaTeX-end-of-environment) |
7d4f8f3d540d
Do not count sub-environment inside math-environment as a counter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
255
diff
changeset
|
952 (goto-char (match-end 0))) |
80 | 953 (t |
954 (if (YaTeX-re-search-active-backward | |
955 YaTeX::ref-labeling-regexp | |
956 percent x t) | |
957 ;; if \label{x} in math-expression, display it | |
958 ;; because formula source is hard to recognize | |
959 (progn | |
960 (goto-char (match-end 0)) | |
961 (setq l2 (format "\"label:%s\"" | |
962 (buffer-substring | |
963 (1- (point)) | |
964 (progn (forward-sexp -1) | |
965 (1+ (point)))))) | |
966 (setq label | |
967 (if (< (YaTeX-string-width l2) ln) | |
968 (concat | |
969 l2 | |
970 (substring | |
971 label | |
972 0 (- ln (YaTeX-string-width l2)))) | |
973 l2)) | |
974 (goto-char e))) | |
975 (funcall output | |
976 (concat | |
977 label " " | |
978 (buffer-substring x m0)) | |
979 x) | |
980 (cond | |
981 ((YaTeX-quick-in-environment-p | |
982 YaTeX-math-gathering-list) | |
983 ;; if here is inner split/cases/gathered env., | |
984 ;; counter for here is only one. | |
985 ;; Go out this environment and, | |
986 (YaTeX-end-of-environment) | |
987 ;; search next expression unit boundary. | |
988 (YaTeX-re-search-active-forward | |
989 (concat endrx "\\|\\\\begin{") | |
990 percent nil 1) | |
991 (end-of-line))) | |
992 (if quit (throw 'scan t))))) | |
993 (setq x (point))))) | |
70 | 994 (setq e0 (point))) |
995 ((string-match enums cmd) | |
996 ;(skip-chars-forward "} \t\n") | |
997 (save-restriction | |
998 (narrow-to-region | |
999 (point) | |
1000 (save-excursion | |
1001 (YaTeX-goto-corresponding-environment) (point))) | |
1002 (forward-line 1) | |
1003 (while (YaTeX-re-search-active-forward | |
1004 (concat YaTeX-ec-regexp "item\\s ") | |
1005 percent nil t) | |
1006 (setq x (match-beginning 0)) | |
1007 (funcall | |
1008 output | |
80 | 1009 (concat |
1010 existlabel | |
1011 (buffer-substring | |
1012 (match-beginning 0) | |
1013 (if (re-search-forward itemsep nil t) | |
1014 (progn (goto-char (match-beginning 0)) | |
1015 (skip-chars-backward " \t") | |
1016 (1- (point))) | |
1017 (point-end-of-line)))) | |
77 | 1018 x)) |
1019 (setq e0 (point-max)))) | |
80 | 1020 ((string-match "bibitem" cmd) ;maybe generated by myself |
1021 (setq label "") | |
1022 (skip-chars-forward " \t") | |
1023 (if (looking-at "{") ;sure to be true!! | |
1024 (forward-list 1)) | |
1025 (let ((list '(30 10 65)) | |
1026 (delim ";") q lim len l str) | |
1027 (save-excursion | |
1028 (setq lim (if (re-search-forward itemsep nil 1) | |
1029 (match-beginning 0) (point)))) | |
1030 (while list | |
1031 (skip-chars-forward " \t\n\\") | |
1032 (setq q (looking-at "[\"'{]") | |
1033 len (car list) | |
1034 str | |
1035 (buffer-substring | |
1036 (point) | |
1037 (progn | |
1038 (if q (forward-sexp 1) | |
1039 (search-forward delim lim 1) | |
1040 (forward-char -1)) | |
1041 (point)))) | |
1042 (if (> (setq l (YaTeX-string-width str)) len) | |
1043 (setq str (concat | |
1044 (YaTeX-truncate-string-width | |
1045 str (- len (if q 5 4))) | |
1046 "... " | |
1047 (if q (substring str -1))))) | |
1048 (if (< (setq l (YaTeX-string-width str)) len) | |
1049 (setq str (concat str (make-string (- len l) ? )))) | |
1050 (if (looking-at delim) (goto-char (match-end 0))) | |
1051 (setq label (concat label " " str) | |
1052 list (cdr list))) | |
1053 (funcall output label match-point))) | |
77 | 1054 ;;else, simple section-type counter |
70 | 1055 ((= (char-after (1- (point))) ?{) |
1056 (setq label (buffer-substring | |
1057 (match-beginning 0) | |
1058 (progn (forward-char -1) | |
1059 (forward-list 1) | |
1060 (point)))) | |
77 | 1061 (funcall output label match-point) |
1062 ;; Skip preceding label if exists | |
80 | 1063 (if (YaTeX::ref-getset-label (current-buffer) match-point t) |
1064 (goto-char (get 'YaTeX::ref-getset-label 'foundpoint))) | |
77 | 1065 (if (save-excursion |
1066 (skip-chars-forward "\t \n") | |
1067 (looking-at YaTeX::ref-labeling-regexp)) | |
1068 (setq e0 (match-end 0)))) | |
70 | 1069 (t |
1070 (skip-chars-forward " \t") | |
1071 (setq label (buffer-substring | |
1072 (match-beginning 0) | |
1073 (if (re-search-forward | |
1074 itemsep | |
1075 nil t) | |
1076 (progn | |
1077 (goto-char (match-beginning 0)) | |
1078 (skip-chars-backward " \t") | |
1079 (1- (point))) | |
1080 (point-end-of-line)))) | |
1081 (funcall output label match-point) | |
77 | 1082 (if (save-excursion |
1083 (skip-chars-forward "\t \n") | |
1084 (looking-at YaTeX::ref-labeling-regexp)) | |
1085 (setq e0 (match-end 0))))) | |
70 | 1086 ) ;;put label buffer |
1087 ;; | |
1088 ;; if user defined label found | |
1089 (t | |
1090 ;; memorize line number and label into property | |
1091 (goto-char (match-beginning 0)) | |
1092 (let ((list YaTeX::ref-labeling-regexp-alist) | |
1093 (cache (symbol-plist 'YaTeX::ref-labeling-regexp))) | |
1094 (while list | |
1095 (if (looking-at (car (car list))) | |
1096 (progn | |
1097 (setq label (YaTeX-match-string 0)) | |
1098 (put 'YaTeX::ref-labeling-regexp lnum | |
1099 (YaTeX-match-string (cdr (car list)))) | |
1100 (funcall output label 0) ;;0 is dummy, never used | |
1101 (setq list nil))) | |
1102 (setq list (cdr list)))) | |
1103 )) | |
11 | 1104 (goto-char e0)) |
1105 (princ YaTeX-label-menu-other) | |
23 | 1106 (princ YaTeX-label-menu-repeat) |
11 | 1107 (princ YaTeX-label-menu-any) |
69 | 1108 );standard-output |
11 | 1109 (goto-char p) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1110 (or initl (setq initl lnum)) |
70 | 1111 (message "Collecting labels...Done") |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1112 (if (fboundp 'select-frame) (select-frame cf)) |
59 | 1113 (YaTeX-showup-buffer YaTeX-label-buffer nil t) |
11 | 1114 (YaTeX::label-setup-key-map) |
1115 (setq truncate-lines t) | |
1116 (setq buffer-read-only t) | |
1117 (use-local-map YaTeX-label-select-map) | |
1118 (message YaTeX-label-guide-msg) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1119 (goto-line (1+ initl)) ;goto recently defined label line |
68 | 1120 (switch-to-buffer (current-buffer)) |
11 | 1121 (unwind-protect |
1122 (progn | |
1123 (recursive-edit) | |
70 | 1124 |
11 | 1125 (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion |
1126 (beginning-of-line) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1127 (setq line (1- (count-lines (point-min)(point)))) |
11 | 1128 (cond |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1129 ((= line -1) (setq label "")) |
11 | 1130 ((= line lnum) (setq label (YaTeX-label-other))) |
23 | 1131 ((= line (1+ lnum)) |
1132 (save-excursion | |
1133 (switch-to-buffer buf) | |
1134 (goto-char p) | |
48 | 1135 (if (re-search-backward |
86 | 1136 (concat "\\\\" refcmd "{") nil t) |
1137 (setq label (YaTeX-buffer-substring | |
1138 (progn (goto-char (1- (match-end 0))) | |
1139 (1+ (point))) | |
1140 (progn (forward-list 1) | |
1141 (1- (point))))) | |
23 | 1142 (setq label "")))) |
1143 ((>= line (+ lnum 2)) | |
48 | 1144 (setq label (read-string (format "\\%s{???}: " refcmd)))) |
70 | 1145 (t ;(setq label (nth (- lnum line 1) label-list)) |
1146 (setq label | |
1147 (or (get 'YaTeX::ref-labeling-regexp line) | |
1148 (YaTeX::ref-getset-label | |
1149 buf (nth (- lnum line 1) point-list)))) | |
1150 ))) | |
11 | 1151 (bury-buffer YaTeX-label-buffer))) |
69 | 1152 label))))) |
1153 | |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1154 (defun YaTeX::label-rename-refs (old new &optional def ref) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1155 "Rename reference tag from OLD to NEW. |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1156 Optional arguments DEF and REF specify defining command and |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1157 referring command respectively. |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1158 --------------------------------------------------------- |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1159 CONTROL KEYS - キーの説明 |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1160 y Replace 置換する |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1161 n Do not replace 置換しない |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1162 ! Replace All w/o query 残る全部を確認なしで置換 |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1163 r Enter Recursive-edit 再帰編集モードへ |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1164 q Quit from replacing ここまでで置換をやめる |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1165 |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1166 Don't forget to exit from recursive edit by typing \\[exit-recursive-edit] |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1167 再帰編集に入ったら \\[exit-recursive-edit] で抜け忘れなきよう。" |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1168 (save-window-excursion |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1169 (catch 'exit |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1170 (let*((bufs (YaTeX-yatex-buffer-list)) buf b e |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1171 (oldptn (regexp-quote old)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1172 (sw (selected-window)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1173 (ptn (concat |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1174 "\\(" YaTeX-refcommand-ref-regexp "\\)" |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1175 "\\s *{" oldptn "}")) |
170
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1176 (repface (and (fboundp 'make-overlay) |
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1177 (fboundp 'internal-find-face) |
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1178 (if (internal-find-face 'isearch) 'isearch 'region))) |
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1179 ov |
173
7dc3c2332da5
YaTeX::label: Message for yank should remain.
yuuji@gentei.org
parents:
170
diff
changeset
|
1180 (qmsg "Replace to `%s'? [yn!rq?]") |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1181 continue ch) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1182 (while bufs |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1183 (set-buffer (setq buf (car bufs))) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1184 (save-excursion |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1185 (goto-char (point-min)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1186 (while (re-search-forward ptn nil t) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1187 (goto-char (match-end 1)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1188 (skip-chars-forward " \t\n{") |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1189 (unwind-protect |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1190 (if (and |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1191 (looking-at oldptn) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1192 (setq b (match-beginning 0) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1193 e (match-end 0)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1194 (or continue |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1195 (catch 'query |
170
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1196 (if repface |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1197 (if ov (move-overlay ov b e) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1198 (overlay-put |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1199 (setq ov (make-overlay b e)) |
170
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1200 'face repface))) |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1201 (switch-to-buffer buf) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1202 (while t |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1203 (message qmsg new) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1204 (setq ch (read-char)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1205 (cond |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1206 ((= ch ?q) (throw 'exit t)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1207 ((= ch ?r) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1208 (message |
173
7dc3c2332da5
YaTeX::label: Message for yank should remain.
yuuji@gentei.org
parents:
170
diff
changeset
|
1209 "Don't forget to exit recursive-edit by `%s'" |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1210 (key-description |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1211 (where-is-internal |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1212 'exit-recursive-edit '(keymap) t))) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1213 (sleep-for 2) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1214 (recursive-edit)) |
255
214702e4df54
SPC is the same as `y' like y-or-n-p(YaTeX::label-rename-refs).
HIROSE Yuuji <yuuji@gentei.org>
parents:
254
diff
changeset
|
1215 ((memq ch '(?y ?\ )) (throw 'query t)) |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1216 ((= ch ?!) (throw 'query (setq continue t))) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1217 ((= ch ??) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1218 (describe-function |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1219 'YaTeX::label-rename-refs) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1220 (select-window (get-buffer-window "*Help*")) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1221 (search-forward "----") |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1222 (forward-line 1) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1223 (set-window-start (selected-window) (point)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1224 (sit-for 0) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1225 (select-window sw)) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1226 ((= ch ?n) (throw 'query nil))))))) |
267
388eaa8b695a
Label replacement should be FIXEDCASE.
HIROSE Yuuji <yuuji@gentei.org>
parents:
259
diff
changeset
|
1227 (replace-match new t)) |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1228 (and ov (delete-overlay ov))))) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1229 (setq bufs (cdr bufs))))))) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1230 |
167 | 1231 (defun YaTeX::label (argp &optional labname refname) |
163
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1232 "Read label name and return it with copying \\ref{LABEL-NAME} to kill-ring." |
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1233 (cond |
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1234 ((= argp 1) |
168
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1235 (let*((chmode (boundp (intern-soft "old"))) |
191cffccc912
Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents:
167
diff
changeset
|
1236 (dlab (if chmode old ;if called via YaTeX-change-section (tricky...) |
163
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1237 (YaTeX::ref-default-label))) |
167 | 1238 (label (read-string |
1239 (format "New %s name: " (or labname "label")) | |
1240 (cons dlab 1)))) | |
163
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1241 (if (string< "" label) |
247
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1242 (let ((refstr (format "\\%s{%s}" (or refname "ref") label))) |
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1243 (YaTeX-push-to-kill-ring refstr) |
170
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1244 (and chmode |
269fb1992c2d
YaTeX-change-section: If new string equals to old one, do not change \ref{}-s.
yuuji@gentei.org
parents:
168
diff
changeset
|
1245 (not (equal old label)) |
247
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1246 (YaTeX::label-rename-refs old label)))) |
163
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1247 label)))) |
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1248 |
a521e761f82c
New add-in function YaTeX::label automatically adds \ref{} string to kill-ring.
yuuji@gentei.org
parents:
141
diff
changeset
|
1249 |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1250 (fset 'YaTeX::pageref 'YaTeX::ref) |
80 | 1251 (defun YaTeX::tabref (argp) ; For the style file of IPSJ journal |
1252 (YaTeX::ref | |
1253 argp nil nil | |
1254 (function | |
1255 (lambda () | |
1256 (YaTeX-quick-in-environment-p "table"))))) | |
1257 (defun YaTeX::figref (argp) ; For the style file of IPSJ journal | |
1258 (YaTeX::ref | |
1259 argp nil nil | |
1260 (function | |
1261 (lambda () | |
1262 (YaTeX-quick-in-environment-p "figure"))))) | |
232
b46b927914c8
Add-in for \eqref{} searches only equations.
yuuji@gentei.org
parents:
222
diff
changeset
|
1263 (defun YaTeX::eqref (argp) |
b46b927914c8
Add-in for \eqref{} searches only equations.
yuuji@gentei.org
parents:
222
diff
changeset
|
1264 (YaTeX::ref |
b46b927914c8
Add-in for \eqref{} searches only equations.
yuuji@gentei.org
parents:
222
diff
changeset
|
1265 argp nil nil |
b46b927914c8
Add-in for \eqref{} searches only equations.
yuuji@gentei.org
parents:
222
diff
changeset
|
1266 (function |
b46b927914c8
Add-in for \eqref{} searches only equations.
yuuji@gentei.org
parents:
222
diff
changeset
|
1267 (lambda () |
b46b927914c8
Add-in for \eqref{} searches only equations.
yuuji@gentei.org
parents:
222
diff
changeset
|
1268 (YaTeX-in-math-mode-p))))) |
70 | 1269 |
80 | 1270 (defun YaTeX::cite-collect-bibs-external (bibptn &rest files) |
1271 "Collect bibentry from FILES(variable length argument) ; | |
70 | 1272 and print them to standard output." |
1273 ;;Thanks; http://icarus.ilcs.hokudai.ac.jp/comp/biblio.html | |
80 | 1274 (let*((tb (get-buffer-create " *bibtmp*")) |
1275 (bibitemsep "^\\s *@[A-Za-z]") | |
1276 (target (if (string< "" bibptn) bibptn bibitemsep)) | |
1277 (checkrx (concat "\\(" bibptn "\\)\\|" bibitemsep)) | |
1278 beg | |
1279 (searchnext | |
1280 (if (string< "" bibptn) | |
1281 (function | |
1282 (lambda() | |
1283 (setq beg (point)) | |
1284 (and | |
1285 (prog1 | |
1286 (re-search-forward target nil t) | |
1287 (end-of-line)) | |
1288 (re-search-backward bibitemsep beg t)))) | |
1289 (function | |
1290 (lambda() | |
1291 (re-search-forward target nil t))))) | |
1292 ) | |
70 | 1293 (save-excursion |
1294 (set-buffer tb) | |
80 | 1295 (princ (format "%sbegin{thebibliography}\n" YaTeX-ec)) |
70 | 1296 (while files |
1297 (erase-buffer) | |
1298 (cond | |
1299 ((file-exists-p (car files)) | |
1300 (insert-file-contents (car files))) | |
1301 ((file-exists-p (concat (car files) ".bib")) | |
1302 (insert-file-contents (concat (car files) ".bib")))) | |
1303 (save-excursion | |
1304 (goto-char (point-min)) | |
80 | 1305 (while (funcall searchnext) |
70 | 1306 (skip-chars-forward "^{,") |
80 | 1307 (setq beg (point)) |
70 | 1308 (if (= (char-after (point)) ?{) |
1309 (princ (format "%sbibitem{%s}%s\n" | |
1310 YaTeX-ec | |
1311 (buffer-substring | |
1312 (1+ (point)) | |
1313 (progn (skip-chars-forward "^,\n") | |
1314 (point))) | |
80 | 1315 (mapconcat |
1316 (function | |
1317 (lambda (kwd) | |
1318 (goto-char beg) | |
1319 (if (re-search-forward | |
1320 (concat kwd "\\s *=") nil t) | |
1321 (buffer-substring | |
1322 (progn | |
1323 (goto-char (match-end 0)) | |
1324 (skip-chars-forward " \t\n") | |
1325 (point)) | |
1326 (progn | |
1327 (if (looking-at "[{\"]") | |
1328 (forward-sexp 1) | |
1329 (forward-char 1) | |
1330 (skip-chars-forward "^,}")) | |
1331 (point)))))) | |
1332 '("author" "year" "title" ) | |
1333 ";")))) | |
1334 (and (re-search-forward bibitemsep nil t) | |
1335 (forward-line -1)))) | |
1336 (setq files (cdr files))) | |
1337 (princ (format "%sbegin{thebibliography}\n" YaTeX-ec))))) | |
70 | 1338 |
77 | 1339 (defvar YaTeX::cite-bibitem-macro-regexp "bibitem\\|harvarditem" |
1340 "*Regexp of macro name of bibitem definition") | |
1341 | |
80 | 1342 (defun YaTeX::cite-collect-bibs-internal (bibptn) |
70 | 1343 "Collect bibentry in the current buffer and print them to standard output." |
77 | 1344 (let ((ptn (concat YaTeX-ec-regexp |
1345 "\\(" YaTeX::cite-bibitem-macro-regexp "\\)\\b")) | |
80 | 1346 (lim (concat YaTeX-ec-regexp |
1347 "\\(" YaTeX::cite-bibitem-macro-regexp "\\b\\)" | |
1348 "\\|\\(end{\\)")) | |
70 | 1349 (pcnt (regexp-quote YaTeX-comment-prefix))) |
80 | 1350 ;; Using bibptn not yet implemented. |
1351 ;; Do you need it?? 2005/11/22 | |
70 | 1352 (save-excursion |
1353 (while (YaTeX-re-search-active-forward ptn pcnt nil t) | |
1354 (skip-chars-forward "^{\n") | |
1355 (or (eolp) | |
80 | 1356 (princ (format "%sbibitem%s %s\n" |
70 | 1357 YaTeX-ec |
1358 (buffer-substring | |
80 | 1359 (point) |
1360 (progn (forward-sexp 1) (point))) | |
1361 (buffer-substring | |
1362 (progn (skip-chars-forward "\n \t") (point)) | |
1363 (save-excursion | |
1364 (if (YaTeX-re-search-active-forward | |
1365 lim pcnt nil t) | |
1366 (progn | |
1367 (goto-char (match-beginning 0)) | |
1368 (skip-chars-backward "\n \t") | |
1369 (point)) | |
1370 (point-end-of-line))))))))))) | |
70 | 1371 |
80 | 1372 (defun YaTeX::cite (argp &rest dummy) |
48 | 1373 (cond |
1374 ((eq argp 1) | |
70 | 1375 (let* ((cb (current-buffer)) |
1376 (f (file-name-nondirectory buffer-file-name)) | |
1377 (d default-directory) | |
1378 (hilit-auto-highlight nil) | |
1379 (pcnt (regexp-quote YaTeX-comment-prefix)) | |
1380 (bibrx (concat YaTeX-ec-regexp "bibliography{\\([^}]+\\)}")) | |
80 | 1381 (bibptn (read-string "Pattern: ")) |
70 | 1382 (bbuf (get-buffer-create " *bibitems*")) |
1383 (standard-output bbuf) | |
80 | 1384 (me 'YaTeX::cite) ;shuld set this for using YaTeX::ref |
70 | 1385 bibs files) |
1386 (set-buffer bbuf)(erase-buffer)(set-buffer cb) | |
1387 (save-excursion | |
1388 (goto-char (point-min)) | |
1389 ;;(1)search external bibdata | |
1390 (while (YaTeX-re-search-active-forward bibrx pcnt nil t) | |
1391 (apply 'YaTeX::cite-collect-bibs-external | |
80 | 1392 bibptn |
70 | 1393 (YaTeX-split-string |
1394 (YaTeX-match-string 1) ","))) | |
1395 ;;(2)search direct \bibitem usage | |
80 | 1396 (YaTeX::cite-collect-bibs-internal bibptn) |
70 | 1397 (if (progn |
1398 (YaTeX-visit-main t) | |
1399 (not (eq (current-buffer) cb))) | |
1400 (save-excursion | |
1401 (goto-char (point-min)) | |
1402 ;;(1)search external bibdata | |
1403 (while (YaTeX-re-search-active-forward bibrx pcnt nil t) | |
1404 (apply 'YaTeX::cite-collect-bibs-external | |
80 | 1405 bibptn |
70 | 1406 (YaTeX-split-string |
1407 (YaTeX-match-string 1) ","))) | |
1408 ;;(2)search internal | |
80 | 1409 (YaTeX::cite-collect-bibs-internal bibptn))) |
70 | 1410 ;;Now bbuf holds the list of bibitem |
1411 (set-buffer bbuf) | |
80 | 1412 ;;;(switch-to-buffer bbuf) |
1413 (if (fboundp 'font-lock-fontify-buffer) (font-lock-fontify-buffer)) | |
77 | 1414 (YaTeX::ref |
1415 argp | |
1416 (concat "\\\\\\(" | |
1417 YaTeX::cite-bibitem-macro-regexp | |
1418 "\\)\\(\\[.*\\]\\)?") | |
1419 "cite")))) | |
1420 | |
48 | 1421 (t nil))) |
11 | 1422 |
167 | 1423 (defun YaTeX::bibitem (argp) |
1424 "Add-in function to insert argument of \\bibitem." | |
1425 (YaTeX::label argp "label" "cite")) | |
1426 | |
77 | 1427 ;;; for Harvard citation style |
1428 (fset 'YaTeX::citeasnoun 'YaTeX::cite) | |
1429 (fset 'YaTeX::possessivecite 'YaTeX::cite) | |
1430 (fset 'YaTeX::citeyear 'YaTeX::cite) | |
1431 (fset 'YaTeX::citename 'YaTeX::cite) | |
80 | 1432 (fset 'YaTeX::citep 'YaTeX::cite) |
1433 (fset 'YaTeX::citet 'YaTeX::cite) | |
70 | 1434 |
48 | 1435 (defun YaTeX-select-other-yatex-buffer () |
1436 "Select buffer from all yatex-mode's buffers interactivelly." | |
1437 (interactive) | |
1438 (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list)) | |
1439 (lnum -1) buf rv | |
11 | 1440 (ff "**find-file**")) |
12 | 1441 (YaTeX-showup-buffer |
1442 lbuf (function (lambda (x) 1))) ;;Select next window surely. | |
69 | 1443 (save-excursion |
1444 (set-buffer (get-buffer lbuf)) | |
1445 (setq buffer-read-only nil) | |
1446 (erase-buffer)) | |
1447 (let ((standard-output (get-buffer lbuf))) | |
11 | 1448 (while blist |
48 | 1449 (princ |
1450 (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A) | |
1451 (buffer-name (car blist)))) | |
11 | 1452 (setq blist (cdr blist))) |
1453 (princ (format "':{%s}" ff))) | |
59 | 1454 (YaTeX-showup-buffer lbuf nil t) |
11 | 1455 (YaTeX::label-setup-key-map) |
1456 (setq buffer-read-only t) | |
1457 (use-local-map YaTeX-label-select-map) | |
1458 (message YaTeX-label-guide-msg) | |
1459 (unwind-protect | |
1460 (progn | |
1461 (recursive-edit) | |
1462 (set-buffer lbuf) | |
1463 (beginning-of-line) | |
1464 (setq rv | |
1465 (if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t) | |
1466 (buffer-substring (match-beginning 1) (match-end 1)) nil))) | |
1467 (kill-buffer lbuf)) | |
48 | 1468 (if (string= rv ff) |
1469 (progn | |
1470 (call-interactively 'find-file) | |
1471 (current-buffer)) | |
69 | 1472 rv))) |
48 | 1473 |
1474 (defun YaTeX-label-other () | |
1475 (let ((rv (YaTeX-select-other-yatex-buffer))) | |
11 | 1476 (cond |
1477 ((null rv) "") | |
1478 (t | |
1479 (set-buffer rv) | |
80 | 1480 (funcall me argp labelcmd refcmd))))) |
11 | 1481 |
13 | 1482 ;; |
1483 ; completion for the arguments of \newcommand | |
1484 ;; | |
1485 (defun YaTeX::newcommand (&optional argp) | |
1486 (cond | |
1487 ((= argp 1) | |
1488 (let ((command (read-string "Define newcommand: " "\\"))) | |
1489 (put 'YaTeX::newcommand 'command (substring command 1)) | |
1490 command)) | |
1491 ((= argp 2) | |
1492 (let ((argc | |
1493 (string-to-int (read-string "Number of arguments(Default 0): "))) | |
1494 (def (read-string "Definition: ")) | |
1495 (command (get 'YaTeX::newcommand 'command))) | |
1496 ;;!!! It's illegal to insert string in the add-in function !!! | |
1497 (if (> argc 0) (insert (format "[%d]" argc))) | |
1498 (if (and (stringp command) | |
1499 (string< "" command) | |
51 | 1500 (y-or-n-p "Update dictionary?")) |
18 | 1501 (cond |
1502 ((= argc 0) | |
1503 (YaTeX-update-table | |
1504 (list command) | |
1505 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table)) | |
1506 ((= argc 1) | |
1507 (YaTeX-update-table | |
1508 (list command) | |
1509 'section-table 'user-section-table 'tmp-section-table)) | |
1510 (t (YaTeX-update-table | |
1511 (list command argc) | |
1512 'section-table 'user-section-table 'tmp-section-table)))) | |
13 | 1513 (message "") |
1514 def ;return command name | |
1515 )) | |
69 | 1516 (t ""))) |
13 | 1517 |
80 | 1518 (defun YaTeX::newcounter (&optional argp) |
1519 (cond | |
1520 ((= argp 1) | |
1521 (read-string "New counter name: ")) | |
1522 (t ""))) | |
1523 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1524 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1525 ; completion for the arguments of \pagestyle |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1526 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1527 (defun YaTeX::pagestyle (&optional argp) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1528 "Read the pagestyle with completion." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1529 (completing-read |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1530 "Page style: " |
69 | 1531 '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil))) |
1532 | |
51 | 1533 (fset 'YaTeX::thispagestyle 'YaTeX::pagestyle) |
1534 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1535 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1536 ; completion for the arguments of \pagenumbering |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1537 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1538 (defun YaTeX::pagenumbering (&optional argp) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1539 "Read the numbering style." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1540 (completing-read |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1541 "Page numbering style: " |
69 | 1542 '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman")))) |
13 | 1543 |
23 | 1544 ;; |
1545 ; Length | |
1546 ;; | |
1547 (defvar YaTeX:style-parameters-default | |
1548 '(("\\arraycolsep") | |
1549 ("\\arrayrulewidth") | |
1550 ("\\baselineskip") | |
1551 ("\\columnsep") | |
1552 ("\\columnseprule") | |
1553 ("\\doublerulesep") | |
1554 ("\\evensidemargin") | |
1555 ("\\footheight") | |
1556 ("\\footskip") | |
1557 ("\\headheight") | |
1558 ("\\headsep") | |
1559 ("\\itemindent") | |
1560 ("\\itemsep") | |
1561 ("\\labelsep") | |
1562 ("\\labelwidth") | |
1563 ("\\leftmargin") | |
1564 ("\\linewidth") | |
1565 ("\\listparindent") | |
1566 ("\\marginparsep") | |
1567 ("\\marginparwidth") | |
1568 ("\\mathindent") | |
1569 ("\\oddsidemargin") | |
1570 ("\\parindent") | |
1571 ("\\parsep") | |
1572 ("\\parskip") | |
1573 ("\\partopsep") | |
1574 ("\\rightmargin") | |
1575 ("\\tabcolsep") | |
1576 ("\\textheight") | |
1577 ("\\textwidth") | |
1578 ("\\topmargin") | |
1579 ("\\topsep") | |
1580 ("\\topskip") | |
1581 ) | |
1582 "Alist of LaTeX style parameters.") | |
1583 (defvar YaTeX:style-parameters-private nil | |
1584 "*User definable alist of style parameters.") | |
49 | 1585 (defvar YaTeX:style-parameters-local nil |
1586 "*User definable alist of local style parameters.") | |
23 | 1587 |
1588 (defvar YaTeX:length-history nil "Holds history of length.") | |
51 | 1589 (put 'YaTeX:length-history 'no-default t) |
23 | 1590 (defun YaTeX::setlength (&optional argp) |
1591 "YaTeX add-in function for arguments of \\setlength." | |
1592 (cond | |
1593 ((equal 1 argp) | |
49 | 1594 ;;(completing-read "Length variable: " YaTeX:style-parameters nil nil "\\") |
1595 (YaTeX-cplread-with-learning | |
1596 "Length variable: " | |
1597 'YaTeX:style-parameters-default | |
1598 'YaTeX:style-parameters-private | |
1599 'YaTeX:style-parameters-local | |
1600 nil nil "\\") | |
1601 ) | |
23 | 1602 ((equal 2 argp) |
69 | 1603 (read-string-with-history "Length: " nil 'YaTeX:length-history)))) |
1604 | |
23 | 1605 (fset 'YaTeX::addtolength 'YaTeX::setlength) |
1606 | |
1607 (defun YaTeX::settowidth (&optional argp) | |
1608 "YaTeX add-in function for arguments of \\settowidth." | |
1609 (cond | |
1610 ((equal 1 argp) | |
49 | 1611 (YaTeX-cplread-with-learning |
1612 "Length variable: " | |
1613 'YaTeX:style-parameters-default | |
1614 'YaTeX:style-parameters-private | |
1615 'YaTeX:style-parameters-local | |
1616 nil nil "\\")) | |
23 | 1617 ((equal 2 argp) |
69 | 1618 (read-string "Text: ")))) |
1619 | |
23 | 1620 (defun YaTeX::newlength (&optional argp) |
1621 "YaTeX add-in function for arguments of \\newlength" | |
1622 (cond | |
1623 ((equal argp 1) | |
1624 (let ((length (read-string "Length variable: " "\\"))) | |
49 | 1625 (if (string< "" length) |
1626 (YaTeX-update-table | |
1627 (list length) | |
1628 'YaTeX:style-parameters-default | |
1629 'YaTeX:style-parameters-private | |
1630 'YaTeX:style-parameters-local)) | |
69 | 1631 length)))) |
23 | 1632 |
1633 ;; \multicolumn's arguments | |
1634 (defun YaTeX::multicolumn (&optional argp) | |
1635 "YaTeX add-in function for arguments of \\multicolumn." | |
1636 (cond | |
1637 ((equal 1 argp) | |
1638 (read-string "Number of columns: ")) | |
1639 ((equal 2 argp) | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1640 (YaTeX:read-oneof "|lrc" nil t)) |
23 | 1641 ((equal 3 argp) |
69 | 1642 (read-string "Item: ")))) |
23 | 1643 |
49 | 1644 (defvar YaTeX:documentstyles-default |
1645 '(("article") ("jarticle") ("j-article") | |
1646 ("book") ("jbook") ("j-book") | |
1647 ("report") ("jreport") ("j-report") | |
1648 ("letter") ("ascjletter")) | |
1649 "List of LaTeX documentstyles.") | |
1650 (defvar YaTeX:documentstyles-private nil | |
1651 "*User defined list of LaTeX documentstyles.") | |
1652 (defvar YaTeX:documentstyles-local nil | |
1653 "*User defined list of local LaTeX documentstyles.") | |
1654 (defvar YaTeX:documentstyle-options-default | |
1655 '(("a4j") ("a5j") ("b4j") ("b5j") | |
1656 ("twocolumn") ("jtwocolumn") ("epsf") ("epsfig") ("epsbox") ("nfig")) | |
1657 "List of LaTeX documentstyle options.") | |
1658 (defvar YaTeX:documentstyle-options-private nil | |
1659 "*User defined list of LaTeX documentstyle options.") | |
1660 (defvar YaTeX:documentstyle-options-local nil | |
1661 "List of LaTeX local documentstyle options.") | |
1662 | |
1663 (defun YaTeX:documentstyle () | |
1664 (let*((delim ",") | |
1665 (dt (append YaTeX:documentstyle-options-local | |
1666 YaTeX:documentstyle-options-private | |
1667 YaTeX:documentstyle-options-default)) | |
1668 (minibuffer-completion-table dt) | |
1669 (opt (read-from-minibuffer | |
1670 "Style options ([opt1,opt2,...]): " | |
51 | 1671 nil YaTeX-minibuffer-completion-map nil)) |
49 | 1672 (substr opt) o) |
1673 (if (string< "" opt) | |
1674 (progn | |
1675 (while substr | |
1676 (setq o (substring substr 0 (string-match delim substr))) | |
1677 (or (assoc o dt) | |
1678 (YaTeX-update-table | |
1679 (list o) | |
1680 'YaTeX:documentstyle-options-default | |
1681 'YaTeX:documentstyle-options-private | |
1682 'YaTeX:documentstyle-options-local)) | |
1683 (setq substr | |
1684 (if (string-match delim substr) | |
1685 (substring substr (1+ (string-match delim substr)))))) | |
1686 (concat "[" opt "]")) | |
1687 ""))) | |
1688 | |
1689 (defun YaTeX::documentstyle (&optional argp) | |
51 | 1690 "YaTeX add-in function for arguments of \\documentstyle." |
49 | 1691 (cond |
1692 ((equal argp 1) | |
72 | 1693 (setq YaTeX-env-name "document") |
49 | 1694 (let ((sname |
1695 (YaTeX-cplread-with-learning | |
1696 (format "Documentstyle (default %s): " | |
1697 YaTeX-default-document-style) | |
1698 'YaTeX:documentstyles-default | |
1699 'YaTeX:documentstyles-private | |
1700 'YaTeX:documentstyles-local))) | |
1701 (if (string= "" sname) (setq sname YaTeX-default-document-style)) | |
69 | 1702 (setq YaTeX-default-document-style sname))))) |
49 | 1703 |
80 | 1704 (defun YaTeX::include (argp &optional prompt) |
86 | 1705 "Read file name setting default directory to that of main file." |
80 | 1706 (cond |
1707 ((= argp 1) | |
86 | 1708 (save-excursion |
1709 (YaTeX-visit-main t) | |
1710 (let*((insert-default-directory) | |
1711 (file (read-file-name (or prompt "Input file: ") ""))) | |
1712 (setq file (substring file 0 (string-match "\\.tex$" file)))))))) | |
80 | 1713 |
1714 (fset 'YaTeX::input 'YaTeX::include) | |
1715 | |
1716 | |
57 | 1717 ;;; -------------------- LaTeX2e stuff -------------------- |
1718 (defvar YaTeX:documentclass-options-default | |
70 | 1719 '(("a4paper") ("a5paper") ("b4paper") ("b5paper") ("10pt") ("11pt") ("12pt") |
57 | 1720 ("latterpaper") ("legalpaper") ("executivepaper") ("landscape") |
1721 ("oneside") ("twoside") ("draft") ("final") ("leqno") ("fleqn") ("openbib") | |
70 | 1722 ("tombow") ("titlepage") ("notitlepage") ("dvips") |
175
6e959a05ae19
Add `jsarticle' and `jsbook' to YaTeX:documentclasses-default.
yuuji@gentei.org
parents:
173
diff
changeset
|
1723 ("mingoth") ;for jsarticle |
57 | 1724 ("clock") ;for slides class only |
1725 ) | |
1726 "Default options list for documentclass") | |
1727 (defvar YaTeX:documentclass-options-private nil | |
1728 "*User defined options list for documentclass") | |
1729 (defvar YaTeX:documentclass-options-local nil | |
1730 "*User defined options list for local documentclass") | |
1731 | |
1732 (defun YaTeX:documentclass () | |
1733 (let*((delim ",") | |
1734 (dt (append YaTeX:documentclass-options-local | |
1735 YaTeX:documentclass-options-private | |
1736 YaTeX:documentclass-options-default)) | |
1737 (minibuffer-completion-table dt) | |
1738 (opt (read-from-minibuffer | |
1739 "Documentclass options ([opt1,opt2,...]): " | |
1740 nil YaTeX-minibuffer-completion-map nil)) | |
1741 (substr opt) o) | |
1742 (if (string< "" opt) | |
1743 (progn | |
1744 (while substr | |
70 | 1745 |
57 | 1746 (setq o (substring substr 0 (string-match delim substr))) |
1747 (or (assoc o dt) | |
1748 (YaTeX-update-table | |
1749 (list o) | |
1750 'YaTeX:documentclass-options-default | |
1751 'YaTeX:documentclass-options-private | |
1752 'YaTeX:documentclass-options-local)) | |
1753 (setq substr | |
1754 (if (string-match delim substr) | |
1755 (substring substr (1+ (string-match delim substr)))))) | |
1756 (concat "[" opt "]")) | |
1757 ""))) | |
1758 | |
1759 (defvar YaTeX:documentclasses-default | |
1760 '(("article") ("jarticle") ("report") ("jreport") ("book") ("jbook") | |
175
6e959a05ae19
Add `jsarticle' and `jsbook' to YaTeX:documentclasses-default.
yuuji@gentei.org
parents:
173
diff
changeset
|
1761 ("jsarticle") ("jsbook") |
57 | 1762 ("j-article") ("j-report") ("j-book") |
1763 ("letter") ("slides") ("ltxdoc") ("ltxguide") ("ltnews") ("proc")) | |
1764 "Default documentclass alist") | |
1765 (defvar YaTeX:documentclasses-private nil | |
1766 "*User defined documentclass alist") | |
1767 (defvar YaTeX:documentclasses-local nil | |
1768 "*User defined local documentclass alist") | |
1769 (defvar YaTeX-default-documentclass (if YaTeX-japan "jarticle" "article") | |
1770 "*Default documentclass") | |
1771 | |
1772 (defun YaTeX::documentclass (&optional argp) | |
1773 (cond | |
1774 ((equal argp 1) | |
72 | 1775 (setq YaTeX-env-name "document") |
57 | 1776 (let ((sname |
1777 (YaTeX-cplread-with-learning | |
1778 (format "Documentclass (default %s): " YaTeX-default-documentclass) | |
1779 'YaTeX:documentclasses-default | |
1780 'YaTeX:documentclasses-private | |
1781 'YaTeX:documentclasses-local))) | |
1782 (if (string= "" sname) (setq sname YaTeX-default-documentclass)) | |
252
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1783 (setq YaTeX-section-name "title" |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1784 YaTeX-default-documentclass sname))))) |
57 | 1785 |
249 | 1786 (defun YaTeX::title (&optional argp) |
1787 (prog1 (read-string "Document Title: ") | |
1788 (setq YaTeX-section-name "author" | |
1789 YaTeX-single-command "maketitle"))) | |
1790 | |
1791 (defun YaTeX::author (&optional argp) | |
1792 (prog1 (read-string "Document Author: ") | |
1793 (setq YaTeX-section-name "date" | |
1794 YaTeX-single-command "maketitle"))) | |
1795 | |
252
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1796 (defun YaTeX:document () |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1797 (setq YaTeX-section-name |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1798 (if (string-match "book\\|bk" YaTeX-default-documentclass) |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1799 "chapter" |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1800 "section")) |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1801 "") |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1802 |
73fef09ebc15
Completion relay: documentclass -> title, document -> section.
HIROSE Yuuji <yuuji@gentei.org>
parents:
249
diff
changeset
|
1803 |
70 | 1804 (defvar YaTeX:latex2e-named-color-alist |
1805 '(("GreenYellow") ("Yellow") ("Goldenrod") ("Dandelion") ("Apricot") | |
1806 ("Peach") ("Melon") ("YellowOrange") ("Orange") ("BurntOrange") | |
1807 ("Bittersweet") ("RedOrange") ("Mahogany") ("Maroon") ("BrickRed") | |
1808 ("Red") ("OrangeRed") ("RubineRed") ("WildStrawberry") ("Salmon") | |
1809 ("CarnationPink") ("Magenta") ("VioletRed") ("Rhodamine") ("Mulberry") | |
1810 ("RedViolet") ("Fuchsia") ("Lavender") ("Thistle") ("Orchid")("DarkOrchid") | |
1811 ("Purple") ("Plum") ("Violet") ("RoyalPurple") ("BlueViolet") | |
1812 ("Periwinkle") ("CadetBlue") ("CornflowerBlue") ("MidnightBlue") | |
1813 ("NavyBlue") ("RoyalBlue") ("Blue") ("Cerulean") ("Cyan") ("ProcessBlue") | |
1814 ("SkyBlue") ("Turquoise") ("TealBlue") ("Aquamarine") ("BlueGreen") | |
1815 ("Emerald") ("JungleGreen") ("SeaGreen") ("Green") ("ForestGreen") | |
1816 ("PineGreen") ("LimeGreen") ("YellowGreen") ("SpringGreen") ("OliveGreen") | |
1817 ("RawSienna") ("Sepia") ("Brown") ("Tan") ("Gray") ("Black") ("White")) | |
141 | 1818 "Colors defined in $TEXMF/tex/plain/dvips/colordvi.tex") |
70 | 1819 |
1820 (defvar YaTeX:latex2e-basic-color-alist | |
1821 '(("black") ("white") ("red") ("blue") ("yellow") ("green") ("cyan") | |
1822 ("magenta")) | |
1823 "Basic colors") | |
1824 | |
1825 (defun YaTeX:textcolor () | |
1826 "Add-in for \\color's option" | |
1827 (if (y-or-n-p "Use `named' color? ") | |
1828 "[named]")) | |
1829 | |
1830 (defun YaTeX::color-completing-read (prompt) | |
1831 (let ((completion-ignore-case t) | |
1832 (namedp (save-excursion | |
1833 (skip-chars-backward "^\n\\[\\\\") | |
1834 (looking-at "named")))) | |
1835 (completing-read | |
1836 prompt | |
1837 (if namedp | |
1838 YaTeX:latex2e-named-color-alist | |
1839 YaTeX:latex2e-basic-color-alist) | |
1840 nil t))) | |
1841 | |
1842 (defun YaTeX::textcolor (argp) | |
1843 "Add-in for \\color's argument" | |
1844 (cond | |
1845 ((= argp 1) (YaTeX::color-completing-read "Color: ")) | |
1846 ((= argp 2) (read-string "Colored string: ")))) | |
1847 | |
1848 (fset 'YaTeX:color 'YaTeX:textcolor) | |
1849 (fset 'YaTeX::color 'YaTeX::textcolor) | |
1850 (fset 'YaTeX:colorbox 'YaTeX:textcolor) | |
1851 (fset 'YaTeX::colorbox 'YaTeX::textcolor) | |
1852 (fset 'YaTeX:fcolorbox 'YaTeX:textcolor) | |
80 | 1853 (fset 'YaTeX:pagecolor 'YaTeX:textcolor) |
1854 (fset 'YaTeX::pagecolor 'YaTeX::textcolor) | |
70 | 1855 |
1856 (defun YaTeX::fcolorbox (argp) | |
1857 (cond | |
1858 ((= argp 1) (YaTeX::color-completing-read "Frame color: ")) | |
1859 ((= argp 2) (YaTeX::color-completing-read "Inner color: ")) | |
1860 ((= argp 3) (read-string "Colored string: ")))) | |
1861 | |
1862 (defun YaTeX:scalebox () | |
80 | 1863 "Add-in for \\scalebox" |
1864 (let ((vmag (read-string | |
1865 (if YaTeX-japan "倍率(負で反転): " | |
1866 "Magnification(Negative for flipped): "))) | |
1867 (hmag (read-string (if YaTeX-japan "縦倍率(省略可): " | |
1868 "Vertical magnification(Optional): ")))) | |
70 | 1869 (if (and hmag (string< "" hmag)) |
1870 (format "{%s}[%s]" vmag hmag) | |
1871 (format "{%s}" vmag)))) | |
1872 | |
80 | 1873 (defun YaTeX:rotatebox () |
1874 "Optional argument add-in for \\rotatebox" | |
1875 (message "Rotate origin? (N)one (O)rigin (X)-Y: ") | |
1876 (let ((c (read-char)) r (defx "x=mm") x (defy "y=mm") y something) | |
1877 (cond | |
1878 ((memq c '(?O ?o)) | |
1879 (if (string< "" (setq r (YaTeX:read-oneof "htbpB"))) | |
1880 (concat "[origin=" r "]"))) | |
1881 ((memq c '(?X ?x ?Y ?y)) | |
1882 (setq r (read-string "" (if YaTeX-emacs-19 (cons defx 3) defx)) | |
1883 x (if (string< "x=" r) r) | |
1884 r (read-string "" (if YaTeX-emacs-19 (cons defy 3) defy)) | |
1885 y (if (string< "y=" r) r) | |
1886 something (or x y)) | |
1887 (format "%s%s%s%s%s" | |
1888 (if something "[" "") | |
1889 (if x x "") | |
1890 (if (and x y) "," "") | |
1891 (if y y "") | |
1892 (if something "]" "")))))) | |
1893 | |
1894 (defun YaTeX::rotatebox (argp) | |
1895 "Argument add-in for \\rotatebox" | |
1896 (cond | |
1897 ((= argp 1) | |
1898 (read-string (if YaTeX-japan "回転角(度; 左回り): " | |
1899 "Angle in degree(unclockwise): "))) | |
1900 ((= argp 2) | |
1901 (read-string (if YaTeX-japan "テキスト: " "Text: "))))) | |
1902 | |
73 | 1903 (defun YaTeX:includegraphics () |
1904 "Add-in for \\includegraphics's option" | |
1905 (let (width height (scale "") angle str) | |
237
af1e6c48eac0
YaTeX-skip-next-reader-p turns to YaTeX-read-string-or-skip.
yuuji@gentei.org
parents:
234
diff
changeset
|
1906 (setq width (YaTeX-read-string-or-skip "Width: ") |
af1e6c48eac0
YaTeX-skip-next-reader-p turns to YaTeX-read-string-or-skip.
yuuji@gentei.org
parents:
234
diff
changeset
|
1907 height (YaTeX-read-string-or-skip "Height: ")) |
254
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1908 (or (string< "" width) (string< "" height) |
237
af1e6c48eac0
YaTeX-skip-next-reader-p turns to YaTeX-read-string-or-skip.
yuuji@gentei.org
parents:
234
diff
changeset
|
1909 (setq scale (YaTeX-read-string-or-skip "Scale: "))) |
af1e6c48eac0
YaTeX-skip-next-reader-p turns to YaTeX-read-string-or-skip.
yuuji@gentei.org
parents:
234
diff
changeset
|
1910 (setq angle (YaTeX-read-string-or-skip "Angle(0-359): ")) |
73 | 1911 (setq str |
1912 (mapconcat | |
1913 'concat | |
1914 (delq nil | |
1915 (mapcar '(lambda (s) | |
1916 (and (stringp (symbol-value s)) | |
1917 (string< "" (symbol-value s)) | |
1918 (format "%s=%s" s (symbol-value s)))) | |
1919 '(width height scale angle))) | |
1920 ",")) | |
1921 (if (string= "" str) "" | |
1922 (concat "[" str "]")))) | |
1923 | |
70 | 1924 (defun YaTeX::includegraphics (argp) |
1925 "Add-in for \\includegraphics" | |
247
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1926 (let ((imgfile (YaTeX::include argp "Image File: ")) |
254
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1927 (case-fold-search t) info bb noupdate needclose c) |
247
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1928 (and (string-match "\\.\\(jpe?g\\|png\\|gif\\|bmp\\)$" imgfile) |
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1929 (file-exists-p imgfile) |
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1930 (or (fboundp 'yahtml-get-image-info) |
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1931 (progn |
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1932 (load "yahtml" t) (featurep 'yahtml))) ;(require 'yahtml nil t) |
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1933 (setq info (yahtml-get-image-info imgfile)) |
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1934 (car info) ;if has width value |
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1935 (car (cdr info)) ;if has height value |
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1936 (setq bb (format "bb=%d %d %d %d" 0 0 (car info) (car (cdr info)))) |
248
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1937 (save-excursion |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1938 (cond |
254
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1939 ((and (save-excursion |
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1940 (YaTeX-re-search-active-backward |
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1941 "\\\\\\(includegraphics\\)\\|\\(bb=[-+ \t0-9]+\\)" |
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1942 YaTeX-comment-prefix nil t)) |
248
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1943 (match-beginning 2) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1944 (not (setq noupdate (equal (YaTeX-match-string 2) bb))) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1945 (y-or-n-p (format "Update `bb=' line to `%s'?: " bb))) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1946 (message "") |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1947 (replace-match bb)) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1948 (noupdate nil) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1949 ((and (match-beginning 1) |
254
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1950 (prog2 |
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1951 (message "Insert `%s'? Y)es N)o C)yes+`clip': " bb) |
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1952 (memq (setq c (read-char)) '(?y ?Y ?\ ?c ?C)) |
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1953 (message ""))) |
248
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1954 (goto-char (match-end 0)) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1955 (message "") |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1956 (if (looking-at "\\[") (forward-char 1) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1957 (insert-before-markers "[") |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1958 (setq needclose t)) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1959 (insert-before-markers bb) |
254
45ea6e6e5b26
Add-in for \includegraphics offers "clip" option.
HIROSE Yuuji <yuuji@gentei.org>
parents:
252
diff
changeset
|
1960 (if (memq c '(?c ?C)) (insert-before-markers ",clip")) |
248
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1961 (if needclose (insert-before-markers "]") |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1962 (or (looking-at "\\]") (insert-before-markers ",")))) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1963 (t (YaTeX-push-to-kill-ring bb))))) |
b9771459243e
Automatic `bb=...' generation for jpg/png/gif/bmp files.
yuuji@gentei.org
parents:
247
diff
changeset
|
1964 (setq YaTeX-section-name "caption") |
247
3e3ccba06ca1
Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents:
246
diff
changeset
|
1965 imgfile)) |
70 | 1966 |
86 | 1967 (defun YaTeX::verbfile (argp) |
1968 "Add-in for \\verbfile" | |
1969 (YaTeX::include argp "Virbatim File: ")) | |
1970 | |
68 | 1971 (defun YaTeX:caption () |
72 | 1972 (setq YaTeX-section-name "label") |
68 | 1973 nil) |
1974 | |
80 | 1975 |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1976 (defvar YaTeX::usepackage-alist-default |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1977 '(("version") ("plext") ("url") ("fancybox") ("pifont") ("longtable") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1978 ("ascmac") ("bm") ("graphics") ("graphicx") ("alltt") ("misc") ("eclbkbox") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1979 ("amsmath") ("amssymb") ("xymtex") ("chemist") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1980 ("a4j") ("array") ("epsf") ("color") ("epsfig") ("floatfig") |
80 | 1981 ("landscape") ("path") ("supertabular") ("twocolumn") |
1982 ("latexsym") ("times") ("makeidx")) | |
1983 "Default completion table for arguments of \\usepackage") | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1984 |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1985 (defvar YaTeX::usepackage-alist-private nil |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1986 "*Private completion list of the argument for usepackage") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1987 |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1988 (defvar YaTeX::usepackage-alist-local nil |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1989 "Directory local completion list of the argument for usepackage") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1990 |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1991 (defun YaTeX::usepackage (&optional argp) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1992 (cond |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1993 ((equal argp 1) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1994 (setq YaTeX-env-name "document") |
80 | 1995 (let ((minibuffer-local-completion-map YaTeX-minibuffer-completion-map) |
1996 (delim ",")) | |
1997 (YaTeX-cplread-with-learning | |
1998 (if YaTeX-japan "Use package(カンマで区切ってOK): " | |
1999 "Use package(delimitable by comma): ") | |
2000 'YaTeX::usepackage-alist-default | |
2001 'YaTeX::usepackage-alist-private | |
2002 'YaTeX::usepackage-alist-local))))) | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2003 |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2004 (defun YaTeX::mask (argp) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2005 (cond |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2006 ((equal argp 1) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2007 (read-string "String: ")) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2008 ((equal argp 2) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2009 (let (c) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2010 (while (not (memq c '(?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2011 (message "Mask type(A..K): ") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2012 (setq c (upcase (read-char)))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2013 (format "%c" c))))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2014 |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2015 (defun YaTeX::maskbox (argp) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2016 (cond |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2017 ((equal argp 1) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2018 (read-string "Width: ")) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2019 ((equal argp 2) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2020 (read-string "Height: ")) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2021 ((equal argp 3) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2022 (let (c) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2023 (while (not (memq c '(?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2024 (message "Mask type(A..K): ") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2025 (setq c (upcase (read-char)))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2026 (format "%c" c))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2027 ((equal argp 4) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2028 (YaTeX:read-oneof "lcr" 'quick)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2029 ((equal argp 5) |
80 | 2030 (read-string "String: ")))) |
2031 | |
2032 (defun YaTeX::textcircled (argp) | |
2033 (cond | |
2034 ((equal argp 1) | |
2035 (let ((char (read-string "Circled char: ")) | |
2036 (left "") (right "") c) | |
2037 (setq c (read-char | |
2038 "Enclose also with (s)mall (t)iny s(C)riptsize (N)one:")) | |
2039 (cond | |
2040 ((memq c '(?s ?S)) (setq left "{\\small " right "}")) | |
2041 ((memq c '(?t ?T)) (setq left "{\\tiny " right "}")) | |
2042 ((memq c '(?c ?C)) (setq left "{\\scriptsize " right "}"))) | |
2043 (format "%s%s%s" left char right))))) | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2044 |
68 | 2045 ;;; -------------------- math-mode stuff -------------------- |
2046 (defun YaTeX::tilde (&optional pos) | |
2047 "For accent macros in mathmode" | |
2048 (cond | |
2049 ((equal pos 1) | |
2050 (message "Put accent on variable: ") | |
2051 (let ((v (char-to-string (read-char))) (case-fold-search nil)) | |
2052 (message "") | |
2053 (cond | |
2054 ((string-match "i\\|j" v) | |
2055 (concat "\\" v "math")) | |
2056 ((string-match "[\r\n\t ]" v) | |
2057 "") | |
2058 (t v)))) | |
2059 (nil ""))) | |
2060 | |
2061 (fset 'YaTeX::hat 'YaTeX::tilde) | |
2062 (fset 'YaTeX::check 'YaTeX::tilde) | |
2063 (fset 'YaTeX::bar 'YaTeX::tilde) | |
2064 (fset 'YaTeX::dot 'YaTeX::tilde) | |
2065 (fset 'YaTeX::ddot 'YaTeX::tilde) | |
2066 (fset 'YaTeX::vec 'YaTeX::tilde) | |
2067 | |
2068 (defun YaTeX::widetilde (&optional pos) | |
2069 "For multichar accent macros in mathmode" | |
2070 (cond | |
2071 ((equal pos 1) | |
2072 (let ((m "Put over chars[%s ]: ") v v2) | |
2073 (message m " ") | |
2074 (setq v (char-to-string (read-char))) | |
2075 (message "") | |
2076 (if (string-match "[\r\n\t ]" v) | |
2077 "" | |
2078 (message m v) | |
2079 (setq v2 (char-to-string (read-char))) | |
2080 (message "") | |
2081 (if (string-match "[\r\n\t ]" v2) | |
2082 v | |
2083 (concat v v2))))) | |
2084 (nil ""))) | |
2085 | |
2086 (fset 'YaTeX::widehat 'YaTeX::widetilde) | |
2087 (fset 'YaTeX::overline 'YaTeX::widetilde) | |
2088 (fset 'YaTeX::overrightarrow 'YaTeX::widetilde) | |
2089 | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2090 ; |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2091 ; for \frac{}{} region |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2092 (defun YaTeX::frac-region (beg end) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2093 (if (catch 'done |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2094 (while (re-search-forward "\\s *\\(\\\\over\\|/\\)\\s *" end t) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2095 (goto-char (match-beginning 0)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2096 (if (y-or-n-p |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2097 (format "Replace this `%s' with `}{'" (YaTeX-match-string 0))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2098 (throw 'done t)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2099 (goto-char (match-end 0)))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2100 (let (p (b0 (match-beginning 0)) e0) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2101 (replace-match "}{") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2102 (setq e0 (point)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2103 (save-restriction |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2104 (narrow-to-region beg end) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2105 (goto-char e0) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2106 (skip-chars-forward " \t") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2107 (setq p (point)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2108 (YaTeX-goto-corresponding-paren) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2109 (forward-char 1) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2110 (skip-chars-forward " \t\r\n") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2111 (if (= end (1+ (point))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2112 (progn |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2113 (goto-char p) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2114 (if (looking-at "\\\\") (forward-char 1)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2115 (YaTeX-kill-paren nil))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2116 (goto-char beg) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2117 (skip-chars-forward " \t") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2118 (setq p (point)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2119 (YaTeX-goto-corresponding-paren) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2120 (forward-char 1) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2121 (skip-chars-forward " \t\r\n") |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2122 (if (>= (point) b0) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2123 (progn |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2124 (goto-char p) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2125 (if (looking-at "\\\\") (forward-char 1)) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2126 (YaTeX-kill-paren nil)))))) |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
2127 (message "")) |
68 | 2128 |
80 | 2129 (defun YaTeX::DeclareMathOperator (argp) |
2130 (cond | |
2131 ((equal argp 1) | |
2132 (read-string "Operator: " "\\")))) | |
2133 | |
68 | 2134 ;;; |
2135 ;; Add-in functions for large-type command. | |
2136 ;;; | |
2137 (defun YaTeX:em () | |
2138 (cond | |
2139 ((eq YaTeX-current-completion-type 'large) "\\/") | |
2140 (t nil))) | |
2141 (fset 'YaTeX:it 'YaTeX:em) | |
2142 | |
23 | 2143 ;;; -------------------- End of yatexadd -------------------- |
2144 (provide 'yatexadd) | |
72 | 2145 ; Local variables: |
2146 ; fill-prefix: ";;; " | |
2147 ; paragraph-start: "^$\\|\\|;;;$" | |
2148 ; paragraph-separate: "^$\\|\\|;;;$" | |
80 | 2149 ; coding: sjis |
72 | 2150 ; End: |