yatex

view yatexadd.el @ 51:b0371b6ed799

Created `ChangeLog'. Log hereafter will be written in `ChangeLog'.
author yuuji
date Tue, 20 Dec 1994 21:00:21 +0000
parents eb0512bfcb7f
children 5d94deabb9f9
line source
1 ;;; -*- Emacs-Lisp -*-
2 ;;; YaTeX add-in functions.
3 ;;; yatexadd.el rev.11
4 ;;; (c )1991-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
5 ;;; Last modified Mon Dec 19 03:07:01 1994 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 ;;;
290 ;;Subroutine
291 ;;;
293 (defun YaTeX:check-completion-type (type)
294 "Check valid completion type."
295 (if (not (eq type YaTeX-current-completion-type))
296 (error "This should be completed with %s-type completion." type))
297 )
300 ;;;
301 ;;; [[Add-in functions for reading section arguments]]
302 ;;;
303 ;; All of add-in functions for reading sections arguments should
304 ;; take an argument ARGP that specify the argument position.
305 ;; If argument position is out of range, nil should be returned,
306 ;; else nil should NOT be returned.
308 ;;
309 ; Label selection
310 ;;
311 (defvar YaTeX-label-menu-other
312 (if YaTeX-japan "':他のバッファのラベル\n" "':LABEL IN OTHER BUFFER.\n"))
313 (defvar YaTeX-label-menu-repeat
314 (if YaTeX-japan ".:直前の\\refと同じ\n" "/:REPEAT LAST \ref{}\n"))
315 (defvar YaTeX-label-menu-any
316 (if YaTeX-japan "*:任意の文字列\n" "*:ANY STRING.\n"))
317 (defvar YaTeX-label-buffer "*Label completions*")
318 (defvar YaTeX-label-guide-msg "Select label and hit RETURN.")
319 (defvar YaTeX-label-select-map nil
320 "Key map used in label selection buffer.")
321 (defun YaTeX::label-setup-key-map ()
322 (if YaTeX-label-select-map nil
323 (message "Setting up label selection mode map...")
324 (setq YaTeX-label-select-map (copy-keymap global-map))
325 (suppress-keymap YaTeX-label-select-map)
326 (substitute-all-key-definition
327 'previous-line 'YaTeX::label-previous YaTeX-label-select-map)
328 (substitute-all-key-definition
329 'next-line 'YaTeX::label-next YaTeX-label-select-map)
330 (define-key YaTeX-label-select-map "\C-n" 'YaTeX::label-next)
331 (define-key YaTeX-label-select-map "\C-p" 'YaTeX::label-previous)
332 (define-key YaTeX-label-select-map "<" 'beginning-of-buffer)
333 (define-key YaTeX-label-select-map ">" 'end-of-buffer)
334 (define-key YaTeX-label-select-map "\C-m" 'exit-recursive-edit)
335 (define-key YaTeX-label-select-map "\C-j" 'exit-recursive-edit)
336 (define-key YaTeX-label-select-map " " 'exit-recursive-edit)
337 (define-key YaTeX-label-select-map "\C-g" 'abort-recursive-edit)
338 (define-key YaTeX-label-select-map "/" 'isearch-forward)
339 (define-key YaTeX-label-select-map "?" 'isearch-backward)
340 (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag)
341 (define-key YaTeX-label-select-map "." 'YaTeX::label-search-tag)
342 (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag)
343 (message "Setting up label selection mode map...Done")
344 (let ((key ?A))
345 (while (<= key ?Z)
346 (define-key YaTeX-label-select-map (char-to-string key)
347 'YaTeX::label-search-tag)
348 (define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A)))
349 'YaTeX::label-search-tag)
350 (setq key (1+ key)))))
351 )
352 (defun YaTeX::label-next ()
353 (interactive) (forward-line 1) (message YaTeX-label-guide-msg))
354 (defun YaTeX::label-previous ()
355 (interactive) (forward-line -1) (message YaTeX-label-guide-msg))
356 (defun YaTeX::label-search-tag ()
357 (interactive)
358 (let ((case-fold-search t) (tag (regexp-quote (this-command-keys))))
359 (cond
360 ((save-excursion
361 (forward-char 1)
362 (re-search-forward (concat "^" tag) nil t))
363 (goto-char (match-beginning 0)))
364 ((save-excursion
365 (goto-char (point-min))
366 (re-search-forward (concat "^" tag) nil t))
367 (goto-char (match-beginning 0))))
368 (message YaTeX-label-guide-msg))
369 )
370 (defun YaTeX::ref (argp &optional labelcmd refcmd)
371 (cond
372 ((= argp 1)
373 (save-excursion
374 (let ((lnum 0) e0 label label-list (buf (current-buffer))
375 (labelcmd (or labelcmd "label")) (refcmd (or refcmd "ref"))
376 (p (point)) initl line)
377 (goto-char (point-min))
378 (message "Collecting labels...")
379 (save-window-excursion
380 (YaTeX-showup-buffer
381 YaTeX-label-buffer (function (lambda (x) (window-width x))))
382 (with-output-to-temp-buffer YaTeX-label-buffer
383 (while (YaTeX-re-search-active-forward
384 (concat "\\\\" labelcmd)
385 (regexp-quote YaTeX-comment-prefix) nil t)
386 (goto-char (match-beginning 0))
387 (skip-chars-forward "^{")
388 (setq label
389 (buffer-substring
390 (1+ (point))
391 (prog2 (forward-list 1) (setq e0 (1- (point)))))
392 label-list (cons label label-list))
393 (or initl
394 (if (< p (point)) (setq initl lnum)))
395 (beginning-of-line)
396 (skip-chars-forward " \t\n" nil)
397 (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label
398 (buffer-substring (point) (point-end-of-line))))
399 (setq lnum (1+ lnum))
400 (message "Collecting \\%s{}... %d" labelcmd lnum)
401 (goto-char e0))
402 (princ YaTeX-label-menu-other)
403 (princ YaTeX-label-menu-repeat)
404 (princ YaTeX-label-menu-any)
405 );with
406 (goto-char p)
407 (message "Collecting %s...Done" labelcmd)
408 (pop-to-buffer YaTeX-label-buffer)
409 (YaTeX::label-setup-key-map)
410 (setq truncate-lines t)
411 (setq buffer-read-only t)
412 (use-local-map YaTeX-label-select-map)
413 (message YaTeX-label-guide-msg)
414 (goto-line (or initl lnum)) ;goto recently defined label line
415 (unwind-protect
416 (progn
417 (recursive-edit)
418 (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion
419 (beginning-of-line)
420 (setq line (count-lines (point-min)(point)))
421 (cond
422 ((= line lnum) (setq label (YaTeX-label-other)))
423 ((= line (1+ lnum))
424 (save-excursion
425 (switch-to-buffer buf)
426 (goto-char p)
427 (if (re-search-backward
428 (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t)
429 (setq label (YaTeX-match-string 1))
430 (setq label ""))))
431 ((>= line (+ lnum 2))
432 (setq label (read-string (format "\\%s{???}: " refcmd))))
433 (t (setq label (nth (- lnum line 1) label-list)))))
434 (bury-buffer YaTeX-label-buffer)))
435 label
436 ))
437 ))
438 )
439 (fset 'YaTeX::pageref 'YaTeX::ref)
440 (defun YaTeX::cite (argp)
441 (cond
442 ((eq argp 1)
443 (YaTeX::ref argp "bibitem\\(\\[.*\\]\\)?" "cite"))
444 (t nil)))
446 (defun YaTeX-yatex-buffer-list ()
447 (save-excursion
448 (delq nil (mapcar (function (lambda (buf)
449 (set-buffer buf)
450 (if (eq major-mode 'yatex-mode) buf)))
451 (buffer-list))))
452 )
454 (defun YaTeX-select-other-yatex-buffer ()
455 "Select buffer from all yatex-mode's buffers interactivelly."
456 (interactive)
457 (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list))
458 (lnum -1) buf rv
459 (ff "**find-file**"))
460 (YaTeX-showup-buffer
461 lbuf (function (lambda (x) 1))) ;;Select next window surely.
462 (with-output-to-temp-buffer lbuf
463 (while blist
464 (princ
465 (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A)
466 (buffer-name (car blist))))
467 (setq blist (cdr blist)))
468 (princ (format "':{%s}" ff)))
469 (pop-to-buffer lbuf)
470 (YaTeX::label-setup-key-map)
471 (setq buffer-read-only t)
472 (use-local-map YaTeX-label-select-map)
473 (message YaTeX-label-guide-msg)
474 (unwind-protect
475 (progn
476 (recursive-edit)
477 (set-buffer lbuf)
478 (beginning-of-line)
479 (setq rv
480 (if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t)
481 (buffer-substring (match-beginning 1) (match-end 1)) nil)))
482 (kill-buffer lbuf))
483 (if (string= rv ff)
484 (progn
485 (call-interactively 'find-file)
486 (current-buffer))
487 rv))
488 )
490 (defun YaTeX-label-other ()
491 (let ((rv (YaTeX-select-other-yatex-buffer)))
492 (cond
493 ((null rv) "")
494 (t
495 (set-buffer rv)
496 (YaTeX::ref argp labelcmd refcmd)))
497 )
498 )
500 ;;
501 ; completion for the arguments of \newcommand
502 ;;
503 (defun YaTeX::newcommand (&optional argp)
504 (cond
505 ((= argp 1)
506 (let ((command (read-string "Define newcommand: " "\\")))
507 (put 'YaTeX::newcommand 'command (substring command 1))
508 command))
509 ((= argp 2)
510 (let ((argc
511 (string-to-int (read-string "Number of arguments(Default 0): ")))
512 (def (read-string "Definition: "))
513 (command (get 'YaTeX::newcommand 'command)))
514 ;;!!! It's illegal to insert string in the add-in function !!!
515 (if (> argc 0) (insert (format "[%d]" argc)))
516 (if (and (stringp command)
517 (string< "" command)
518 (y-or-n-p "Update dictionary?"))
519 (cond
520 ((= argc 0)
521 (YaTeX-update-table
522 (list command)
523 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table))
524 ((= argc 1)
525 (YaTeX-update-table
526 (list command)
527 'section-table 'user-section-table 'tmp-section-table))
528 (t (YaTeX-update-table
529 (list command argc)
530 'section-table 'user-section-table 'tmp-section-table))))
531 (message "")
532 def ;return command name
533 ))
534 (t ""))
535 )
537 ;;
538 ; completion for the arguments of \pagestyle
539 ;;
540 (defun YaTeX::pagestyle (&optional argp)
541 "Read the pagestyle with completion."
542 (completing-read
543 "Page style: "
544 '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil))
545 )
546 (fset 'YaTeX::thispagestyle 'YaTeX::pagestyle)
548 ;;
549 ; completion for the arguments of \pagenumbering
550 ;;
551 (defun YaTeX::pagenumbering (&optional argp)
552 "Read the numbering style."
553 (completing-read
554 "Page numbering style: "
555 '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman")))
556 )
558 ;;
559 ; Length
560 ;;
561 (defvar YaTeX:style-parameters-default
562 '(("\\arraycolsep")
563 ("\\arrayrulewidth")
564 ("\\baselineskip")
565 ("\\columnsep")
566 ("\\columnseprule")
567 ("\\doublerulesep")
568 ("\\evensidemargin")
569 ("\\footheight")
570 ("\\footskip")
571 ("\\headheight")
572 ("\\headsep")
573 ("\\itemindent")
574 ("\\itemsep")
575 ("\\labelsep")
576 ("\\labelwidth")
577 ("\\leftmargin")
578 ("\\linewidth")
579 ("\\listparindent")
580 ("\\marginparsep")
581 ("\\marginparwidth")
582 ("\\mathindent")
583 ("\\oddsidemargin")
584 ("\\parindent")
585 ("\\parsep")
586 ("\\parskip")
587 ("\\partopsep")
588 ("\\rightmargin")
589 ("\\tabcolsep")
590 ("\\textheight")
591 ("\\textwidth")
592 ("\\topmargin")
593 ("\\topsep")
594 ("\\topskip")
595 )
596 "Alist of LaTeX style parameters.")
597 (defvar YaTeX:style-parameters-private nil
598 "*User definable alist of style parameters.")
599 (defvar YaTeX:style-parameters-local nil
600 "*User definable alist of local style parameters.")
602 (defvar YaTeX:length-history nil "Holds history of length.")
603 (put 'YaTeX:length-history 'no-default t)
604 (defun YaTeX::setlength (&optional argp)
605 "YaTeX add-in function for arguments of \\setlength."
606 (cond
607 ((equal 1 argp)
608 ;;(completing-read "Length variable: " YaTeX:style-parameters nil nil "\\")
609 (YaTeX-cplread-with-learning
610 "Length variable: "
611 'YaTeX:style-parameters-default
612 'YaTeX:style-parameters-private
613 'YaTeX:style-parameters-local
614 nil nil "\\")
615 )
616 ((equal 2 argp)
617 (read-string-with-history "Length: " nil 'YaTeX:length-history)))
618 )
619 (fset 'YaTeX::addtolength 'YaTeX::setlength)
621 (defun YaTeX::settowidth (&optional argp)
622 "YaTeX add-in function for arguments of \\settowidth."
623 (cond
624 ((equal 1 argp)
625 (YaTeX-cplread-with-learning
626 "Length variable: "
627 'YaTeX:style-parameters-default
628 'YaTeX:style-parameters-private
629 'YaTeX:style-parameters-local
630 nil nil "\\"))
631 ((equal 2 argp)
632 (read-string "Text: ")))
633 )
634 (defun YaTeX::newlength (&optional argp)
635 "YaTeX add-in function for arguments of \\newlength"
636 (cond
637 ((equal argp 1)
638 (let ((length (read-string "Length variable: " "\\")))
639 (if (string< "" length)
640 (YaTeX-update-table
641 (list length)
642 'YaTeX:style-parameters-default
643 'YaTeX:style-parameters-private
644 'YaTeX:style-parameters-local))
645 length)
646 ))
647 )
649 ;; \multicolumn's arguments
650 (defun YaTeX::multicolumn (&optional argp)
651 "YaTeX add-in function for arguments of \\multicolumn."
652 (cond
653 ((equal 1 argp)
654 (read-string "Number of columns: "))
655 ((equal 2 argp)
656 (let (c)
657 (while (not (string-match
658 (progn (message "Format(one of l,r,c): ")
659 (setq c (char-to-string (read-char))))
660 "lrc")))
661 c))
662 ((equal 3 argp)
663 (read-string "Item: ")))
664 )
666 (defvar YaTeX:documentstyles-default
667 '(("article") ("jarticle") ("j-article")
668 ("book") ("jbook") ("j-book")
669 ("report") ("jreport") ("j-report")
670 ("letter") ("ascjletter"))
671 "List of LaTeX documentstyles.")
672 (defvar YaTeX:documentstyles-private nil
673 "*User defined list of LaTeX documentstyles.")
674 (defvar YaTeX:documentstyles-local nil
675 "*User defined list of local LaTeX documentstyles.")
676 (defvar YaTeX:documentstyle-options-default
677 '(("a4j") ("a5j") ("b4j") ("b5j")
678 ("twocolumn") ("jtwocolumn") ("epsf") ("epsfig") ("epsbox") ("nfig"))
679 "List of LaTeX documentstyle options.")
680 (defvar YaTeX:documentstyle-options-private nil
681 "*User defined list of LaTeX documentstyle options.")
682 (defvar YaTeX:documentstyle-options-local nil
683 "List of LaTeX local documentstyle options.")
685 (defvar YaTeX-minibuffer-completion-map nil
686 "Minibuffer completion key map that allows comma completion.")
687 (if YaTeX-minibuffer-completion-map nil
688 (setq YaTeX-minibuffer-completion-map
689 (copy-keymap minibuffer-local-completion-map))
690 (define-key YaTeX-minibuffer-completion-map " "
691 'YaTeX-minibuffer-complete)
692 (define-key YaTeX-minibuffer-completion-map "\t"
693 'YaTeX-minibuffer-complete))
695 (defun YaTeX:documentstyle ()
696 (let*((delim ",")
697 (dt (append YaTeX:documentstyle-options-local
698 YaTeX:documentstyle-options-private
699 YaTeX:documentstyle-options-default))
700 (minibuffer-completion-table dt)
701 (opt (read-from-minibuffer
702 "Style options ([opt1,opt2,...]): "
703 nil YaTeX-minibuffer-completion-map nil))
704 (substr opt) o)
705 (if (string< "" opt)
706 (progn
707 (while substr
708 (setq o (substring substr 0 (string-match delim substr)))
709 (or (assoc o dt)
710 (YaTeX-update-table
711 (list o)
712 'YaTeX:documentstyle-options-default
713 'YaTeX:documentstyle-options-private
714 'YaTeX:documentstyle-options-local))
715 (setq substr
716 (if (string-match delim substr)
717 (substring substr (1+ (string-match delim substr))))))
718 (concat "[" opt "]"))
719 "")))
721 (defun YaTeX::documentstyle (&optional argp)
722 "YaTeX add-in function for arguments of \\documentstyle."
723 (cond
724 ((equal argp 1)
725 (setq env-name "document")
726 (let ((sname
727 (YaTeX-cplread-with-learning
728 (format "Documentstyle (default %s): "
729 YaTeX-default-document-style)
730 'YaTeX:documentstyles-default
731 'YaTeX:documentstyles-private
732 'YaTeX:documentstyles-local)))
733 (if (string= "" sname) (setq sname YaTeX-default-document-style))
734 (setq YaTeX-default-document-style sname))))
735 )
737 ;;; -------------------- End of yatexadd --------------------
738 (provide 'yatexadd)