yatex

view yatexadd.el @ 58:3a7c0c2bf16d

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