yatex

view yatexadd.el @ 52:5d94deabb9f9

Set YaTeX-indent-line to 'indent-line-function. Revise fill features.
author yuuji
date Sun, 22 Jan 1995 14:20:46 +0000
parents b0371b6ed799
children 5f4b18da14b3
line source
1 ;;; -*- Emacs-Lisp -*-
2 ;;; YaTeX add-in functions.
3 ;;; yatexadd.el rev.12
4 ;;; (c )1991-1995 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
5 ;;; Last modified Sun Jan 22 23:15:48 1995 on landcruiser
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))
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))))
62 )
63 (fset 'YaTeX:tabular* 'YaTeX:tabular)
64 (defun YaTeX:array ()
65 (concat (YaTeX:read-position "tb")
66 "{" (read-string "Column format: ") "}")
67 )
69 (defun YaTeX:read-oneof (oneof)
70 (let ((pos "") loc (guide ""))
71 (and (boundp 'name) name (setq guide (format "%s " name)))
72 (while (not (string-match
73 (setq loc (read-key-sequence
74 (format "%s position (`%s') [%s]: "
75 guide oneof pos)));name is in YaTeX-addin
76 "\r\^g\n"))
77 (cond
78 ((string-match loc oneof)
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)
85 (message "Please input one of `%s'." oneof)
86 (sit-for 3))))
87 (message "")
88 pos)
89 )
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 "]")))
95 )
97 (defun YaTeX:table ()
98 "YaTeX add-in function for table environment."
99 (YaTeX:read-position "htbp")
100 )
102 (fset 'YaTeX:figure 'YaTeX:table)
103 (fset 'YaTeX:figure* 'YaTeX:table)
106 (defun YaTeX:description ()
107 "Truly poor service:-)"
108 (setq single-command "item[]")
109 ""
110 )
112 (defun YaTeX:itemize ()
113 "It's also poor service."
114 (setq single-command "item")
115 ""
116 )
118 (fset 'YaTeX:enumerate 'YaTeX:itemize)
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 )
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)
133 (defun YaTeX:list ()
134 "%\n{} %default label\n{} %formatting parameter"
135 )
137 (defun YaTeX:minipage ()
138 (concat (YaTeX:read-position "cbt")
139 "{" (read-string "Width: ") "}")
140 )
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 )
151 (defun YaTeX:put ()
152 (YaTeX:read-coordinates "Pos")
153 )
155 (defun YaTeX:makebox ()
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")))))))
167 )
169 (defun YaTeX:framebox ()
170 (if (YaTeX-quick-in-environment-p "picture")
171 (YaTeX:makebox))
172 )
174 (defun YaTeX:dashbox ()
175 (concat "{" (read-string "Dash dimension: ") "}"
176 (YaTeX:read-coordinates "Dimension"))
177 )
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)))))
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.")
199 (defvar YaTeX:left-right-default nil "Default string of YaTeX:right.")
201 (defun YaTeX:left ()
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))
217 (fset 'YaTeX:right 'YaTeX:left)
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 )
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 )
238 (fset 'YaTeX:int 'YaTeX:sum)
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 )
250 (defun YaTeX:gcd ()
251 "Add-in function for \\gcd(m,n)."
252 (YaTeX:check-completion-type 'maketitle)
253 (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)")
254 )
256 (defun YaTeX:read-boundary (ULchar)
257 "Read boundary usage by _ or ^. _ or ^ is indicated by argument ULchar."
258 (let ((bndry (read-string (concat ULchar "{???} ($ for infinity): "))))
259 (if (string= bndry "") ""
260 (if (string= bndry "$") (setq bndry "\\infty"))
261 (concat ULchar "{" bndry "}")))
262 )
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 )
270 (fset 'YaTeX:verb* 'YaTeX:verb)
272 (defun YaTeX:footnotemark ()
273 (setq section-name "footnotetext")
274 nil
275 )
277 (defun YaTeX:cite ()
278 (let ((comment (read-string "Comment for citation: ")))
279 (if (string= comment "") ""
280 (concat "[" comment "]")))
281 )
283 (defun YaTeX:bibitem ()
284 (let ((label (read-string "Citation label: ")))
285 (if (string= label "") ""
286 (concat "[" label "]")))
287 )
289 (defun YaTeX:item () " ")
290 (fset 'YaTeX:item\[\] 'YaTeX:item)
291 (fset 'YaTeX:subitem 'YaTeX:item)
292 (fset 'YaTeX:subsubitem 'YaTeX:item)
294 ;;;
295 ;;Subroutine
296 ;;;
298 (defun YaTeX:check-completion-type (type)
299 "Check valid completion type."
300 (if (not (eq type YaTeX-current-completion-type))
301 (error "This should be completed with %s-type completion." type))
302 )
305 ;;;
306 ;;; [[Add-in functions for reading section arguments]]
307 ;;;
308 ;; All of add-in functions for reading sections arguments should
309 ;; take an argument ARGP that specify the argument position.
310 ;; If argument position is out of range, nil should be returned,
311 ;; else nil should NOT be returned.
313 ;;
314 ; Label selection
315 ;;
316 (defvar YaTeX-label-menu-other
317 (if YaTeX-japan "':他のバッファのラベル\n" "':LABEL IN OTHER BUFFER.\n"))
318 (defvar YaTeX-label-menu-repeat
319 (if YaTeX-japan ".:直前の\\refと同じ\n" "/:REPEAT LAST \ref{}\n"))
320 (defvar YaTeX-label-menu-any
321 (if YaTeX-japan "*:任意の文字列\n" "*:ANY STRING.\n"))
322 (defvar YaTeX-label-buffer "*Label completions*")
323 (defvar YaTeX-label-guide-msg "Select label and hit RETURN.")
324 (defvar YaTeX-label-select-map nil
325 "Key map used in label selection buffer.")
326 (defun YaTeX::label-setup-key-map ()
327 (if YaTeX-label-select-map nil
328 (message "Setting up label selection mode map...")
329 (setq YaTeX-label-select-map (copy-keymap global-map))
330 (suppress-keymap YaTeX-label-select-map)
331 (substitute-all-key-definition
332 'previous-line 'YaTeX::label-previous YaTeX-label-select-map)
333 (substitute-all-key-definition
334 'next-line 'YaTeX::label-next YaTeX-label-select-map)
335 (define-key YaTeX-label-select-map "\C-n" 'YaTeX::label-next)
336 (define-key YaTeX-label-select-map "\C-p" 'YaTeX::label-previous)
337 (define-key YaTeX-label-select-map "<" 'beginning-of-buffer)
338 (define-key YaTeX-label-select-map ">" 'end-of-buffer)
339 (define-key YaTeX-label-select-map "\C-m" 'exit-recursive-edit)
340 (define-key YaTeX-label-select-map "\C-j" 'exit-recursive-edit)
341 (define-key YaTeX-label-select-map " " 'exit-recursive-edit)
342 (define-key YaTeX-label-select-map "\C-g" 'abort-recursive-edit)
343 (define-key YaTeX-label-select-map "/" 'isearch-forward)
344 (define-key YaTeX-label-select-map "?" 'isearch-backward)
345 (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag)
346 (define-key YaTeX-label-select-map "." 'YaTeX::label-search-tag)
347 (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag)
348 (message "Setting up label selection mode map...Done")
349 (let ((key ?A))
350 (while (<= key ?Z)
351 (define-key YaTeX-label-select-map (char-to-string key)
352 'YaTeX::label-search-tag)
353 (define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A)))
354 'YaTeX::label-search-tag)
355 (setq key (1+ key)))))
356 )
357 (defun YaTeX::label-next ()
358 (interactive) (forward-line 1) (message YaTeX-label-guide-msg))
359 (defun YaTeX::label-previous ()
360 (interactive) (forward-line -1) (message YaTeX-label-guide-msg))
361 (defun YaTeX::label-search-tag ()
362 (interactive)
363 (let ((case-fold-search t) (tag (regexp-quote (this-command-keys))))
364 (cond
365 ((save-excursion
366 (forward-char 1)
367 (re-search-forward (concat "^" tag) nil t))
368 (goto-char (match-beginning 0)))
369 ((save-excursion
370 (goto-char (point-min))
371 (re-search-forward (concat "^" tag) nil t))
372 (goto-char (match-beginning 0))))
373 (message YaTeX-label-guide-msg))
374 )
375 (defun YaTeX::ref (argp &optional labelcmd refcmd)
376 (cond
377 ((= argp 1)
378 (save-excursion
379 (let ((lnum 0) e0 label label-list (buf (current-buffer))
380 (labelcmd (or labelcmd "label")) (refcmd (or refcmd "ref"))
381 (p (point)) initl line)
382 (goto-char (point-min))
383 (message "Collecting labels...")
384 (save-window-excursion
385 (YaTeX-showup-buffer
386 YaTeX-label-buffer (function (lambda (x) (window-width x))))
387 (with-output-to-temp-buffer YaTeX-label-buffer
388 (while (YaTeX-re-search-active-forward
389 (concat "\\\\" labelcmd)
390 (regexp-quote YaTeX-comment-prefix) nil t)
391 (goto-char (match-beginning 0))
392 (skip-chars-forward "^{")
393 (setq label
394 (buffer-substring
395 (1+ (point))
396 (prog2 (forward-list 1) (setq e0 (1- (point)))))
397 label-list (cons label label-list))
398 (or initl
399 (if (< p (point)) (setq initl lnum)))
400 (beginning-of-line)
401 (skip-chars-forward " \t\n" nil)
402 (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label
403 (buffer-substring (point) (point-end-of-line))))
404 (setq lnum (1+ lnum))
405 (message "Collecting \\%s{}... %d" labelcmd lnum)
406 (goto-char e0))
407 (princ YaTeX-label-menu-other)
408 (princ YaTeX-label-menu-repeat)
409 (princ YaTeX-label-menu-any)
410 );with
411 (goto-char p)
412 (message "Collecting %s...Done" labelcmd)
413 (pop-to-buffer YaTeX-label-buffer)
414 (YaTeX::label-setup-key-map)
415 (setq truncate-lines t)
416 (setq buffer-read-only t)
417 (use-local-map YaTeX-label-select-map)
418 (message YaTeX-label-guide-msg)
419 (goto-line (or initl lnum)) ;goto recently defined label line
420 (unwind-protect
421 (progn
422 (recursive-edit)
423 (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion
424 (beginning-of-line)
425 (setq line (count-lines (point-min)(point)))
426 (cond
427 ((= line lnum) (setq label (YaTeX-label-other)))
428 ((= line (1+ lnum))
429 (save-excursion
430 (switch-to-buffer buf)
431 (goto-char p)
432 (if (re-search-backward
433 (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t)
434 (setq label (YaTeX-match-string 1))
435 (setq label ""))))
436 ((>= line (+ lnum 2))
437 (setq label (read-string (format "\\%s{???}: " refcmd))))
438 (t (setq label (nth (- lnum line 1) label-list)))))
439 (bury-buffer YaTeX-label-buffer)))
440 label
441 ))
442 ))
443 )
444 (fset 'YaTeX::pageref 'YaTeX::ref)
445 (defun YaTeX::cite (argp)
446 (cond
447 ((eq argp 1)
448 (YaTeX::ref argp "bibitem\\(\\[.*\\]\\)?" "cite"))
449 (t nil)))
451 (defun YaTeX-yatex-buffer-list ()
452 (save-excursion
453 (delq nil (mapcar (function (lambda (buf)
454 (set-buffer buf)
455 (if (eq major-mode 'yatex-mode) buf)))
456 (buffer-list))))
457 )
459 (defun YaTeX-select-other-yatex-buffer ()
460 "Select buffer from all yatex-mode's buffers interactivelly."
461 (interactive)
462 (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list))
463 (lnum -1) buf rv
464 (ff "**find-file**"))
465 (YaTeX-showup-buffer
466 lbuf (function (lambda (x) 1))) ;;Select next window surely.
467 (with-output-to-temp-buffer lbuf
468 (while blist
469 (princ
470 (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A)
471 (buffer-name (car blist))))
472 (setq blist (cdr blist)))
473 (princ (format "':{%s}" ff)))
474 (pop-to-buffer lbuf)
475 (YaTeX::label-setup-key-map)
476 (setq buffer-read-only t)
477 (use-local-map YaTeX-label-select-map)
478 (message YaTeX-label-guide-msg)
479 (unwind-protect
480 (progn
481 (recursive-edit)
482 (set-buffer lbuf)
483 (beginning-of-line)
484 (setq rv
485 (if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t)
486 (buffer-substring (match-beginning 1) (match-end 1)) nil)))
487 (kill-buffer lbuf))
488 (if (string= rv ff)
489 (progn
490 (call-interactively 'find-file)
491 (current-buffer))
492 rv))
493 )
495 (defun YaTeX-label-other ()
496 (let ((rv (YaTeX-select-other-yatex-buffer)))
497 (cond
498 ((null rv) "")
499 (t
500 (set-buffer rv)
501 (YaTeX::ref argp labelcmd refcmd)))
502 )
503 )
505 ;;
506 ; completion for the arguments of \newcommand
507 ;;
508 (defun YaTeX::newcommand (&optional argp)
509 (cond
510 ((= argp 1)
511 (let ((command (read-string "Define newcommand: " "\\")))
512 (put 'YaTeX::newcommand 'command (substring command 1))
513 command))
514 ((= argp 2)
515 (let ((argc
516 (string-to-int (read-string "Number of arguments(Default 0): ")))
517 (def (read-string "Definition: "))
518 (command (get 'YaTeX::newcommand 'command)))
519 ;;!!! It's illegal to insert string in the add-in function !!!
520 (if (> argc 0) (insert (format "[%d]" argc)))
521 (if (and (stringp command)
522 (string< "" command)
523 (y-or-n-p "Update dictionary?"))
524 (cond
525 ((= argc 0)
526 (YaTeX-update-table
527 (list command)
528 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table))
529 ((= argc 1)
530 (YaTeX-update-table
531 (list command)
532 'section-table 'user-section-table 'tmp-section-table))
533 (t (YaTeX-update-table
534 (list command argc)
535 'section-table 'user-section-table 'tmp-section-table))))
536 (message "")
537 def ;return command name
538 ))
539 (t ""))
540 )
542 ;;
543 ; completion for the arguments of \pagestyle
544 ;;
545 (defun YaTeX::pagestyle (&optional argp)
546 "Read the pagestyle with completion."
547 (completing-read
548 "Page style: "
549 '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil))
550 )
551 (fset 'YaTeX::thispagestyle 'YaTeX::pagestyle)
553 ;;
554 ; completion for the arguments of \pagenumbering
555 ;;
556 (defun YaTeX::pagenumbering (&optional argp)
557 "Read the numbering style."
558 (completing-read
559 "Page numbering style: "
560 '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman")))
561 )
563 ;;
564 ; Length
565 ;;
566 (defvar YaTeX:style-parameters-default
567 '(("\\arraycolsep")
568 ("\\arrayrulewidth")
569 ("\\baselineskip")
570 ("\\columnsep")
571 ("\\columnseprule")
572 ("\\doublerulesep")
573 ("\\evensidemargin")
574 ("\\footheight")
575 ("\\footskip")
576 ("\\headheight")
577 ("\\headsep")
578 ("\\itemindent")
579 ("\\itemsep")
580 ("\\labelsep")
581 ("\\labelwidth")
582 ("\\leftmargin")
583 ("\\linewidth")
584 ("\\listparindent")
585 ("\\marginparsep")
586 ("\\marginparwidth")
587 ("\\mathindent")
588 ("\\oddsidemargin")
589 ("\\parindent")
590 ("\\parsep")
591 ("\\parskip")
592 ("\\partopsep")
593 ("\\rightmargin")
594 ("\\tabcolsep")
595 ("\\textheight")
596 ("\\textwidth")
597 ("\\topmargin")
598 ("\\topsep")
599 ("\\topskip")
600 )
601 "Alist of LaTeX style parameters.")
602 (defvar YaTeX:style-parameters-private nil
603 "*User definable alist of style parameters.")
604 (defvar YaTeX:style-parameters-local nil
605 "*User definable alist of local style parameters.")
607 (defvar YaTeX:length-history nil "Holds history of length.")
608 (put 'YaTeX:length-history 'no-default t)
609 (defun YaTeX::setlength (&optional argp)
610 "YaTeX add-in function for arguments of \\setlength."
611 (cond
612 ((equal 1 argp)
613 ;;(completing-read "Length variable: " YaTeX:style-parameters nil nil "\\")
614 (YaTeX-cplread-with-learning
615 "Length variable: "
616 'YaTeX:style-parameters-default
617 'YaTeX:style-parameters-private
618 'YaTeX:style-parameters-local
619 nil nil "\\")
620 )
621 ((equal 2 argp)
622 (read-string-with-history "Length: " nil 'YaTeX:length-history)))
623 )
624 (fset 'YaTeX::addtolength 'YaTeX::setlength)
626 (defun YaTeX::settowidth (&optional argp)
627 "YaTeX add-in function for arguments of \\settowidth."
628 (cond
629 ((equal 1 argp)
630 (YaTeX-cplread-with-learning
631 "Length variable: "
632 'YaTeX:style-parameters-default
633 'YaTeX:style-parameters-private
634 'YaTeX:style-parameters-local
635 nil nil "\\"))
636 ((equal 2 argp)
637 (read-string "Text: ")))
638 )
639 (defun YaTeX::newlength (&optional argp)
640 "YaTeX add-in function for arguments of \\newlength"
641 (cond
642 ((equal argp 1)
643 (let ((length (read-string "Length variable: " "\\")))
644 (if (string< "" length)
645 (YaTeX-update-table
646 (list length)
647 'YaTeX:style-parameters-default
648 'YaTeX:style-parameters-private
649 'YaTeX:style-parameters-local))
650 length)
651 ))
652 )
654 ;; \multicolumn's arguments
655 (defun YaTeX::multicolumn (&optional argp)
656 "YaTeX add-in function for arguments of \\multicolumn."
657 (cond
658 ((equal 1 argp)
659 (read-string "Number of columns: "))
660 ((equal 2 argp)
661 (let (c)
662 (while (not (string-match
663 (progn (message "Format(one of l,r,c): ")
664 (setq c (char-to-string (read-char))))
665 "lrc")))
666 c))
667 ((equal 3 argp)
668 (read-string "Item: ")))
669 )
671 (defvar YaTeX:documentstyles-default
672 '(("article") ("jarticle") ("j-article")
673 ("book") ("jbook") ("j-book")
674 ("report") ("jreport") ("j-report")
675 ("letter") ("ascjletter"))
676 "List of LaTeX documentstyles.")
677 (defvar YaTeX:documentstyles-private nil
678 "*User defined list of LaTeX documentstyles.")
679 (defvar YaTeX:documentstyles-local nil
680 "*User defined list of local LaTeX documentstyles.")
681 (defvar YaTeX:documentstyle-options-default
682 '(("a4j") ("a5j") ("b4j") ("b5j")
683 ("twocolumn") ("jtwocolumn") ("epsf") ("epsfig") ("epsbox") ("nfig"))
684 "List of LaTeX documentstyle options.")
685 (defvar YaTeX:documentstyle-options-private nil
686 "*User defined list of LaTeX documentstyle options.")
687 (defvar YaTeX:documentstyle-options-local nil
688 "List of LaTeX local documentstyle options.")
690 (defvar YaTeX-minibuffer-completion-map nil
691 "Minibuffer completion key map that allows comma completion.")
692 (if YaTeX-minibuffer-completion-map nil
693 (setq YaTeX-minibuffer-completion-map
694 (copy-keymap minibuffer-local-completion-map))
695 (define-key YaTeX-minibuffer-completion-map " "
696 'YaTeX-minibuffer-complete)
697 (define-key YaTeX-minibuffer-completion-map "\t"
698 'YaTeX-minibuffer-complete))
700 (defun YaTeX:documentstyle ()
701 (let*((delim ",")
702 (dt (append YaTeX:documentstyle-options-local
703 YaTeX:documentstyle-options-private
704 YaTeX:documentstyle-options-default))
705 (minibuffer-completion-table dt)
706 (opt (read-from-minibuffer
707 "Style options ([opt1,opt2,...]): "
708 nil YaTeX-minibuffer-completion-map nil))
709 (substr opt) o)
710 (if (string< "" opt)
711 (progn
712 (while substr
713 (setq o (substring substr 0 (string-match delim substr)))
714 (or (assoc o dt)
715 (YaTeX-update-table
716 (list o)
717 'YaTeX:documentstyle-options-default
718 'YaTeX:documentstyle-options-private
719 'YaTeX:documentstyle-options-local))
720 (setq substr
721 (if (string-match delim substr)
722 (substring substr (1+ (string-match delim substr))))))
723 (concat "[" opt "]"))
724 "")))
726 (defun YaTeX::documentstyle (&optional argp)
727 "YaTeX add-in function for arguments of \\documentstyle."
728 (cond
729 ((equal argp 1)
730 (setq env-name "document")
731 (let ((sname
732 (YaTeX-cplread-with-learning
733 (format "Documentstyle (default %s): "
734 YaTeX-default-document-style)
735 'YaTeX:documentstyles-default
736 'YaTeX:documentstyles-private
737 'YaTeX:documentstyles-local)))
738 (if (string= "" sname) (setq sname YaTeX-default-document-style))
739 (setq YaTeX-default-document-style sname))))
740 )
742 ;;; -------------------- End of yatexadd --------------------
743 (provide 'yatexadd)