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