Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexadd.el @ 49:eb0512bfcb7f
Abolish user-article table.
Use normal read-string instead.
Supply smart add-in function for documentstyle.
Update user dictionary whenever new words entered.
Enhance [prefix] c.
Allow user defined sectioning commands in yatexsec.
author | yuuji |
---|---|
date | Fri, 25 Nov 1994 08:26:13 +0000 |
parents | a0640ff3f72f |
children | b0371b6ed799 |
rev | line source |
---|---|
6 | 1 ;;; -*- Emacs-Lisp -*- |
8 | 2 ;;; YaTeX add-in functions. |
23 | 3 ;;; yatexadd.el rev.9 |
14 | 4 ;;; (c )1991-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] |
49 | 5 ;;; Last modified Sat Nov 12 07:03:15 1994 on VFR |
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 | |
23 | 179 (defun YaTeX:left () |
180 (let (c) | |
181 (while (not (string-match | |
182 (progn (message "Which parenthesis? One of [{(|)}]: ") | |
183 (setq c (regexp-quote (char-to-string (read-char))))) | |
184 "[{(|)}]"))) | |
185 (setq single-command "right") | |
186 (cond | |
187 ((string-match c "[(|)]") c) | |
188 (t (concat "\\" c)))) | |
189 ) | |
190 (fset 'YaTeX:right 'YaTeX:left) | |
191 | |
8 | 192 (defun YaTeX:read-coordinates (&optional mes varX varY) |
193 (concat | |
194 "(" | |
195 (read-string (format "%s %s: " (or mes "Dimension") (or varX "X"))) | |
196 "," | |
197 (read-string (format "%s %s: " (or mes "Dimension") (or varY "Y"))) | |
198 ")") | |
199 ) | |
200 | |
201 ;;; | |
202 ;;Sample functions for maketitle-type command. | |
203 ;;; | |
204 (defun YaTeX:sum () | |
205 "Read range of summation." | |
206 (YaTeX:check-completion-type 'maketitle) | |
207 (concat (YaTeX:read-boundary "_") (YaTeX:read-boundary "^")) | |
208 ) | |
209 | |
210 (fset 'YaTeX:int 'YaTeX:sum) | |
211 | |
212 (defun YaTeX:lim () | |
213 "Insert limit notation of \\lim." | |
214 (YaTeX:check-completion-type 'maketitle) | |
215 (let ((var (read-string "Variable: ")) limit) | |
216 (if (string= "" var) "" | |
217 (setq limit (read-string "Limit ($ means infinity): ")) | |
218 (if (string= "$" limit) (setq limit "\\infty")) | |
219 (concat "_{" var " \\rightarrow " limit "}"))) | |
220 ) | |
221 | |
222 (defun YaTeX:gcd () | |
223 "Add-in function for \\gcd(m,n)." | |
224 (YaTeX:check-completion-type 'maketitle) | |
225 (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)") | |
226 ) | |
227 | |
228 (defun YaTeX:read-boundary (ULchar) | |
229 "Read boundary usage by _ or ^. _ or ^ is indicated by argument ULchar." | |
11 | 230 (let ((bndry (read-string (concat ULchar "{???} ($ for infinity): ")))) |
8 | 231 (if (string= bndry "") "" |
11 | 232 (if (string= bndry "$") (setq bndry "\\infty")) |
8 | 233 (concat ULchar "{" bndry "}"))) |
234 ) | |
235 | |
14 | 236 (defun YaTeX:verb () |
237 "Enclose \\verb's contents with the same characters." | |
238 (let ((quote-char (read-string "Quoting char: " "|")) | |
239 (contents (read-string "Quoted contents: "))) | |
240 (concat quote-char contents quote-char)) | |
241 ) | |
23 | 242 (fset 'YaTeX:verb* 'YaTeX:verb) |
14 | 243 |
43
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
244 (defun YaTeX:footnotemark () |
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
245 (setq section-name "footnotetext") |
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
246 nil |
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
247 ) |
ef686a35472d
Change the default section-type command to footnotetext after
yuuji
parents:
23
diff
changeset
|
248 |
48 | 249 (defun YaTeX:cite () |
250 (let ((comment (read-string "Comment for citation: "))) | |
251 (if (string= comment "") "" | |
252 (concat "[" comment "]"))) | |
253 ) | |
254 | |
255 (defun YaTeX:bibitem () | |
256 (let ((label (read-string "Citation label: "))) | |
257 (if (string= label "") "" | |
258 (concat "[" label "]"))) | |
259 ) | |
260 | |
14 | 261 ;;; |
262 ;;Subroutine | |
263 ;;; | |
264 | |
8 | 265 (defun YaTeX:check-completion-type (type) |
266 "Check valid completion type." | |
267 (if (not (eq type YaTeX-current-completion-type)) | |
268 (error "This should be completed with %s-type completion." type)) | |
269 ) | |
11 | 270 |
271 | |
272 ;;; | |
273 ;;; [[Add-in functions for reading section arguments]] | |
274 ;;; | |
275 ;; All of add-in functions for reading sections arguments should | |
276 ;; take an argument ARGP that specify the argument position. | |
277 ;; If argument position is out of range, nil should be returned, | |
278 ;; else nil should NOT be returned. | |
13 | 279 |
280 ;; | |
281 ; Label selection | |
282 ;; | |
11 | 283 (defvar YaTeX-label-menu-other |
284 (if YaTeX-japan "':‘¼‚̃oƒbƒtƒ@‚̃‰ƒxƒ‹\n" "':LABEL IN OTHER BUFFER.\n")) | |
23 | 285 (defvar YaTeX-label-menu-repeat |
286 (if YaTeX-japan ".:’¼‘O‚Ì\\ref‚Æ“¯‚¶\n" "/:REPEAT LAST \ref{}\n")) | |
11 | 287 (defvar YaTeX-label-menu-any |
288 (if YaTeX-japan "*:”CˆÓ‚Ì•¶Žš—ñ\n" "*:ANY STRING.\n")) | |
289 (defvar YaTeX-label-buffer "*Label completions*") | |
290 (defvar YaTeX-label-guide-msg "Select label and hit RETURN.") | |
291 (defvar YaTeX-label-select-map nil | |
292 "Key map used in label selection buffer.") | |
293 (defun YaTeX::label-setup-key-map () | |
294 (if YaTeX-label-select-map nil | |
295 (message "Setting up label selection mode map...") | |
296 (setq YaTeX-label-select-map (copy-keymap global-map)) | |
297 (suppress-keymap YaTeX-label-select-map) | |
298 (substitute-all-key-definition | |
299 'previous-line 'YaTeX::label-previous YaTeX-label-select-map) | |
300 (substitute-all-key-definition | |
301 'next-line 'YaTeX::label-next YaTeX-label-select-map) | |
302 (define-key YaTeX-label-select-map "\C-n" 'YaTeX::label-next) | |
303 (define-key YaTeX-label-select-map "\C-p" 'YaTeX::label-previous) | |
304 (define-key YaTeX-label-select-map "<" 'beginning-of-buffer) | |
305 (define-key YaTeX-label-select-map ">" 'end-of-buffer) | |
306 (define-key YaTeX-label-select-map "\C-m" 'exit-recursive-edit) | |
307 (define-key YaTeX-label-select-map "\C-j" 'exit-recursive-edit) | |
308 (define-key YaTeX-label-select-map " " 'exit-recursive-edit) | |
309 (define-key YaTeX-label-select-map "\C-g" 'abort-recursive-edit) | |
310 (define-key YaTeX-label-select-map "/" 'isearch-forward) | |
311 (define-key YaTeX-label-select-map "?" 'isearch-backward) | |
312 (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag) | |
23 | 313 (define-key YaTeX-label-select-map "." 'YaTeX::label-search-tag) |
11 | 314 (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag) |
315 (message "Setting up label selection mode map...Done") | |
316 (let ((key ?A)) | |
317 (while (<= key ?Z) | |
318 (define-key YaTeX-label-select-map (char-to-string key) | |
319 'YaTeX::label-search-tag) | |
320 (define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A))) | |
321 'YaTeX::label-search-tag) | |
322 (setq key (1+ key))))) | |
323 ) | |
324 (defun YaTeX::label-next () | |
325 (interactive) (forward-line 1) (message YaTeX-label-guide-msg)) | |
326 (defun YaTeX::label-previous () | |
327 (interactive) (forward-line -1) (message YaTeX-label-guide-msg)) | |
328 (defun YaTeX::label-search-tag () | |
329 (interactive) | |
23 | 330 (let ((case-fold-search t) (tag (regexp-quote (this-command-keys)))) |
11 | 331 (cond |
332 ((save-excursion | |
333 (forward-char 1) | |
23 | 334 (re-search-forward (concat "^" tag) nil t)) |
11 | 335 (goto-char (match-beginning 0))) |
336 ((save-excursion | |
337 (goto-char (point-min)) | |
23 | 338 (re-search-forward (concat "^" tag) nil t)) |
11 | 339 (goto-char (match-beginning 0)))) |
340 (message YaTeX-label-guide-msg)) | |
341 ) | |
48 | 342 (defun YaTeX::ref (argp &optional labelcmd refcmd) |
11 | 343 (cond |
344 ((= argp 1) | |
345 (save-excursion | |
48 | 346 (let ((lnum 0) e0 label label-list (buf (current-buffer)) |
347 (labelcmd (or labelcmd "label")) (refcmd (or refcmd "ref")) | |
11 | 348 (p (point)) initl line) |
349 (goto-char (point-min)) | |
350 (message "Collecting labels...") | |
351 (save-window-excursion | |
12 | 352 (YaTeX-showup-buffer |
353 YaTeX-label-buffer (function (lambda (x) (window-width x)))) | |
11 | 354 (with-output-to-temp-buffer YaTeX-label-buffer |
48 | 355 (while (YaTeX-re-search-active-forward |
356 (concat "\\\\" labelcmd) | |
357 (regexp-quote YaTeX-comment-prefix) nil t) | |
358 (goto-char (match-beginning 0)) | |
359 (skip-chars-forward "^{") | |
360 (setq label | |
361 (buffer-substring | |
362 (1+ (point)) | |
363 (prog2 (forward-list 1) (setq e0 (1- (point))))) | |
364 label-list (cons label label-list)) | |
365 (or initl | |
366 (if (< p (point)) (setq initl lnum))) | |
367 (beginning-of-line) | |
368 (skip-chars-forward " \t\n" nil) | |
369 (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label | |
370 (buffer-substring (point) (point-end-of-line)))) | |
371 (setq lnum (1+ lnum)) | |
372 (message "Collecting \\%s{}... %d" labelcmd lnum) | |
11 | 373 (goto-char e0)) |
374 (princ YaTeX-label-menu-other) | |
23 | 375 (princ YaTeX-label-menu-repeat) |
11 | 376 (princ YaTeX-label-menu-any) |
377 );with | |
378 (goto-char p) | |
48 | 379 (message "Collecting %s...Done" labelcmd) |
11 | 380 (pop-to-buffer YaTeX-label-buffer) |
381 (YaTeX::label-setup-key-map) | |
382 (setq truncate-lines t) | |
383 (setq buffer-read-only t) | |
384 (use-local-map YaTeX-label-select-map) | |
385 (message YaTeX-label-guide-msg) | |
386 (goto-line (or initl lnum)) ;goto recently defined label line | |
387 (unwind-protect | |
388 (progn | |
389 (recursive-edit) | |
390 (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion | |
391 (beginning-of-line) | |
392 (setq line (count-lines (point-min)(point))) | |
393 (cond | |
394 ((= line lnum) (setq label (YaTeX-label-other))) | |
23 | 395 ((= line (1+ lnum)) |
396 (save-excursion | |
397 (switch-to-buffer buf) | |
398 (goto-char p) | |
48 | 399 (if (re-search-backward |
400 (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t) | |
401 (setq label (YaTeX-match-string 1)) | |
23 | 402 (setq label "")))) |
403 ((>= line (+ lnum 2)) | |
48 | 404 (setq label (read-string (format "\\%s{???}: " refcmd)))) |
11 | 405 (t (setq label (nth (- lnum line 1) label-list))))) |
406 (bury-buffer YaTeX-label-buffer))) | |
407 label | |
408 )) | |
409 )) | |
410 ) | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
411 (fset 'YaTeX::pageref 'YaTeX::ref) |
48 | 412 (defun YaTeX::cite (argp) |
413 (cond | |
414 ((eq argp 1) | |
415 (YaTeX::ref argp "bibitem\\(\\[.*\\]\\)?" "cite")) | |
416 (t nil))) | |
11 | 417 |
48 | 418 (defun YaTeX-yatex-buffer-list () |
419 (save-excursion | |
420 (delq nil (mapcar (function (lambda (buf) | |
421 (set-buffer buf) | |
422 (if (eq major-mode 'yatex-mode) buf))) | |
423 (buffer-list)))) | |
424 ) | |
425 | |
426 (defun YaTeX-select-other-yatex-buffer () | |
427 "Select buffer from all yatex-mode's buffers interactivelly." | |
428 (interactive) | |
429 (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list)) | |
430 (lnum -1) buf rv | |
11 | 431 (ff "**find-file**")) |
12 | 432 (YaTeX-showup-buffer |
433 lbuf (function (lambda (x) 1))) ;;Select next window surely. | |
11 | 434 (with-output-to-temp-buffer lbuf |
435 (while blist | |
48 | 436 (princ |
437 (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A) | |
438 (buffer-name (car blist)))) | |
11 | 439 (setq blist (cdr blist))) |
440 (princ (format "':{%s}" ff))) | |
441 (pop-to-buffer lbuf) | |
442 (YaTeX::label-setup-key-map) | |
443 (setq buffer-read-only t) | |
444 (use-local-map YaTeX-label-select-map) | |
445 (message YaTeX-label-guide-msg) | |
446 (unwind-protect | |
447 (progn | |
448 (recursive-edit) | |
449 (set-buffer lbuf) | |
450 (beginning-of-line) | |
451 (setq rv | |
452 (if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t) | |
453 (buffer-substring (match-beginning 1) (match-end 1)) nil))) | |
454 (kill-buffer lbuf)) | |
48 | 455 (if (string= rv ff) |
456 (progn | |
457 (call-interactively 'find-file) | |
458 (current-buffer)) | |
459 rv)) | |
460 ) | |
461 | |
462 (defun YaTeX-label-other () | |
463 (let ((rv (YaTeX-select-other-yatex-buffer))) | |
11 | 464 (cond |
465 ((null rv) "") | |
466 (t | |
467 (set-buffer rv) | |
48 | 468 (YaTeX::ref argp labelcmd refcmd))) |
11 | 469 ) |
470 ) | |
471 | |
13 | 472 ;; |
473 ; completion for the arguments of \newcommand | |
474 ;; | |
475 (defun YaTeX::newcommand (&optional argp) | |
476 (cond | |
477 ((= argp 1) | |
478 (let ((command (read-string "Define newcommand: " "\\"))) | |
479 (put 'YaTeX::newcommand 'command (substring command 1)) | |
480 command)) | |
481 ((= argp 2) | |
482 (let ((argc | |
483 (string-to-int (read-string "Number of arguments(Default 0): "))) | |
484 (def (read-string "Definition: ")) | |
485 (command (get 'YaTeX::newcommand 'command))) | |
486 ;;!!! It's illegal to insert string in the add-in function !!! | |
487 (if (> argc 0) (insert (format "[%d]" argc))) | |
488 (if (and (stringp command) | |
489 (string< "" command) | |
490 (y-or-n-p "Update user completion table?")) | |
18 | 491 (cond |
492 ((= argc 0) | |
493 (YaTeX-update-table | |
494 (list command) | |
495 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table)) | |
496 ((= argc 1) | |
497 (YaTeX-update-table | |
498 (list command) | |
499 'section-table 'user-section-table 'tmp-section-table)) | |
500 (t (YaTeX-update-table | |
501 (list command argc) | |
502 'section-table 'user-section-table 'tmp-section-table)))) | |
13 | 503 (message "") |
504 def ;return command name | |
505 )) | |
506 (t "")) | |
507 ) | |
508 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
509 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
510 ; completion for the arguments of \pagestyle |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
511 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
512 (defun YaTeX::pagestyle (&optional argp) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
513 "Read the pagestyle with completion." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
514 (completing-read |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
515 "Page style: " |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
516 '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
517 ) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
518 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
519 ; completion for the arguments of \pagenumbering |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
520 ;; |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
521 (defun YaTeX::pagenumbering (&optional argp) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
522 "Read the numbering style." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
523 (completing-read |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
524 "Page numbering style: " |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
525 '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman"))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
14
diff
changeset
|
526 ) |
13 | 527 |
23 | 528 ;; |
529 ; Length | |
530 ;; | |
531 (defvar YaTeX:style-parameters-default | |
532 '(("\\arraycolsep") | |
533 ("\\arrayrulewidth") | |
534 ("\\baselineskip") | |
535 ("\\columnsep") | |
536 ("\\columnseprule") | |
537 ("\\doublerulesep") | |
538 ("\\evensidemargin") | |
539 ("\\footheight") | |
540 ("\\footskip") | |
541 ("\\headheight") | |
542 ("\\headsep") | |
543 ("\\itemindent") | |
544 ("\\itemsep") | |
545 ("\\labelsep") | |
546 ("\\labelwidth") | |
547 ("\\leftmargin") | |
548 ("\\linewidth") | |
549 ("\\listparindent") | |
550 ("\\marginparsep") | |
551 ("\\marginparwidth") | |
552 ("\\mathindent") | |
553 ("\\oddsidemargin") | |
554 ("\\parindent") | |
555 ("\\parsep") | |
556 ("\\parskip") | |
557 ("\\partopsep") | |
558 ("\\rightmargin") | |
559 ("\\tabcolsep") | |
560 ("\\textheight") | |
561 ("\\textwidth") | |
562 ("\\topmargin") | |
563 ("\\topsep") | |
564 ("\\topskip") | |
565 ) | |
566 "Alist of LaTeX style parameters.") | |
567 (defvar YaTeX:style-parameters-private nil | |
568 "*User definable alist of style parameters.") | |
49 | 569 (defvar YaTeX:style-parameters-local nil |
570 "*User definable alist of local style parameters.") | |
23 | 571 |
572 (defvar YaTeX:length-history nil "Holds history of length.") | |
573 (defun YaTeX::setlength (&optional argp) | |
574 "YaTeX add-in function for arguments of \\setlength." | |
575 (cond | |
576 ((equal 1 argp) | |
49 | 577 ;;(completing-read "Length variable: " YaTeX:style-parameters nil nil "\\") |
578 (YaTeX-cplread-with-learning | |
579 "Length variable: " | |
580 'YaTeX:style-parameters-default | |
581 'YaTeX:style-parameters-private | |
582 'YaTeX:style-parameters-local | |
583 nil nil "\\") | |
584 ) | |
23 | 585 ((equal 2 argp) |
586 (let ((minibuffer-history-symbol 'YaTeX:length-history)) | |
587 (read-string "Length: ")))) | |
588 ) | |
589 (fset 'YaTeX::addtolength 'YaTeX::setlength) | |
590 | |
591 (defun YaTeX::settowidth (&optional argp) | |
592 "YaTeX add-in function for arguments of \\settowidth." | |
593 (cond | |
594 ((equal 1 argp) | |
49 | 595 (YaTeX-cplread-with-learning |
596 "Length variable: " | |
597 'YaTeX:style-parameters-default | |
598 'YaTeX:style-parameters-private | |
599 'YaTeX:style-parameters-local | |
600 nil nil "\\")) | |
23 | 601 ((equal 2 argp) |
602 (read-string "Text: "))) | |
603 ) | |
604 (defun YaTeX::newlength (&optional argp) | |
605 "YaTeX add-in function for arguments of \\newlength" | |
606 (cond | |
607 ((equal argp 1) | |
608 (let ((length (read-string "Length variable: " "\\"))) | |
49 | 609 (if (string< "" length) |
610 (YaTeX-update-table | |
611 (list length) | |
612 'YaTeX:style-parameters-default | |
613 'YaTeX:style-parameters-private | |
614 'YaTeX:style-parameters-local)) | |
615 length) | |
616 )) | |
23 | 617 ) |
618 | |
619 ;; \multicolumn's arguments | |
620 (defun YaTeX::multicolumn (&optional argp) | |
621 "YaTeX add-in function for arguments of \\multicolumn." | |
622 (cond | |
623 ((equal 1 argp) | |
624 (read-string "Number of columns: ")) | |
625 ((equal 2 argp) | |
626 (let (c) | |
627 (while (not (string-match | |
628 (progn (message "Format(one of l,r,c): ") | |
629 (setq c (char-to-string (read-char)))) | |
630 "lrc"))) | |
631 c)) | |
632 ((equal 3 argp) | |
633 (read-string "Item: "))) | |
634 ) | |
635 | |
49 | 636 (defvar YaTeX:documentstyles-default |
637 '(("article") ("jarticle") ("j-article") | |
638 ("book") ("jbook") ("j-book") | |
639 ("report") ("jreport") ("j-report") | |
640 ("letter") ("ascjletter")) | |
641 "List of LaTeX documentstyles.") | |
642 (defvar YaTeX:documentstyles-private nil | |
643 "*User defined list of LaTeX documentstyles.") | |
644 (defvar YaTeX:documentstyles-local nil | |
645 "*User defined list of local LaTeX documentstyles.") | |
646 (defvar YaTeX:documentstyle-options-default | |
647 '(("a4j") ("a5j") ("b4j") ("b5j") | |
648 ("twocolumn") ("jtwocolumn") ("epsf") ("epsfig") ("epsbox") ("nfig")) | |
649 "List of LaTeX documentstyle options.") | |
650 (defvar YaTeX:documentstyle-options-private nil | |
651 "*User defined list of LaTeX documentstyle options.") | |
652 (defvar YaTeX:documentstyle-options-local nil | |
653 "List of LaTeX local documentstyle options.") | |
654 | |
655 (defvar YaTeX-minibuffer-completion-map nil | |
656 "Minibuffer completion key map that allows comma completion.") | |
657 (if YaTeX-minibuffer-completion-map nil | |
658 (setq YaTeX-minibuffer-completion-map | |
659 (copy-keymap minibuffer-local-completion-map)) | |
660 (define-key YaTeX-minibuffer-completion-map " " | |
661 'YaTeX-minibuffer-complete) | |
662 (define-key YaTeX-minibuffer-completion-map "\t" | |
663 'YaTeX-minibuffer-complete)) | |
664 | |
665 (defun YaTeX:documentstyle () | |
666 (let*((delim ",") | |
667 (dt (append YaTeX:documentstyle-options-local | |
668 YaTeX:documentstyle-options-private | |
669 YaTeX:documentstyle-options-default)) | |
670 (minibuffer-completion-table dt) | |
671 (opt (read-from-minibuffer | |
672 "Style options ([opt1,opt2,...]): " | |
673 nil YaTeX-minibuffer-completion-map)) | |
674 (substr opt) o) | |
675 (if (string< "" opt) | |
676 (progn | |
677 (while substr | |
678 (setq o (substring substr 0 (string-match delim substr))) | |
679 (or (assoc o dt) | |
680 (YaTeX-update-table | |
681 (list o) | |
682 'YaTeX:documentstyle-options-default | |
683 'YaTeX:documentstyle-options-private | |
684 'YaTeX:documentstyle-options-local)) | |
685 (setq substr | |
686 (if (string-match delim substr) | |
687 (substring substr (1+ (string-match delim substr)))))) | |
688 (concat "[" opt "]")) | |
689 ""))) | |
690 | |
691 (defun YaTeX::documentstyle (&optional argp) | |
692 "YaTeX add-in function for arguments of \\socumentstyle." | |
693 (cond | |
694 ((equal argp 1) | |
695 (let ((sname | |
696 (YaTeX-cplread-with-learning | |
697 (format "Documentstyle (default %s): " | |
698 YaTeX-default-document-style) | |
699 'YaTeX:documentstyles-default | |
700 'YaTeX:documentstyles-private | |
701 'YaTeX:documentstyles-local))) | |
702 (if (string= "" sname) (setq sname YaTeX-default-document-style)) | |
703 (setq YaTeX-default-document-style sname)))) | |
704 ) | |
705 | |
23 | 706 ;;; -------------------- End of yatexadd -------------------- |
707 (provide 'yatexadd) |