Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexadd.el @ 77:1b172d26b55e
Fix auto-fill movement on Emacs21.
Fix YaTeX:ref.
Support jump/change on AMS-LaTeX's parentheses.
author | yuuji |
---|---|
date | Thu, 01 May 2003 13:38:27 +0000 |
parents | f41b01fef5d6 |
children | 0734be649cb8 |
rev | line source |
---|---|
6 | 1 ;;; -*- Emacs-Lisp -*- |
8 | 2 ;;; YaTeX add-in functions. |
77 | 3 ;;; yatexadd.el rev.15 |
4 ;;; (c )1991-2003 by HIROSE Yuuji.[yuuji@yatex.org] | |
5 ;;; Last modified Mon Mar 17 16:46:01 2003 on serow | |
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) |
59 (defun YaTeX:array () | |
60 (concat (YaTeX:read-position "tb") | |
69 | 61 "{" (read-string "Column format: ") "}")) |
6 | 62 |
23 | 63 (defun YaTeX:read-oneof (oneof) |
64 (let ((pos "") loc (guide "")) | |
65 (and (boundp 'name) name (setq guide (format "%s " name))) | |
6 | 66 (while (not (string-match |
8 | 67 (setq loc (read-key-sequence |
23 | 68 (format "%s position (`%s') [%s]: " |
68 | 69 guide oneof pos));name is in YaTeX-addin |
70 loc (if (fboundp 'events-to-keys) | |
71 (events-to-keys loc) loc)) | |
6 | 72 "\r\^g\n")) |
73 (cond | |
8 | 74 ((string-match loc oneof) |
6 | 75 (if (not (string-match loc pos)) |
76 (setq pos (concat pos loc)))) | |
77 ((and (string-match loc "\C-h\C-?") (> (length pos) 0)) | |
78 (setq pos (substring pos 0 (1- (length pos))))) | |
79 (t | |
80 (ding) | |
8 | 81 (message "Please input one of `%s'." oneof) |
6 | 82 (sit-for 3)))) |
8 | 83 (message "") |
69 | 84 pos)) |
23 | 85 |
86 (defun YaTeX:read-position (oneof) | |
87 "Read a LaTeX (optional) position format such as `[htbp]'." | |
88 (let ((pos (YaTeX:read-oneof oneof))) | |
69 | 89 (if (string= pos "") "" (concat "[" pos "]")))) |
8 | 90 |
91 (defun YaTeX:table () | |
92 "YaTeX add-in function for table environment." | |
73 | 93 (cond |
94 ((eq major-mode 'yatex-mode) | |
95 (setq YaTeX-env-name "tabular" | |
96 YaTeX-section-name "caption") | |
97 (YaTeX:read-position "htbp")) | |
98 ((eq major-mode 'texinfo-mode) | |
99 (concat " " | |
100 (completing-read | |
101 "Highlights with: " | |
102 '(("@samp")("@kbd")("@code")("@asis")("@file")("@var")) | |
103 nil nil "@"))))) | |
6 | 104 |
46 | 105 (fset 'YaTeX:figure 'YaTeX:table) |
106 (fset 'YaTeX:figure* 'YaTeX:table) | |
107 | |
108 | |
6 | 109 (defun YaTeX:description () |
110 "Truly poor service:-)" | |
72 | 111 (setq YaTeX-single-command "item[]") |
69 | 112 "") |
6 | 113 |
114 (defun YaTeX:itemize () | |
115 "It's also poor service." | |
72 | 116 (setq YaTeX-single-command "item") |
69 | 117 "") |
6 | 118 |
119 (fset 'YaTeX:enumerate 'YaTeX:itemize) | |
8 | 120 |
11 | 121 (defun YaTeX:picture () |
122 "Ask the size of coordinates of picture environment." | |
123 (concat (YaTeX:read-coordinates "Picture size") | |
69 | 124 (YaTeX:read-coordinates "Initial position"))) |
11 | 125 |
12 | 126 (defun YaTeX:equation () |
59 | 127 (YaTeX-jmode-off) |
12 | 128 (if (fboundp 'YaTeX-toggle-math-mode) |
69 | 129 (YaTeX-toggle-math-mode t))) ;force math-mode ON. |
130 | |
59 | 131 (mapcar '(lambda (f) (fset f 'YaTeX:equation)) |
132 '(YaTeX:eqnarray YaTeX:eqnarray* YaTeX:align YaTeX:align* | |
133 YaTeX:split YaTeX:multline YaTeX:multline* YaTeX:gather YaTeX:gather* | |
134 YaTeX:aligned* YaTeX:gathered YaTeX:gathered* | |
135 YaTeX:alignat YaTeX:alignat* YaTeX:xalignat YaTeX:xalignat* | |
136 YaTeX:xxalignat YaTeX:xxalignat*)) | |
12 | 137 |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
138 (defun YaTeX:list () |
69 | 139 "%\n{} %default label\n{} %formatting parameter") |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
140 |
18 | 141 (defun YaTeX:minipage () |
142 (concat (YaTeX:read-position "cbt") | |
69 | 143 "{" (read-string "Width: ") "}")) |
18 | 144 |
64 | 145 (defun YaTeX:thebibliography () |
72 | 146 (setq YaTeX-section-name "bibitem") |
77 | 147 (concat "{" (read-string "Longest label: ") "}")) |
64 | 148 |
8 | 149 ;;; |
150 ;;Sample functions for section-type command. | |
151 ;;; | |
152 (defun YaTeX:multiput () | |
153 (concat (YaTeX:read-coordinates "Pos") | |
154 (YaTeX:read-coordinates "Step") | |
69 | 155 "{" (read-string "How many times: ") "}")) |
8 | 156 |
157 (defun YaTeX:put () | |
69 | 158 (YaTeX:read-coordinates "Pos")) |
8 | 159 |
160 (defun YaTeX:makebox () | |
23 | 161 (cond |
162 ((YaTeX-in-environment-p "picture") | |
163 (concat (YaTeX:read-coordinates "Dimension") | |
164 (YaTeX:read-position "lrtb"))) | |
165 (t | |
166 (let ((width (read-string "Width: "))) | |
167 (if (string< "" width) | |
168 (progn | |
169 (or (equal (aref width 0) ?\[) | |
170 (setq width (concat "[" width "]"))) | |
69 | 171 (concat width (YaTeX:read-position "lr")))))))) |
8 | 172 |
173 (defun YaTeX:framebox () | |
174 (if (YaTeX-quick-in-environment-p "picture") | |
69 | 175 (YaTeX:makebox))) |
8 | 176 |
177 (defun YaTeX:dashbox () | |
178 (concat "{" (read-string "Dash dimension: ") "}" | |
69 | 179 (YaTeX:read-coordinates "Dimension"))) |
8 | 180 |
51 | 181 (defvar YaTeX-minibuffer-quick-map nil) |
182 (if YaTeX-minibuffer-quick-map nil | |
183 (setq YaTeX-minibuffer-quick-map | |
184 (copy-keymap minibuffer-local-completion-map)) | |
185 (let ((ch (1+ ? ))) | |
186 (while (< ch 127) | |
187 (define-key YaTeX-minibuffer-quick-map (char-to-string ch) | |
188 'YaTeX-minibuffer-quick-complete) | |
189 (setq ch (1+ ch))))) | |
190 | |
191 (defvar YaTeX:left-right-delimiters | |
192 '(("(" . ")") (")" . "(") ("[" . "]") ("]" . "[") | |
193 ("\\{" . "\\}") ("\\}" . "\\{") ("|") ("\\|") | |
194 ("\\lfloor" . "\\rfloor") ("\\lceil" . "\\rceil") | |
195 ("\\langle" . "\\rangle") ("/") (".") | |
196 ("\\rfloor" . "\\rfloor") ("\\rceil" . "\\lceil") | |
197 ("\\rangle" . "\\langle") ("\\backslash") | |
198 ("\\uparrow") ("\\downarrow") ("\\updownarrow") ("\\Updownarrow")) | |
199 "TeX math delimiter, which can be completed after \\right or \\left.") | |
200 | |
201 (defvar YaTeX:left-right-default nil "Default string of YaTeX:right.") | |
202 | |
23 | 203 (defun YaTeX:left () |
51 | 204 (let ((minibuffer-completion-table YaTeX:left-right-delimiters) |
72 | 205 delimiter (leftp (string= YaTeX-single-command "left"))) |
51 | 206 (setq delimiter |
207 (read-from-minibuffer | |
208 (format "Delimiter%s: " | |
209 (if YaTeX:left-right-default | |
210 (format "(default=`%s')" YaTeX:left-right-default) | |
211 "(SPC for menu)")) | |
212 nil YaTeX-minibuffer-quick-map)) | |
213 (if (string= "" delimiter) (setq delimiter YaTeX:left-right-default)) | |
72 | 214 (setq YaTeX-single-command (if leftp "right" "left") |
51 | 215 YaTeX:left-right-default |
216 (or (cdr (assoc delimiter YaTeX:left-right-delimiters)) delimiter)) | |
217 delimiter)) | |
218 | |
23 | 219 (fset 'YaTeX:right 'YaTeX:left) |
220 | |
51 | 221 |
8 | 222 (defun YaTeX:read-coordinates (&optional mes varX varY) |
223 (concat | |
224 "(" | |
225 (read-string (format "%s %s: " (or mes "Dimension") (or varX "X"))) | |
226 "," | |
227 (read-string (format "%s %s: " (or mes "Dimension") (or varY "Y"))) | |
69 | 228 ")")) |
8 | 229 |
230 ;;; | |
231 ;;Sample functions for maketitle-type command. | |
232 ;;; | |
233 (defun YaTeX:sum () | |
234 "Read range of summation." | |
235 (YaTeX:check-completion-type 'maketitle) | |
69 | 236 (concat (YaTeX:read-boundary "_") (YaTeX:read-boundary "^"))) |
8 | 237 |
238 (fset 'YaTeX:int 'YaTeX:sum) | |
239 | |
240 (defun YaTeX:lim () | |
241 "Insert limit notation of \\lim." | |
242 (YaTeX:check-completion-type 'maketitle) | |
243 (let ((var (read-string "Variable: ")) limit) | |
244 (if (string= "" var) "" | |
245 (setq limit (read-string "Limit ($ means infinity): ")) | |
246 (if (string= "$" limit) (setq limit "\\infty")) | |
69 | 247 (concat "_{" var " \\rightarrow " limit "}")))) |
8 | 248 |
249 (defun YaTeX:gcd () | |
250 "Add-in function for \\gcd(m,n)." | |
251 (YaTeX:check-completion-type 'maketitle) | |
69 | 252 (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)")) |
8 | 253 |
254 (defun YaTeX:read-boundary (ULchar) | |
255 "Read boundary usage by _ or ^. _ or ^ is indicated by argument ULchar." | |
11 | 256 (let ((bndry (read-string (concat ULchar "{???} ($ for infinity): ")))) |
8 | 257 (if (string= bndry "") "" |
11 | 258 (if (string= bndry "$") (setq bndry "\\infty")) |
69 | 259 (concat ULchar "{" bndry "}")))) |
8 | 260 |
14 | 261 (defun YaTeX:verb () |
262 "Enclose \\verb's contents with the same characters." | |
263 (let ((quote-char (read-string "Quoting char: " "|")) | |
264 (contents (read-string "Quoted contents: "))) | |
69 | 265 (concat quote-char contents quote-char))) |
266 | |
23 | 267 (fset 'YaTeX:verb* 'YaTeX:verb) |
14 | 268 |
43
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
269 (defun YaTeX:footnotemark () |
72 | 270 (setq YaTeX-section-name "footnotetext") |
69 | 271 nil) |
43
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
272 |
48 | 273 (defun YaTeX:cite () |
274 (let ((comment (read-string "Comment for citation: "))) | |
275 (if (string= comment "") "" | |
69 | 276 (concat "[" comment "]")))) |
48 | 277 |
278 (defun YaTeX:bibitem () | |
64 | 279 (let ((label (read-string "Citation label for bibitem: "))) |
48 | 280 (if (string= label "") "" |
69 | 281 (concat "[" label "]")))) |
48 | 282 |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
283 (defun YaTeX:item () |
73 | 284 (cond |
285 ((eq major-mode 'yatex-mode) | |
286 (YaTeX-indent-line) | |
287 (setq YaTeX-section-name "label")) | |
288 ((eq major-mode 'texinfo-mode) | |
289 (setq YaTeX-section-name "dots"))) ;?? | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
290 " ") |
52 | 291 (fset 'YaTeX:item\[\] 'YaTeX:item) |
292 (fset 'YaTeX:subitem 'YaTeX:item) | |
293 (fset 'YaTeX:subsubitem 'YaTeX:item) | |
294 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
295 (defun YaTeX:linebreak () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
296 (let (obl) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
297 (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
|
298 (setq obl (char-to-string (read-char))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
299 (if (string-match "[0-4]" obl) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
300 (concat "[" obl "]") |
69 | 301 ""))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
302 (fset 'YaTeX:pagebreak 'YaTeX:linebreak) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
303 |
14 | 304 ;;; |
305 ;;Subroutine | |
306 ;;; | |
307 | |
8 | 308 (defun YaTeX:check-completion-type (type) |
309 "Check valid completion type." | |
310 (if (not (eq type YaTeX-current-completion-type)) | |
69 | 311 (error "This should be completed with %s-type completion." type))) |
11 | 312 |
313 | |
314 ;;; | |
315 ;;; [[Add-in functions for reading section arguments]] | |
316 ;;; | |
317 ;; All of add-in functions for reading sections arguments should | |
318 ;; take an argument ARGP that specify the argument position. | |
319 ;; If argument position is out of range, nil should be returned, | |
320 ;; else nil should NOT be returned. | |
13 | 321 |
322 ;; | |
323 ; Label selection | |
324 ;; | |
11 | 325 (defvar YaTeX-label-menu-other |
326 (if YaTeX-japan "':̃obt@̃x\n" "':LABEL IN OTHER BUFFER.\n")) | |
23 | 327 (defvar YaTeX-label-menu-repeat |
328 (if YaTeX-japan ".:O\\refƓ\n" "/:REPEAT LAST \ref{}\n")) | |
11 | 329 (defvar YaTeX-label-menu-any |
330 (if YaTeX-japan "*:Cӂ̕\n" "*:ANY STRING.\n")) | |
331 (defvar YaTeX-label-buffer "*Label completions*") | |
332 (defvar YaTeX-label-guide-msg "Select label and hit RETURN.") | |
333 (defvar YaTeX-label-select-map nil | |
334 "Key map used in label selection buffer.") | |
335 (defun YaTeX::label-setup-key-map () | |
336 (if YaTeX-label-select-map nil | |
337 (message "Setting up label selection mode map...") | |
68 | 338 ;(setq YaTeX-label-select-map (copy-keymap global-map)) |
339 (setq YaTeX-label-select-map (make-keymap)) | |
11 | 340 (suppress-keymap YaTeX-label-select-map) |
341 (substitute-all-key-definition | |
342 'previous-line 'YaTeX::label-previous YaTeX-label-select-map) | |
343 (substitute-all-key-definition | |
344 'next-line 'YaTeX::label-next YaTeX-label-select-map) | |
345 (define-key YaTeX-label-select-map "\C-n" 'YaTeX::label-next) | |
346 (define-key YaTeX-label-select-map "\C-p" 'YaTeX::label-previous) | |
347 (define-key YaTeX-label-select-map "<" 'beginning-of-buffer) | |
348 (define-key YaTeX-label-select-map ">" 'end-of-buffer) | |
349 (define-key YaTeX-label-select-map "\C-m" 'exit-recursive-edit) | |
350 (define-key YaTeX-label-select-map "\C-j" 'exit-recursive-edit) | |
351 (define-key YaTeX-label-select-map " " 'exit-recursive-edit) | |
352 (define-key YaTeX-label-select-map "\C-g" 'abort-recursive-edit) | |
353 (define-key YaTeX-label-select-map "/" 'isearch-forward) | |
354 (define-key YaTeX-label-select-map "?" 'isearch-backward) | |
355 (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag) | |
23 | 356 (define-key YaTeX-label-select-map "." 'YaTeX::label-search-tag) |
11 | 357 (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag) |
358 (message "Setting up label selection mode map...Done") | |
359 (let ((key ?A)) | |
360 (while (<= key ?Z) | |
361 (define-key YaTeX-label-select-map (char-to-string key) | |
362 'YaTeX::label-search-tag) | |
363 (define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A))) | |
364 'YaTeX::label-search-tag) | |
69 | 365 (setq key (1+ key)))))) |
366 | |
11 | 367 (defun YaTeX::label-next () |
368 (interactive) (forward-line 1) (message YaTeX-label-guide-msg)) | |
369 (defun YaTeX::label-previous () | |
370 (interactive) (forward-line -1) (message YaTeX-label-guide-msg)) | |
371 (defun YaTeX::label-search-tag () | |
372 (interactive) | |
68 | 373 (let ((case-fold-search t) |
374 (tag (regexp-quote (char-to-string last-command-char)))) | |
11 | 375 (cond |
376 ((save-excursion | |
377 (forward-char 1) | |
23 | 378 (re-search-forward (concat "^" tag) nil t)) |
11 | 379 (goto-char (match-beginning 0))) |
380 ((save-excursion | |
381 (goto-char (point-min)) | |
23 | 382 (re-search-forward (concat "^" tag) nil t)) |
11 | 383 (goto-char (match-beginning 0)))) |
69 | 384 (message YaTeX-label-guide-msg))) |
385 | |
70 | 386 ; (defun YaTeX::ref (argp &optional labelcmd refcmd) |
387 ; (cond | |
388 ; ((= argp 1) | |
389 ; (let ((lnum 0) e0 label label-list (buf (current-buffer)) | |
390 ; (labelcmd (or labelcmd "label")) (refcmd (or refcmd "ref")) | |
391 ; (p (point)) initl line cf) | |
392 ; (message "Collecting labels...") | |
393 ; (save-window-excursion | |
394 ; (YaTeX-showup-buffer | |
395 ; YaTeX-label-buffer (function (lambda (x) (window-width x)))) | |
396 ; (if (fboundp 'select-frame) (setq cf (selected-frame))) | |
397 ; (if (eq (window-buffer (minibuffer-window)) buf) | |
398 ; (progn | |
399 ; (other-window 1) | |
400 ; (setq buf (current-buffer)) | |
401 ; (set-buffer buf) | |
402 ; ;(message "cb=%s" buf)(sit-for 3) | |
403 ; )) | |
404 ; (save-excursion | |
405 ; (set-buffer (get-buffer-create YaTeX-label-buffer)) | |
406 ; (setq buffer-read-only nil) | |
407 ; (erase-buffer)) | |
408 ; (save-excursion | |
409 ; (goto-char (point-min)) | |
410 ; (let ((standard-output (get-buffer YaTeX-label-buffer))) | |
411 ; (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf))) | |
412 ; (while (YaTeX-re-search-active-forward | |
413 ; (concat "\\\\" labelcmd "\\b") | |
414 ; (regexp-quote YaTeX-comment-prefix) nil t) | |
415 ; (goto-char (match-beginning 0)) | |
416 ; (skip-chars-forward "^{") | |
417 ; (setq label | |
418 ; (buffer-substring | |
419 ; (1+ (point)) | |
420 ; (prog2 (forward-list 1) (setq e0 (1- (point))))) | |
421 ; label-list (cons label label-list)) | |
422 ; (or initl | |
423 ; (if (< p (point)) (setq initl lnum))) | |
424 ; (beginning-of-line) | |
425 ; (skip-chars-forward " \t\n" nil) | |
426 ; (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label | |
427 ; (buffer-substring (point) (point-end-of-line)))) | |
428 ; (setq lnum (1+ lnum)) | |
429 ; (message "Collecting \\%s{}... %d" labelcmd lnum) | |
430 ; (goto-char e0)) | |
431 ; (princ YaTeX-label-menu-other) | |
432 ; (princ YaTeX-label-menu-repeat) | |
433 ; (princ YaTeX-label-menu-any) | |
434 ; );standard-output | |
435 ; (goto-char p) | |
436 ; (or initl (setq initl lnum)) | |
437 ; (message "Collecting %s...Done" labelcmd) | |
438 ; (if (fboundp 'select-frame) (select-frame cf)) | |
439 ; (YaTeX-showup-buffer YaTeX-label-buffer nil t) | |
440 ; (YaTeX::label-setup-key-map) | |
441 ; (setq truncate-lines t) | |
442 ; (setq buffer-read-only t) | |
443 ; (use-local-map YaTeX-label-select-map) | |
444 ; (message YaTeX-label-guide-msg) | |
445 ; (goto-line (1+ initl)) ;goto recently defined label line | |
446 ; (switch-to-buffer (current-buffer)) | |
447 ; (unwind-protect | |
448 ; (progn | |
449 ; (recursive-edit) | |
450 ; (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion | |
451 ; (beginning-of-line) | |
452 ; (setq line (1- (count-lines (point-min)(point)))) | |
453 ; (cond | |
454 ; ((= line -1) (setq label "")) | |
455 ; ((= line lnum) (setq label (YaTeX-label-other))) | |
456 ; ((= line (1+ lnum)) | |
457 ; (save-excursion | |
458 ; (switch-to-buffer buf) | |
459 ; (goto-char p) | |
460 ; (if (re-search-backward | |
461 ; (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t) | |
462 ; (setq label (YaTeX-match-string 1)) | |
463 ; (setq label "")))) | |
464 ; ((>= line (+ lnum 2)) | |
465 ; (setq label (read-string (format "\\%s{???}: " refcmd)))) | |
466 ; (t (setq label (nth (- lnum line 1) label-list))))) | |
467 ; (bury-buffer YaTeX-label-buffer))) | |
468 ; label))))) | |
469 | |
470 (defun YaTeX::ref-generate-label () | |
471 "Generate a label string which is unique in current buffer." | |
472 (let ((default (substring (current-time-string) 4))) | |
473 (read-string "Give a label for this line: " | |
474 (if YaTeX-emacs-19 (cons default 1) default)))) | |
475 | |
476 (defun YaTeX::ref-getset-label (buffer point) | |
477 "Get label string in the BUFFER near the POINT. | |
478 Make \\label{xx} if no label." | |
73 | 479 ;;Here, we rewrite the LaTeX source. Therefore we should be careful |
480 ;;to decide the location suitable for \label. Do straightforward! | |
481 (let (boundary inspoint cc newlabel (labelholder "label") mathp env | |
482 (r-escape (regexp-quote YaTeX-comment-prefix))) | |
483 ;;(set-buffer buffer) | |
70 | 484 (switch-to-buffer buffer) |
485 (save-excursion | |
486 (goto-char point) | |
487 (setq cc (current-column)) | |
488 (if (= (char-after (point)) ?\\) (forward-char 1)) | |
489 (cond | |
490 ((looking-at YaTeX-sectioning-regexp) | |
491 (skip-chars-forward "^{") | |
492 (forward-list 1) | |
493 (skip-chars-forward " \t\n") | |
73 | 494 ;(setq boundary "[^\\]") |
77 | 495 (setq inspoint (point)) |
73 | 496 (setq boundary |
497 (save-excursion | |
77 | 498 (if (YaTeX-re-search-active-forward |
499 (concat YaTeX-ec-regexp | |
500 "\\(" YaTeX-sectioning-regexp "\\|" | |
501 "begin\\|item\\)") | |
502 r-escape nil 1) | |
73 | 503 (match-beginning 0) |
504 (1- (point)))))) | |
70 | 505 ((looking-at "item\\s ") |
506 (setq cc (+ cc 6)) | |
73 | 507 ;(setq boundary (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b")) |
508 (setq boundary | |
509 (save-excursion | |
510 (if (YaTeX-re-search-active-forward | |
511 (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b") | |
512 r-escape nil 1) | |
513 (match-beginning 0) | |
77 | 514 (1- (point)))) |
515 inspoint boundary)) | |
70 | 516 ((looking-at "bibitem") |
73 | 517 (setq labelholder "bibitem") ; label holder is bibitem itself |
518 (setq boundary | |
519 (save-excursion | |
520 (if (YaTeX-re-search-active-forward | |
521 (concat YaTeX-ec-regexp "\\(bibitem\\|end\\)\\b") | |
522 r-escape nil 1) | |
523 (match-beginning 0) | |
77 | 524 (1- (point)))) |
525 inspoint boundary)) | |
70 | 526 ((string-match YaTeX::ref-mathenv-regexp |
527 (setq env (or (YaTeX-inner-environment t) "document"))) | |
528 (setq mathp t) | |
73 | 529 ;;(setq boundary (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)")) |
530 (setq boundary | |
531 (save-excursion | |
532 (if (YaTeX-re-search-active-forward | |
533 (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)") | |
534 r-escape nil 1) | |
535 (match-beginning 0) | |
77 | 536 (1- (point)))) |
537 inspoint boundary)) | |
73 | 538 ((looking-at "footnote\\s *{") |
539 (skip-chars-forward "^{") ;move onto `{' | |
540 (setq boundary | |
541 (save-excursion | |
542 (condition-case err | |
543 (forward-list 1) | |
544 (error (error "\\\\footnote at point %s's brace not closed" | |
545 (point)))) | |
77 | 546 (1- (point))) |
547 inspoint boundary)) | |
70 | 548 ((looking-at "caption\\|\\(begin\\)") |
549 (skip-chars-forward "^{") | |
77 | 550 ;;;;;;(if (match-beginning 1) (forward-list 1)) |
551 ;; caption can be treated as mathenv, is it right?? | |
552 (forward-list 1) | |
73 | 553 ;;(setq boundary (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b")) |
77 | 554 (setq inspoint (point)) |
73 | 555 (setq boundary |
556 (save-excursion | |
557 (if (YaTeX-re-search-active-forward | |
558 (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b") | |
559 r-escape nil 1) | |
560 (match-beginning 0) | |
561 (1- (point)))))) | |
70 | 562 (t )) |
563 (if (save-excursion (skip-chars-forward " \t") (looking-at "%")) | |
564 (forward-line 1)) | |
565 (if (and (save-excursion | |
566 (YaTeX-re-search-active-forward | |
73 | 567 ;;(concat "\\(" labelholder "\\)\\|\\(" boundary "\\)") |
568 labelholder | |
70 | 569 (regexp-quote YaTeX-comment-prefix) |
73 | 570 boundary 1)) |
571 (match-beginning 0)) | |
70 | 572 ;; if \label{hoge} found, return it |
573 (buffer-substring | |
574 (progn | |
575 (goto-char (match-end 0)) | |
576 (skip-chars-forward "^{") (1+ (point))) | |
577 (progn | |
578 (forward-sexp 1) (1- (point)))) | |
579 ;;else make a label | |
73 | 580 ;(goto-char (match-beginning 0)) |
77 | 581 (goto-char inspoint) |
70 | 582 (skip-chars-backward " \t\n") |
583 (save-excursion (setq newlabel (YaTeX::ref-generate-label))) | |
584 (delete-region (point) (progn (skip-chars-backward " \t") (point))) | |
585 (if mathp nil | |
586 (insert "\n") | |
587 (YaTeX-reindent cc)) | |
588 (insert (format "\\label{%s}" newlabel)) | |
589 newlabel)))) | |
590 | |
591 (defvar YaTeX::ref-labeling-regexp-alist | |
592 '(("\\\\begin{java}{\\([^}]+\\)}" . 1) | |
77 | 593 ("\\\\label{\\([^}]+\\)}" . 1))) |
70 | 594 (defvar YaTeX::ref-labeling-regexp |
595 (mapconcat 'car YaTeX::ref-labeling-regexp-alist "\\|")) | |
596 (defvar YaTeX::ref-mathenv-regexp | |
597 "equation\\|eqnarray\\|align\\|gather\\|alignat\\|xalignat") | |
598 (defvar YaTeX::ref-enumerateenv-regexp | |
599 "enumerate") | |
600 | |
601 (defvar YaTeX::ref-labeling-section-level 2 | |
72 | 602 "*ref⊮ŎWZNVjOR}h̉x |
70 | 603 YaTeX-sectioning-level̐lŎw.") |
604 | |
48 | 605 (defun YaTeX::ref (argp &optional labelcmd refcmd) |
70 | 606 (setplist 'YaTeX::ref-labeling-regexp nil) ;erase memory cache |
607 (require 'yatexsec) | |
11 | 608 (cond |
609 ((= argp 1) | |
70 | 610 (let*((lnum 0) e0 x cmd label match-point point-list boundary |
611 (buf (current-buffer)) | |
612 (llv YaTeX::ref-labeling-section-level) | |
613 (mathenvs YaTeX::ref-mathenv-regexp) | |
614 (enums YaTeX::ref-enumerateenv-regexp) | |
615 (counter | |
616 (or labelcmd | |
617 (concat | |
618 YaTeX-ec-regexp "\\(\\(" | |
619 (mapconcat | |
620 'concat | |
621 (delq nil | |
622 (mapcar | |
72 | 623 (function |
624 (lambda (s) | |
625 (if (>= llv (cdr s)) | |
626 (car s)))) | |
70 | 627 YaTeX-sectioning-level)) |
628 "\\|") | |
77 | 629 "\\|caption\\(\\[[^]]+\\]\\)?\\|footnote\\){" |
70 | 630 "\\|\\(begin{\\(" mathenvs "\\|" enums "\\)\\)\\)"))) |
631 (regexp (concat "\\(" counter | |
632 "\\)\\|\\(" YaTeX::ref-labeling-regexp "\\)")) | |
633 (itemsep (concat YaTeX-ec-regexp | |
634 "\\(\\(bib\\)?item\\|begin\\|end\\)")) | |
635 (refcmd (or refcmd "ref")) | |
636 (p (point)) initl line cf | |
637 (percent (regexp-quote YaTeX-comment-prefix)) | |
638 (output | |
639 (function | |
640 (lambda (label p) | |
641 (while (setq x (string-match "\n" label)) | |
642 (aset label x ? )) | |
643 (while (setq x (string-match "[ \t\n][ \t\n]+" label)) | |
644 (setq label (concat | |
645 (substring label 0 (1+ (match-beginning 0))) | |
646 (substring label (match-end 0))))) | |
647 (princ (format "%c: <<%s>>\n" (+ (% lnum 26) ?A) label)) | |
648 (setq point-list (cons p point-list)) | |
649 (message "Collecting labels... %d" lnum) | |
650 (setq lnum (1+ lnum))))) | |
651 ) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
652 (message "Collecting labels...") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
653 (save-window-excursion |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
654 (YaTeX-showup-buffer |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
655 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
|
656 (if (fboundp 'select-frame) (setq cf (selected-frame))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
657 (if (eq (window-buffer (minibuffer-window)) buf) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
658 (progn |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
659 (other-window 1) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
660 (setq buf (current-buffer)) |
70 | 661 (set-buffer buf))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
662 (save-excursion |
69 | 663 (set-buffer (get-buffer-create YaTeX-label-buffer)) |
664 (setq buffer-read-only nil) | |
665 (erase-buffer)) | |
666 (save-excursion | |
70 | 667 (set-buffer buf) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
668 (goto-char (point-min)) |
69 | 669 (let ((standard-output (get-buffer YaTeX-label-buffer))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
670 (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf))) |
48 | 671 (while (YaTeX-re-search-active-forward |
70 | 672 regexp ;;counter |
673 percent nil t) | |
674 ;(goto-char (match-beginning 0)) | |
675 (setq e0 (match-end 0)) | |
676 (cond | |
73 | 677 ((YaTeX-literal-p) nil) |
72 | 678 ((YaTeX-match-string 1) |
70 | 679 ;;if standard counter commands found |
680 (setq cmd (YaTeX-match-string 2)) | |
681 (setq match-point (match-beginning 0)) | |
682 (or initl | |
683 (if (< p (point)) (setq initl lnum))) | |
684 (cond | |
685 ((string-match mathenvs cmd) ;;if matches mathematical env | |
686 ;(skip-chars-forward "} \t\n") | |
687 (forward-line 1) | |
688 (setq x (point)) | |
689 (catch 'scan | |
690 (while (YaTeX-re-search-active-forward | |
691 (concat "\\\\\\\\$\\|\\\\end{\\(" mathenvs "\\)") | |
692 percent nil t) | |
693 (let ((quit (match-beginning 1))) | |
694 (funcall output | |
695 (buffer-substring x (match-beginning 0)) | |
696 x) | |
697 (if quit (throw 'scan t))) | |
698 (setq x (point)))) | |
699 (setq e0 (point))) | |
700 ((string-match enums cmd) | |
701 ;(skip-chars-forward "} \t\n") | |
702 (save-restriction | |
703 (narrow-to-region | |
704 (point) | |
705 (save-excursion | |
706 (YaTeX-goto-corresponding-environment) (point))) | |
707 (forward-line 1) | |
708 (while (YaTeX-re-search-active-forward | |
709 (concat YaTeX-ec-regexp "item\\s ") | |
710 percent nil t) | |
711 (setq x (match-beginning 0)) | |
712 (funcall | |
713 output | |
714 (buffer-substring | |
715 (match-beginning 0) | |
716 (if (re-search-forward itemsep nil t) | |
717 (progn (goto-char (match-beginning 0)) | |
718 (skip-chars-backward " \t") | |
719 (1- (point))) | |
720 (point-end-of-line))) | |
77 | 721 x)) |
722 (setq e0 (point-max)))) | |
723 ;;else, simple section-type counter | |
70 | 724 ((= (char-after (1- (point))) ?{) |
725 (setq label (buffer-substring | |
726 (match-beginning 0) | |
727 (progn (forward-char -1) | |
728 (forward-list 1) | |
729 (point)))) | |
77 | 730 (funcall output label match-point) |
731 ;; Skip preceding label if exists | |
732 (if (save-excursion | |
733 (skip-chars-forward "\t \n") | |
734 (looking-at YaTeX::ref-labeling-regexp)) | |
735 (setq e0 (match-end 0)))) | |
70 | 736 (t |
737 (skip-chars-forward " \t") | |
738 (setq label (buffer-substring | |
739 (match-beginning 0) | |
740 (if (re-search-forward | |
741 itemsep | |
742 nil t) | |
743 (progn | |
744 (goto-char (match-beginning 0)) | |
745 (skip-chars-backward " \t") | |
746 (1- (point))) | |
747 (point-end-of-line)))) | |
748 (funcall output label match-point) | |
77 | 749 (if (save-excursion |
750 (skip-chars-forward "\t \n") | |
751 (looking-at YaTeX::ref-labeling-regexp)) | |
752 (setq e0 (match-end 0))))) | |
70 | 753 ) ;;put label buffer |
754 ;; | |
755 ;; if user defined label found | |
756 (t | |
757 ;; memorize line number and label into property | |
758 (goto-char (match-beginning 0)) | |
759 (let ((list YaTeX::ref-labeling-regexp-alist) | |
760 (cache (symbol-plist 'YaTeX::ref-labeling-regexp))) | |
761 (while list | |
762 (if (looking-at (car (car list))) | |
763 (progn | |
764 (setq label (YaTeX-match-string 0)) | |
765 (put 'YaTeX::ref-labeling-regexp lnum | |
766 (YaTeX-match-string (cdr (car list)))) | |
767 (funcall output label 0) ;;0 is dummy, never used | |
768 (setq list nil))) | |
769 (setq list (cdr list)))) | |
770 )) | |
11 | 771 (goto-char e0)) |
772 (princ YaTeX-label-menu-other) | |
23 | 773 (princ YaTeX-label-menu-repeat) |
11 | 774 (princ YaTeX-label-menu-any) |
69 | 775 );standard-output |
11 | 776 (goto-char p) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
777 (or initl (setq initl lnum)) |
70 | 778 (message "Collecting labels...Done") |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
779 (if (fboundp 'select-frame) (select-frame cf)) |
59 | 780 (YaTeX-showup-buffer YaTeX-label-buffer nil t) |
11 | 781 (YaTeX::label-setup-key-map) |
782 (setq truncate-lines t) | |
783 (setq buffer-read-only t) | |
784 (use-local-map YaTeX-label-select-map) | |
785 (message YaTeX-label-guide-msg) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
786 (goto-line (1+ initl)) ;goto recently defined label line |
68 | 787 (switch-to-buffer (current-buffer)) |
11 | 788 (unwind-protect |
789 (progn | |
790 (recursive-edit) | |
70 | 791 |
11 | 792 (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion |
793 (beginning-of-line) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
794 (setq line (1- (count-lines (point-min)(point)))) |
11 | 795 (cond |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
796 ((= line -1) (setq label "")) |
11 | 797 ((= line lnum) (setq label (YaTeX-label-other))) |
23 | 798 ((= line (1+ lnum)) |
799 (save-excursion | |
800 (switch-to-buffer buf) | |
801 (goto-char p) | |
48 | 802 (if (re-search-backward |
803 (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t) | |
804 (setq label (YaTeX-match-string 1)) | |
23 | 805 (setq label "")))) |
806 ((>= line (+ lnum 2)) | |
48 | 807 (setq label (read-string (format "\\%s{???}: " refcmd)))) |
70 | 808 (t ;(setq label (nth (- lnum line 1) label-list)) |
809 (setq label | |
810 (or (get 'YaTeX::ref-labeling-regexp line) | |
811 (YaTeX::ref-getset-label | |
812 buf (nth (- lnum line 1) point-list)))) | |
813 ))) | |
11 | 814 (bury-buffer YaTeX-label-buffer))) |
69 | 815 label))))) |
816 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
817 (fset 'YaTeX::pageref 'YaTeX::ref) |
70 | 818 |
819 (defun YaTeX::cite-collect-bibs-external (&rest files) | |
820 "Collect bibentry from FILES(variable length argument); | |
821 and print them to standard output." | |
822 ;;Thanks; http://icarus.ilcs.hokudai.ac.jp/comp/biblio.html | |
823 (let ((tb (get-buffer-create " *bibtmp*"))) | |
824 (save-excursion | |
825 (set-buffer tb) | |
826 (while files | |
827 (erase-buffer) | |
828 (cond | |
829 ((file-exists-p (car files)) | |
830 (insert-file-contents (car files))) | |
831 ((file-exists-p (concat (car files) ".bib")) | |
832 (insert-file-contents (concat (car files) ".bib")))) | |
833 (save-excursion | |
834 (goto-char (point-min)) | |
835 (while (re-search-forward "^\\s *@[A-Za-z]" nil t) | |
836 (skip-chars-forward "^{,") | |
837 (if (= (char-after (point)) ?{) | |
838 (princ (format "%sbibitem{%s}%s\n" | |
839 YaTeX-ec | |
840 (buffer-substring | |
841 (1+ (point)) | |
842 (progn (skip-chars-forward "^,\n") | |
843 (point))) | |
844 (if (re-search-forward "title\\s *=" nil t) | |
845 (buffer-substring | |
846 (progn | |
847 (goto-char (match-end 0)) | |
848 (skip-chars-forward " \t\n") | |
849 (point)) | |
850 (progn | |
851 (if (looking-at "[{\"]") | |
852 (forward-sexp 1) | |
853 (forward-char 1) | |
854 (skip-chars-forward "^,")) | |
855 (point))))))))) | |
856 (setq files (cdr files)))))) | |
857 | |
77 | 858 (defvar YaTeX::cite-bibitem-macro-regexp "bibitem\\|harvarditem" |
859 "*Regexp of macro name of bibitem definition") | |
860 | |
70 | 861 (defun YaTeX::cite-collect-bibs-internal () |
862 "Collect bibentry in the current buffer and print them to standard output." | |
77 | 863 (let ((ptn (concat YaTeX-ec-regexp |
864 "\\(" YaTeX::cite-bibitem-macro-regexp "\\)\\b")) | |
70 | 865 (pcnt (regexp-quote YaTeX-comment-prefix))) |
866 (save-excursion | |
867 (while (YaTeX-re-search-active-forward ptn pcnt nil t) | |
868 (skip-chars-forward "^{\n") | |
869 (or (eolp) | |
870 (princ (format "%sbibitem{%s}\n" | |
871 YaTeX-ec | |
872 (buffer-substring | |
873 (1+ (point)) | |
874 (progn (forward-sexp 1) (point)))))))))) | |
875 | |
48 | 876 (defun YaTeX::cite (argp) |
877 (cond | |
878 ((eq argp 1) | |
70 | 879 (let* ((cb (current-buffer)) |
880 (f (file-name-nondirectory buffer-file-name)) | |
881 (d default-directory) | |
882 (hilit-auto-highlight nil) | |
883 (pcnt (regexp-quote YaTeX-comment-prefix)) | |
884 (bibrx (concat YaTeX-ec-regexp "bibliography{\\([^}]+\\)}")) | |
885 (bbuf (get-buffer-create " *bibitems*")) | |
886 (standard-output bbuf) | |
887 bibs files) | |
888 (set-buffer bbuf)(erase-buffer)(set-buffer cb) | |
889 (save-excursion | |
890 (goto-char (point-min)) | |
891 ;;(1)search external bibdata | |
892 (while (YaTeX-re-search-active-forward bibrx pcnt nil t) | |
893 (apply 'YaTeX::cite-collect-bibs-external | |
894 (YaTeX-split-string | |
895 (YaTeX-match-string 1) ","))) | |
896 ;;(2)search direct \bibitem usage | |
897 (YaTeX::cite-collect-bibs-internal) | |
898 (if (progn | |
899 (YaTeX-visit-main t) | |
900 (not (eq (current-buffer) cb))) | |
901 (save-excursion | |
902 (goto-char (point-min)) | |
903 ;;(1)search external bibdata | |
904 (while (YaTeX-re-search-active-forward bibrx pcnt nil t) | |
905 (apply 'YaTeX::cite-collect-bibs-external | |
906 (YaTeX-split-string | |
907 (YaTeX-match-string 1) ","))) | |
908 ;;(2)search internal | |
909 (YaTeX::cite-collect-bibs-internal))) | |
910 ;;Now bbuf holds the list of bibitem | |
911 (set-buffer bbuf) | |
77 | 912 (YaTeX::ref |
913 argp | |
914 (concat "\\\\\\(" | |
915 YaTeX::cite-bibitem-macro-regexp | |
916 "\\)\\(\\[.*\\]\\)?") | |
917 "cite")))) | |
918 | |
48 | 919 (t nil))) |
11 | 920 |
77 | 921 ;;; for AMS-LaTeX |
70 | 922 (and YaTeX-use-AMS-LaTeX (fset 'YaTeX::eqref 'YaTeX::ref)) |
77 | 923 ;;; for Harvard citation style |
924 (fset 'YaTeX::citeasnoun 'YaTeX::cite) | |
925 (fset 'YaTeX::possessivecite 'YaTeX::cite) | |
926 (fset 'YaTeX::citeyear 'YaTeX::cite) | |
927 (fset 'YaTeX::citename 'YaTeX::cite) | |
70 | 928 |
48 | 929 (defun YaTeX-yatex-buffer-list () |
930 (save-excursion | |
931 (delq nil (mapcar (function (lambda (buf) | |
932 (set-buffer buf) | |
933 (if (eq major-mode 'yatex-mode) buf))) | |
69 | 934 (buffer-list))))) |
48 | 935 |
936 (defun YaTeX-select-other-yatex-buffer () | |
937 "Select buffer from all yatex-mode's buffers interactivelly." | |
938 (interactive) | |
939 (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list)) | |
940 (lnum -1) buf rv | |
11 | 941 (ff "**find-file**")) |
12 | 942 (YaTeX-showup-buffer |
943 lbuf (function (lambda (x) 1))) ;;Select next window surely. | |
69 | 944 (save-excursion |
945 (set-buffer (get-buffer lbuf)) | |
946 (setq buffer-read-only nil) | |
947 (erase-buffer)) | |
948 (let ((standard-output (get-buffer lbuf))) | |
11 | 949 (while blist |
48 | 950 (princ |
951 (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A) | |
952 (buffer-name (car blist)))) | |
11 | 953 (setq blist (cdr blist))) |
954 (princ (format "':{%s}" ff))) | |
59 | 955 (YaTeX-showup-buffer lbuf nil t) |
11 | 956 (YaTeX::label-setup-key-map) |
957 (setq buffer-read-only t) | |
958 (use-local-map YaTeX-label-select-map) | |
959 (message YaTeX-label-guide-msg) | |
960 (unwind-protect | |
961 (progn | |
962 (recursive-edit) | |
963 (set-buffer lbuf) | |
964 (beginning-of-line) | |
965 (setq rv | |
966 (if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t) | |
967 (buffer-substring (match-beginning 1) (match-end 1)) nil))) | |
968 (kill-buffer lbuf)) | |
48 | 969 (if (string= rv ff) |
970 (progn | |
971 (call-interactively 'find-file) | |
972 (current-buffer)) | |
69 | 973 rv))) |
48 | 974 |
975 (defun YaTeX-label-other () | |
976 (let ((rv (YaTeX-select-other-yatex-buffer))) | |
11 | 977 (cond |
978 ((null rv) "") | |
979 (t | |
980 (set-buffer rv) | |
69 | 981 (YaTeX::ref argp labelcmd refcmd))))) |
11 | 982 |
13 | 983 ;; |
984 ; completion for the arguments of \newcommand | |
985 ;; | |
986 (defun YaTeX::newcommand (&optional argp) | |
987 (cond | |
988 ((= argp 1) | |
989 (let ((command (read-string "Define newcommand: " "\\"))) | |
990 (put 'YaTeX::newcommand 'command (substring command 1)) | |
991 command)) | |
992 ((= argp 2) | |
993 (let ((argc | |
994 (string-to-int (read-string "Number of arguments(Default 0): "))) | |
995 (def (read-string "Definition: ")) | |
996 (command (get 'YaTeX::newcommand 'command))) | |
997 ;;!!! It's illegal to insert string in the add-in function !!! | |
998 (if (> argc 0) (insert (format "[%d]" argc))) | |
999 (if (and (stringp command) | |
1000 (string< "" command) | |
51 | 1001 (y-or-n-p "Update dictionary?")) |
18 | 1002 (cond |
1003 ((= argc 0) | |
1004 (YaTeX-update-table | |
1005 (list command) | |
1006 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table)) | |
1007 ((= argc 1) | |
1008 (YaTeX-update-table | |
1009 (list command) | |
1010 'section-table 'user-section-table 'tmp-section-table)) | |
1011 (t (YaTeX-update-table | |
1012 (list command argc) | |
1013 'section-table 'user-section-table 'tmp-section-table)))) | |
13 | 1014 (message "") |
1015 def ;return command name | |
1016 )) | |
69 | 1017 (t ""))) |
13 | 1018 |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1019 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1020 ; completion for the arguments of \pagestyle |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1021 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1022 (defun YaTeX::pagestyle (&optional argp) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1023 "Read the pagestyle with completion." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1024 (completing-read |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1025 "Page style: " |
69 | 1026 '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil))) |
1027 | |
51 | 1028 (fset 'YaTeX::thispagestyle 'YaTeX::pagestyle) |
1029 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1030 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1031 ; completion for the arguments of \pagenumbering |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1032 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1033 (defun YaTeX::pagenumbering (&optional argp) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1034 "Read the numbering style." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1035 (completing-read |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
1036 "Page numbering style: " |
69 | 1037 '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman")))) |
13 | 1038 |
23 | 1039 ;; |
1040 ; Length | |
1041 ;; | |
1042 (defvar YaTeX:style-parameters-default | |
1043 '(("\\arraycolsep") | |
1044 ("\\arrayrulewidth") | |
1045 ("\\baselineskip") | |
1046 ("\\columnsep") | |
1047 ("\\columnseprule") | |
1048 ("\\doublerulesep") | |
1049 ("\\evensidemargin") | |
1050 ("\\footheight") | |
1051 ("\\footskip") | |
1052 ("\\headheight") | |
1053 ("\\headsep") | |
1054 ("\\itemindent") | |
1055 ("\\itemsep") | |
1056 ("\\labelsep") | |
1057 ("\\labelwidth") | |
1058 ("\\leftmargin") | |
1059 ("\\linewidth") | |
1060 ("\\listparindent") | |
1061 ("\\marginparsep") | |
1062 ("\\marginparwidth") | |
1063 ("\\mathindent") | |
1064 ("\\oddsidemargin") | |
1065 ("\\parindent") | |
1066 ("\\parsep") | |
1067 ("\\parskip") | |
1068 ("\\partopsep") | |
1069 ("\\rightmargin") | |
1070 ("\\tabcolsep") | |
1071 ("\\textheight") | |
1072 ("\\textwidth") | |
1073 ("\\topmargin") | |
1074 ("\\topsep") | |
1075 ("\\topskip") | |
1076 ) | |
1077 "Alist of LaTeX style parameters.") | |
1078 (defvar YaTeX:style-parameters-private nil | |
1079 "*User definable alist of style parameters.") | |
49 | 1080 (defvar YaTeX:style-parameters-local nil |
1081 "*User definable alist of local style parameters.") | |
23 | 1082 |
1083 (defvar YaTeX:length-history nil "Holds history of length.") | |
51 | 1084 (put 'YaTeX:length-history 'no-default t) |
23 | 1085 (defun YaTeX::setlength (&optional argp) |
1086 "YaTeX add-in function for arguments of \\setlength." | |
1087 (cond | |
1088 ((equal 1 argp) | |
49 | 1089 ;;(completing-read "Length variable: " YaTeX:style-parameters nil nil "\\") |
1090 (YaTeX-cplread-with-learning | |
1091 "Length variable: " | |
1092 'YaTeX:style-parameters-default | |
1093 'YaTeX:style-parameters-private | |
1094 'YaTeX:style-parameters-local | |
1095 nil nil "\\") | |
1096 ) | |
23 | 1097 ((equal 2 argp) |
69 | 1098 (read-string-with-history "Length: " nil 'YaTeX:length-history)))) |
1099 | |
23 | 1100 (fset 'YaTeX::addtolength 'YaTeX::setlength) |
1101 | |
1102 (defun YaTeX::settowidth (&optional argp) | |
1103 "YaTeX add-in function for arguments of \\settowidth." | |
1104 (cond | |
1105 ((equal 1 argp) | |
49 | 1106 (YaTeX-cplread-with-learning |
1107 "Length variable: " | |
1108 'YaTeX:style-parameters-default | |
1109 'YaTeX:style-parameters-private | |
1110 'YaTeX:style-parameters-local | |
1111 nil nil "\\")) | |
23 | 1112 ((equal 2 argp) |
69 | 1113 (read-string "Text: ")))) |
1114 | |
23 | 1115 (defun YaTeX::newlength (&optional argp) |
1116 "YaTeX add-in function for arguments of \\newlength" | |
1117 (cond | |
1118 ((equal argp 1) | |
1119 (let ((length (read-string "Length variable: " "\\"))) | |
49 | 1120 (if (string< "" length) |
1121 (YaTeX-update-table | |
1122 (list length) | |
1123 'YaTeX:style-parameters-default | |
1124 'YaTeX:style-parameters-private | |
1125 'YaTeX:style-parameters-local)) | |
69 | 1126 length)))) |
23 | 1127 |
1128 ;; \multicolumn's arguments | |
1129 (defun YaTeX::multicolumn (&optional argp) | |
1130 "YaTeX add-in function for arguments of \\multicolumn." | |
1131 (cond | |
1132 ((equal 1 argp) | |
1133 (read-string "Number of columns: ")) | |
1134 ((equal 2 argp) | |
1135 (let (c) | |
1136 (while (not (string-match | |
1137 (progn (message "Format(one of l,r,c): ") | |
1138 (setq c (char-to-string (read-char)))) | |
1139 "lrc"))) | |
1140 c)) | |
1141 ((equal 3 argp) | |
69 | 1142 (read-string "Item: ")))) |
23 | 1143 |
49 | 1144 (defvar YaTeX:documentstyles-default |
1145 '(("article") ("jarticle") ("j-article") | |
1146 ("book") ("jbook") ("j-book") | |
1147 ("report") ("jreport") ("j-report") | |
1148 ("letter") ("ascjletter")) | |
1149 "List of LaTeX documentstyles.") | |
1150 (defvar YaTeX:documentstyles-private nil | |
1151 "*User defined list of LaTeX documentstyles.") | |
1152 (defvar YaTeX:documentstyles-local nil | |
1153 "*User defined list of local LaTeX documentstyles.") | |
1154 (defvar YaTeX:documentstyle-options-default | |
1155 '(("a4j") ("a5j") ("b4j") ("b5j") | |
1156 ("twocolumn") ("jtwocolumn") ("epsf") ("epsfig") ("epsbox") ("nfig")) | |
1157 "List of LaTeX documentstyle options.") | |
1158 (defvar YaTeX:documentstyle-options-private nil | |
1159 "*User defined list of LaTeX documentstyle options.") | |
1160 (defvar YaTeX:documentstyle-options-local nil | |
1161 "List of LaTeX local documentstyle options.") | |
1162 | |
1163 (defvar YaTeX-minibuffer-completion-map nil | |
1164 "Minibuffer completion key map that allows comma completion.") | |
1165 (if YaTeX-minibuffer-completion-map nil | |
1166 (setq YaTeX-minibuffer-completion-map | |
1167 (copy-keymap minibuffer-local-completion-map)) | |
1168 (define-key YaTeX-minibuffer-completion-map " " | |
1169 'YaTeX-minibuffer-complete) | |
1170 (define-key YaTeX-minibuffer-completion-map "\t" | |
1171 'YaTeX-minibuffer-complete)) | |
1172 | |
1173 (defun YaTeX:documentstyle () | |
1174 (let*((delim ",") | |
1175 (dt (append YaTeX:documentstyle-options-local | |
1176 YaTeX:documentstyle-options-private | |
1177 YaTeX:documentstyle-options-default)) | |
1178 (minibuffer-completion-table dt) | |
1179 (opt (read-from-minibuffer | |
1180 "Style options ([opt1,opt2,...]): " | |
51 | 1181 nil YaTeX-minibuffer-completion-map nil)) |
49 | 1182 (substr opt) o) |
1183 (if (string< "" opt) | |
1184 (progn | |
1185 (while substr | |
1186 (setq o (substring substr 0 (string-match delim substr))) | |
1187 (or (assoc o dt) | |
1188 (YaTeX-update-table | |
1189 (list o) | |
1190 'YaTeX:documentstyle-options-default | |
1191 'YaTeX:documentstyle-options-private | |
1192 'YaTeX:documentstyle-options-local)) | |
1193 (setq substr | |
1194 (if (string-match delim substr) | |
1195 (substring substr (1+ (string-match delim substr)))))) | |
1196 (concat "[" opt "]")) | |
1197 ""))) | |
1198 | |
1199 (defun YaTeX::documentstyle (&optional argp) | |
51 | 1200 "YaTeX add-in function for arguments of \\documentstyle." |
49 | 1201 (cond |
1202 ((equal argp 1) | |
72 | 1203 (setq YaTeX-env-name "document") |
49 | 1204 (let ((sname |
1205 (YaTeX-cplread-with-learning | |
1206 (format "Documentstyle (default %s): " | |
1207 YaTeX-default-document-style) | |
1208 'YaTeX:documentstyles-default | |
1209 'YaTeX:documentstyles-private | |
1210 'YaTeX:documentstyles-local))) | |
1211 (if (string= "" sname) (setq sname YaTeX-default-document-style)) | |
69 | 1212 (setq YaTeX-default-document-style sname))))) |
49 | 1213 |
57 | 1214 ;;; -------------------- LaTeX2e stuff -------------------- |
1215 (defvar YaTeX:documentclass-options-default | |
70 | 1216 '(("a4paper") ("a5paper") ("b4paper") ("b5paper") ("10pt") ("11pt") ("12pt") |
57 | 1217 ("latterpaper") ("legalpaper") ("executivepaper") ("landscape") |
1218 ("oneside") ("twoside") ("draft") ("final") ("leqno") ("fleqn") ("openbib") | |
70 | 1219 ("tombow") ("titlepage") ("notitlepage") ("dvips") |
57 | 1220 ("clock") ;for slides class only |
1221 ) | |
1222 "Default options list for documentclass") | |
1223 (defvar YaTeX:documentclass-options-private nil | |
1224 "*User defined options list for documentclass") | |
1225 (defvar YaTeX:documentclass-options-local nil | |
1226 "*User defined options list for local documentclass") | |
1227 | |
1228 (defun YaTeX:documentclass () | |
1229 (let*((delim ",") | |
1230 (dt (append YaTeX:documentclass-options-local | |
1231 YaTeX:documentclass-options-private | |
1232 YaTeX:documentclass-options-default)) | |
1233 (minibuffer-completion-table dt) | |
1234 (opt (read-from-minibuffer | |
1235 "Documentclass options ([opt1,opt2,...]): " | |
1236 nil YaTeX-minibuffer-completion-map nil)) | |
1237 (substr opt) o) | |
1238 (if (string< "" opt) | |
1239 (progn | |
1240 (while substr | |
70 | 1241 |
57 | 1242 (setq o (substring substr 0 (string-match delim substr))) |
1243 (or (assoc o dt) | |
1244 (YaTeX-update-table | |
1245 (list o) | |
1246 'YaTeX:documentclass-options-default | |
1247 'YaTeX:documentclass-options-private | |
1248 'YaTeX:documentclass-options-local)) | |
1249 (setq substr | |
1250 (if (string-match delim substr) | |
1251 (substring substr (1+ (string-match delim substr)))))) | |
1252 (concat "[" opt "]")) | |
1253 ""))) | |
1254 | |
1255 (defvar YaTeX:documentclasses-default | |
1256 '(("article") ("jarticle") ("report") ("jreport") ("book") ("jbook") | |
1257 ("j-article") ("j-report") ("j-book") | |
1258 ("letter") ("slides") ("ltxdoc") ("ltxguide") ("ltnews") ("proc")) | |
1259 "Default documentclass alist") | |
1260 (defvar YaTeX:documentclasses-private nil | |
1261 "*User defined documentclass alist") | |
1262 (defvar YaTeX:documentclasses-local nil | |
1263 "*User defined local documentclass alist") | |
1264 (defvar YaTeX-default-documentclass (if YaTeX-japan "jarticle" "article") | |
1265 "*Default documentclass") | |
1266 | |
1267 (defun YaTeX::documentclass (&optional argp) | |
1268 (cond | |
1269 ((equal argp 1) | |
72 | 1270 (setq YaTeX-env-name "document") |
57 | 1271 (let ((sname |
1272 (YaTeX-cplread-with-learning | |
1273 (format "Documentclass (default %s): " YaTeX-default-documentclass) | |
1274 'YaTeX:documentclasses-default | |
1275 'YaTeX:documentclasses-private | |
1276 'YaTeX:documentclasses-local))) | |
1277 (if (string= "" sname) (setq sname YaTeX-default-documentclass)) | |
1278 (setq YaTeX-default-documentclass sname))))) | |
1279 | |
70 | 1280 (defvar YaTeX:latex2e-named-color-alist |
1281 '(("GreenYellow") ("Yellow") ("Goldenrod") ("Dandelion") ("Apricot") | |
1282 ("Peach") ("Melon") ("YellowOrange") ("Orange") ("BurntOrange") | |
1283 ("Bittersweet") ("RedOrange") ("Mahogany") ("Maroon") ("BrickRed") | |
1284 ("Red") ("OrangeRed") ("RubineRed") ("WildStrawberry") ("Salmon") | |
1285 ("CarnationPink") ("Magenta") ("VioletRed") ("Rhodamine") ("Mulberry") | |
1286 ("RedViolet") ("Fuchsia") ("Lavender") ("Thistle") ("Orchid")("DarkOrchid") | |
1287 ("Purple") ("Plum") ("Violet") ("RoyalPurple") ("BlueViolet") | |
1288 ("Periwinkle") ("CadetBlue") ("CornflowerBlue") ("MidnightBlue") | |
1289 ("NavyBlue") ("RoyalBlue") ("Blue") ("Cerulean") ("Cyan") ("ProcessBlue") | |
1290 ("SkyBlue") ("Turquoise") ("TealBlue") ("Aquamarine") ("BlueGreen") | |
1291 ("Emerald") ("JungleGreen") ("SeaGreen") ("Green") ("ForestGreen") | |
1292 ("PineGreen") ("LimeGreen") ("YellowGreen") ("SpringGreen") ("OliveGreen") | |
1293 ("RawSienna") ("Sepia") ("Brown") ("Tan") ("Gray") ("Black") ("White")) | |
1294 "Colors defined in $TEXMF/tex/plain/colordvi.tex") | |
1295 | |
1296 (defvar YaTeX:latex2e-basic-color-alist | |
1297 '(("black") ("white") ("red") ("blue") ("yellow") ("green") ("cyan") | |
1298 ("magenta")) | |
1299 "Basic colors") | |
1300 | |
1301 (defun YaTeX:textcolor () | |
1302 "Add-in for \\color's option" | |
1303 (if (y-or-n-p "Use `named' color? ") | |
1304 "[named]")) | |
1305 | |
1306 (defun YaTeX::color-completing-read (prompt) | |
1307 (let ((completion-ignore-case t) | |
1308 (namedp (save-excursion | |
1309 (skip-chars-backward "^\n\\[\\\\") | |
1310 (looking-at "named")))) | |
1311 (completing-read | |
1312 prompt | |
1313 (if namedp | |
1314 YaTeX:latex2e-named-color-alist | |
1315 YaTeX:latex2e-basic-color-alist) | |
1316 nil t))) | |
1317 | |
1318 (defun YaTeX::textcolor (argp) | |
1319 "Add-in for \\color's argument" | |
1320 (cond | |
1321 ((= argp 1) (YaTeX::color-completing-read "Color: ")) | |
1322 ((= argp 2) (read-string "Colored string: ")))) | |
1323 | |
1324 (fset 'YaTeX:color 'YaTeX:textcolor) | |
1325 (fset 'YaTeX::color 'YaTeX::textcolor) | |
1326 (fset 'YaTeX:colorbox 'YaTeX:textcolor) | |
1327 (fset 'YaTeX::colorbox 'YaTeX::textcolor) | |
1328 (fset 'YaTeX:fcolorbox 'YaTeX:textcolor) | |
1329 | |
1330 (defun YaTeX::fcolorbox (argp) | |
1331 (cond | |
1332 ((= argp 1) (YaTeX::color-completing-read "Frame color: ")) | |
1333 ((= argp 2) (YaTeX::color-completing-read "Inner color: ")) | |
1334 ((= argp 3) (read-string "Colored string: ")))) | |
1335 | |
1336 (defun YaTeX:scalebox () | |
1337 "Add-in for \\rotatebox" | |
1338 (let ((vmag (read-string (if YaTeX-japan "{: " "Magnification: "))) | |
1339 (hmag (read-string (if YaTeX-japan "{(ȗ): " | |
1340 "Horizontal magnification(Optional): ")))) | |
1341 (if (and hmag (string< "" hmag)) | |
1342 (format "{%s}[%s]" vmag hmag) | |
1343 (format "{%s}" vmag)))) | |
1344 | |
73 | 1345 (defun YaTeX:includegraphics () |
1346 "Add-in for \\includegraphics's option" | |
1347 (let (width height (scale "") angle str) | |
1348 (setq width (read-string "Width: ") | |
1349 height (read-string "Height: ")) | |
1350 (or (string< width "") (string< "" height) | |
1351 (setq scale (read-string "Scale: "))) | |
1352 (setq angle (read-string "Angle(0-359): ")) | |
1353 (setq str | |
1354 (mapconcat | |
1355 'concat | |
1356 (delq nil | |
1357 (mapcar '(lambda (s) | |
1358 (and (stringp (symbol-value s)) | |
1359 (string< "" (symbol-value s)) | |
1360 (format "%s=%s" s (symbol-value s)))) | |
1361 '(width height scale angle))) | |
1362 ",")) | |
1363 (if (string= "" str) "" | |
1364 (concat "[" str "]")))) | |
1365 | |
70 | 1366 (defun YaTeX::includegraphics (argp) |
1367 "Add-in for \\includegraphics" | |
1368 (cond | |
1369 ((= argp 1) | |
1370 (read-file-name "EPS File: " "")))) | |
1371 | |
68 | 1372 (defun YaTeX:caption () |
72 | 1373 (setq YaTeX-section-name "label") |
68 | 1374 nil) |
1375 | |
1376 ;;; -------------------- math-mode stuff -------------------- | |
1377 (defun YaTeX::tilde (&optional pos) | |
1378 "For accent macros in mathmode" | |
1379 (cond | |
1380 ((equal pos 1) | |
1381 (message "Put accent on variable: ") | |
1382 (let ((v (char-to-string (read-char))) (case-fold-search nil)) | |
1383 (message "") | |
1384 (cond | |
1385 ((string-match "i\\|j" v) | |
1386 (concat "\\" v "math")) | |
1387 ((string-match "[\r\n\t ]" v) | |
1388 "") | |
1389 (t v)))) | |
1390 (nil ""))) | |
1391 | |
1392 (fset 'YaTeX::hat 'YaTeX::tilde) | |
1393 (fset 'YaTeX::check 'YaTeX::tilde) | |
1394 (fset 'YaTeX::bar 'YaTeX::tilde) | |
1395 (fset 'YaTeX::dot 'YaTeX::tilde) | |
1396 (fset 'YaTeX::ddot 'YaTeX::tilde) | |
1397 (fset 'YaTeX::vec 'YaTeX::tilde) | |
1398 | |
1399 (defun YaTeX::widetilde (&optional pos) | |
1400 "For multichar accent macros in mathmode" | |
1401 (cond | |
1402 ((equal pos 1) | |
1403 (let ((m "Put over chars[%s ]: ") v v2) | |
1404 (message m " ") | |
1405 (setq v (char-to-string (read-char))) | |
1406 (message "") | |
1407 (if (string-match "[\r\n\t ]" v) | |
1408 "" | |
1409 (message m v) | |
1410 (setq v2 (char-to-string (read-char))) | |
1411 (message "") | |
1412 (if (string-match "[\r\n\t ]" v2) | |
1413 v | |
1414 (concat v v2))))) | |
1415 (nil ""))) | |
1416 | |
1417 (fset 'YaTeX::widehat 'YaTeX::widetilde) | |
1418 (fset 'YaTeX::overline 'YaTeX::widetilde) | |
1419 (fset 'YaTeX::overrightarrow 'YaTeX::widetilde) | |
1420 | |
1421 | |
1422 ;;; | |
1423 ;; Add-in functions for large-type command. | |
1424 ;;; | |
1425 (defun YaTeX:em () | |
1426 (cond | |
1427 ((eq YaTeX-current-completion-type 'large) "\\/") | |
1428 (t nil))) | |
1429 (fset 'YaTeX:it 'YaTeX:em) | |
1430 | |
23 | 1431 ;;; -------------------- End of yatexadd -------------------- |
1432 (provide 'yatexadd) | |
72 | 1433 ; Local variables: |
1434 ; fill-prefix: ";;; " | |
1435 ; paragraph-start: "^$\\|\\|;;;$" | |
1436 ; paragraph-separate: "^$\\|\\|;;;$" | |
1437 ; buffer-file-coding-system: sjis | |
1438 ; End: |