Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexadd.el @ 57:18f4939986e6
(j)LaTeX2e supported
yatex19.el fixed a lot
author | yuuji |
---|---|
date | Sat, 02 Dec 1995 18:35:28 +0000 |
parents | 5f4b18da14b3 |
children | 3a7c0c2bf16d |
rev | line source |
---|---|
6 | 1 ;;; -*- Emacs-Lisp -*- |
8 | 2 ;;; YaTeX add-in functions. |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
3 ;;; yatexadd.el rev.13 |
52 | 4 ;;; (c )1991-1995 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] |
57 | 5 ;;; Last modified Mon Nov 6 14:30:25 1995 on inspire |
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}" | |
13 "*Your favorite default rule format." | |
14 ) | |
23 | 15 (defvar YaTeX:tabular-thick-vrule "\\vrule width %s" |
16 "*Vertical thick line format (without @{}). %s'll be replaced by its width." | |
17 ) | |
18 (defvar YaTeX:tabular-thick-hrule "\\noalign{\\hrule height %s}" | |
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")) |
18 | 26 (if (string= env "tabular*") |
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)) |
54 | |
23 | 55 (message "Dont forget to remove null line at the end of tabular.") |
56 (format "%s%s{%s}%s" | |
57 width loc rule | |
58 (if (and (boundp 'region-mode) region-mode) | |
59 "" ;do nothing in region-mode | |
60 (format "\n%s\n%s \\\\ \\hline\n%s\n\\\\ %s" | |
61 hline and and hline)))) | |
18 | 62 ) |
63 (fset 'YaTeX:tabular* 'YaTeX:tabular) | |
64 (defun YaTeX:array () | |
65 (concat (YaTeX:read-position "tb") | |
66 "{" (read-string "Column format: ") "}") | |
6 | 67 ) |
68 | |
23 | 69 (defun YaTeX:read-oneof (oneof) |
70 (let ((pos "") loc (guide "")) | |
71 (and (boundp 'name) name (setq guide (format "%s " name))) | |
6 | 72 (while (not (string-match |
8 | 73 (setq loc (read-key-sequence |
23 | 74 (format "%s position (`%s') [%s]: " |
75 guide oneof pos)));name is in YaTeX-addin | |
6 | 76 "\r\^g\n")) |
77 (cond | |
8 | 78 ((string-match loc oneof) |
6 | 79 (if (not (string-match loc pos)) |
80 (setq pos (concat pos loc)))) | |
81 ((and (string-match loc "\C-h\C-?") (> (length pos) 0)) | |
82 (setq pos (substring pos 0 (1- (length pos))))) | |
83 (t | |
84 (ding) | |
8 | 85 (message "Please input one of `%s'." oneof) |
6 | 86 (sit-for 3)))) |
8 | 87 (message "") |
23 | 88 pos) |
89 ) | |
90 | |
91 (defun YaTeX:read-position (oneof) | |
92 "Read a LaTeX (optional) position format such as `[htbp]'." | |
93 (let ((pos (YaTeX:read-oneof oneof))) | |
94 (if (string= pos "") "" (concat "[" pos "]"))) | |
8 | 95 ) |
96 | |
97 (defun YaTeX:table () | |
98 "YaTeX add-in function for table environment." | |
99 (YaTeX:read-position "htbp") | |
6 | 100 ) |
101 | |
46 | 102 (fset 'YaTeX:figure 'YaTeX:table) |
103 (fset 'YaTeX:figure* 'YaTeX:table) | |
104 | |
105 | |
6 | 106 (defun YaTeX:description () |
107 "Truly poor service:-)" | |
108 (setq single-command "item[]") | |
8 | 109 "" |
6 | 110 ) |
111 | |
112 (defun YaTeX:itemize () | |
113 "It's also poor service." | |
114 (setq single-command "item") | |
8 | 115 "" |
6 | 116 ) |
117 | |
118 (fset 'YaTeX:enumerate 'YaTeX:itemize) | |
8 | 119 |
11 | 120 (defun YaTeX:picture () |
121 "Ask the size of coordinates of picture environment." | |
122 (concat (YaTeX:read-coordinates "Picture size") | |
123 (YaTeX:read-coordinates "Initial position")) | |
124 ) | |
125 | |
12 | 126 (defun YaTeX:equation () |
127 (if (fboundp 'YaTeX-toggle-math-mode) | |
128 (YaTeX-toggle-math-mode t)) ;force math-mode ON. | |
129 ) | |
130 (fset 'YaTeX:eqnarray 'YaTeX:equation) | |
131 (fset 'YaTeX:displaymath 'YaTeX:equation) | |
132 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
133 (defun YaTeX:list () |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
134 "%\n{} %default label\n{} %formatting parameter" |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
135 ) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
136 |
18 | 137 (defun YaTeX:minipage () |
138 (concat (YaTeX:read-position "cbt") | |
139 "{" (read-string "Width: ") "}") | |
140 ) | |
141 | |
8 | 142 ;;; |
143 ;;Sample functions for section-type command. | |
144 ;;; | |
145 (defun YaTeX:multiput () | |
146 (concat (YaTeX:read-coordinates "Pos") | |
147 (YaTeX:read-coordinates "Step") | |
148 "{" (read-string "How many times: ") "}") | |
149 ) | |
150 | |
151 (defun YaTeX:put () | |
152 (YaTeX:read-coordinates "Pos") | |
153 ) | |
154 | |
155 (defun YaTeX:makebox () | |
23 | 156 (cond |
157 ((YaTeX-in-environment-p "picture") | |
158 (concat (YaTeX:read-coordinates "Dimension") | |
159 (YaTeX:read-position "lrtb"))) | |
160 (t | |
161 (let ((width (read-string "Width: "))) | |
162 (if (string< "" width) | |
163 (progn | |
164 (or (equal (aref width 0) ?\[) | |
165 (setq width (concat "[" width "]"))) | |
166 (concat width (YaTeX:read-position "lr"))))))) | |
8 | 167 ) |
168 | |
169 (defun YaTeX:framebox () | |
170 (if (YaTeX-quick-in-environment-p "picture") | |
171 (YaTeX:makebox)) | |
172 ) | |
173 | |
174 (defun YaTeX:dashbox () | |
175 (concat "{" (read-string "Dash dimension: ") "}" | |
176 (YaTeX:read-coordinates "Dimension")) | |
177 ) | |
178 | |
51 | 179 (defvar YaTeX-minibuffer-quick-map nil) |
180 (if YaTeX-minibuffer-quick-map nil | |
181 (setq YaTeX-minibuffer-quick-map | |
182 (copy-keymap minibuffer-local-completion-map)) | |
183 (let ((ch (1+ ? ))) | |
184 (while (< ch 127) | |
185 (define-key YaTeX-minibuffer-quick-map (char-to-string ch) | |
186 'YaTeX-minibuffer-quick-complete) | |
187 (setq ch (1+ ch))))) | |
188 | |
189 (defvar YaTeX:left-right-delimiters | |
190 '(("(" . ")") (")" . "(") ("[" . "]") ("]" . "[") | |
191 ("\\{" . "\\}") ("\\}" . "\\{") ("|") ("\\|") | |
192 ("\\lfloor" . "\\rfloor") ("\\lceil" . "\\rceil") | |
193 ("\\langle" . "\\rangle") ("/") (".") | |
194 ("\\rfloor" . "\\rfloor") ("\\rceil" . "\\lceil") | |
195 ("\\rangle" . "\\langle") ("\\backslash") | |
196 ("\\uparrow") ("\\downarrow") ("\\updownarrow") ("\\Updownarrow")) | |
197 "TeX math delimiter, which can be completed after \\right or \\left.") | |
198 | |
199 (defvar YaTeX:left-right-default nil "Default string of YaTeX:right.") | |
200 | |
23 | 201 (defun YaTeX:left () |
51 | 202 (let ((minibuffer-completion-table YaTeX:left-right-delimiters) |
203 delimiter (leftp (string= single-command "left"))) | |
204 (setq delimiter | |
205 (read-from-minibuffer | |
206 (format "Delimiter%s: " | |
207 (if YaTeX:left-right-default | |
208 (format "(default=`%s')" YaTeX:left-right-default) | |
209 "(SPC for menu)")) | |
210 nil YaTeX-minibuffer-quick-map)) | |
211 (if (string= "" delimiter) (setq delimiter YaTeX:left-right-default)) | |
212 (setq single-command (if leftp "right" "left") | |
213 YaTeX:left-right-default | |
214 (or (cdr (assoc delimiter YaTeX:left-right-delimiters)) delimiter)) | |
215 delimiter)) | |
216 | |
23 | 217 (fset 'YaTeX:right 'YaTeX:left) |
218 | |
51 | 219 |
8 | 220 (defun YaTeX:read-coordinates (&optional mes varX varY) |
221 (concat | |
222 "(" | |
223 (read-string (format "%s %s: " (or mes "Dimension") (or varX "X"))) | |
224 "," | |
225 (read-string (format "%s %s: " (or mes "Dimension") (or varY "Y"))) | |
226 ")") | |
227 ) | |
228 | |
229 ;;; | |
230 ;;Sample functions for maketitle-type command. | |
231 ;;; | |
232 (defun YaTeX:sum () | |
233 "Read range of summation." | |
234 (YaTeX:check-completion-type 'maketitle) | |
235 (concat (YaTeX:read-boundary "_") (YaTeX:read-boundary "^")) | |
236 ) | |
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")) | |
247 (concat "_{" var " \\rightarrow " limit "}"))) | |
248 ) | |
249 | |
250 (defun YaTeX:gcd () | |
251 "Add-in function for \\gcd(m,n)." | |
252 (YaTeX:check-completion-type 'maketitle) | |
253 (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)") | |
254 ) | |
255 | |
256 (defun YaTeX:read-boundary (ULchar) | |
257 "Read boundary usage by _ or ^. _ or ^ is indicated by argument ULchar." | |
11 | 258 (let ((bndry (read-string (concat ULchar "{???} ($ for infinity): ")))) |
8 | 259 (if (string= bndry "") "" |
11 | 260 (if (string= bndry "$") (setq bndry "\\infty")) |
8 | 261 (concat ULchar "{" bndry "}"))) |
262 ) | |
263 | |
14 | 264 (defun YaTeX:verb () |
265 "Enclose \\verb's contents with the same characters." | |
266 (let ((quote-char (read-string "Quoting char: " "|")) | |
267 (contents (read-string "Quoted contents: "))) | |
268 (concat quote-char contents quote-char)) | |
269 ) | |
23 | 270 (fset 'YaTeX:verb* 'YaTeX:verb) |
14 | 271 |
43
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
272 (defun YaTeX:footnotemark () |
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
273 (setq section-name "footnotetext") |
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
274 nil |
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
275 ) |
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
276 |
48 | 277 (defun YaTeX:cite () |
278 (let ((comment (read-string "Comment for citation: "))) | |
279 (if (string= comment "") "" | |
280 (concat "[" comment "]"))) | |
281 ) | |
282 | |
283 (defun YaTeX:bibitem () | |
284 (let ((label (read-string "Citation label: "))) | |
285 (if (string= label "") "" | |
286 (concat "[" label "]"))) | |
287 ) | |
288 | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
289 (defun YaTeX:item () |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
290 (YaTeX-indent-line) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
291 (setq section-name "label") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
292 " ") |
52 | 293 (fset 'YaTeX:item\[\] 'YaTeX:item) |
294 (fset 'YaTeX:subitem 'YaTeX:item) | |
295 (fset 'YaTeX:subsubitem 'YaTeX:item) | |
296 | |
14 | 297 ;;; |
298 ;;Subroutine | |
299 ;;; | |
300 | |
8 | 301 (defun YaTeX:check-completion-type (type) |
302 "Check valid completion type." | |
303 (if (not (eq type YaTeX-current-completion-type)) | |
304 (error "This should be completed with %s-type completion." type)) | |
305 ) | |
11 | 306 |
307 | |
308 ;;; | |
309 ;;; [[Add-in functions for reading section arguments]] | |
310 ;;; | |
311 ;; All of add-in functions for reading sections arguments should | |
312 ;; take an argument ARGP that specify the argument position. | |
313 ;; If argument position is out of range, nil should be returned, | |
314 ;; else nil should NOT be returned. | |
13 | 315 |
316 ;; | |
317 ; Label selection | |
318 ;; | |
11 | 319 (defvar YaTeX-label-menu-other |
320 (if YaTeX-japan "':‘¼‚̃oƒbƒtƒ@‚̃‰ƒxƒ‹\n" "':LABEL IN OTHER BUFFER.\n")) | |
23 | 321 (defvar YaTeX-label-menu-repeat |
322 (if YaTeX-japan ".:’¼‘O‚Ì\\ref‚Æ“¯‚¶\n" "/:REPEAT LAST \ref{}\n")) | |
11 | 323 (defvar YaTeX-label-menu-any |
324 (if YaTeX-japan "*:”CˆÓ‚Ì•¶Žš—ñ\n" "*:ANY STRING.\n")) | |
325 (defvar YaTeX-label-buffer "*Label completions*") | |
326 (defvar YaTeX-label-guide-msg "Select label and hit RETURN.") | |
327 (defvar YaTeX-label-select-map nil | |
328 "Key map used in label selection buffer.") | |
329 (defun YaTeX::label-setup-key-map () | |
330 (if YaTeX-label-select-map nil | |
331 (message "Setting up label selection mode map...") | |
332 (setq YaTeX-label-select-map (copy-keymap global-map)) | |
333 (suppress-keymap YaTeX-label-select-map) | |
334 (substitute-all-key-definition | |
335 'previous-line 'YaTeX::label-previous YaTeX-label-select-map) | |
336 (substitute-all-key-definition | |
337 'next-line 'YaTeX::label-next YaTeX-label-select-map) | |
338 (define-key YaTeX-label-select-map "\C-n" 'YaTeX::label-next) | |
339 (define-key YaTeX-label-select-map "\C-p" 'YaTeX::label-previous) | |
340 (define-key YaTeX-label-select-map "<" 'beginning-of-buffer) | |
341 (define-key YaTeX-label-select-map ">" 'end-of-buffer) | |
342 (define-key YaTeX-label-select-map "\C-m" 'exit-recursive-edit) | |
343 (define-key YaTeX-label-select-map "\C-j" 'exit-recursive-edit) | |
344 (define-key YaTeX-label-select-map " " 'exit-recursive-edit) | |
345 (define-key YaTeX-label-select-map "\C-g" 'abort-recursive-edit) | |
346 (define-key YaTeX-label-select-map "/" 'isearch-forward) | |
347 (define-key YaTeX-label-select-map "?" 'isearch-backward) | |
348 (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag) | |
23 | 349 (define-key YaTeX-label-select-map "." 'YaTeX::label-search-tag) |
11 | 350 (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag) |
351 (message "Setting up label selection mode map...Done") | |
352 (let ((key ?A)) | |
353 (while (<= key ?Z) | |
354 (define-key YaTeX-label-select-map (char-to-string key) | |
355 'YaTeX::label-search-tag) | |
356 (define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A))) | |
357 'YaTeX::label-search-tag) | |
358 (setq key (1+ key))))) | |
359 ) | |
360 (defun YaTeX::label-next () | |
361 (interactive) (forward-line 1) (message YaTeX-label-guide-msg)) | |
362 (defun YaTeX::label-previous () | |
363 (interactive) (forward-line -1) (message YaTeX-label-guide-msg)) | |
364 (defun YaTeX::label-search-tag () | |
365 (interactive) | |
23 | 366 (let ((case-fold-search t) (tag (regexp-quote (this-command-keys)))) |
11 | 367 (cond |
368 ((save-excursion | |
369 (forward-char 1) | |
23 | 370 (re-search-forward (concat "^" tag) nil t)) |
11 | 371 (goto-char (match-beginning 0))) |
372 ((save-excursion | |
373 (goto-char (point-min)) | |
23 | 374 (re-search-forward (concat "^" tag) nil t)) |
11 | 375 (goto-char (match-beginning 0)))) |
376 (message YaTeX-label-guide-msg)) | |
377 ) | |
48 | 378 (defun YaTeX::ref (argp &optional labelcmd refcmd) |
11 | 379 (cond |
380 ((= argp 1) | |
381 (save-excursion | |
48 | 382 (let ((lnum 0) e0 label label-list (buf (current-buffer)) |
383 (labelcmd (or labelcmd "label")) (refcmd (or refcmd "ref")) | |
11 | 384 (p (point)) initl line) |
385 (goto-char (point-min)) | |
386 (message "Collecting labels...") | |
387 (save-window-excursion | |
12 | 388 (YaTeX-showup-buffer |
389 YaTeX-label-buffer (function (lambda (x) (window-width x)))) | |
11 | 390 (with-output-to-temp-buffer YaTeX-label-buffer |
48 | 391 (while (YaTeX-re-search-active-forward |
57 | 392 (concat "\\\\" labelcmd "\\b") |
48 | 393 (regexp-quote YaTeX-comment-prefix) nil t) |
394 (goto-char (match-beginning 0)) | |
395 (skip-chars-forward "^{") | |
396 (setq label | |
397 (buffer-substring | |
398 (1+ (point)) | |
399 (prog2 (forward-list 1) (setq e0 (1- (point))))) | |
400 label-list (cons label label-list)) | |
401 (or initl | |
402 (if (< p (point)) (setq initl lnum))) | |
403 (beginning-of-line) | |
404 (skip-chars-forward " \t\n" nil) | |
405 (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label | |
406 (buffer-substring (point) (point-end-of-line)))) | |
407 (setq lnum (1+ lnum)) | |
408 (message "Collecting \\%s{}... %d" labelcmd lnum) | |
11 | 409 (goto-char e0)) |
410 (princ YaTeX-label-menu-other) | |
23 | 411 (princ YaTeX-label-menu-repeat) |
11 | 412 (princ YaTeX-label-menu-any) |
413 );with | |
414 (goto-char p) | |
48 | 415 (message "Collecting %s...Done" labelcmd) |
11 | 416 (pop-to-buffer YaTeX-label-buffer) |
417 (YaTeX::label-setup-key-map) | |
418 (setq truncate-lines t) | |
419 (setq buffer-read-only t) | |
420 (use-local-map YaTeX-label-select-map) | |
421 (message YaTeX-label-guide-msg) | |
422 (goto-line (or initl lnum)) ;goto recently defined label line | |
423 (unwind-protect | |
424 (progn | |
425 (recursive-edit) | |
426 (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion | |
427 (beginning-of-line) | |
428 (setq line (count-lines (point-min)(point))) | |
429 (cond | |
430 ((= line lnum) (setq label (YaTeX-label-other))) | |
23 | 431 ((= line (1+ lnum)) |
432 (save-excursion | |
433 (switch-to-buffer buf) | |
434 (goto-char p) | |
48 | 435 (if (re-search-backward |
436 (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t) | |
437 (setq label (YaTeX-match-string 1)) | |
23 | 438 (setq label "")))) |
439 ((>= line (+ lnum 2)) | |
48 | 440 (setq label (read-string (format "\\%s{???}: " refcmd)))) |
11 | 441 (t (setq label (nth (- lnum line 1) label-list))))) |
442 (bury-buffer YaTeX-label-buffer))) | |
443 label | |
444 )) | |
445 )) | |
446 ) | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
447 (fset 'YaTeX::pageref 'YaTeX::ref) |
48 | 448 (defun YaTeX::cite (argp) |
449 (cond | |
450 ((eq argp 1) | |
451 (YaTeX::ref argp "bibitem\\(\\[.*\\]\\)?" "cite")) | |
452 (t nil))) | |
11 | 453 |
48 | 454 (defun YaTeX-yatex-buffer-list () |
455 (save-excursion | |
456 (delq nil (mapcar (function (lambda (buf) | |
457 (set-buffer buf) | |
458 (if (eq major-mode 'yatex-mode) buf))) | |
459 (buffer-list)))) | |
460 ) | |
461 | |
462 (defun YaTeX-select-other-yatex-buffer () | |
463 "Select buffer from all yatex-mode's buffers interactivelly." | |
464 (interactive) | |
465 (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list)) | |
466 (lnum -1) buf rv | |
11 | 467 (ff "**find-file**")) |
12 | 468 (YaTeX-showup-buffer |
469 lbuf (function (lambda (x) 1))) ;;Select next window surely. | |
11 | 470 (with-output-to-temp-buffer lbuf |
471 (while blist | |
48 | 472 (princ |
473 (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A) | |
474 (buffer-name (car blist)))) | |
11 | 475 (setq blist (cdr blist))) |
476 (princ (format "':{%s}" ff))) | |
477 (pop-to-buffer lbuf) | |
478 (YaTeX::label-setup-key-map) | |
479 (setq buffer-read-only t) | |
480 (use-local-map YaTeX-label-select-map) | |
481 (message YaTeX-label-guide-msg) | |
482 (unwind-protect | |
483 (progn | |
484 (recursive-edit) | |
485 (set-buffer lbuf) | |
486 (beginning-of-line) | |
487 (setq rv | |
488 (if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t) | |
489 (buffer-substring (match-beginning 1) (match-end 1)) nil))) | |
490 (kill-buffer lbuf)) | |
48 | 491 (if (string= rv ff) |
492 (progn | |
493 (call-interactively 'find-file) | |
494 (current-buffer)) | |
495 rv)) | |
496 ) | |
497 | |
498 (defun YaTeX-label-other () | |
499 (let ((rv (YaTeX-select-other-yatex-buffer))) | |
11 | 500 (cond |
501 ((null rv) "") | |
502 (t | |
503 (set-buffer rv) | |
48 | 504 (YaTeX::ref argp labelcmd refcmd))) |
11 | 505 ) |
506 ) | |
507 | |
13 | 508 ;; |
509 ; completion for the arguments of \newcommand | |
510 ;; | |
511 (defun YaTeX::newcommand (&optional argp) | |
512 (cond | |
513 ((= argp 1) | |
514 (let ((command (read-string "Define newcommand: " "\\"))) | |
515 (put 'YaTeX::newcommand 'command (substring command 1)) | |
516 command)) | |
517 ((= argp 2) | |
518 (let ((argc | |
519 (string-to-int (read-string "Number of arguments(Default 0): "))) | |
520 (def (read-string "Definition: ")) | |
521 (command (get 'YaTeX::newcommand 'command))) | |
522 ;;!!! It's illegal to insert string in the add-in function !!! | |
523 (if (> argc 0) (insert (format "[%d]" argc))) | |
524 (if (and (stringp command) | |
525 (string< "" command) | |
51 | 526 (y-or-n-p "Update dictionary?")) |
18 | 527 (cond |
528 ((= argc 0) | |
529 (YaTeX-update-table | |
530 (list command) | |
531 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table)) | |
532 ((= argc 1) | |
533 (YaTeX-update-table | |
534 (list command) | |
535 'section-table 'user-section-table 'tmp-section-table)) | |
536 (t (YaTeX-update-table | |
537 (list command argc) | |
538 'section-table 'user-section-table 'tmp-section-table)))) | |
13 | 539 (message "") |
540 def ;return command name | |
541 )) | |
542 (t "")) | |
543 ) | |
544 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
545 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
546 ; completion for the arguments of \pagestyle |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
547 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
548 (defun YaTeX::pagestyle (&optional argp) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
549 "Read the pagestyle with completion." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
550 (completing-read |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
551 "Page style: " |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
552 '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
553 ) |
51 | 554 (fset 'YaTeX::thispagestyle 'YaTeX::pagestyle) |
555 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
556 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
557 ; completion for the arguments of \pagenumbering |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
558 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
559 (defun YaTeX::pagenumbering (&optional argp) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
560 "Read the numbering style." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
561 (completing-read |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
562 "Page numbering style: " |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
563 '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman"))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
564 ) |
13 | 565 |
23 | 566 ;; |
567 ; Length | |
568 ;; | |
569 (defvar YaTeX:style-parameters-default | |
570 '(("\\arraycolsep") | |
571 ("\\arrayrulewidth") | |
572 ("\\baselineskip") | |
573 ("\\columnsep") | |
574 ("\\columnseprule") | |
575 ("\\doublerulesep") | |
576 ("\\evensidemargin") | |
577 ("\\footheight") | |
578 ("\\footskip") | |
579 ("\\headheight") | |
580 ("\\headsep") | |
581 ("\\itemindent") | |
582 ("\\itemsep") | |
583 ("\\labelsep") | |
584 ("\\labelwidth") | |
585 ("\\leftmargin") | |
586 ("\\linewidth") | |
587 ("\\listparindent") | |
588 ("\\marginparsep") | |
589 ("\\marginparwidth") | |
590 ("\\mathindent") | |
591 ("\\oddsidemargin") | |
592 ("\\parindent") | |
593 ("\\parsep") | |
594 ("\\parskip") | |
595 ("\\partopsep") | |
596 ("\\rightmargin") | |
597 ("\\tabcolsep") | |
598 ("\\textheight") | |
599 ("\\textwidth") | |
600 ("\\topmargin") | |
601 ("\\topsep") | |
602 ("\\topskip") | |
603 ) | |
604 "Alist of LaTeX style parameters.") | |
605 (defvar YaTeX:style-parameters-private nil | |
606 "*User definable alist of style parameters.") | |
49 | 607 (defvar YaTeX:style-parameters-local nil |
608 "*User definable alist of local style parameters.") | |
23 | 609 |
610 (defvar YaTeX:length-history nil "Holds history of length.") | |
51 | 611 (put 'YaTeX:length-history 'no-default t) |
23 | 612 (defun YaTeX::setlength (&optional argp) |
613 "YaTeX add-in function for arguments of \\setlength." | |
614 (cond | |
615 ((equal 1 argp) | |
49 | 616 ;;(completing-read "Length variable: " YaTeX:style-parameters nil nil "\\") |
617 (YaTeX-cplread-with-learning | |
618 "Length variable: " | |
619 'YaTeX:style-parameters-default | |
620 'YaTeX:style-parameters-private | |
621 'YaTeX:style-parameters-local | |
622 nil nil "\\") | |
623 ) | |
23 | 624 ((equal 2 argp) |
51 | 625 (read-string-with-history "Length: " nil 'YaTeX:length-history))) |
23 | 626 ) |
627 (fset 'YaTeX::addtolength 'YaTeX::setlength) | |
628 | |
629 (defun YaTeX::settowidth (&optional argp) | |
630 "YaTeX add-in function for arguments of \\settowidth." | |
631 (cond | |
632 ((equal 1 argp) | |
49 | 633 (YaTeX-cplread-with-learning |
634 "Length variable: " | |
635 'YaTeX:style-parameters-default | |
636 'YaTeX:style-parameters-private | |
637 'YaTeX:style-parameters-local | |
638 nil nil "\\")) | |
23 | 639 ((equal 2 argp) |
640 (read-string "Text: "))) | |
641 ) | |
642 (defun YaTeX::newlength (&optional argp) | |
643 "YaTeX add-in function for arguments of \\newlength" | |
644 (cond | |
645 ((equal argp 1) | |
646 (let ((length (read-string "Length variable: " "\\"))) | |
49 | 647 (if (string< "" length) |
648 (YaTeX-update-table | |
649 (list length) | |
650 'YaTeX:style-parameters-default | |
651 'YaTeX:style-parameters-private | |
652 'YaTeX:style-parameters-local)) | |
653 length) | |
654 )) | |
23 | 655 ) |
656 | |
657 ;; \multicolumn's arguments | |
658 (defun YaTeX::multicolumn (&optional argp) | |
659 "YaTeX add-in function for arguments of \\multicolumn." | |
660 (cond | |
661 ((equal 1 argp) | |
662 (read-string "Number of columns: ")) | |
663 ((equal 2 argp) | |
664 (let (c) | |
665 (while (not (string-match | |
666 (progn (message "Format(one of l,r,c): ") | |
667 (setq c (char-to-string (read-char)))) | |
668 "lrc"))) | |
669 c)) | |
670 ((equal 3 argp) | |
671 (read-string "Item: "))) | |
672 ) | |
673 | |
49 | 674 (defvar YaTeX:documentstyles-default |
675 '(("article") ("jarticle") ("j-article") | |
676 ("book") ("jbook") ("j-book") | |
677 ("report") ("jreport") ("j-report") | |
678 ("letter") ("ascjletter")) | |
679 "List of LaTeX documentstyles.") | |
680 (defvar YaTeX:documentstyles-private nil | |
681 "*User defined list of LaTeX documentstyles.") | |
682 (defvar YaTeX:documentstyles-local nil | |
683 "*User defined list of local LaTeX documentstyles.") | |
684 (defvar YaTeX:documentstyle-options-default | |
685 '(("a4j") ("a5j") ("b4j") ("b5j") | |
686 ("twocolumn") ("jtwocolumn") ("epsf") ("epsfig") ("epsbox") ("nfig")) | |
687 "List of LaTeX documentstyle options.") | |
688 (defvar YaTeX:documentstyle-options-private nil | |
689 "*User defined list of LaTeX documentstyle options.") | |
690 (defvar YaTeX:documentstyle-options-local nil | |
691 "List of LaTeX local documentstyle options.") | |
692 | |
693 (defvar YaTeX-minibuffer-completion-map nil | |
694 "Minibuffer completion key map that allows comma completion.") | |
695 (if YaTeX-minibuffer-completion-map nil | |
696 (setq YaTeX-minibuffer-completion-map | |
697 (copy-keymap minibuffer-local-completion-map)) | |
698 (define-key YaTeX-minibuffer-completion-map " " | |
699 'YaTeX-minibuffer-complete) | |
700 (define-key YaTeX-minibuffer-completion-map "\t" | |
701 'YaTeX-minibuffer-complete)) | |
702 | |
703 (defun YaTeX:documentstyle () | |
704 (let*((delim ",") | |
705 (dt (append YaTeX:documentstyle-options-local | |
706 YaTeX:documentstyle-options-private | |
707 YaTeX:documentstyle-options-default)) | |
708 (minibuffer-completion-table dt) | |
709 (opt (read-from-minibuffer | |
710 "Style options ([opt1,opt2,...]): " | |
51 | 711 nil YaTeX-minibuffer-completion-map nil)) |
49 | 712 (substr opt) o) |
713 (if (string< "" opt) | |
714 (progn | |
715 (while substr | |
716 (setq o (substring substr 0 (string-match delim substr))) | |
717 (or (assoc o dt) | |
718 (YaTeX-update-table | |
719 (list o) | |
720 'YaTeX:documentstyle-options-default | |
721 'YaTeX:documentstyle-options-private | |
722 'YaTeX:documentstyle-options-local)) | |
723 (setq substr | |
724 (if (string-match delim substr) | |
725 (substring substr (1+ (string-match delim substr)))))) | |
726 (concat "[" opt "]")) | |
727 ""))) | |
728 | |
729 (defun YaTeX::documentstyle (&optional argp) | |
51 | 730 "YaTeX add-in function for arguments of \\documentstyle." |
49 | 731 (cond |
732 ((equal argp 1) | |
51 | 733 (setq env-name "document") |
49 | 734 (let ((sname |
735 (YaTeX-cplread-with-learning | |
736 (format "Documentstyle (default %s): " | |
737 YaTeX-default-document-style) | |
738 'YaTeX:documentstyles-default | |
739 'YaTeX:documentstyles-private | |
740 'YaTeX:documentstyles-local))) | |
741 (if (string= "" sname) (setq sname YaTeX-default-document-style)) | |
742 (setq YaTeX-default-document-style sname)))) | |
743 ) | |
744 | |
57 | 745 ;;; -------------------- LaTeX2e stuff -------------------- |
746 (defvar YaTeX:documentclass-options-default | |
747 '(("a4paper") ("a5paper") ("b5paper") ("10pt") ("11pt") ("12pt") | |
748 ("latterpaper") ("legalpaper") ("executivepaper") ("landscape") | |
749 ("oneside") ("twoside") ("draft") ("final") ("leqno") ("fleqn") ("openbib") | |
750 ("clock") ;for slides class only | |
751 ) | |
752 "Default options list for documentclass") | |
753 (defvar YaTeX:documentclass-options-private nil | |
754 "*User defined options list for documentclass") | |
755 (defvar YaTeX:documentclass-options-local nil | |
756 "*User defined options list for local documentclass") | |
757 | |
758 (defun YaTeX:documentclass () | |
759 (let*((delim ",") | |
760 (dt (append YaTeX:documentclass-options-local | |
761 YaTeX:documentclass-options-private | |
762 YaTeX:documentclass-options-default)) | |
763 (minibuffer-completion-table dt) | |
764 (opt (read-from-minibuffer | |
765 "Documentclass options ([opt1,opt2,...]): " | |
766 nil YaTeX-minibuffer-completion-map nil)) | |
767 (substr opt) o) | |
768 (if (string< "" opt) | |
769 (progn | |
770 (while substr | |
771 (setq o (substring substr 0 (string-match delim substr))) | |
772 (or (assoc o dt) | |
773 (YaTeX-update-table | |
774 (list o) | |
775 'YaTeX:documentclass-options-default | |
776 'YaTeX:documentclass-options-private | |
777 'YaTeX:documentclass-options-local)) | |
778 (setq substr | |
779 (if (string-match delim substr) | |
780 (substring substr (1+ (string-match delim substr)))))) | |
781 (concat "[" opt "]")) | |
782 ""))) | |
783 | |
784 (defvar YaTeX:documentclasses-default | |
785 '(("article") ("jarticle") ("report") ("jreport") ("book") ("jbook") | |
786 ("j-article") ("j-report") ("j-book") | |
787 ("letter") ("slides") ("ltxdoc") ("ltxguide") ("ltnews") ("proc")) | |
788 "Default documentclass alist") | |
789 (defvar YaTeX:documentclasses-private nil | |
790 "*User defined documentclass alist") | |
791 (defvar YaTeX:documentclasses-local nil | |
792 "*User defined local documentclass alist") | |
793 (defvar YaTeX-default-documentclass (if YaTeX-japan "jarticle" "article") | |
794 "*Default documentclass") | |
795 | |
796 (defun YaTeX::documentclass (&optional argp) | |
797 (cond | |
798 ((equal argp 1) | |
799 (setq env-name "document") | |
800 (let ((sname | |
801 (YaTeX-cplread-with-learning | |
802 (format "Documentclass (default %s): " YaTeX-default-documentclass) | |
803 'YaTeX:documentclasses-default | |
804 'YaTeX:documentclasses-private | |
805 'YaTeX:documentclasses-local))) | |
806 (if (string= "" sname) (setq sname YaTeX-default-documentclass)) | |
807 (setq YaTeX-default-documentclass sname))))) | |
808 | |
23 | 809 ;;; -------------------- End of yatexadd -------------------- |
810 (provide 'yatexadd) |