* vc-hg.el (log-edit-extract-headers): Remove duplicate declaration.
[emacs.git] / lisp / textmodes / texinfmt.el
blobb735b446b811bb362efed1b162abdfb27fb3eb59
1 ;;; texinfmt.el --- format Texinfo files into Info files
3 ;; Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993,
4 ;; 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003,
5 ;; 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
7 ;; Maintainer: Robert J. Chassell <bug-texinfo@gnu.org>
8 ;; Keywords: maint, tex, docs
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;;; Commentary:
27 ;;; Code:
29 ;;; Emacs lisp functions to convert Texinfo files to Info files.
31 (defvar texinfmt-version "2.42 of 7 Jul 2006")
33 (defun texinfmt-version (&optional here)
34 "Show the version of texinfmt.el in the minibuffer.
35 If optional argument HERE is non-nil, insert info at point."
36 (interactive "P")
37 (let ((version-string
38 (format "Version of \`texinfmt.el\': %s" texinfmt-version)))
39 (if here
40 (insert version-string)
41 (if (called-interactively-p 'interactive)
42 (message "%s" version-string)
43 version-string))))
46 ;;; Variable definitions
48 (require 'texinfo) ; So `texinfo-footnote-style' is defined.
49 (require 'texnfo-upd) ; So `texinfo-section-types-regexp' is defined.
51 (defvar texinfo-vindex)
52 (defvar texinfo-findex)
53 (defvar texinfo-cindex)
54 (defvar texinfo-pindex)
55 (defvar texinfo-tindex)
56 (defvar texinfo-kindex)
57 (defvar texinfo-last-node)
58 (defvar texinfo-node-names)
59 (defvar texinfo-enclosure-list)
60 (defvar texinfo-alias-list)
61 (defvar texinfo-fold-nodename-case nil)
63 (defvar texinfo-command-start)
64 (defvar texinfo-command-end)
65 (defvar texinfo-command-name)
66 (defvar texinfo-defun-type)
67 (defvar texinfo-last-node-pos)
68 (defvar texinfo-stack)
69 (defvar texinfo-short-index-cmds-alist)
70 (defvar texinfo-short-index-format-cmds-alist)
71 (defvar texinfo-format-filename)
72 (defvar texinfo-footnote-number)
74 (defvar texinfo-raisesections-alist
75 '((@chapter . @chapter) ; Cannot go higher
76 (@unnumbered . @unnumbered)
77 (@centerchap . @unnumbered)
79 (@majorheading . @majorheading)
80 (@chapheading . @chapheading)
81 (@appendix . @appendix)
83 (@section . @chapter)
84 (@unnumberedsec . @unnumbered)
85 (@heading . @chapheading)
86 (@appendixsec . @appendix)
88 (@subsection . @section)
89 (@unnumberedsubsec . @unnumberedsec)
90 (@subheading . @heading)
91 (@appendixsubsec . @appendixsec)
93 (@subsubsection . @subsection)
94 (@unnumberedsubsubsec . @unnumberedsubsec)
95 (@subsubheading . @subheading)
96 (@appendixsubsubsec . @appendixsubsec))
97 "*An alist of next higher levels for chapters, sections, etc...
98 For example, section to chapter, subsection to section.
99 Used by `texinfo-raise-lower-sections'.
100 The keys specify types of section; the values correspond to the next
101 higher types.")
103 (defvar texinfo-lowersections-alist
104 '((@chapter . @section)
105 (@unnumbered . @unnumberedsec)
106 (@centerchap . @unnumberedsec)
107 (@majorheading . @heading)
108 (@chapheading . @heading)
109 (@appendix . @appendixsec)
111 (@section . @subsection)
112 (@unnumberedsec . @unnumberedsubsec)
113 (@heading . @subheading)
114 (@appendixsec . @appendixsubsec)
116 (@subsection . @subsubsection)
117 (@unnumberedsubsec . @unnumberedsubsubsec)
118 (@subheading . @subsubheading)
119 (@appendixsubsec . @appendixsubsubsec)
121 (@subsubsection . @subsubsection) ; Cannot go lower.
122 (@unnumberedsubsubsec . @unnumberedsubsubsec)
123 (@subsubheading . @subsubheading)
124 (@appendixsubsubsec . @appendixsubsubsec))
125 "*An alist of next lower levels for chapters, sections, etc...
126 For example, chapter to section, section to subsection.
127 Used by `texinfo-raise-lower-sections'.
128 The keys specify types of section; the values correspond to the next
129 lower types.")
131 ;;; Syntax table
133 (defvar texinfo-format-syntax-table
134 (let ((st (make-syntax-table)))
135 (modify-syntax-entry ?\" " " st)
136 (modify-syntax-entry ?\\ " " st)
137 (modify-syntax-entry ?@ "\\" st)
138 (modify-syntax-entry ?\^q "\\" st)
139 (modify-syntax-entry ?\[ "." st)
140 (modify-syntax-entry ?\] "." st)
141 (modify-syntax-entry ?\( "." st)
142 (modify-syntax-entry ?\) "." st)
143 (modify-syntax-entry ?{ "(}" st)
144 (modify-syntax-entry ?} "){" st)
145 (modify-syntax-entry ?\' "." st)
146 st))
149 ;;; Top level buffer and region formatting functions
151 ;;;###autoload
152 (defun texinfo-format-buffer (&optional nosplit)
153 "Process the current buffer as texinfo code, into an Info file.
154 The Info file output is generated in a buffer visiting the Info file
155 name specified in the @setfilename command.
157 Non-nil argument (prefix, if interactive) means don't make tag table
158 and don't split the file if large. You can use `Info-tagify' and
159 `Info-split' to do these manually."
160 (interactive "P")
161 (let ((lastmessage "Formatting Info file...")
162 (coding-system-for-write buffer-file-coding-system))
163 (message lastmessage)
164 (widen)
165 (texinfo-format-buffer-1)
166 (Info-tagify)
167 (if nosplit
169 (if (> (buffer-size) (+ 50000 Info-split-threshold))
170 (progn
171 (message (setq lastmessage "Splitting Info file..."))
172 (Info-split))))
173 (message (concat lastmessage
174 (if (called-interactively-p 'interactive)
175 "done. Now save it." "done.")))))
177 (defvar texinfo-region-buffer-name "*Info Region*"
178 "*Name of the temporary buffer used by \\[texinfo-format-region].")
180 (defvar texinfo-pre-format-hook nil
181 "Hook called before the conversion of the Texinfo file to Info format.
182 The functions on this hook are called with argument BUFFER, the buffer
183 containing the Texinfo file.")
185 ;; These come from tex-mode.el.
186 (defvar tex-start-of-header)
187 (defvar tex-end-of-header)
189 ;;;###autoload
190 (defun texinfo-format-region (region-beginning region-end)
191 "Convert the current region of the Texinfo file to Info format.
192 This lets you see what that part of the file will look like in Info.
193 The command is bound to \\[texinfo-format-region]. The text that is
194 converted to Info is stored in a temporary buffer."
195 (interactive "r")
196 (message "Converting region to Info format...")
197 (let (texinfo-command-start
198 texinfo-command-end
199 texinfo-command-name
200 texinfo-vindex
201 texinfo-findex
202 texinfo-cindex
203 texinfo-pindex
204 texinfo-tindex
205 texinfo-kindex
206 texinfo-stack
207 (texinfo-format-filename "")
208 texinfo-example-start
209 texinfo-last-node-pos
210 texinfo-last-node
211 texinfo-node-names
212 (texinfo-footnote-number 0)
213 last-input-buffer
214 (fill-column-for-info fill-column)
215 (input-buffer (current-buffer))
216 (input-directory default-directory)
217 (header-text "")
218 (header-beginning 1)
219 (header-end 1))
221 ;;; Copy lines between beginning and end of header lines,
222 ;;; if any, or else copy the `@setfilename' line, if any.
223 (save-excursion
224 (save-restriction
225 (widen)
226 (goto-char (point-min))
227 (let ((search-end (save-excursion (forward-line 100) (point))))
228 (if (or
229 ;; Either copy header text.
230 (and
231 (prog1
232 (search-forward tex-start-of-header search-end t)
233 (forward-line 1)
234 ;; Mark beginning of header.
235 (setq header-beginning (point)))
236 (prog1
237 (search-forward tex-end-of-header nil t)
238 (beginning-of-line)
239 ;; Mark end of header
240 (setq header-end (point))))
241 ;; Or copy @filename line.
242 (prog2
243 (goto-char (point-min))
244 (search-forward "@setfilename" search-end t)
245 (beginning-of-line)
246 (setq header-beginning (point))
247 (forward-line 1)
248 (setq header-end (point))))
250 ;; Copy header
251 (setq header-text
252 (buffer-substring-no-properties
253 (min header-beginning region-beginning)
254 header-end))))))
256 ;;; Find a buffer to use.
257 (switch-to-buffer (get-buffer-create texinfo-region-buffer-name))
258 (setq buffer-read-only t)
259 (let ((inhibit-read-only t))
260 (erase-buffer)
261 ;; Insert the header into the buffer.
262 (insert header-text)
263 ;; Insert the region into the buffer.
264 (insert-buffer-substring
265 input-buffer
266 (max region-beginning header-end)
267 region-end)
268 (run-hook-with-args 'texinfo-pre-format-hook input-buffer)
269 ;; Make sure region ends in a newline.
270 (or (= (preceding-char) ?\n)
271 (insert "\n"))
273 (goto-char (point-min))
274 (texinfo-mode)
275 (message "Converting region to Info format...")
276 (setq fill-column fill-column-for-info)
277 ;; Install a syntax table useful for scanning command operands.
278 (set-syntax-table texinfo-format-syntax-table)
280 ;; Insert @include files so `texinfo-raise-lower-sections' can
281 ;; work on them without losing track of multiple
282 ;; @raise/@lowersections commands.
283 (while (re-search-forward "^@include" nil t)
284 (setq texinfo-command-end (point))
285 (let ((filename (concat input-directory
286 (texinfo-parse-line-arg))))
287 (re-search-backward "^@include")
288 (delete-region (point) (save-excursion (forward-line 1) (point)))
289 (message "Reading included file: %s" filename)
290 (save-excursion
291 (save-restriction
292 (narrow-to-region
293 (point)
294 (+ (point) (car (cdr (insert-file-contents filename)))))
295 (goto-char (point-min))
296 ;; Remove `@setfilename' line from included file, if any,
297 ;; so @setfilename command not duplicated.
298 (if (re-search-forward "^@setfilename" (line-end-position 100) t)
299 (delete-region (line-beginning-position 1)
300 (line-beginning-position 2)))))))
302 ;; Raise or lower level of each section, if necessary.
303 (goto-char (point-min))
304 (texinfo-raise-lower-sections)
305 ;; Append @refill to appropriate paragraphs for filling.
306 (goto-char (point-min))
307 (texinfo-append-refill)
308 ;; If the region includes the effective end of the data,
309 ;; discard everything after that.
310 (goto-char (point-max))
311 (if (re-search-backward "^@bye" nil t)
312 (delete-region (point) (point-max)))
313 ;; Make sure buffer ends in a newline.
314 (or (= (preceding-char) ?\n)
315 (insert "\n"))
316 ;; Don't use a previous value of texinfo-enclosure-list.
317 (setq texinfo-enclosure-list nil)
318 (setq texinfo-alias-list nil)
320 (goto-char (point-min))
321 (if (looking-at "\\\\input[ \t]+texinfo")
322 (delete-region (point) (line-beginning-position 2)))
324 ;; Insert Info region title text.
325 (goto-char (point-min))
326 (if (search-forward
327 "@setfilename" (save-excursion (forward-line 100) (point)) t)
328 (progn
329 (setq texinfo-command-end (point))
330 (beginning-of-line)
331 (setq texinfo-command-start (point))
332 (let ((arg (texinfo-parse-arg-discard)))
333 (insert " "
334 texinfo-region-buffer-name
335 " buffer for: `")
336 (insert (file-name-nondirectory (expand-file-name arg)))
337 (insert "', -*-Text-*-\n")))
338 ;; Else no `@setfilename' line
339 (insert " "
340 texinfo-region-buffer-name
341 " buffer -*-Text-*-\n"))
342 (insert "produced by `texinfo-format-region'\n"
343 "from a region in: "
344 (if (buffer-file-name input-buffer)
345 (concat "`"
346 (file-name-sans-versions
347 (file-name-nondirectory
348 (buffer-file-name input-buffer)))
349 "'")
350 (concat "buffer `" (buffer-name input-buffer) "'"))
351 "\nusing `texinfmt.el' version "
352 texinfmt-version
353 ".\n\n")
355 ;; Now convert for real.
356 (goto-char (point-min))
357 (texinfo-format-scan)
358 (goto-char (point-min))
359 (Info-tagify input-buffer)
360 (goto-char (point-min))
361 (message "Done."))))
363 ;;;###autoload
364 (defun texi2info (&optional nosplit)
365 "Convert the current buffer (written in Texinfo code) into an Info file.
366 The Info file output is generated in a buffer visiting the Info file
367 names specified in the @setfilename command.
369 This function automatically updates all node pointers and menus, and
370 creates a master menu. This work is done on a temporary buffer that
371 is automatically removed when the Info file is created. The original
372 Texinfo source buffer is not changed.
374 Non-nil argument (prefix, if interactive) means don't split the file
375 if large. You can use `Info-split' to do this manually."
376 (interactive "P")
377 (let ((temp-buffer (concat "*--" (buffer-name) "--temporary-buffer*" )))
378 (message "First updating nodes and menus, then creating Info file.")
379 ;; (sit-for 2)
380 (copy-to-buffer temp-buffer (point-min) (point-max))
381 (switch-to-buffer temp-buffer)
382 (texinfo-master-menu t)
383 (message "Now creating Info file.")
384 (sit-for 2)
385 (texinfo-format-buffer nosplit)
386 (save-buffer)
387 (kill-buffer temp-buffer)))
390 ;;; Primary internal formatting function for the whole buffer.
392 (defun texinfo-format-buffer-1 ()
393 (let (texinfo-format-filename
394 texinfo-example-start
395 texinfo-command-start
396 texinfo-command-end
397 texinfo-command-name
398 texinfo-last-node
399 texinfo-last-node-pos
400 texinfo-vindex
401 texinfo-findex
402 texinfo-cindex
403 texinfo-pindex
404 texinfo-tindex
405 texinfo-kindex
406 texinfo-stack
407 texinfo-node-names
408 (texinfo-footnote-number 0)
409 last-input-buffer
410 outfile
411 (fill-column-for-info fill-column)
412 (input-buffer (current-buffer))
413 (input-directory default-directory))
414 (setq texinfo-enclosure-list nil)
415 (setq texinfo-alias-list nil)
416 (save-excursion
417 (goto-char (point-min))
418 (or (search-forward "@setfilename" nil t)
419 (error "Texinfo file needs an `@setfilename FILENAME' line"))
420 (setq texinfo-command-end (point))
421 (setq outfile (texinfo-parse-line-arg)))
423 (find-file outfile)
424 (texinfo-mode)
425 (erase-buffer)
426 (buffer-disable-undo)
428 (message "Formatting Info file: %s" outfile)
429 (setq texinfo-format-filename
430 (file-name-nondirectory (expand-file-name outfile)))
432 (setq fill-column fill-column-for-info)
433 (set-syntax-table texinfo-format-syntax-table)
435 (insert-buffer-substring input-buffer)
436 (run-hook-with-args 'texinfo-pre-format-hook input-buffer)
437 (message "Converting %s to Info format..." (buffer-name input-buffer))
439 ;; Insert @include files so `texinfo-raise-lower-sections' can
440 ;; work on them without losing track of multiple
441 ;; @raise/@lowersections commands.
442 (goto-char (point-min))
443 (while (re-search-forward "^@include" nil t)
444 (setq texinfo-command-end (point))
445 (let ((filename (concat input-directory
446 (texinfo-parse-line-arg))))
447 (re-search-backward "^@include")
448 (delete-region (point) (line-beginning-position 2))
449 (message "Reading included file: %s" filename)
450 (save-excursion
451 (save-restriction
452 (narrow-to-region
453 (point)
454 (+ (point) (car (cdr (insert-file-contents filename)))))
455 (goto-char (point-min))
456 ;; Remove `@setfilename' line from included file, if any,
457 ;; so @setfilename command not duplicated.
458 (if (re-search-forward "^@setfilename" (line-end-position 100) t)
459 (delete-region (line-beginning-position 1)
460 (line-beginning-position 2)))))))
461 ;; Raise or lower level of each section, if necessary.
462 (goto-char (point-min))
463 (texinfo-raise-lower-sections)
464 ;; Append @refill to appropriate paragraphs
465 (goto-char (point-min))
466 (texinfo-append-refill)
467 (goto-char (point-min))
468 (search-forward "@setfilename")
469 (beginning-of-line)
470 (delete-region (point-min) (point))
471 ;; Remove @bye at end of file, if it is there.
472 (goto-char (point-max))
473 (if (search-backward "@bye" nil t)
474 (delete-region (point) (point-max)))
475 ;; Make sure buffer ends in a newline.
476 (or (= (preceding-char) ?\n)
477 (insert "\n"))
478 ;; Scan the whole buffer, converting to Info format.
479 (texinfo-format-scan)
480 (goto-char (point-min))
481 ;; Insert info about how this file was made.
482 (insert "Info file: "
483 texinfo-format-filename ", -*-Text-*-\n"
484 "produced by `texinfo-format-buffer'\n"
485 ;; Date string removed so that regression testing is easier.
486 ;; "on "
487 ;; (insert (format-time-string "%e %b %Y")) " "
488 "from file"
489 (if (buffer-file-name input-buffer)
490 (concat " `"
491 (file-name-sans-versions
492 (file-name-nondirectory
493 (buffer-file-name input-buffer)))
494 "'")
495 (concat "buffer `" (buffer-name input-buffer) "'"))
496 "\nusing `texinfmt.el' version "
497 texinfmt-version
498 ".\n\n")
499 ;; Return data for indices.
500 (list outfile
501 texinfo-vindex texinfo-findex texinfo-cindex
502 texinfo-pindex texinfo-tindex texinfo-kindex)))
505 ;;; Perform non-@-command file conversions: quotes and hyphens
507 (defun texinfo-format-convert (min max)
508 ;; Convert left and right quotes to typewriter font quotes.
509 (goto-char min)
510 (while (search-forward "``" max t)
511 (replace-match "\""))
512 (goto-char min)
513 (while (search-forward "''" max t)
514 (replace-match "\""))
515 ;; Convert three hyphens in a row to two.
516 (goto-char min)
517 (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t)
518 (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning 2)))))
521 ;;; Handle paragraph filling
523 ;; Keep as concatinated lists for ease of maintenance
525 (defvar texinfo-no-refill-regexp
526 (concat
527 "^@"
528 "\\("
529 ;; add "itemize\\|" (from experiment of 2001 Nov 28)
530 ;; because of a problem with @end itemize@refill
531 ;; I don't know if this causes other problems.
532 ;; I suspect itemized lists don't get filled properly and a
533 ;; more precise fix is required. Bob
534 ;; commented out on 2005 Feb 28 by Bob
535 ;; "itemize\\|"
536 "direntry\\|"
537 "lisp\\|"
538 "smalllisp\\|"
539 "example\\|"
540 "smallexample\\|"
541 "display\\|"
542 "smalldisplay\\|"
543 "format\\|"
544 "smallformat\\|"
545 "flushleft\\|"
546 "flushright\\|"
547 "menu\\|"
548 "multitable\\|"
549 "titlepage\\|"
550 "iftex\\|"
551 "ifhtml\\|"
552 "tex\\|"
553 "html"
554 "\\)")
555 "Regexp specifying environments in which paragraphs are not filled.")
557 (defvar texinfo-accent-commands
558 (concat
559 "@^\\|"
560 "@`\\|"
561 "@'\\|"
562 "@\"\\|"
563 "@,\\|"
564 "@=\\|"
565 "@~\\|"
566 "@OE{\\|"
567 "@oe{\\|"
568 "@AA{\\|"
569 "@aa{\\|"
570 "@AE{\\|"
571 "@ae{\\|"
572 "@ss{\\|"
573 "@questiondown{\\|"
574 "@exclamdown{\\|"
575 "@L{\\|"
576 "@l{\\|"
577 "@O{\\|"
578 "@o{\\|"
579 "@dotaccent{\\|"
580 "@ubaraccent{\\|"
581 "@d{\\|"
582 "@H{\\|"
583 "@ringaccent{\\|"
584 "@tieaccent{\\|"
585 "@u{\\|"
586 "@v{\\|"
587 "@dotless{"
590 (defvar texinfo-part-of-para-regexp
591 (concat
592 "^@"
593 "\\("
594 "b{\\|"
595 "bullet{\\|"
596 "cite{\\|"
597 "code{\\|"
598 "email{\\|"
599 "emph{\\|"
600 "equiv{\\|"
601 "error{\\|"
602 "expansion{\\|"
603 "file{\\|"
604 "i{\\|"
605 "inforef{\\|"
606 "kbd{\\|"
607 "key{\\|"
608 "lisp{\\|"
609 "minus{\\|"
610 "point{\\|"
611 "print{\\|"
612 "pxref{\\|"
613 "r{\\|"
614 "ref{\\|"
615 "result{\\|"
616 "samp{\\|"
617 "sc{\\|"
618 "t{\\|"
619 "TeX{\\|"
620 "today{\\|"
621 "url{\\|"
622 "var{\\|"
623 "w{\\|"
624 "xref{\\|"
625 "@-\\|" ; @- is a descretionary hyphen (not an accent) (a noop).
626 texinfo-accent-commands
627 "\\)"
629 "Regexp specifying @-commands found within paragraphs.")
631 (defun texinfo-append-refill ()
632 "Append @refill at end of each paragraph that should be filled.
633 Do not append @refill to paragraphs within @example and similar environments.
634 Do not append @refill to paragraphs containing @w{TEXT} or @*."
636 ;; It is necessary to append @refill before other processing because
637 ;; the other processing removes information that tells Texinfo
638 ;; whether the text should or should not be filled.
640 (while (< (point) (point-max))
641 (let ((refill-blank-lines "^[ \t\n]*$")
642 (case-fold-search nil)) ; Don't confuse @TeX and @tex....
643 (beginning-of-line)
644 ;; 1. Skip over blank lines;
645 ;; skip over lines beginning with @-commands,
646 ;; but do not skip over lines
647 ;; that are no-refill environments such as @example or
648 ;; that begin with within-paragraph @-commands such as @code.
649 (while (and (looking-at (concat "^@\\|^\\\\\\|" refill-blank-lines))
650 (not (looking-at
651 (concat
652 "\\("
653 texinfo-no-refill-regexp
654 "\\|"
655 texinfo-part-of-para-regexp
656 "\\)")))
657 (< (point) (point-max)))
658 (forward-line 1))
659 ;; 2. Skip over @example and similar no-refill environments.
660 (if (looking-at texinfo-no-refill-regexp)
661 (let ((environment (match-string-no-properties 1)))
662 (progn (re-search-forward (concat "^@end " environment) nil t)
663 (forward-line 1)))
664 ;; Else
665 ;; 3. Do not refill a paragraph containing @w or @*, or ending
666 ;; with @<newline> followed by a newline.
667 (if (or (>= (point) (point-max))
668 (re-search-forward
669 "@w{\\|@\\*\\|@\n\n"
670 (save-excursion (forward-paragraph) (forward-line 1) (point))
672 ;; Go to end of paragraph and do nothing.
673 (forward-paragraph)
674 ;; 4. Else go to end of paragraph and insert @refill
675 (forward-paragraph)
676 (forward-line -1)
677 (let ((line-beg (point)))
678 (end-of-line)
679 (delete-region
680 (point)
681 (save-excursion (skip-chars-backward " \t") (point)))
682 (forward-char 1)
683 (unless (re-search-backward "@c[ \t\n]\\|@comment[ \t\n]" line-beg t)
684 (forward-char -1))
685 (unless (re-search-backward "@refill\\|^[ \t]*@" line-beg t)
686 (insert "@refill")))
687 (forward-line 1))))))
690 ;;; Handle `@raisesections' and `@lowersections' commands
692 ;; These commands change the hierarchical level of chapter structuring
693 ;; commands.
695 ;; @raisesections changes @subsection to @section,
696 ;; @section to @chapter,
697 ;; etc.
699 ;; @lowersections changes @chapter to @section
700 ;; @subsection to @subsubsection,
701 ;; etc.
703 ;; An @raisesections/@lowersections command changes only those
704 ;; structuring commands that follow the @raisesections/@lowersections
705 ;; command.
707 ;; Repeated @raisesections/@lowersections continue to raise or lower
708 ;; the heading level.
710 ;; An @lowersections command cancels an @raisesections command, and
711 ;; vice versa.
713 ;; You cannot raise or lower "beyond" chapters or subsubsections, but
714 ;; trying to do so does not elicit an error---you just get more
715 ;; headings that mean the same thing as you keep raising or lowering
716 ;; (for example, after a single @raisesections, both @chapter and
717 ;; @section produce chapter headings).
719 (defun texinfo-raise-lower-sections ()
720 "Raise or lower the hierarchical level of chapters, sections, etc.
722 This function acts according to `@raisesections' and `@lowersections'
723 commands in the Texinfo file.
725 For example, an `@lowersections' command is useful if you wish to
726 include what is written as an outer or standalone Texinfo file in
727 another Texinfo file as an inner, included file. The `@lowersections'
728 command changes chapters to sections, sections to subsections and so
731 @raisesections changes @subsection to @section,
732 @section to @chapter,
733 @heading to @chapheading,
734 etc.
736 @lowersections changes @chapter to @section,
737 @subsection to @subsubsection,
738 @heading to @subheading,
739 etc.
741 An `@raisesections' or `@lowersections' command changes only those
742 structuring commands that follow the `@raisesections' or
743 `@lowersections' command.
745 An `@lowersections' command cancels an `@raisesections' command, and
746 vice versa.
748 Repeated use of the commands continue to raise or lower the hierarchical
749 level a step at a time.
751 An attempt to raise above `chapters' reproduces chapter commands; an
752 attempt to lower below subsubsections reproduces subsubsection
753 commands."
755 ;; `texinfo-section-types-regexp' is defined in `texnfo-upd.el';
756 ;; it is a regexp matching chapter, section, other headings
757 ;; (but not the top node).
759 (let (type (level 0))
760 (while
761 (re-search-forward
762 (concat
763 "\\(\\(^@\\(raise\\|lower\\)sections\\)\\|\\("
764 texinfo-section-types-regexp
765 "\\)\\)")
766 nil t)
767 (beginning-of-line)
768 (save-excursion (setq type (read (current-buffer))))
769 (cond
771 ;; 1. Increment level
772 ((eq type '@raisesections)
773 (setq level (1+ level))
774 (delete-region
775 (point) (save-excursion (forward-line 1) (point))))
777 ;; 2. Decrement level
778 ((eq type '@lowersections)
779 (setq level (1- level))
780 (delete-region
781 (point) (save-excursion (forward-line 1) (point))))
783 ;; Now handle structuring commands
784 ((cond
786 ;; 3. Raise level when positive
787 ((> level 0)
788 (let ((count level)
789 (new-level type))
790 (while (> count 0)
791 (setq new-level
792 (cdr (assq new-level texinfo-raisesections-alist)))
793 (setq count (1- count)))
794 (kill-word 1)
795 (insert (symbol-name new-level))))
797 ;; 4. Do nothing except move point when level is zero
798 ((= level 0) (forward-line 1))
800 ;; 5. Lower level when positive
801 ((< level 0)
802 (let ((count level)
803 (new-level type))
804 (while (< count 0)
805 (setq new-level
806 (cdr (assq new-level texinfo-lowersections-alist)))
807 (setq count (1+ count)))
808 (kill-word 1)
809 (insert (symbol-name new-level))))))))))
811 ;;; Perform those texinfo-to-info conversions that apply to the whole input
812 ;;; uniformly.
814 (defun texinfo-format-scan ()
815 (texinfo-format-convert (point-min) (point-max))
816 ;; Search for @copying, which has to be first since the
817 ;; @insertcopying command then inserts the text elsewhere.
818 (goto-char (point-min))
819 (when (search-forward "@copying" nil t)
820 (texinfo-copying))
821 (while (search-forward "@insertcopying" nil t)
822 (delete-region (match-beginning 0) (match-end 0))
824 (texinfo-insertcopying))
825 ;; Scan for other @-commands.
826 (goto-char (point-min))
827 (while (search-forward "@" nil t)
829 ;; These are the single-character accent commands: @^ @` @' @" @= @~
830 ;; In Info, they are simply quoted and the @ deleted.
831 ;; Other single-character commands:
832 ;; @* forces a line break,
833 ;; @- is a discretionary hyphenation point; does nothing in Info.
834 ;; @<space>, @<tab>, @<newline> each produce a single space,
835 ;; unless followed by a newline.
837 ;; Old version 2.34 expression: (looking-at "[@{}^'` *\"?!]")
838 (if (looking-at "[@{}^'`\"=~ \t\n*?!-]")
839 ;; @*, causes a line break.
840 (cond
841 ;; @*, a line break
842 ((= (following-char) ?*)
843 ;; remove command
844 (delete-region (1- (point)) (1+ (point)))
845 ;; insert return if not at end of line;
846 ;; else line is already broken.
847 (if (not (= (following-char) ?\n))
848 (insert ?\n)))
849 ;; @-, deleted
850 ((= (following-char) ?-)
851 (delete-region (1- (point)) (1+ (point))))
852 ;; @<space>, @<tab>, @<newline>: produce a single space,
853 ;; unless followed by a newline.
854 ((= (following-char) ? )
855 (delete-region (1- (point)) (1+ (point)))
856 ;; insert single space if not at end of line;
857 ;; else line is already broken.
858 (if (not (= (following-char) ?\n))
859 (insert ? )))
860 ((= (following-char) ?\t)
861 (delete-region (1- (point)) (1+ (point)))
862 ;; insert single space if not at end of line;
863 ;; else line is already broken.
864 (if (not (= (following-char) ?\n))
865 (insert ? )))
866 ;; following char is a carriage return
867 ((= (following-char) ?\n)
868 ;; remove command
869 (delete-region (1- (point)) (1+ (point)))
870 ;; insert single space if not at end of line;
871 ;; else line is already broken.
872 (if (not (= (following-char) ?\n))
873 (insert ? )))
874 ;; Otherwise: the other characters are simply quoted. Delete the @.
876 (delete-char -1)
877 ;; Be compatible with makeinfo: if @' and its ilk are
878 ;; followed by a @ without a brace, barf.
879 (if (looking-at "[\"'^`~=]")
880 (progn
881 (if (= (char-after (1+ (point))) ?@)
882 (error "Use braces to give a command as an argument to @%c"
883 (following-char)))
884 (forward-char 1)
885 ;; @' etc. can optionally accept their argument in
886 ;; braces (makeinfo supports that).
887 (when (looking-at "{")
888 (let ((start (point)))
889 (forward-list 1)
890 (delete-char -1)
891 (goto-char start)
892 (delete-char 1))))
893 (forward-char 1))))
894 ;; @ is followed by a command-word; find the end of the word.
895 (setq texinfo-command-start (1- (point)))
896 (if (= (char-syntax (following-char)) ?w)
897 (forward-word 1)
898 (forward-char 1))
899 (setq texinfo-command-end (point))
900 ;; Detect the case of two @-commands in a row;
901 ;; process just the first one.
902 (goto-char (1+ texinfo-command-start))
903 (skip-chars-forward "^@" texinfo-command-end)
904 (setq texinfo-command-end (point))
905 ;; Handle let aliasing
906 (setq texinfo-command-name
907 (let (trial
908 (cmdname
909 (buffer-substring-no-properties
910 (1+ texinfo-command-start) texinfo-command-end)))
911 (while (setq trial (assoc cmdname texinfo-alias-list))
912 (setq cmdname (cdr trial)))
913 (intern cmdname)))
914 ;; Call the handler for this command.
915 (let ((enclosure-type
916 (assoc
917 (symbol-name texinfo-command-name)
918 texinfo-enclosure-list)))
919 (if enclosure-type
920 (progn
921 (insert
922 (car (car (cdr enclosure-type)))
923 (texinfo-parse-arg-discard)
924 (car (cdr (car (cdr enclosure-type)))))
925 (goto-char texinfo-command-start))
926 (let ((cmd (get texinfo-command-name 'texinfo-format)))
927 (if cmd (funcall cmd) (texinfo-unsupported)))))))
929 (cond (texinfo-stack
930 (goto-char (nth 2 (car texinfo-stack)))
931 (error "Unterminated @%s" (car (car texinfo-stack)))))
933 ;; Remove excess whitespace
934 (let ((whitespace-silent t))
935 (whitespace-cleanup)))
937 (defvar texinfo-copying-text ""
938 "Text of the copyright notice and copying permissions.")
940 (defun texinfo-copying ()
941 "Copy the copyright notice and copying permissions from the Texinfo file,
942 as indicated by the @copying ... @end copying command;
943 insert the text with the @insertcopying command."
944 (let ((beg (progn (beginning-of-line) (point)))
945 (end (progn (re-search-forward "^@end copying[ \t]*\n") (point))))
946 (setq texinfo-copying-text
947 (buffer-substring-no-properties
948 (save-excursion (goto-char beg) (forward-line 1) (point))
949 (save-excursion (goto-char end) (forward-line -1) (point))))
950 (delete-region beg end)))
952 (defun texinfo-insertcopying ()
953 "Insert the copyright notice and copying permissions from the Texinfo file,
954 which are indicated by the @copying ... @end copying command."
955 (insert (concat "\n" texinfo-copying-text)))
957 (put 'begin 'texinfo-format 'texinfo-format-begin)
958 (defun texinfo-format-begin ()
959 (texinfo-format-begin-end 'texinfo-format))
961 (put 'end 'texinfo-format 'texinfo-format-end)
962 (defun texinfo-format-end ()
963 (texinfo-format-begin-end 'texinfo-end))
965 (defun texinfo-format-begin-end (prop)
966 (setq texinfo-command-name (intern (texinfo-parse-line-arg)))
967 (let ((cmd (get texinfo-command-name prop)))
968 (if cmd (funcall cmd)
969 (texinfo-unsupported))))
971 ;;; Parsing functions
973 (defun texinfo-parse-line-arg ()
974 "Return argument of @-command as string.
975 Argument is separated from command either by a space or by a brace.
976 If a space, return rest of line, with beginning and ending white
977 space removed. If a brace, return string between braces.
978 Leave point after argument."
979 (goto-char texinfo-command-end)
980 (let ((start (point)))
981 (cond ((looking-at " ")
982 (skip-chars-forward " ")
983 (setq start (point))
984 (end-of-line)
985 (skip-chars-backward " ")
986 (delete-region (point) (progn (end-of-line) (point)))
987 (setq texinfo-command-end (1+ (point))))
988 ((looking-at "{")
989 (setq start (1+ (point)))
990 (forward-list 1)
991 (setq texinfo-command-end (point))
992 (forward-char -1))
994 (error "Invalid texinfo command arg format")))
995 (prog1 (buffer-substring-no-properties start (point))
996 (if (eolp) (forward-char 1)))))
998 (defun texinfo-parse-expanded-arg ()
999 (goto-char texinfo-command-end)
1000 (let ((start (point))
1001 marker)
1002 (cond ((looking-at " ")
1003 (skip-chars-forward " ")
1004 (setq start (point))
1005 (end-of-line)
1006 (setq texinfo-command-end (1+ (point))))
1007 ((looking-at "{")
1008 (setq start (1+ (point)))
1009 (forward-list 1)
1010 (setq texinfo-command-end (point))
1011 (forward-char -1))
1013 (error "Invalid texinfo command arg format")))
1014 (setq marker (move-marker (make-marker) texinfo-command-end))
1015 (texinfo-format-expand-region start (point))
1016 (setq texinfo-command-end (marker-position marker))
1017 (move-marker marker nil)
1018 (prog1 (buffer-substring-no-properties start (point))
1019 (if (eolp) (forward-char 1)))))
1021 (defun texinfo-format-expand-region (start end)
1022 (save-restriction
1023 (narrow-to-region start end)
1024 (let (texinfo-command-start
1025 texinfo-command-end
1026 texinfo-command-name
1027 texinfo-stack)
1028 (texinfo-format-scan))
1029 (goto-char (point-max))))
1031 (defun texinfo-parse-arg-discard ()
1032 "Delete command and argument; return argument of command."
1033 (prog1 (texinfo-parse-line-arg)
1034 (texinfo-discard-command)))
1036 (defun texinfo-discard-command ()
1037 (delete-region texinfo-command-start texinfo-command-end))
1039 (defun texinfo-optional-braces-discard ()
1040 "Discard braces following command, if any."
1041 (goto-char texinfo-command-end)
1042 (let ((start (point)))
1043 (cond ((looking-at "[ \t]*\n")) ; do nothing
1044 ((looking-at "{") ; remove braces, if any
1045 (forward-list 1)
1046 (setq texinfo-command-end (point)))
1048 (error
1049 "Invalid `texinfo-optional-braces-discard' format \(need braces?\)")))
1050 (delete-region texinfo-command-start texinfo-command-end)))
1052 (defun texinfo-format-parse-line-args ()
1053 (let ((start (1- (point)))
1054 next beg end
1055 args)
1056 (skip-chars-forward " ")
1057 (while (not (eolp))
1058 (setq beg (point))
1059 (re-search-forward "[\n,]")
1060 (setq next (point))
1061 (if (bolp) (setq next (1- next)))
1062 (forward-char -1)
1063 (skip-chars-backward " ")
1064 (setq end (point))
1065 (push (if (> end beg) (buffer-substring-no-properties beg end))
1066 args)
1067 (goto-char next)
1068 (skip-chars-forward " "))
1069 (if (eolp) (forward-char 1))
1070 (setq texinfo-command-end (point))
1071 (nreverse args)))
1073 (defun texinfo-format-parse-args ()
1074 (let ((start (1- (point)))
1075 next beg end
1076 args)
1077 (search-forward "{")
1078 (save-excursion
1079 (texinfo-format-expand-region
1080 (point)
1081 (save-excursion (up-list 1) (1- (point)))))
1082 ;; The following does not handle cross references of the form:
1083 ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the
1084 ;; re-search-forward finds the first right brace after the second
1085 ;; comma.
1086 (while (/= (preceding-char) ?\})
1087 (skip-chars-forward " \t\n")
1088 (setq beg (point))
1089 (re-search-forward "[},]")
1090 (setq next (point))
1091 (forward-char -1)
1092 (skip-chars-backward " \t\n")
1093 (setq end (point))
1094 (cond ((< beg end)
1095 (goto-char beg)
1096 (while (search-forward "\n" end t)
1097 (replace-match " "))))
1098 (push (if (> end beg) (buffer-substring-no-properties beg end))
1099 args)
1100 (goto-char next))
1101 ;;(if (eolp) (forward-char 1))
1102 (setq texinfo-command-end (point))
1103 (nreverse args)))
1105 (defun texinfo-format-parse-defun-args ()
1106 (goto-char texinfo-command-end)
1107 (let ((start (point)))
1108 (end-of-line)
1109 (setq texinfo-command-end (1+ (point)))
1110 (let ((marker (move-marker (make-marker) texinfo-command-end)))
1111 (texinfo-format-expand-region start (point))
1112 (setq texinfo-command-end (marker-position marker))
1113 (move-marker marker nil))
1114 (goto-char start)
1115 (let ((args '())
1116 beg end)
1117 (skip-chars-forward " ")
1118 (while (not (eolp))
1119 (cond ((looking-at "{")
1120 (setq beg (1+ (point)))
1121 (forward-list 1)
1122 (setq end (1- (point))))
1124 (setq beg (point))
1125 (re-search-forward "[\n ]")
1126 (forward-char -1)
1127 (setq end (point))))
1128 (push (buffer-substring-no-properties beg end) args)
1129 (skip-chars-forward " "))
1130 (forward-char 1)
1131 (nreverse args))))
1133 (defun texinfo-discard-line ()
1134 (goto-char texinfo-command-end)
1135 (skip-chars-forward " \t")
1136 (or (eolp)
1137 (error "Extraneous text at end of command line"))
1138 (goto-char texinfo-command-start)
1139 (or (bolp)
1140 (error "Extraneous text at beginning of command line"))
1141 (delete-region (point) (progn (forward-line 1) (point))))
1143 (defun texinfo-discard-line-with-args ()
1144 (goto-char texinfo-command-start)
1145 (delete-region (point) (progn (forward-line 1) (point))))
1148 ;;; @setfilename
1150 ;; Only `texinfo-format-buffer' handles @setfilename with this
1151 ;; definition; `texinfo-format-region' handles @setfilename, if any,
1152 ;; specially.
1153 (put 'setfilename 'texinfo-format 'texinfo-format-setfilename)
1154 (defun texinfo-format-setfilename ()
1155 (texinfo-parse-arg-discard))
1157 ;;; @node, @menu, @detailmenu
1159 (put 'node 'texinfo-format 'texinfo-format-node)
1160 (put 'nwnode 'texinfo-format 'texinfo-format-node)
1161 (defun texinfo-format-node ()
1162 (let* ((args (texinfo-format-parse-line-args))
1163 (name (nth 0 args))
1164 (next (nth 1 args))
1165 (prev (nth 2 args))
1166 (up (nth 3 args)))
1167 (texinfo-discard-command)
1168 (setq texinfo-last-node name)
1169 (let ((tem (if texinfo-fold-nodename-case (downcase name) name)))
1170 (if (assoc tem texinfo-node-names)
1171 (error "Duplicate node name: %s" name)
1172 (push (list tem) texinfo-node-names)))
1173 (setq texinfo-footnote-number 0)
1174 ;; insert "\n\^_" unconditionally since this is what info is looking for
1175 (insert "\n\^_\nFile: " texinfo-format-filename
1176 ", Node: " name)
1177 (if next
1178 (insert ", Next: " next))
1179 (if prev
1180 (insert ", Prev: " prev))
1181 (if up
1182 (insert ", Up: " up))
1183 (insert ?\n)
1184 (setq texinfo-last-node-pos (point))))
1186 (put 'anchor 'texinfo-format 'texinfo-anchor)
1187 (defun texinfo-anchor ()
1188 (let (anchor-string
1189 (here (- (point) 7)) ; save location of beginning of `@anchor'
1190 (arg (texinfo-parse-arg-discard)))
1191 (if (looking-at " ") ; since a space may be left after -discard
1192 (delete-char 1))
1193 (forward-paragraph)
1194 (let ((end (point)))
1195 (if (save-excursion
1196 (backward-word 1)
1197 (search-forward "@refill" end t))
1198 (setq anchor-string "@anchor-yes-refill")
1199 (setq anchor-string "@anchor-no-refill")))
1200 (goto-char here)
1201 (insert anchor-string "{" arg "}")))
1203 (put 'menu 'texinfo-format 'texinfo-format-menu)
1204 (defun texinfo-format-menu ()
1205 (texinfo-discard-line)
1206 (insert "* Menu:\n\n"))
1208 (put 'menu 'texinfo-end 'texinfo-discard-command)
1210 ;; The @detailmenu should be removed eventually.
1212 ;; According to Karl Berry, 31 August 1996:
1214 ;; You don't like, I don't like it. I agree, it would be better just to
1215 ;; fix the bug [in `makeinfo']. .. At this point, since inserting those
1216 ;; two commands in the Elisp fn is trivial, I don't especially want to
1217 ;; expend more effort...
1219 ;; I added a couple sentences of documentation to the manual (putting the
1220 ;; blame on makeinfo where it belongs :-().
1222 (put 'detailmenu 'texinfo-format 'texinfo-discard-line)
1223 (put 'detailmenu 'texinfo-end 'texinfo-discard-command)
1225 ;; (Also see `texnfo-upd.el')
1228 ;;; Cross references
1230 ;; @xref {NODE, FNAME, NAME, FILE, DOCUMENT}
1231 ;; -> *Note FNAME: (FILE)NODE
1232 ;; If FILE is missing,
1233 ;; *Note FNAME: NODE
1234 ;; If FNAME is empty and NAME is present
1235 ;; *Note NAME: Node
1236 ;; If both NAME and FNAME are missing
1237 ;; *Note NODE::
1238 ;; texinfo ignores the DOCUMENT argument.
1239 ;; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1240 ;; If FILE is specified, (FILE)NODE is used for xrefs.
1241 ;; If fifth argument DOCUMENT is specified, produces
1242 ;; See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1243 ;; of DOCUMENT
1245 ;; @ref a reference that does not put `See' or `see' in
1246 ;; the hardcopy and is the same as @xref in Info
1247 (put 'ref 'texinfo-format 'texinfo-format-xref)
1249 (put 'xref 'texinfo-format 'texinfo-format-xref)
1250 (defun texinfo-format-xref ()
1251 (let ((args (texinfo-format-parse-args)))
1252 (texinfo-discard-command)
1253 (insert "*Note ")
1254 (let ((fname (or (nth 1 args) (nth 2 args))))
1255 (if (null (or fname (nth 3 args)))
1256 (insert (car args) "::")
1257 (insert (or fname (car args)) ": ")
1258 (if (nth 3 args)
1259 (insert "(" (nth 3 args) ")"))
1260 (and (car args) (insert (car args)))))))
1262 (put 'pxref 'texinfo-format 'texinfo-format-pxref)
1263 (defun texinfo-format-pxref ()
1264 (texinfo-format-xref)
1265 (or (save-excursion
1266 (forward-char -2)
1267 (looking-at "::"))
1268 (insert ".")))
1270 ;; @inforef{NODE, FNAME, FILE}
1271 ;; Like @xref{NODE, FNAME,,FILE} in texinfo.
1272 ;; In Tex, generates "See Info file FILE, node NODE"
1273 (put 'inforef 'texinfo-format 'texinfo-format-inforef)
1274 (defun texinfo-format-inforef ()
1275 (let ((args (texinfo-format-parse-args)))
1276 (texinfo-discard-command)
1277 (if (nth 1 args)
1278 (insert "*Note " (nth 1 args) ": (" (nth 2 args) ")" (car args))
1279 (insert "*Note " "(" (nth 2 args) ")" (car args) "::"))))
1282 ;;; URL Reference: @uref
1284 ;; @uref produces a reference to a uniform resource locator (URL).
1285 ;; It takes one mandatory argument, the URL, and one optional argument,
1286 ;; the text to display (the default is the URL itself).
1288 (put 'uref 'texinfo-format 'texinfo-format-uref)
1289 (defun texinfo-format-uref ()
1290 "Format URL and optional URL-TITLE.
1291 Insert ` ... ' around URL if no URL-TITLE argument;
1292 otherwise, insert URL-TITLE followed by URL in parentheses."
1293 (let ((args (texinfo-format-parse-args)))
1294 (texinfo-discard-command)
1295 ;; if url-title
1296 (if (nth 1 args)
1297 (insert (nth 1 args) " (" (nth 0 args) ")")
1298 (insert "`" (nth 0 args) "'"))
1299 (goto-char texinfo-command-start)))
1302 ;;; Section headings
1304 (put 'majorheading 'texinfo-format 'texinfo-format-chapter)
1305 (put 'chapheading 'texinfo-format 'texinfo-format-chapter)
1306 (put 'ichapter 'texinfo-format 'texinfo-format-chapter)
1307 (put 'chapter 'texinfo-format 'texinfo-format-chapter)
1308 (put 'iappendix 'texinfo-format 'texinfo-format-chapter)
1309 (put 'appendix 'texinfo-format 'texinfo-format-chapter)
1310 (put 'iunnumbered 'texinfo-format 'texinfo-format-chapter)
1311 (put 'top 'texinfo-format 'texinfo-format-chapter)
1312 (put 'unnumbered 'texinfo-format 'texinfo-format-chapter)
1313 (put 'centerchap 'texinfo-format 'texinfo-format-chapter)
1314 (defun texinfo-format-chapter ()
1315 (texinfo-format-chapter-1 ?*))
1317 (put 'heading 'texinfo-format 'texinfo-format-section)
1318 (put 'isection 'texinfo-format 'texinfo-format-section)
1319 (put 'section 'texinfo-format 'texinfo-format-section)
1320 (put 'iappendixsection 'texinfo-format 'texinfo-format-section)
1321 (put 'appendixsection 'texinfo-format 'texinfo-format-section)
1322 (put 'iappendixsec 'texinfo-format 'texinfo-format-section)
1323 (put 'appendixsec 'texinfo-format 'texinfo-format-section)
1324 (put 'iunnumberedsec 'texinfo-format 'texinfo-format-section)
1325 (put 'unnumberedsec 'texinfo-format 'texinfo-format-section)
1326 (defun texinfo-format-section ()
1327 (texinfo-format-chapter-1 ?=))
1329 (put 'subheading 'texinfo-format 'texinfo-format-subsection)
1330 (put 'isubsection 'texinfo-format 'texinfo-format-subsection)
1331 (put 'subsection 'texinfo-format 'texinfo-format-subsection)
1332 (put 'iappendixsubsec 'texinfo-format 'texinfo-format-subsection)
1333 (put 'appendixsubsec 'texinfo-format 'texinfo-format-subsection)
1334 (put 'iunnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
1335 (put 'unnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
1336 (defun texinfo-format-subsection ()
1337 (texinfo-format-chapter-1 ?-))
1339 (put 'subsubheading 'texinfo-format 'texinfo-format-subsubsection)
1340 (put 'isubsubsection 'texinfo-format 'texinfo-format-subsubsection)
1341 (put 'subsubsection 'texinfo-format 'texinfo-format-subsubsection)
1342 (put 'iappendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
1343 (put 'appendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
1344 (put 'iunnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
1345 (put 'unnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
1346 (defun texinfo-format-subsubsection ()
1347 (texinfo-format-chapter-1 ?.))
1349 (defun texinfo-format-chapter-1 (belowchar)
1350 (let ((arg (texinfo-parse-arg-discard)))
1351 (message "Formatting: %s ... " arg) ; So we can see where we are.
1352 (insert ?\n arg ?\n "@SectionPAD " belowchar ?\n)
1353 (forward-line -2)))
1355 (put 'SectionPAD 'texinfo-format 'texinfo-format-sectionpad)
1356 (defun texinfo-format-sectionpad ()
1357 (let ((str (texinfo-parse-arg-discard)))
1358 (forward-char -1)
1359 (let ((column (current-column)))
1360 (forward-char 1)
1361 (while (> column 0)
1362 (insert str)
1363 (setq column (1- column))))
1364 (insert ?\n)))
1367 ;;; Space controlling commands: @. and @:, and the soft hyphen.
1369 (put '\. 'texinfo-format 'texinfo-format-\.)
1370 (defun texinfo-format-\. ()
1371 (texinfo-discard-command)
1372 (insert "."))
1374 (put '\: 'texinfo-format 'texinfo-format-\:)
1375 (defun texinfo-format-\: ()
1376 (texinfo-discard-command))
1378 (put '\- 'texinfo-format 'texinfo-format-soft-hyphen)
1379 (defun texinfo-format-soft-hyphen ()
1380 (texinfo-discard-command))
1383 ;;; @kbdinputstyle, @vskip, headings & footings
1384 ;; These commands for not for Info and should never
1385 ;; appear in an Info environment; but if they do,
1386 ;; this causes them to be discarded.
1388 ;; @kbdinputstyle
1389 (put 'kbdinputstyle 'texinfo-format 'texinfo-discard-line-with-args)
1391 ;; @vskip
1392 (put 'vskip 'texinfo-format 'texinfo-discard-line-with-args)
1394 ;; headings & footings
1395 (put 'evenfooting 'texinfo-format 'texinfo-discard-line-with-args)
1396 (put 'evenheading 'texinfo-format 'texinfo-discard-line-with-args)
1397 (put 'oddfooting 'texinfo-format 'texinfo-discard-line-with-args)
1398 (put 'oddheading 'texinfo-format 'texinfo-discard-line-with-args)
1399 (put 'everyfooting 'texinfo-format 'texinfo-discard-line-with-args)
1400 (put 'everyheading 'texinfo-format 'texinfo-discard-line-with-args)
1403 ;;; @documentdescription ... @end documentdescription
1404 ;; This command is for HTML output and should never
1405 ;; appear in an Info environment; but if it does,
1406 ;; this causes it to be discarded.
1408 (put 'documentdescription 'texinfo-format 'texinfo-format-documentdescription)
1409 (defun texinfo-format-documentdescription ()
1410 (delete-region texinfo-command-start
1411 (progn (re-search-forward "^@end documentdescription[ \t]*\n")
1412 (point))))
1416 ;;; @center, @sp, and @br
1418 (put 'center 'texinfo-format 'texinfo-format-center)
1419 (defun texinfo-format-center ()
1420 (let ((arg (texinfo-parse-expanded-arg)))
1421 (texinfo-discard-command)
1422 (insert arg)
1423 (insert ?\n)
1424 (save-restriction
1425 (goto-char (1- (point)))
1426 (let ((indent-tabs-mode nil))
1427 (center-line)))))
1429 (put 'sp 'texinfo-format 'texinfo-format-sp)
1430 (defun texinfo-format-sp ()
1431 (let* ((arg (texinfo-parse-arg-discard))
1432 (num (read arg)))
1433 (insert-char ?\n num)))
1435 (put 'br 'texinfo-format 'texinfo-format-paragraph-break)
1436 (defun texinfo-format-paragraph-break ()
1437 "Force a paragraph break.
1438 If used within a line, follow `@br' with braces."
1439 (texinfo-optional-braces-discard)
1440 ;; insert one return if at end of line;
1441 ;; else insert two returns, to generate a blank line.
1442 (if (= (following-char) ?\n)
1443 (insert ?\n)
1444 (insert-char ?\n 2)))
1447 ;;; @footnote and @footnotestyle
1449 ;; In Texinfo, footnotes are created with the `@footnote' command.
1450 ;; This command is followed immediately by a left brace, then by the text of
1451 ;; the footnote, and then by a terminating right brace. The
1452 ;; template for a footnote is:
1454 ;; @footnote{TEXT}
1456 ;; Info has two footnote styles:
1458 ;; * In the End of node style, all the footnotes for a single node
1459 ;; are placed at the end of that node. The footnotes are
1460 ;; separated from the rest of the node by a line of dashes with
1461 ;; the word `Footnotes' within it.
1463 ;; * In the Separate node style, all the footnotes for a single node
1464 ;; are placed in an automatically constructed node of their own.
1466 ;; Footnote style is specified by the @footnotestyle command, either
1467 ;; @footnotestyle separate
1468 ;; or
1469 ;; @footnotestyle end
1471 ;; The default is separate
1473 (defvar texinfo-footnote-style "separate"
1474 "Footnote style, either separate or end.")
1476 (put 'footnotestyle 'texinfo-format 'texinfo-footnotestyle)
1477 (defun texinfo-footnotestyle ()
1478 "Specify whether footnotes are at end of node or in separate nodes.
1479 Argument is either end or separate."
1480 (setq texinfo-footnote-style (texinfo-parse-arg-discard)))
1482 (put 'footnote 'texinfo-format 'texinfo-format-footnote)
1483 (defun texinfo-format-footnote ()
1484 "Format a footnote in either end of node or separate node style.
1485 The texinfo-footnote-style variable controls which style is used."
1486 (setq texinfo-footnote-number (1+ texinfo-footnote-number))
1487 (cond ((string= texinfo-footnote-style "end")
1488 (texinfo-format-end-node))
1489 ((string= texinfo-footnote-style "separate")
1490 (texinfo-format-separate-node))))
1492 (defun texinfo-format-separate-node ()
1493 "Format footnote in Separate node style, with notes in own node.
1494 The node is constructed automatically."
1495 (let* (start
1496 (arg (texinfo-parse-line-arg))
1497 (node-name-beginning
1498 (save-excursion
1499 (re-search-backward
1500 "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:")
1501 (match-end 0)))
1502 (node-name
1503 (save-excursion
1504 (buffer-substring-no-properties
1505 (progn (goto-char node-name-beginning) ; skip over node command
1506 (skip-chars-forward " \t") ; and over spaces
1507 (point))
1508 (if (search-forward
1510 (save-excursion (end-of-line) (point)) t) ; bound search
1511 (1- (point))
1512 (end-of-line) (point))))))
1513 (texinfo-discard-command) ; remove or insert whitespace, as needed
1514 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1515 (point))
1516 (insert (format " (%d) (*Note %s-Footnotes::)"
1517 texinfo-footnote-number node-name))
1518 (fill-paragraph nil)
1519 (save-excursion
1520 (if (re-search-forward "^@node" nil 'move)
1521 (forward-line -1))
1523 ;; two cases: for the first footnote, we must insert a node header;
1524 ;; for the second and subsequent footnotes, we need only insert
1525 ;; the text of the footnote.
1527 (if (save-excursion
1528 (search-backward
1529 (concat node-name "-Footnotes, Up: ")
1530 node-name-beginning
1532 (progn ; already at least one footnote
1533 (setq start (point))
1534 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
1535 (fill-region start (point)))
1536 ;; else not yet a footnote
1537 (insert "\n\^_\nFile: " texinfo-format-filename
1538 " Node: " node-name "-Footnotes, Up: " node-name "\n")
1539 (setq start (point))
1540 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
1541 (narrow-to-region (save-excursion (goto-char start) (point)) (point))
1542 (fill-region (point-min) (point-max))
1543 (widen)))))
1545 (defun texinfo-format-end-node ()
1546 "Format footnote in the End of node style, with notes at end of node."
1547 (let (start
1548 (arg (texinfo-parse-line-arg)))
1549 (texinfo-discard-command) ; remove or insert whitespace, as needed
1550 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1551 (point))
1552 (insert (format " (%d) " texinfo-footnote-number))
1553 (fill-paragraph nil)
1554 (save-excursion
1555 (if (search-forward "\n--------- Footnotes ---------\n" nil t)
1556 (progn ; already have footnote, put new one before end of node
1557 (if (re-search-forward "^@node" nil 'move)
1558 (forward-line -1))
1559 (setq start (point))
1560 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
1561 (fill-region start (point)))
1562 ;; else no prior footnote
1563 (if (re-search-forward "^@node" nil 'move)
1564 (forward-line -1))
1565 (insert "\n--------- Footnotes ---------\n")
1566 (setq start (point))
1567 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))))))
1570 ;;; @itemize, @enumerate, and similar commands
1572 ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.
1573 ;; @enumerate pushes (enumerate 0 STARTPOS).
1574 ;; @item dispatches to the texinfo-item prop of the first elt of the list.
1575 ;; For itemize, this puts in and rescans the COMMANDS.
1576 ;; For enumerate, this increments the number and puts it in.
1577 ;; In either case, it puts a Backspace at the front of the line
1578 ;; which marks it not to be indented later.
1579 ;; All other lines get indented by 5 when the @end is reached.
1581 (defvar texinfo-stack-depth 0
1582 "Count of number of unpopped texinfo-push-stack calls.
1583 Used by @refill indenting command to avoid indenting within lists, etc.")
1585 (defun texinfo-push-stack (check arg)
1586 (setq texinfo-stack-depth (1+ texinfo-stack-depth))
1587 (push (list check arg texinfo-command-start)
1588 texinfo-stack))
1590 (defun texinfo-pop-stack (check)
1591 (setq texinfo-stack-depth (1- texinfo-stack-depth))
1592 (if (null texinfo-stack)
1593 (error "Unmatched @end %s" check))
1594 (if (not (eq (car (car texinfo-stack)) check))
1595 (error "@end %s matches @%s"
1596 check (car (car texinfo-stack))))
1597 (prog1 (cdr (car texinfo-stack))
1598 (setq texinfo-stack (cdr texinfo-stack))))
1600 (put 'itemize 'texinfo-format 'texinfo-itemize)
1601 (defun texinfo-itemize ()
1602 (texinfo-push-stack
1603 'itemize
1604 (progn (skip-chars-forward " \t")
1605 (if (eolp)
1606 "@bullet"
1607 (texinfo-parse-line-arg))))
1608 (texinfo-discard-line-with-args)
1609 (setq fill-column (- fill-column 5)))
1611 (put 'itemize 'texinfo-end 'texinfo-end-itemize)
1612 (defun texinfo-end-itemize ()
1613 (setq fill-column (+ fill-column 5))
1614 (texinfo-discard-command)
1615 (let ((stacktop
1616 (texinfo-pop-stack 'itemize)))
1617 (texinfo-do-itemize (nth 1 stacktop))))
1619 (put 'enumerate 'texinfo-format 'texinfo-enumerate)
1620 (defun texinfo-enumerate ()
1621 (texinfo-push-stack
1622 'enumerate
1623 (progn (skip-chars-forward " \t")
1624 (if (eolp)
1626 (read (current-buffer)))))
1627 (if (and (symbolp (car (cdr (car texinfo-stack))))
1628 (> 1 (length (symbol-name (car (cdr (car texinfo-stack)))))))
1629 (error
1630 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." ))
1631 (texinfo-discard-line-with-args)
1632 (setq fill-column (- fill-column 5)))
1634 (put 'enumerate 'texinfo-end 'texinfo-end-enumerate)
1635 (defun texinfo-end-enumerate ()
1636 (setq fill-column (+ fill-column 5))
1637 (texinfo-discard-command)
1638 (let ((stacktop
1639 (texinfo-pop-stack 'enumerate)))
1640 (texinfo-do-itemize (nth 1 stacktop))))
1642 ;; @alphaenumerate never became a standard part of Texinfo
1643 (put 'alphaenumerate 'texinfo-format 'texinfo-alphaenumerate)
1644 (defun texinfo-alphaenumerate ()
1645 (texinfo-push-stack 'alphaenumerate (1- ?a))
1646 (setq fill-column (- fill-column 5))
1647 (texinfo-discard-line))
1649 (put 'alphaenumerate 'texinfo-end 'texinfo-end-alphaenumerate)
1650 (defun texinfo-end-alphaenumerate ()
1651 (setq fill-column (+ fill-column 5))
1652 (texinfo-discard-command)
1653 (let ((stacktop
1654 (texinfo-pop-stack 'alphaenumerate)))
1655 (texinfo-do-itemize (nth 1 stacktop))))
1657 ;; @capsenumerate never became a standard part of Texinfo
1658 (put 'capsenumerate 'texinfo-format 'texinfo-capsenumerate)
1659 (defun texinfo-capsenumerate ()
1660 (texinfo-push-stack 'capsenumerate (1- ?A))
1661 (setq fill-column (- fill-column 5))
1662 (texinfo-discard-line))
1664 (put 'capsenumerate 'texinfo-end 'texinfo-end-capsenumerate)
1665 (defun texinfo-end-capsenumerate ()
1666 (setq fill-column (+ fill-column 5))
1667 (texinfo-discard-command)
1668 (let ((stacktop
1669 (texinfo-pop-stack 'capsenumerate)))
1670 (texinfo-do-itemize (nth 1 stacktop))))
1672 ;; At the @end, indent all the lines within the construct
1673 ;; except those marked with backspace. FROM says where
1674 ;; construct started.
1675 (defun texinfo-do-itemize (from)
1676 (save-excursion
1677 (while (progn (forward-line -1)
1678 (>= (point) from))
1679 (if (= (following-char) ?\b)
1680 (save-excursion
1681 (delete-char 1)
1682 (end-of-line)
1683 (delete-char 6))
1684 (if (not (looking-at "[ \t]*$"))
1685 (save-excursion (insert " ")))))))
1687 (put 'item 'texinfo-format 'texinfo-item)
1688 (put 'itemx 'texinfo-format 'texinfo-item)
1689 (defun texinfo-item ()
1690 (funcall (get (car (car texinfo-stack)) 'texinfo-item)))
1692 (put 'itemize 'texinfo-item 'texinfo-itemize-item)
1693 (defun texinfo-itemize-item ()
1694 ;; (texinfo-discard-line) ; Did not handle text on same line as @item.
1695 (delete-region (1+ (point)) (save-excursion (beginning-of-line) (point)))
1696 (if (looking-at "[ \t]*[^ \t\n]+")
1697 ;; Text on same line as @item command.
1698 (insert "\b " (nth 1 (car texinfo-stack)) " \n")
1699 ;; Else text on next line.
1700 (insert "\b " (nth 1 (car texinfo-stack)) " "))
1701 (forward-line -1))
1703 (put 'enumerate 'texinfo-item 'texinfo-enumerate-item)
1704 (defun texinfo-enumerate-item ()
1705 (texinfo-discard-line)
1706 (let (enumerating-symbol)
1707 (cond ((integerp (car (cdr (car texinfo-stack))))
1708 (setq enumerating-symbol (car (cdr (car texinfo-stack))))
1709 (insert ?\b (format "%3d. " enumerating-symbol) ?\n)
1710 (setcar (cdr (car texinfo-stack)) (1+ enumerating-symbol)))
1711 ((symbolp (car (cdr (car texinfo-stack))))
1712 (setq enumerating-symbol
1713 (symbol-name (car (cdr (car texinfo-stack)))))
1714 (if (or (equal ?\[ (string-to-char enumerating-symbol))
1715 (equal ?\{ (string-to-char enumerating-symbol)))
1716 (error
1717 "Too many items in enumerated list; alphabet ends at Z."))
1718 (insert ?\b (format "%3s. " enumerating-symbol) ?\n)
1719 (setcar (cdr (car texinfo-stack))
1720 (make-symbol
1721 (char-to-string
1723 (string-to-char enumerating-symbol))))))
1725 (error
1726 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." )))
1727 (forward-line -1)))
1729 (put 'alphaenumerate 'texinfo-item 'texinfo-alphaenumerate-item)
1730 (defun texinfo-alphaenumerate-item ()
1731 (texinfo-discard-line)
1732 (let ((next (1+ (car (cdr (car texinfo-stack))))))
1733 (if (> next ?z)
1734 (error "More than 26 items in @alphaenumerate; get a bigger alphabet"))
1735 (setcar (cdr (car texinfo-stack)) next)
1736 (insert "\b " next ". \n"))
1737 (forward-line -1))
1739 (put 'capsenumerate 'texinfo-item 'texinfo-capsenumerate-item)
1740 (defun texinfo-capsenumerate-item ()
1741 (texinfo-discard-line)
1742 (let ((next (1+ (car (cdr (car texinfo-stack))))))
1743 (if (> next ?Z)
1744 (error "More than 26 items in @capsenumerate; get a bigger alphabet"))
1745 (setcar (cdr (car texinfo-stack)) next)
1746 (insert "\b " next ". \n"))
1747 (forward-line -1))
1750 ;;; @table
1752 ;; The `@table' command produces two-column tables.
1754 (put 'table 'texinfo-format 'texinfo-table)
1755 (defun texinfo-table ()
1756 (texinfo-push-stack
1757 'table
1758 (progn (skip-chars-forward " \t")
1759 (if (eolp)
1760 "@asis"
1761 (texinfo-parse-line-arg))))
1762 (texinfo-discard-line-with-args)
1763 (setq fill-column (- fill-column 5)))
1765 (put 'table 'texinfo-item 'texinfo-table-item)
1766 (defun texinfo-table-item ()
1767 (let ((arg (texinfo-parse-arg-discard))
1768 (itemfont (car (cdr (car texinfo-stack)))))
1769 (insert ?\b itemfont ?\{ arg "}\n \n"))
1770 (forward-line -2))
1772 (put 'table 'texinfo-end 'texinfo-end-table)
1773 (defun texinfo-end-table ()
1774 (setq fill-column (+ fill-column 5))
1775 (texinfo-discard-command)
1776 (let ((stacktop
1777 (texinfo-pop-stack 'table)))
1778 (texinfo-do-itemize (nth 1 stacktop))))
1780 ;; @description appears to be an undocumented variant on @table that
1781 ;; does not require an arg. It fails in texinfo.tex 2.58 and is not
1782 ;; part of makeinfo.c The command appears to be a relic of the past.
1783 (put 'description 'texinfo-end 'texinfo-end-table)
1784 (put 'description 'texinfo-format 'texinfo-description)
1785 (defun texinfo-description ()
1786 (texinfo-push-stack 'table "@asis")
1787 (setq fill-column (- fill-column 5))
1788 (texinfo-discard-line))
1791 ;;; @ftable, @vtable
1793 ;; The `@ftable' and `@vtable' commands are like the `@table' command
1794 ;; but they also insert each entry in the first column of the table
1795 ;; into the function or variable index.
1797 ;; Handle the @ftable and @vtable commands:
1799 (put 'ftable 'texinfo-format 'texinfo-ftable)
1800 (put 'vtable 'texinfo-format 'texinfo-vtable)
1802 (defun texinfo-ftable () (texinfo-indextable 'ftable))
1803 (defun texinfo-vtable () (texinfo-indextable 'vtable))
1805 (defun texinfo-indextable (table-type)
1806 (texinfo-push-stack table-type (texinfo-parse-arg-discard))
1807 (setq fill-column (- fill-column 5)))
1809 ;; Handle the @item commands within ftable and vtable:
1811 (put 'ftable 'texinfo-item 'texinfo-ftable-item)
1812 (put 'vtable 'texinfo-item 'texinfo-vtable-item)
1814 (defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex))
1815 (defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex))
1817 (defun texinfo-indextable-item (index-type)
1818 (let ((item (texinfo-parse-arg-discard))
1819 (itemfont (car (cdr (car texinfo-stack))))
1820 (indexvar index-type))
1821 (insert ?\b itemfont ?\{ item "}\n \n")
1822 (set indexvar
1823 (cons
1824 (list item texinfo-last-node)
1825 (symbol-value indexvar)))
1826 (forward-line -2)))
1828 ;; Handle @end ftable, @end vtable
1830 (put 'ftable 'texinfo-end 'texinfo-end-ftable)
1831 (put 'vtable 'texinfo-end 'texinfo-end-vtable)
1833 (defun texinfo-end-ftable () (texinfo-end-indextable 'ftable))
1834 (defun texinfo-end-vtable () (texinfo-end-indextable 'vtable))
1836 (defun texinfo-end-indextable (table-type)
1837 (setq fill-column (+ fill-column 5))
1838 (texinfo-discard-command)
1839 (let ((stacktop
1840 (texinfo-pop-stack table-type)))
1841 (texinfo-do-itemize (nth 1 stacktop))))
1844 ;;; @multitable ... @end multitable
1846 ;; Produce a multi-column table, with as many columns as desired.
1848 ;; A multi-column table has this template:
1850 ;; @multitable {A1} {A2} {A3}
1851 ;; @item A1 @tab A2 @tab A3
1852 ;; @item B1 @tab B2 @tab B3
1853 ;; @item C1 @tab C2 @tab C3
1854 ;; @end multitable
1856 ;; where the width of the text in brackets specifies the width of the
1857 ;; respective column.
1859 ;; Or else:
1861 ;; @multitable @columnfractions .25 .3 .45
1862 ;; @item A1 @tab A2 @tab A3
1863 ;; @item B1 @tab B2 @tab B3
1864 ;; @end multitable
1866 ;; where the fractions specify the width of each column as a percent
1867 ;; of the current width of the text (i.e., of the fill-column).
1869 ;; Long lines of text are filled within columns.
1871 ;; Using the Emacs Lisp formatter, texinfmt.el,
1872 ;; the whitespace between columns can be increased by setting
1873 ;; `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1874 ;; there is at least one blank space between columns.
1876 ;; The Emacs Lisp formatter, texinfmt.el, ignores the following four
1877 ;; commands that are defined in texinfo.tex for printed output.
1879 ;; @multitableparskip,
1880 ;; @multitableparindent,
1881 ;; @multitablecolmargin,
1882 ;; @multitablelinespace.
1884 ;; How @multitable works.
1885 ;; =====================
1887 ;; `texinfo-multitable' reads the @multitable line and determines from it
1888 ;; how wide each column should be.
1890 ;; Also, it pushes this information, along with an identifying symbol,
1891 ;; onto the `texinfo-stack'. At the @end multitable command, the stack
1892 ;; is checked for its matching @multitable command, and then popped, or
1893 ;; else an error is signaled. Also, this command pushes the location of
1894 ;; the start of the table onto the stack.
1896 ;; `texinfo-end-multitable' checks the `texinfo-stack' that the @end
1897 ;; multitable truly is ending a corresponding beginning, and if it is,
1898 ;; pops the stack.
1900 ;; `texinfo-multitable-widths' is called by `texinfo-multitable'.
1901 ;; The function returns a list of the widths of each column in a
1902 ;; multi-column table, based on the information supplied by the arguments
1903 ;; to the @multitable command (by arguments, I mean the text on the rest
1904 ;; of the @multitable line, not the remainder of the multi-column table
1905 ;; environment).
1907 ;; `texinfo-multitable-item' formats a row within a multicolumn table.
1908 ;; This command is executed when texinfmt sees @item inside @multitable.
1909 ;; Cells in row are separated by `@tab's. Widths of cells are specified
1910 ;; by the arguments in the @multitable line. Cells are filled. All cells
1911 ;; are made to be the same height by padding their bottoms, as needed,
1912 ;; with blanks.
1914 ;; `texinfo-multitable-extract-row' is called by `texinfo-multitable-item'.
1915 ;; This function returns the text in a multitable row, as a string.
1916 ;; The start of a row is marked by an @item and the end of row is the
1917 ;; beginning of next @item or beginning of the @end multitable line.
1918 ;; Cells within a row are separated by @tab.
1920 ;; Note that @tab, the cell separators, are not treated as independent
1921 ;; Texinfo commands.
1923 (defvar texinfo-extra-inter-column-width 0
1924 "*Number of extra spaces between entries (columns) in @multitable.")
1926 (defvar texinfo-multitable-buffer-name "*multitable-temporary-buffer*")
1927 (defvar texinfo-multitable-rectangle-name "texinfo-multitable-temp-")
1929 ;; These commands are defined in texinfo.tex for printed output.
1930 (put 'multitableparskip 'texinfo-format 'texinfo-discard-line-with-args)
1931 (put 'multitableparindent 'texinfo-format 'texinfo-discard-line-with-args)
1932 (put 'multitablecolmargin 'texinfo-format 'texinfo-discard-line-with-args)
1933 (put 'multitablelinespace 'texinfo-format 'texinfo-discard-line-with-args)
1935 (put 'multitable 'texinfo-format 'texinfo-multitable)
1937 (defun texinfo-multitable ()
1938 "Produce multi-column tables.
1940 A multi-column table has this template:
1942 @multitable {A1} {A2} {A3}
1943 @item A1 @tab A2 @tab A3
1944 @item B1 @tab B2 @tab B3
1945 @item C1 @tab C2 @tab C3
1946 @end multitable
1948 where the width of the text in brackets specifies the width of the
1949 respective column.
1951 Or else:
1953 @multitable @columnfractions .25 .3 .45
1954 @item A1 @tab A2 @tab A3
1955 @item B1 @tab B2 @tab B3
1956 @end multitable
1958 where the fractions specify the width of each column as a percent
1959 of the current width of the text (i.e., of the `fill-column').
1961 Long lines of text are filled within columns.
1963 Using the Emacs Lisp formatter, texinfmt.el,
1964 the whitespace between columns can be increased by setting
1965 `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1966 there is at least one blank space between columns.
1968 The Emacs Lisp formatter, texinfmt.el, ignores the following four
1969 commands that are defined in texinfo.tex for printed output.
1971 @multitableparskip,
1972 @multitableparindent,
1973 @multitablecolmargin,
1974 @multitablelinespace."
1976 ;; This function pushes information onto the `texinfo-stack'.
1977 ;; A stack element consists of:
1978 ;; - type-of-command, i.e., multitable
1979 ;; - the information about column widths, and
1980 ;; - the position of texinfo-command-start.
1981 ;; e.g., ('multitable (1 2 3 4) 123)
1982 ;; The command line is then deleted.
1983 (texinfo-push-stack
1984 'multitable
1985 ;; push width information on stack
1986 (texinfo-multitable-widths))
1987 (texinfo-discard-line-with-args))
1989 (put 'multitable 'texinfo-end 'texinfo-end-multitable)
1990 (defun texinfo-end-multitable ()
1991 "Discard the @end multitable line and pop the stack of multitable."
1992 (texinfo-discard-command)
1993 (texinfo-pop-stack 'multitable))
1995 (defun texinfo-multitable-widths ()
1996 "Return list of widths of each column in a multi-column table."
1997 (let (texinfo-multitable-width-list)
1998 ;; Fractions format:
1999 ;; @multitable @columnfractions .25 .3 .45
2001 ;; Template format:
2002 ;; @multitable {Column 1 template} {Column 2} {Column 3 example}
2003 ;; Place point before first argument
2004 (skip-chars-forward " \t")
2005 (cond
2006 ;; Check for common misspelling
2007 ((looking-at "@columnfraction ")
2008 (error "In @multitable, @columnfractions misspelled"))
2009 ;; Case 1: @columnfractions .25 .3 .45
2010 ((looking-at "@columnfractions")
2011 (forward-word 1)
2012 (while (not (eolp))
2013 (push (truncate
2015 (* fill-column (read (get-buffer (current-buffer))))))
2016 texinfo-multitable-width-list)))
2018 ;; Case 2: {Column 1 template} {Column 2} {Column 3 example}
2019 ((looking-at "{")
2020 (let ((start-of-templates (point)))
2021 (while (not (eolp))
2022 (skip-chars-forward " \t")
2023 (let* ((start-of-template (1+ (point)))
2024 (end-of-template
2025 ;; forward-sexp works with braces in Texinfo mode
2026 (progn (forward-sexp 1) (1- (point)))))
2027 (push (- end-of-template start-of-template)
2028 texinfo-multitable-width-list)
2029 ;; Remove carriage return from within a template, if any.
2030 ;; This helps those those who want to use more than
2031 ;; one line's worth of words in @multitable line.
2032 (narrow-to-region start-of-template end-of-template)
2033 (goto-char (point-min))
2034 (while (search-forward "
2035 " nil t)
2036 (delete-char -1))
2037 (goto-char (point-max))
2038 (widen)
2039 (forward-char 1)))))
2041 ;; Case 3: Trouble
2043 (error
2044 "You probably need to specify column widths for @multitable correctly.")))
2045 ;; Check whether columns fit on page.
2046 (let ((desired-columns
2048 ;; between column spaces
2049 (length texinfo-multitable-width-list)
2050 ;; additional between column spaces, if any
2051 texinfo-extra-inter-column-width
2052 ;; sum of spaces for each entry
2053 (apply '+ texinfo-multitable-width-list))))
2054 (if (> desired-columns fill-column)
2055 (error
2056 "Multi-column table width, %d chars, is greater than page width, %d chars."
2057 desired-columns fill-column)))
2058 texinfo-multitable-width-list))
2060 ;; @item A1 @tab A2 @tab A3
2061 (defun texinfo-multitable-extract-row ()
2062 "Return multitable row, as a string.
2063 End of row is beginning of next @item or beginning of @end.
2064 Cells within rows are separated by @tab."
2065 (skip-chars-forward " \t")
2066 (let* ((start (point))
2067 (end (progn
2068 (re-search-forward "@item\\|@end")
2069 (match-beginning 0)))
2070 (row (progn (goto-char end)
2071 (skip-chars-backward " ")
2072 ;; remove whitespace at end of argument
2073 (delete-region (point) end)
2074 (buffer-substring-no-properties start (point)))))
2075 (delete-region texinfo-command-start end)
2076 row))
2078 (put 'multitable 'texinfo-item 'texinfo-multitable-item)
2079 (defun texinfo-multitable-item ()
2080 "Format a row within a multicolumn table.
2081 Cells in row are separated by @tab.
2082 Widths of cells are specified by the arguments in the @multitable line.
2083 All cells are made to be the same height.
2084 This command is executed when texinfmt sees @item inside @multitable."
2085 (let ((original-buffer (current-buffer))
2086 (table-widths (reverse (car (cdr (car texinfo-stack)))))
2087 (existing-fill-column fill-column)
2088 start
2090 (table-column 0)
2091 (table-entry-height 0)
2092 ;; unformatted row looks like: A1 @tab A2 @tab A3
2093 ;; extract-row command deletes the source line in the table.
2094 (unformated-row (texinfo-multitable-extract-row)))
2095 ;; Use a temporary buffer
2096 (set-buffer (get-buffer-create texinfo-multitable-buffer-name))
2097 (delete-region (point-min) (point-max))
2098 (insert unformated-row)
2099 (goto-char (point-min))
2100 ;; 1. Check for correct number of @tab in line.
2101 (let ((tab-number 1)) ; one @tab between two columns
2102 (while (search-forward "@tab" nil t)
2103 (setq tab-number (1+ tab-number)))
2104 (let ((needed-tabs (- (length table-widths) tab-number)))
2105 (when (> needed-tabs 0)
2106 (goto-char (point-min))
2107 (end-of-line)
2108 (while (> needed-tabs 0)
2109 (insert "@w{ }\n@tab")
2110 (setq needed-tabs (1- needed-tabs))
2111 (message
2112 "Added @tabs and empty spaces to a @multitable row")))))
2113 (goto-char (point-min))
2114 ;; 2. Format each cell, and copy to a rectangle
2115 ;; buffer looks like this: A1 @tab A2 @tab A3
2116 ;; Cell #1: format up to @tab
2117 ;; Cell #2: format up to @tab
2118 ;; Cell #3: format up to eob
2119 (while (not (eobp))
2120 (setq start (point))
2121 (setq end (save-excursion
2122 (if (search-forward "@tab" nil 'move)
2123 ;; Delete the @tab command, including the @-sign
2124 (delete-region
2125 (point)
2126 (progn (forward-word -1) (1- (point)))))
2127 (point)))
2128 ;; Set fill-column *wider* than needed to produce inter-column space
2129 (setq fill-column (+ 1
2130 texinfo-extra-inter-column-width
2131 (nth table-column table-widths)))
2132 (narrow-to-region start end)
2133 ;; Remove whitespace before and after entry.
2134 (skip-chars-forward " ")
2135 (delete-region (point) (save-excursion (beginning-of-line) (point)))
2136 (goto-char (point-max))
2137 (skip-chars-backward " ")
2138 (delete-region (point) (save-excursion (end-of-line) (point)))
2139 ;; Temporarily set texinfo-stack to nil so texinfo-format-scan
2140 ;; does not see an unterminated @multitable.
2141 (let (texinfo-stack) ; nil
2142 (texinfo-format-scan))
2143 (let (fill-prefix) ; no fill prefix
2144 (fill-region (point-min) (point-max)))
2145 (setq table-entry-height
2146 (max table-entry-height (count-lines (point-min) (point-max))))
2147 ;; 3. Move point to end of bottom line, and pad that line to fill column.
2148 (goto-char (point-min))
2149 (forward-line (1- table-entry-height))
2150 (let* ((beg (point)) ; beginning of line
2151 ;; add one more space for inter-column spacing
2152 (needed-whitespace
2154 (- fill-column
2156 (progn (end-of-line) (point)) ; end of existing line
2157 beg)))))
2158 (insert (make-string
2159 (if (> needed-whitespace 0) needed-whitespace 1)
2160 ? )))
2161 ;; now, put formatted cell into a rectangle
2162 (set (intern (concat texinfo-multitable-rectangle-name
2163 (int-to-string table-column)))
2164 (extract-rectangle (point-min) (point)))
2165 (delete-region (point-min) (point))
2166 (goto-char (point-max))
2167 (setq table-column (1+ table-column))
2168 (widen))
2169 ;; 4. Add extra lines to rectangles so all are of same height
2170 (let ((total-number-of-columns table-column)
2171 (column-number 0)
2172 here)
2173 (while (> table-column 0)
2174 (let ((this-rectangle (int-to-string table-column)))
2175 (while (< (length this-rectangle) table-entry-height)
2176 (setq this-rectangle (append this-rectangle '("")))))
2177 (setq table-column (1- table-column)))
2178 ;; 5. Insert formatted rectangles in original buffer
2179 (switch-to-buffer original-buffer)
2180 (open-line table-entry-height)
2181 (while (< column-number total-number-of-columns)
2182 (setq here (point))
2183 (insert-rectangle
2184 (eval (intern
2185 (concat texinfo-multitable-rectangle-name
2186 (int-to-string column-number)))))
2187 (goto-char here)
2188 (end-of-line)
2189 (setq column-number (1+ column-number))))
2190 (kill-buffer texinfo-multitable-buffer-name)
2191 (setq fill-column existing-fill-column)))
2194 ;;; @image
2195 ;; Use only the FILENAME argument to the command.
2196 ;; In Info, ignore the other arguments.
2198 (put 'image 'texinfo-format 'texinfo-format-image)
2199 (defun texinfo-format-image ()
2200 "Insert an image from an an file ending in .txt.
2201 Use only the FILENAME arg; for Info, ignore the other arguments to @image."
2202 (let ((args (texinfo-format-parse-args))
2203 filename)
2204 (when (null (nth 0 args))
2205 (error "Invalid image command"))
2206 (texinfo-discard-command)
2207 ;; makeinfo uses FILENAME.txt
2208 (setq filename (format "%s.txt" (nth 0 args)))
2209 (message "Reading included file: %s" filename)
2210 ;; verbatim for Info output
2211 (goto-char (+ (point) (cadr (insert-file-contents filename))))
2212 (message "Reading included file: %s...done" filename)))
2215 ;;; @ifinfo, @iftex, @tex, @ifhtml, @html, @ifplaintext, @ifxml, @xml
2216 ;; @ifnottex, @ifnotinfo, @ifnothtml, @ifnotplaintext, @ifnotxml
2218 (put 'ifinfo 'texinfo-format 'texinfo-discard-line)
2219 (put 'ifinfo 'texinfo-end 'texinfo-discard-command)
2221 (put 'iftex 'texinfo-format 'texinfo-format-iftex)
2222 (defun texinfo-format-iftex ()
2223 (delete-region texinfo-command-start
2224 (re-search-forward "@end iftex[ \t]*\n")))
2226 (put 'ifhtml 'texinfo-format 'texinfo-format-ifhtml)
2227 (defun texinfo-format-ifhtml ()
2228 (delete-region texinfo-command-start
2229 (re-search-forward "@end ifhtml[ \t]*\n")))
2231 (put 'ifplaintext 'texinfo-format 'texinfo-format-ifplaintext)
2232 (defun texinfo-format-ifplaintext ()
2233 (delete-region texinfo-command-start
2234 (re-search-forward "@end ifplaintext[ \t]*\n")))
2236 (put 'ifxml 'texinfo-format 'texinfo-format-ifxml)
2237 (defun texinfo-format-ifxml ()
2238 (delete-region texinfo-command-start
2239 (progn (re-search-forward "^@end ifxml[ \t]*\n")
2240 (point))))
2242 (put 'tex 'texinfo-format 'texinfo-format-tex)
2243 (defun texinfo-format-tex ()
2244 (delete-region texinfo-command-start
2245 (re-search-forward "@end tex[ \t]*\n")))
2247 (put 'html 'texinfo-format 'texinfo-format-html)
2248 (defun texinfo-format-html ()
2249 (delete-region texinfo-command-start
2250 (re-search-forward "@end html[ \t]*\n")))
2252 (put 'xml 'texinfo-format 'texinfo-format-xml)
2253 (defun texinfo-format-xml ()
2254 (delete-region texinfo-command-start
2255 (progn (re-search-forward "^@end xml[ \t]*\n")
2256 (point))))
2258 (put 'ifnotinfo 'texinfo-format 'texinfo-format-ifnotinfo)
2259 (defun texinfo-format-ifnotinfo ()
2260 (delete-region texinfo-command-start
2261 (re-search-forward "@end ifnotinfo[ \t]*\n")))
2263 (put 'ifnotplaintext 'texinfo-format 'texinfo-discard-line)
2264 (put 'ifnotplaintext 'texinfo-end 'texinfo-discard-command)
2266 (put 'ifnottex 'texinfo-format 'texinfo-discard-line)
2267 (put 'ifnottex 'texinfo-end 'texinfo-discard-command)
2269 (put 'ifnothtml 'texinfo-format 'texinfo-discard-line)
2270 (put 'ifnothtml 'texinfo-end 'texinfo-discard-command)
2272 (put 'ifnotxml 'texinfo-format 'texinfo-discard-line)
2273 (put 'ifnotxml 'texinfo-end 'texinfo-discard-command)
2276 ;;; @titlepage
2278 (put 'titlepage 'texinfo-format 'texinfo-format-titlepage)
2279 (defun texinfo-format-titlepage ()
2280 (delete-region texinfo-command-start
2281 (re-search-forward "@end titlepage[ \t]*\n")))
2283 (put 'endtitlepage 'texinfo-format 'texinfo-discard-line)
2285 ;; @titlespec an alternative titling command; ignored by Info
2287 (put 'titlespec 'texinfo-format 'texinfo-format-titlespec)
2288 (defun texinfo-format-titlespec ()
2289 (delete-region texinfo-command-start
2290 (re-search-forward "@end titlespec[ \t]*\n")))
2292 (put 'endtitlespec 'texinfo-format 'texinfo-discard-line)
2295 ;;; @today
2297 (put 'today 'texinfo-format 'texinfo-format-today)
2299 ;; Produces Day Month Year style of output. eg `1 Jan 1900'
2300 ;; The `@today{}' command requires a pair of braces, like `@dots{}'.
2301 (defun texinfo-format-today ()
2302 (texinfo-parse-arg-discard)
2303 (insert (format-time-string "%e %b %Y")))
2306 ;;; @timestamp{}
2307 ;; Produce `Day Month Year Hour:Min' style of output.
2308 ;; eg `1 Jan 1900 13:52'
2310 (put 'timestamp 'texinfo-format 'texinfo-format-timestamp)
2312 ;; The `@timestamp{}' command requires a pair of braces, like `@dots{}'.
2313 (defun texinfo-format-timestamp ()
2314 "Insert the current local time and date."
2315 (texinfo-parse-arg-discard)
2316 ;; For seconds and time zone, replace format string with "%e %b %Y %T %Z"
2317 (insert (format-time-string "%e %b %Y %R")))
2320 ;;; @ignore
2322 (put 'ignore 'texinfo-format 'texinfo-format-ignore)
2323 (defun texinfo-format-ignore ()
2324 (delete-region texinfo-command-start
2325 (re-search-forward "@end ignore[ \t]*\n")))
2327 (put 'endignore 'texinfo-format 'texinfo-discard-line)
2330 ;;; Define the Info enclosure command: @definfoenclose
2332 ;; A `@definfoenclose' command may be used to define a highlighting
2333 ;; command for Info, but not for TeX. A command defined using
2334 ;; `@definfoenclose' marks text by enclosing it in strings that precede
2335 ;; and follow the text.
2337 ;; Presumably, if you define a command with `@definfoenclose` for Info,
2338 ;; you will also define the same command in the TeX definitions file,
2339 ;; `texinfo.tex' in a manner appropriate for typesetting.
2341 ;; Write a `@definfoenclose' command on a line and follow it with three
2342 ;; arguments separated by commas (commas are used as separators in an
2343 ;; `@node' line in the same way). The first argument to
2344 ;; `@definfoenclose' is the @-command name \(without the `@'\); the
2345 ;; second argument is the Info start delimiter string; and the third
2346 ;; argument is the Info end delimiter string. The latter two arguments
2347 ;; enclose the highlighted text in the Info file. A delimiter string
2348 ;; may contain spaces. Neither the start nor end delimiter is
2349 ;; required. However, if you do not provide a start delimiter, you
2350 ;; must follow the command name with two commas in a row; otherwise,
2351 ;; the Info formatting commands will misinterpret the end delimiter
2352 ;; string as a start delimiter string.
2354 ;; If you do a @definfoenclose{} on the name of a pre-defined macro (such
2355 ;; as @emph{}, @strong{}, @tt{}, or @i{}) the enclosure definition will
2356 ;; override the built-in definition.
2358 ;; An enclosure command defined this way takes one argument in braces.
2360 ;; For example, you can write:
2362 ;; @ifinfo
2363 ;; @definfoenclose phoo, //, \\
2364 ;; @end ifinfo
2366 ;; near the beginning of a Texinfo file at the beginning of the lines
2367 ;; to define `@phoo' as an Info formatting command that inserts `//'
2368 ;; before and `\\' after the argument to `@phoo'. You can then write
2369 ;; `@phoo{bar}' wherever you want `//bar\\' highlighted in Info.
2371 ;; Also, for TeX formatting, you could write
2373 ;; @iftex
2374 ;; @global@let@phoo=@i
2375 ;; @end iftex
2377 ;; to define `@phoo' as a command that causes TeX to typeset
2378 ;; the argument to `@phoo' in italics.
2380 ;; Note that each definition applies to its own formatter: one for TeX,
2381 ;; the other for texinfo-format-buffer or texinfo-format-region.
2383 ;; Here is another example: write
2385 ;; @definfoenclose headword, , :
2387 ;; near the beginning of the file, to define `@headword' as an Info
2388 ;; formatting command that inserts nothing before and a colon after the
2389 ;; argument to `@headword'.
2391 (put 'definfoenclose 'texinfo-format 'texinfo-define-info-enclosure)
2392 (defun texinfo-define-info-enclosure ()
2393 (let* ((args (texinfo-format-parse-line-args))
2394 (command-name (nth 0 args))
2395 (beginning-delimiter (or (nth 1 args) ""))
2396 (end-delimiter (or (nth 2 args) "")))
2397 (texinfo-discard-command)
2398 (push (list command-name
2399 (list
2400 beginning-delimiter
2401 end-delimiter))
2402 texinfo-enclosure-list)))
2405 ;;; @alias
2407 (put 'alias 'texinfo-format 'texinfo-alias)
2408 (defun texinfo-alias ()
2409 (let ((start (1- (point)))
2410 args)
2411 (skip-chars-forward " ")
2412 (save-excursion (end-of-line) (setq texinfo-command-end (point)))
2413 (if (not (looking-at "\\([^=]+\\)=\\(.*\\)"))
2414 (error "Invalid alias command")
2415 (push (cons
2416 (match-string-no-properties 1)
2417 (match-string-no-properties 2))
2418 texinfo-alias-list)
2419 (texinfo-discard-command))
2424 ;;; @var, @code and the like
2426 (put 'var 'texinfo-format 'texinfo-format-var)
2427 ;; @sc a small caps font for TeX; formatted as `var' in Info
2428 (put 'sc 'texinfo-format 'texinfo-format-var)
2429 ;; @acronym for abbreviations in all caps, such as `NASA'.
2430 ;; Convert all letters to uppercase if they are not already.
2431 (put 'acronym 'texinfo-format 'texinfo-format-var)
2432 (defun texinfo-format-var ()
2433 (let ((arg (texinfo-parse-expanded-arg)))
2434 (texinfo-discard-command)
2435 (insert (upcase arg))))
2437 (put 'cite 'texinfo-format 'texinfo-format-code)
2438 (put 'code 'texinfo-format 'texinfo-format-code)
2439 ;; @command (for command names)
2440 (put 'command 'texinfo-format 'texinfo-format-code)
2441 ;; @env (for environment variables)
2442 (put 'env 'texinfo-format 'texinfo-format-code)
2443 (put 'file 'texinfo-format 'texinfo-format-code)
2444 (put 'samp 'texinfo-format 'texinfo-format-code)
2445 (put 'url 'texinfo-format 'texinfo-format-code)
2446 (defun texinfo-format-code ()
2447 (insert "`" (texinfo-parse-arg-discard) "'")
2448 (goto-char texinfo-command-start))
2450 ;; @option (for command-line options) must be different from @code
2451 ;; because of its special formatting in @table; namely that it does
2452 ;; not lead to inserted ` ... ' in a table, but does elsewhere.
2453 (put 'option 'texinfo-format 'texinfo-format-option)
2454 (defun texinfo-format-option ()
2455 "Insert ` ... ' around arg unless inside a table; in that case, no quotes."
2456 ;; `looking-at-backward' not available in v. 18.57, 20.2
2457 (if (not (search-backward "\b" ; searched-for character is a control-H
2458 (save-excursion (beginning-of-line) (point))
2460 (insert "`" (texinfo-parse-arg-discard) "'")
2461 (insert (texinfo-parse-arg-discard)))
2462 (goto-char texinfo-command-start))
2464 (put 'emph 'texinfo-format 'texinfo-format-emph)
2465 (put 'strong 'texinfo-format 'texinfo-format-emph)
2466 (defun texinfo-format-emph ()
2467 (insert "*" (texinfo-parse-arg-discard) "*")
2468 (goto-char texinfo-command-start))
2470 (put 'dfn 'texinfo-format 'texinfo-format-defn)
2471 (put 'defn 'texinfo-format 'texinfo-format-defn)
2472 (defun texinfo-format-defn ()
2473 (insert "\"" (texinfo-parse-arg-discard) "\"")
2474 (goto-char texinfo-command-start))
2476 (put 'email 'texinfo-format 'texinfo-format-email)
2477 (defun texinfo-format-email ()
2478 "Format email address and optional following full name.
2479 Insert full name, if present, followed by email address
2480 surrounded by in angle brackets."
2481 (let ((args (texinfo-format-parse-args)))
2482 (texinfo-discard-command)
2483 ;; if full-name
2484 (if (nth 1 args)
2485 (insert (nth 1 args) " "))
2486 (insert "<" (nth 0 args) ">")))
2488 (put 'key 'texinfo-format 'texinfo-format-key)
2489 ;; I've decided not want to have angle brackets around these -- rms.
2490 (defun texinfo-format-key ()
2491 (insert (texinfo-parse-arg-discard))
2492 (goto-char texinfo-command-start))
2494 ;; @verb{<char>TEXT<char>} (in `makeinfo' 4.1 and later)
2495 (put 'verb 'texinfo-format 'texinfo-format-verb)
2496 (defun texinfo-format-verb ()
2497 "Format text between non-quoted unique delimiter characters verbatim.
2498 Enclose the verbatim text, including the delimiters, in braces. Print
2499 text exactly as written (but not the delimiters) in a fixed-width.
2501 For example, @verb\{|@|\} results in @ and
2502 @verb\{+@'e?`!`+} results in @'e?`!`."
2504 (let ((delimiter (buffer-substring-no-properties
2505 (1+ texinfo-command-end) (+ 2 texinfo-command-end))))
2506 (unless (looking-at "{")
2507 (error "Not found: @verb start brace"))
2508 (delete-region texinfo-command-start (+ 2 texinfo-command-end))
2509 (search-forward delimiter))
2510 (delete-char -1)
2511 (unless (looking-at "}")
2512 (error "Not found: @verb end brace"))
2513 (delete-char 1))
2515 ;; as of 2002 Dec 10
2516 ;; see (texinfo)Block Enclosing Commands
2517 ;; need: @verbatim
2519 ;; as of 2002 Dec 10
2520 ;; see (texinfo)verbatiminclude
2521 ;; need: @verbatiminclude FILENAME
2523 (put 'bullet 'texinfo-format 'texinfo-format-bullet)
2524 (defun texinfo-format-bullet ()
2525 "Insert an asterisk.
2526 If used within a line, follow `@bullet' with braces."
2527 (texinfo-optional-braces-discard)
2528 (insert "*"))
2531 ;;; @kbd
2533 ;; Inside of @example ... @end example and similar environments,
2534 ;; @kbd does nothing; but outside of such environments, it places
2535 ;; single quotation marks around its argument.
2537 (defvar texinfo-format-kbd-regexp
2538 (concat
2539 "^@"
2540 "\\("
2541 "display\\|"
2542 "example\\|"
2543 "smallexample\\|"
2544 "lisp\\|"
2545 "smalllisp"
2546 "\\)")
2547 "Regexp matching environments in which @kbd does not put `...' around arg.")
2549 (defvar texinfo-format-kbd-end-regexp
2550 (concat
2551 "^@end "
2552 "\\("
2553 "display\\|"
2554 "example\\|"
2555 "smallexample\\|"
2556 "lisp\\|"
2557 "smalllisp"
2558 "\\)")
2559 "Regexp specifying end of environments in which @kbd does not put `...'
2560 around argument. (See `texinfo-format-kbd-regexp')")
2562 (put 'kbd 'texinfo-format 'texinfo-format-kbd)
2563 (defun texinfo-format-kbd ()
2564 "Place single quote marks around arg, except in @example and similar."
2565 ;; Search forward for @end example closer than an @example.
2566 ;; Can stop search at nearest @node or texinfo-section-types-regexp
2567 (let* ((stop
2568 (save-excursion
2569 (re-search-forward
2570 (concat "^@node\\|\\(" texinfo-section-types-regexp "\\)")
2572 'move-to-end) ; if necessary, return point at end of buffer
2573 (point)))
2574 (example-location
2575 (save-excursion
2576 (re-search-forward texinfo-format-kbd-regexp stop 'move-to-end)
2577 (point)))
2578 (end-example-location
2579 (save-excursion
2580 (re-search-forward texinfo-format-kbd-end-regexp stop 'move-to-end)
2581 (point))))
2582 ;; If inside @example, @end example will be closer than @example
2583 ;; or end of search i.e., end-example-location less than example-location
2584 (if (>= end-example-location example-location)
2585 ;; outside an @example or equivalent
2586 (insert "`" (texinfo-parse-arg-discard) "'")
2587 ;; else, in @example; do not surround with `...'
2588 (insert (texinfo-parse-arg-discard)))
2589 (goto-char texinfo-command-start)))
2592 ;;; @example, @lisp, @quotation, @display, @smalllisp, @smallexample,
2593 ;; @smalldisplay
2595 (put 'display 'texinfo-format 'texinfo-format-example)
2596 (put 'smalldisplay 'texinfo-format 'texinfo-format-example)
2597 (put 'example 'texinfo-format 'texinfo-format-example)
2598 (put 'lisp 'texinfo-format 'texinfo-format-example)
2599 (put 'quotation 'texinfo-format 'texinfo-format-example)
2600 (put 'smallexample 'texinfo-format 'texinfo-format-example)
2601 (put 'smalllisp 'texinfo-format 'texinfo-format-example)
2602 (defun texinfo-format-example ()
2603 (texinfo-push-stack 'example nil)
2604 (setq fill-column (- fill-column 5))
2605 (texinfo-discard-line))
2607 (put 'example 'texinfo-end 'texinfo-end-example)
2608 (put 'display 'texinfo-end 'texinfo-end-example)
2609 (put 'smalldisplay 'texinfo-end 'texinfo-end-example)
2610 (put 'lisp 'texinfo-end 'texinfo-end-example)
2611 (put 'quotation 'texinfo-end 'texinfo-end-example)
2612 (put 'smallexample 'texinfo-end 'texinfo-end-example)
2613 (put 'smalllisp 'texinfo-end 'texinfo-end-example)
2614 (defun texinfo-end-example ()
2615 (setq fill-column (+ fill-column 5))
2616 (texinfo-discard-command)
2617 (let ((stacktop
2618 (texinfo-pop-stack 'example)))
2619 (texinfo-do-itemize (nth 1 stacktop))))
2621 (put 'exdent 'texinfo-format 'texinfo-format-exdent)
2622 (defun texinfo-format-exdent ()
2623 (texinfo-discard-command)
2624 (delete-region (point)
2625 (progn
2626 (skip-chars-forward " ")
2627 (point)))
2628 (insert ?\b)
2629 ;; Cancel out the deletion that texinfo-do-itemize
2630 ;; is going to do at the end of this line.
2631 (save-excursion
2632 (end-of-line)
2633 (insert "\n ")))
2636 ;; @direntry and @dircategory
2638 (put 'direntry 'texinfo-format 'texinfo-format-direntry)
2639 (defun texinfo-format-direntry ()
2640 (texinfo-push-stack 'direntry nil)
2641 (texinfo-discard-line)
2642 (insert "START-INFO-DIR-ENTRY\n"))
2644 (put 'direntry 'texinfo-end 'texinfo-end-direntry)
2645 (defun texinfo-end-direntry ()
2646 (texinfo-discard-command)
2647 (insert "END-INFO-DIR-ENTRY\n\n")
2648 (texinfo-pop-stack 'direntry))
2650 (put 'dircategory 'texinfo-format 'texinfo-format-dircategory)
2651 (defun texinfo-format-dircategory ()
2652 (let ((str (texinfo-parse-arg-discard)))
2653 (delete-region (point)
2654 (progn
2655 (skip-chars-forward " ")
2656 (point)))
2657 (insert "INFO-DIR-SECTION " str "\n")))
2659 ;;; @cartouche
2661 ;; The @cartouche command is a noop in Info; in a printed manual,
2662 ;; it makes a box with rounded corners.
2664 (put 'cartouche 'texinfo-format 'texinfo-discard-line)
2665 (put 'cartouche 'texinfo-end 'texinfo-discard-command)
2668 ;;; @flushleft and @format
2670 ;; The @flushleft command left justifies every line but leaves the
2671 ;; right end ragged. As far as Info is concerned, @flushleft is a
2672 ;; `do-nothing' command
2674 ;; The @format command is similar to @example except that it does not
2675 ;; indent; this means that in Info, @format is similar to @flushleft.
2677 (put 'format 'texinfo-format 'texinfo-format-flushleft)
2678 (put 'smallformat 'texinfo-format 'texinfo-format-flushleft)
2679 (put 'flushleft 'texinfo-format 'texinfo-format-flushleft)
2680 (defun texinfo-format-flushleft ()
2681 (texinfo-discard-line))
2683 (put 'format 'texinfo-end 'texinfo-end-flushleft)
2684 (put 'smallformat 'texinfo-end 'texinfo-end-flushleft)
2685 (put 'flushleft 'texinfo-end 'texinfo-end-flushleft)
2686 (defun texinfo-end-flushleft ()
2687 (texinfo-discard-command))
2690 ;;; @flushright
2692 ;; The @flushright command right justifies every line but leaves the
2693 ;; left end ragged. Spaces and tabs at the right ends of lines are
2694 ;; removed so that visible text lines up on the right side.
2696 (put 'flushright 'texinfo-format 'texinfo-format-flushright)
2697 (defun texinfo-format-flushright ()
2698 (texinfo-push-stack 'flushright nil)
2699 (texinfo-discard-line))
2701 (put 'flushright 'texinfo-end 'texinfo-end-flushright)
2702 (defun texinfo-end-flushright ()
2703 (texinfo-discard-command)
2705 (let ((stacktop
2706 (texinfo-pop-stack 'flushright)))
2708 (texinfo-do-flushright (nth 1 stacktop))))
2710 (defun texinfo-do-flushright (from)
2711 (save-excursion
2712 (while (progn (forward-line -1)
2713 (>= (point) from))
2715 (beginning-of-line)
2716 (insert
2717 (make-string
2718 (- fill-column
2719 (save-excursion
2720 (end-of-line)
2721 (skip-chars-backward " \t")
2722 (delete-region (point) (progn (end-of-line) (point)))
2723 (current-column)))
2724 ? )))))
2727 ;;; @ctrl, @TeX, @copyright, @minus, @dots, @enddots, @pounds
2729 (put 'ctrl 'texinfo-format 'texinfo-format-ctrl)
2730 (defun texinfo-format-ctrl ()
2731 (let ((str (texinfo-parse-arg-discard)))
2732 (insert (logand 31 (aref str 0)))))
2734 (put 'TeX 'texinfo-format 'texinfo-format-TeX)
2735 (defun texinfo-format-TeX ()
2736 (texinfo-parse-arg-discard)
2737 (insert "TeX"))
2739 (put 'copyright 'texinfo-format 'texinfo-format-copyright)
2740 (defun texinfo-format-copyright ()
2741 (texinfo-parse-arg-discard)
2742 (insert "(C)"))
2744 (put 'minus 'texinfo-format 'texinfo-format-minus)
2745 (defun texinfo-format-minus ()
2746 "Insert a minus sign.
2747 If used within a line, follow `@minus' with braces."
2748 (texinfo-optional-braces-discard)
2749 (insert "-"))
2751 (put 'dots 'texinfo-format 'texinfo-format-dots)
2752 (defun texinfo-format-dots ()
2753 (texinfo-parse-arg-discard)
2754 (insert "..."))
2756 (put 'enddots 'texinfo-format 'texinfo-format-enddots)
2757 (defun texinfo-format-enddots ()
2758 (texinfo-parse-arg-discard)
2759 (insert "...."))
2761 (put 'pounds 'texinfo-format 'texinfo-format-pounds)
2762 (defun texinfo-format-pounds ()
2763 (texinfo-parse-arg-discard)
2764 (insert "#"))
2767 ;;; Refilling and indenting: @refill, @paragraphindent, @noindent
2769 ;; Indent only those paragraphs that are refilled as a result of an
2770 ;; @refill command.
2772 ;; * If the value is `asis', do not change the existing indentation at
2773 ;; the starts of paragraphs.
2775 ;; * If the value zero, delete any existing indentation.
2777 ;; * If the value is greater than zero, indent each paragraph by that
2778 ;; number of spaces.
2780 ;; But do not refill paragraphs with an @refill command that are
2781 ;; preceded by @noindent or are part of a table, list, or deffn.
2783 (defvar texinfo-paragraph-indent "asis"
2784 "Number of spaces for @refill to indent a paragraph; else to leave as is.")
2786 (put 'paragraphindent 'texinfo-format 'texinfo-paragraphindent)
2788 (defun texinfo-paragraphindent ()
2789 "Specify the number of spaces for @refill to indent a paragraph.
2790 Default is to leave the number of spaces as is."
2791 (let ((arg (texinfo-parse-arg-discard)))
2792 (if (string= "asis" arg)
2793 (setq texinfo-paragraph-indent "asis")
2794 (setq texinfo-paragraph-indent (string-to-number arg)))))
2796 (put 'refill 'texinfo-format 'texinfo-format-refill)
2797 (defun texinfo-format-refill ()
2798 "Refill paragraph. Also, indent first line as set by @paragraphindent.
2799 Default is to leave paragraph indentation as is."
2800 (texinfo-discard-command)
2801 (let ((position (point-marker)))
2802 (forward-paragraph -1)
2803 (if (looking-at "[ \t\n]*$") (forward-line 1))
2804 ;; Do not indent if an entry in a list, table, or deffn,
2805 ;; or if paragraph is preceded by @noindent.
2806 ;; Otherwise, indent
2807 (cond
2808 ;; delete a @noindent line and do not indent paragraph
2809 ((save-excursion (forward-line -1)
2810 (looking-at "^@noindent"))
2811 (forward-line -1)
2812 (delete-region (point) (progn (forward-line 1) (point))))
2813 ;; do nothing if "asis"
2814 ((equal texinfo-paragraph-indent "asis"))
2815 ;; do no indenting in list, etc.
2816 ((> texinfo-stack-depth 0))
2817 ;; otherwise delete existing whitespace and indent
2819 (delete-region (point) (progn (skip-chars-forward " \t") (point)))
2820 (insert (make-string texinfo-paragraph-indent ? ))))
2821 (forward-paragraph 1)
2822 (forward-line -1)
2823 (end-of-line)
2824 ;; Do not fill a section title line with asterisks, hyphens, etc. that
2825 ;; are used to underline it. This could occur if the line following
2826 ;; the underlining is not an index entry and has text within it.
2827 (let* ((previous-paragraph-separate paragraph-separate)
2828 (paragraph-separate
2829 (concat paragraph-separate "\\|[-=.]+\\|\\*\\*+"))
2830 (previous-paragraph-start paragraph-start)
2831 (paragraph-start
2832 (concat paragraph-start "\\|[-=.]+\\|\\*\\*+")))
2833 (unwind-protect
2834 (fill-paragraph nil)
2835 (setq paragraph-separate previous-paragraph-separate)
2836 (setq paragraph-start previous-paragraph-start)))
2837 (goto-char position)))
2839 (put 'noindent 'texinfo-format 'texinfo-noindent)
2840 (defun texinfo-noindent ()
2841 (save-excursion
2842 (forward-paragraph 1)
2843 (if (search-backward "@refill"
2844 (save-excursion (forward-line -1) (point)) t)
2845 () ; leave @noindent command so @refill command knows not to indent
2846 ;; else
2847 (texinfo-discard-line))))
2850 ;;; Index generation
2852 (put 'vindex 'texinfo-format 'texinfo-format-vindex)
2853 (defun texinfo-format-vindex ()
2854 (texinfo-index 'texinfo-vindex))
2856 (put 'cindex 'texinfo-format 'texinfo-format-cindex)
2857 (defun texinfo-format-cindex ()
2858 (texinfo-index 'texinfo-cindex))
2860 (put 'findex 'texinfo-format 'texinfo-format-findex)
2861 (defun texinfo-format-findex ()
2862 (texinfo-index 'texinfo-findex))
2864 (put 'pindex 'texinfo-format 'texinfo-format-pindex)
2865 (defun texinfo-format-pindex ()
2866 (texinfo-index 'texinfo-pindex))
2868 (put 'tindex 'texinfo-format 'texinfo-format-tindex)
2869 (defun texinfo-format-tindex ()
2870 (texinfo-index 'texinfo-tindex))
2872 (put 'kindex 'texinfo-format 'texinfo-format-kindex)
2873 (defun texinfo-format-kindex ()
2874 (texinfo-index 'texinfo-kindex))
2876 (defun texinfo-index (indexvar)
2877 (let ((arg (texinfo-parse-expanded-arg)))
2878 (texinfo-discard-command)
2879 (set indexvar
2880 (cons (list arg
2881 texinfo-last-node
2882 ;; Region formatting may not provide last node position.
2883 (if texinfo-last-node-pos
2884 (1+ (count-lines texinfo-last-node-pos (point)))
2886 (symbol-value indexvar)))))
2888 (defvar texinfo-indexvar-alist
2889 '(("cp" . texinfo-cindex)
2890 ("fn" . texinfo-findex)
2891 ("vr" . texinfo-vindex)
2892 ("tp" . texinfo-tindex)
2893 ("pg" . texinfo-pindex)
2894 ("ky" . texinfo-kindex)))
2897 ;;; @defindex @defcodeindex
2898 (put 'defindex 'texinfo-format 'texinfo-format-defindex)
2899 (put 'defcodeindex 'texinfo-format 'texinfo-format-defindex)
2901 (defun texinfo-format-defindex ()
2902 (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa'
2903 (indexing-command (intern (concat index-name "index")))
2904 (index-formatting-command ; eg: `texinfo-format-aaindex'
2905 (intern (concat "texinfo-format-" index-name "index")))
2906 (index-alist-name ; eg: `texinfo-aaindex'
2907 (intern (concat "texinfo-" index-name "index"))))
2909 (set index-alist-name nil)
2911 (put indexing-command ; eg, aaindex
2912 'texinfo-format
2913 index-formatting-command) ; eg, texinfo-format-aaindex
2915 ;; eg: "aa" . texinfo-aaindex
2916 (or (assoc index-name texinfo-indexvar-alist)
2917 (push (cons index-name
2918 index-alist-name)
2919 texinfo-indexvar-alist))
2921 (fset index-formatting-command
2922 (list 'lambda 'nil
2923 (list 'texinfo-index
2924 (list 'quote index-alist-name))))))
2927 ;;; @synindex @syncodeindex
2929 (put 'synindex 'texinfo-format 'texinfo-format-synindex)
2930 (put 'syncodeindex 'texinfo-format 'texinfo-format-synindex)
2932 (defun texinfo-format-synindex ()
2933 (let* ((args (texinfo-parse-arg-discard))
2934 (second (cdr (read-from-string args)))
2935 (joiner (symbol-name (car (read-from-string args))))
2936 (joined (symbol-name (car (read-from-string args second)))))
2938 (if (assoc joiner texinfo-short-index-cmds-alist)
2939 (put
2940 (cdr (assoc joiner texinfo-short-index-cmds-alist))
2941 'texinfo-format
2942 (or (cdr (assoc joined texinfo-short-index-format-cmds-alist))
2943 (intern (concat "texinfo-format-" joined "index"))))
2944 (put
2945 (intern (concat joiner "index"))
2946 'texinfo-format
2947 (or (cdr(assoc joined texinfo-short-index-format-cmds-alist))
2948 (intern (concat "texinfo-format-" joined "index")))))))
2950 (defconst texinfo-short-index-cmds-alist
2951 '(("cp" . cindex)
2952 ("fn" . findex)
2953 ("vr" . vindex)
2954 ("tp" . tindex)
2955 ("pg" . pindex)
2956 ("ky" . kindex)))
2958 (defconst texinfo-short-index-format-cmds-alist
2959 '(("cp" . texinfo-format-cindex)
2960 ("fn" . texinfo-format-findex)
2961 ("vr" . texinfo-format-vindex)
2962 ("tp" . texinfo-format-tindex)
2963 ("pg" . texinfo-format-pindex)
2964 ("ky" . texinfo-format-kindex)))
2967 ;;; @printindex
2969 (put 'printindex 'texinfo-format 'texinfo-format-printindex)
2971 (defun texinfo-format-printindex ()
2972 (let* ((arg (texinfo-parse-arg-discard))
2973 (fmt (cdr (assoc arg texinfo-short-index-format-cmds-alist)))
2974 (index-list (delq nil (mapcar (lambda (e)
2975 (and (eq fmt (get (cdr e) 'texinfo-format))
2976 (cdr (assoc (car e) texinfo-indexvar-alist))))
2977 texinfo-short-index-cmds-alist)))
2978 (indexelts (apply #'append nil (mapcar #'symbol-value index-list)))
2979 opoint)
2980 (insert "\n* Menu:\n\n")
2981 (setq opoint (point))
2982 (texinfo-print-index nil indexelts)
2983 (shell-command-on-region opoint (point) "sort -fd" 1)))
2985 (defun texinfo-print-index (file indexelts)
2986 (while indexelts
2987 (if (stringp (car (car indexelts)))
2988 (progn
2989 (insert "* " (car (car indexelts)) ": " )
2990 (indent-to 32)
2991 (insert
2992 (if file (concat "(" file ")") "")
2993 (nth 1 (car indexelts)) ".")
2994 (indent-to 54)
2995 (insert
2996 (if (nth 2 (car indexelts))
2997 (format " (line %3d)" (1+ (nth 2 (car indexelts))))
2999 "\n"))
3000 ;; index entries from @include'd file
3001 (texinfo-print-index (nth 1 (car indexelts))
3002 (nth 2 (car indexelts))))
3003 (setq indexelts (cdr indexelts))))
3006 ;;; Glyphs: @equiv, @error, etc
3008 ;; @equiv to show that two expressions are equivalent
3009 ;; @error to show an error message
3010 ;; @expansion to show what a macro expands to
3011 ;; @point to show the location of point in an example
3012 ;; @print to show what an evaluated expression prints
3013 ;; @result to indicate the value returned by an expression
3015 (put 'equiv 'texinfo-format 'texinfo-format-equiv)
3016 (defun texinfo-format-equiv ()
3017 (texinfo-parse-arg-discard)
3018 (insert "=="))
3020 (put 'error 'texinfo-format 'texinfo-format-error)
3021 (defun texinfo-format-error ()
3022 (texinfo-parse-arg-discard)
3023 (insert "error-->"))
3025 (put 'expansion 'texinfo-format 'texinfo-format-expansion)
3026 (defun texinfo-format-expansion ()
3027 (texinfo-parse-arg-discard)
3028 (insert "==>"))
3030 (put 'point 'texinfo-format 'texinfo-format-point)
3031 (defun texinfo-format-point ()
3032 (texinfo-parse-arg-discard)
3033 (insert "-!-"))
3035 (put 'print 'texinfo-format 'texinfo-format-print)
3036 (defun texinfo-format-print ()
3037 (texinfo-parse-arg-discard)
3038 (insert "-|"))
3040 (put 'result 'texinfo-format 'texinfo-format-result)
3041 (defun texinfo-format-result ()
3042 (texinfo-parse-arg-discard)
3043 (insert "=>"))
3046 ;;; Accent commands
3048 ;; Info presumes a plain ASCII output, so the accented characters do
3049 ;; not look as they would if typeset, or output with a different
3050 ;; character set.
3052 ;; See the `texinfo-accent-commands' variable
3053 ;; in the section for `texinfo-append-refill'.
3054 ;; Also, see the defun for `texinfo-format-scan'
3055 ;; for single-character accent commands.
3057 ;; Command Info output Name
3059 ;; These do not have braces:
3060 ;; @^ ==> ^ circumflex accent
3061 ;; @` ==> ` grave accent
3062 ;; @' ==> ' acute accent
3063 ;; @" ==> " umlaut accent
3064 ;; @= ==> = overbar accent
3065 ;; @~ ==> ~ tilde accent
3067 ;; These have braces, but take no argument:
3068 ;; @OE{} ==> OE French-OE-ligature
3069 ;; @oe{} ==> oe
3070 ;; @AA{} ==> AA Scandinavian-A-with-circle
3071 ;; @aa{} ==> aa
3072 ;; @AE{} ==> AE Latin-Scandinavian-AE
3073 ;; @ae{} ==> ae
3074 ;; @ss{} ==> ss German-sharp-S
3076 ;; @questiondown{} ==> ? upside-down-question-mark
3077 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
3078 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
3079 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
3080 ;; @O{} ==> O/ Scandinavian O-with-slash
3081 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
3083 ;; These have braces, and take an argument:
3084 ;; @,{c} ==> c, cedilla accent
3085 ;; @dotaccent{o} ==> .o overdot-accent
3086 ;; @ubaraccent{o} ==> _o underbar-accent
3087 ;; @udotaccent{o} ==> o-. underdot-accent
3088 ;; @H{o} ==> ""o long Hungarian umlaut
3089 ;; @ringaccent{o} ==> *o ring accent
3090 ;; @tieaccent{oo} ==> [oo tie after accent
3091 ;; @u{o} ==> (o breve accent
3092 ;; @v{o} ==> <o hacek accent
3093 ;; @dotless{i} ==> i dotless i and dotless j
3095 ;; ==========
3097 ;; Note: The defun texinfo-format-scan
3098 ;; looks at "[@{}^'`\",=~ *?!-]"
3099 ;; In the case of @*, a line break is inserted;
3100 ;; in the other cases, the characters are simply quoted and the @ is deleted.
3101 ;; Thus, `texinfo-format-scan' handles the following
3102 ;; single-character accent commands: @^ @` @' @" @, @- @= @~
3104 ;; @^ ==> ^ circumflex accent
3105 ;; (put '^ 'texinfo-format 'texinfo-format-circumflex-accent)
3106 ;; (defun texinfo-format-circumflex-accent ()
3107 ;; (texinfo-discard-command)
3108 ;; (insert "^"))
3110 ;; @` ==> ` grave accent
3111 ;; (put '\` 'texinfo-format 'texinfo-format-grave-accent)
3112 ;; (defun texinfo-format-grave-accent ()
3113 ;; (texinfo-discard-command)
3114 ;; (insert "\`"))
3116 ;; @' ==> ' acute accent
3117 ;; (put '\' 'texinfo-format 'texinfo-format-acute-accent)
3118 ;; (defun texinfo-format-acute-accent ()
3119 ;; (texinfo-discard-command)
3120 ;; (insert "'"))
3122 ;; @" ==> " umlaut accent
3123 ;; (put '\" 'texinfo-format 'texinfo-format-umlaut-accent)
3124 ;; (defun texinfo-format-umlaut-accent ()
3125 ;; (texinfo-discard-command)
3126 ;; (insert "\""))
3128 ;; @= ==> = overbar accent
3129 ;; (put '= 'texinfo-format 'texinfo-format-overbar-accent)
3130 ;; (defun texinfo-format-overbar-accent ()
3131 ;; (texinfo-discard-command)
3132 ;; (insert "="))
3134 ;; @~ ==> ~ tilde accent
3135 ;; (put '~ 'texinfo-format 'texinfo-format-tilde-accent)
3136 ;; (defun texinfo-format-tilde-accent ()
3137 ;; (texinfo-discard-command)
3138 ;; (insert "~"))
3140 ;; @OE{} ==> OE French-OE-ligature
3141 (put 'OE 'texinfo-format 'texinfo-format-French-OE-ligature)
3142 (defun texinfo-format-French-OE-ligature ()
3143 (insert "OE" (texinfo-parse-arg-discard))
3144 (goto-char texinfo-command-start))
3146 ;; @oe{} ==> oe
3147 (put 'oe 'texinfo-format 'texinfo-format-French-oe-ligature)
3148 (defun texinfo-format-French-oe-ligature () ; lower case
3149 (insert "oe" (texinfo-parse-arg-discard))
3150 (goto-char texinfo-command-start))
3152 ;; @AA{} ==> AA Scandinavian-A-with-circle
3153 (put 'AA 'texinfo-format 'texinfo-format-Scandinavian-A-with-circle)
3154 (defun texinfo-format-Scandinavian-A-with-circle ()
3155 (insert "AA" (texinfo-parse-arg-discard))
3156 (goto-char texinfo-command-start))
3158 ;; @aa{} ==> aa
3159 (put 'aa 'texinfo-format 'texinfo-format-Scandinavian-a-with-circle)
3160 (defun texinfo-format-Scandinavian-a-with-circle () ; lower case
3161 (insert "aa" (texinfo-parse-arg-discard))
3162 (goto-char texinfo-command-start))
3164 ;; @AE{} ==> AE Latin-Scandinavian-AE
3165 (put 'AE 'texinfo-format 'texinfo-format-Latin-Scandinavian-AE)
3166 (defun texinfo-format-Latin-Scandinavian-AE ()
3167 (insert "AE" (texinfo-parse-arg-discard))
3168 (goto-char texinfo-command-start))
3170 ;; @ae{} ==> ae
3171 (put 'ae 'texinfo-format 'texinfo-format-Latin-Scandinavian-ae)
3172 (defun texinfo-format-Latin-Scandinavian-ae () ; lower case
3173 (insert "ae" (texinfo-parse-arg-discard))
3174 (goto-char texinfo-command-start))
3176 ;; @ss{} ==> ss German-sharp-S
3177 (put 'ss 'texinfo-format 'texinfo-format-German-sharp-S)
3178 (defun texinfo-format-German-sharp-S ()
3179 (insert "ss" (texinfo-parse-arg-discard))
3180 (goto-char texinfo-command-start))
3182 ;; @questiondown{} ==> ? upside-down-question-mark
3183 (put 'questiondown 'texinfo-format 'texinfo-format-upside-down-question-mark)
3184 (defun texinfo-format-upside-down-question-mark ()
3185 (insert "?" (texinfo-parse-arg-discard))
3186 (goto-char texinfo-command-start))
3188 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
3189 (put 'exclamdown 'texinfo-format 'texinfo-format-upside-down-exclamation-mark)
3190 (defun texinfo-format-upside-down-exclamation-mark ()
3191 (insert "!" (texinfo-parse-arg-discard))
3192 (goto-char texinfo-command-start))
3194 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
3195 (put 'L 'texinfo-format 'texinfo-format-Polish-suppressed-L)
3196 (defun texinfo-format-Polish-suppressed-L ()
3197 (insert (texinfo-parse-arg-discard) "/L")
3198 (goto-char texinfo-command-start))
3200 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
3201 (put 'l 'texinfo-format 'texinfo-format-Polish-suppressed-l-lower-case)
3202 (defun texinfo-format-Polish-suppressed-l-lower-case ()
3203 (insert (texinfo-parse-arg-discard) "/l")
3204 (goto-char texinfo-command-start))
3207 ;; @O{} ==> O/ Scandinavian O-with-slash
3208 (put 'O 'texinfo-format 'texinfo-format-Scandinavian-O-with-slash)
3209 (defun texinfo-format-Scandinavian-O-with-slash ()
3210 (insert (texinfo-parse-arg-discard) "O/")
3211 (goto-char texinfo-command-start))
3213 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
3214 (put 'o 'texinfo-format 'texinfo-format-Scandinavian-o-with-slash-lower-case)
3215 (defun texinfo-format-Scandinavian-o-with-slash-lower-case ()
3216 (insert (texinfo-parse-arg-discard) "o/")
3217 (goto-char texinfo-command-start))
3219 ;; Take arguments
3221 ;; @,{c} ==> c, cedilla accent
3222 (put '\, 'texinfo-format 'texinfo-format-cedilla-accent)
3223 (defun texinfo-format-cedilla-accent ()
3224 (insert (texinfo-parse-arg-discard) ",")
3225 (goto-char texinfo-command-start))
3228 ;; @dotaccent{o} ==> .o overdot-accent
3229 (put 'dotaccent 'texinfo-format 'texinfo-format-overdot-accent)
3230 (defun texinfo-format-overdot-accent ()
3231 (insert "." (texinfo-parse-arg-discard))
3232 (goto-char texinfo-command-start))
3234 ;; @ubaraccent{o} ==> _o underbar-accent
3235 (put 'ubaraccent 'texinfo-format 'texinfo-format-underbar-accent)
3236 (defun texinfo-format-underbar-accent ()
3237 (insert "_" (texinfo-parse-arg-discard))
3238 (goto-char texinfo-command-start))
3240 ;; @udotaccent{o} ==> o-. underdot-accent
3241 (put 'udotaccent 'texinfo-format 'texinfo-format-underdot-accent)
3242 (defun texinfo-format-underdot-accent ()
3243 (insert (texinfo-parse-arg-discard) "-.")
3244 (goto-char texinfo-command-start))
3246 ;; @H{o} ==> ""o long Hungarian umlaut
3247 (put 'H 'texinfo-format 'texinfo-format-long-Hungarian-umlaut)
3248 (defun texinfo-format-long-Hungarian-umlaut ()
3249 (insert "\"\"" (texinfo-parse-arg-discard))
3250 (goto-char texinfo-command-start))
3252 ;; @ringaccent{o} ==> *o ring accent
3253 (put 'ringaccent 'texinfo-format 'texinfo-format-ring-accent)
3254 (defun texinfo-format-ring-accent ()
3255 (insert "*" (texinfo-parse-arg-discard))
3256 (goto-char texinfo-command-start))
3258 ;; @tieaccent{oo} ==> [oo tie after accent
3259 (put 'tieaccent 'texinfo-format 'texinfo-format-tie-after-accent)
3260 (defun texinfo-format-tie-after-accent ()
3261 (insert "[" (texinfo-parse-arg-discard))
3262 (goto-char texinfo-command-start))
3265 ;; @u{o} ==> (o breve accent
3266 (put 'u 'texinfo-format 'texinfo-format-breve-accent)
3267 (defun texinfo-format-breve-accent ()
3268 (insert "(" (texinfo-parse-arg-discard))
3269 (goto-char texinfo-command-start))
3271 ;; @v{o} ==> <o hacek accent
3272 (put 'v 'texinfo-format 'texinfo-format-hacek-accent)
3273 (defun texinfo-format-hacek-accent ()
3274 (insert "<" (texinfo-parse-arg-discard))
3275 (goto-char texinfo-command-start))
3278 ;; @dotless{i} ==> i dotless i and dotless j
3279 (put 'dotless 'texinfo-format 'texinfo-format-dotless)
3280 (defun texinfo-format-dotless ()
3281 (insert (texinfo-parse-arg-discard))
3282 (goto-char texinfo-command-start))
3285 ;;; Definition formatting: @deffn, @defun, etc
3287 ;; What definition formatting produces:
3289 ;; @deffn category name args...
3290 ;; In Info, `Category: name ARGS'
3291 ;; In index: name: node. line#.
3293 ;; @defvr category name
3294 ;; In Info, `Category: name'
3295 ;; In index: name: node. line#.
3297 ;; @deftp category name attributes...
3298 ;; `category name attributes...' Note: @deftp args in lower case.
3299 ;; In index: name: node. line#.
3301 ;; Specialized function-like or variable-like entity:
3303 ;; @defun, @defmac, @defspec, @defvar, @defopt
3305 ;; @defun name args In Info, `Function: name ARGS'
3306 ;; @defmac name args In Info, `Macro: name ARGS'
3307 ;; @defvar name In Info, `Variable: name'
3308 ;; etc.
3309 ;; In index: name: node. line#.
3311 ;; Generalized typed-function-like or typed-variable-like entity:
3312 ;; @deftypefn category data-type name args...
3313 ;; In Info, `Category: data-type name args...'
3314 ;; @deftypevr category data-type name
3315 ;; In Info, `Category: data-type name'
3316 ;; In index: name: node. line#.
3318 ;; Specialized typed-function-like or typed-variable-like entity:
3319 ;; @deftypefun data-type name args...
3320 ;; In Info, `Function: data-type name ARGS'
3321 ;; In index: name: node. line#.
3323 ;; @deftypevar data-type name
3324 ;; In Info, `Variable: data-type name'
3325 ;; In index: name: node. line#. but include args after name!?
3327 ;; Generalized object oriented entity:
3328 ;; @defop category class name args...
3329 ;; In Info, `Category on class: name ARG'
3330 ;; In index: name on class: node. line#.
3332 ;; @defcv category class name
3333 ;; In Info, `Category of class: name'
3334 ;; In index: name of class: node. line#.
3336 ;; Specialized object oriented entity:
3337 ;; @defmethod class name args...
3338 ;; In Info, `Method on class: name ARGS'
3339 ;; In index: name on class: node. line#.
3341 ;; @defivar class name
3342 ;; In Info, `Instance variable of class: name'
3343 ;; In index: name of class: node. line#.
3346 ;;; The definition formatting functions
3348 (defun texinfo-format-defun ()
3349 (texinfo-push-stack 'defun nil)
3350 (setq fill-column (- fill-column 5))
3351 (texinfo-format-defun-1 t))
3353 (defun texinfo-end-defun ()
3354 (setq fill-column (+ fill-column 5))
3355 (texinfo-discard-command)
3356 (let ((start (nth 1 (texinfo-pop-stack 'defun))))
3357 (texinfo-do-itemize start)
3358 ;; Delete extra newline inserted after header.
3359 (save-excursion
3360 (goto-char start)
3361 (delete-char -1))))
3363 (defun texinfo-format-defunx ()
3364 (texinfo-format-defun-1 nil))
3366 (defun texinfo-format-defun-1 (first-p)
3367 (let ((parse-args (texinfo-format-parse-defun-args))
3368 (texinfo-defun-type (get texinfo-command-name 'texinfo-defun-type)))
3369 (texinfo-discard-command)
3370 ;; Delete extra newline inserted after previous header line.
3371 (if (not first-p)
3372 (delete-char -1))
3373 (funcall
3374 (get texinfo-command-name 'texinfo-deffn-formatting-property) parse-args)
3375 ;; Insert extra newline so that paragraph filling does not mess
3376 ;; with header line.
3377 (insert "\n\n")
3378 (rplaca (cdr (cdr (car texinfo-stack))) (point))
3379 (funcall
3380 (get texinfo-command-name 'texinfo-defun-indexing-property) parse-args)))
3382 ;;; Formatting the first line of a definition
3384 ;; @deffn, @defvr, @deftp
3385 (put 'deffn 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3386 (put 'deffnx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3387 (put 'defvr 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3388 (put 'defvrx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3389 (put 'deftp 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3390 (put 'deftpx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3391 (defun texinfo-format-deffn (parsed-args)
3392 ;; Generalized function-like, variable-like, or generic data-type entity:
3393 ;; @deffn category name args...
3394 ;; In Info, `Category: name ARGS'
3395 ;; @deftp category name attributes...
3396 ;; `category name attributes...' Note: @deftp args in lower case.
3397 (let ((category (car parsed-args))
3398 (name (car (cdr parsed-args)))
3399 (args (cdr (cdr parsed-args))))
3400 (insert " -- " category ": " name)
3401 (while args
3402 (insert " "
3403 (if (or (= ?& (aref (car args) 0))
3404 (eq (eval (car texinfo-defun-type)) 'deftp-type))
3405 (car args)
3406 (upcase (car args))))
3407 (setq args (cdr args)))))
3409 ;; @defun, @defmac, @defspec, @defvar, @defopt: Specialized, simple
3410 (put 'defun 'texinfo-deffn-formatting-property
3411 'texinfo-format-specialized-defun)
3412 (put 'defunx 'texinfo-deffn-formatting-property
3413 'texinfo-format-specialized-defun)
3414 (put 'defmac 'texinfo-deffn-formatting-property
3415 'texinfo-format-specialized-defun)
3416 (put 'defmacx 'texinfo-deffn-formatting-property
3417 'texinfo-format-specialized-defun)
3418 (put 'defspec 'texinfo-deffn-formatting-property
3419 'texinfo-format-specialized-defun)
3420 (put 'defspecx 'texinfo-deffn-formatting-property
3421 'texinfo-format-specialized-defun)
3422 (put 'defvar 'texinfo-deffn-formatting-property
3423 'texinfo-format-specialized-defun)
3424 (put 'defvarx 'texinfo-deffn-formatting-property
3425 'texinfo-format-specialized-defun)
3426 (put 'defopt 'texinfo-deffn-formatting-property
3427 'texinfo-format-specialized-defun)
3428 (put 'defoptx 'texinfo-deffn-formatting-property
3429 'texinfo-format-specialized-defun)
3430 (defun texinfo-format-specialized-defun (parsed-args)
3431 ;; Specialized function-like or variable-like entity:
3432 ;; @defun name args In Info, `Function: Name ARGS'
3433 ;; @defmac name args In Info, `Macro: Name ARGS'
3434 ;; @defvar name In Info, `Variable: Name'
3435 ;; Use cdr of texinfo-defun-type to determine category:
3436 (let ((category (car (cdr texinfo-defun-type)))
3437 (name (car parsed-args))
3438 (args (cdr parsed-args)))
3439 (insert " -- " category ": " name)
3440 (while args
3441 (insert " "
3442 (if (= ?& (aref (car args) 0))
3443 (car args)
3444 (upcase (car args))))
3445 (setq args (cdr args)))))
3447 ;; @deftypefn, @deftypevr: Generalized typed
3448 (put 'deftypefn 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
3449 (put 'deftypefnx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
3450 (put 'deftypevr 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
3451 (put 'deftypevrx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
3452 (defun texinfo-format-deftypefn (parsed-args)
3453 ;; Generalized typed-function-like or typed-variable-like entity:
3454 ;; @deftypefn category data-type name args...
3455 ;; In Info, `Category: data-type name args...'
3456 ;; @deftypevr category data-type name
3457 ;; In Info, `Category: data-type name'
3458 ;; Note: args in lower case, unless modified in command line.
3459 (let ((category (car parsed-args))
3460 (data-type (car (cdr parsed-args)))
3461 (name (car (cdr (cdr parsed-args))))
3462 (args (cdr (cdr (cdr parsed-args)))))
3463 (insert " -- " category ": " data-type " " name)
3464 (while args
3465 (insert " " (car args))
3466 (setq args (cdr args)))))
3468 ;; @deftypefun, @deftypevar: Specialized typed
3469 (put 'deftypefun 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun)
3470 (put 'deftypefunx 'texinfo-deffn-formatting-property
3471 'texinfo-format-deftypefun)
3472 (put 'deftypevar 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun)
3473 (put 'deftypevarx 'texinfo-deffn-formatting-property
3474 'texinfo-format-deftypefun)
3475 (defun texinfo-format-deftypefun (parsed-args)
3476 ;; Specialized typed-function-like or typed-variable-like entity:
3477 ;; @deftypefun data-type name args...
3478 ;; In Info, `Function: data-type name ARGS'
3479 ;; @deftypevar data-type name
3480 ;; In Info, `Variable: data-type name'
3481 ;; Note: args in lower case, unless modified in command line.
3482 ;; Use cdr of texinfo-defun-type to determine category:
3483 (let ((category (car (cdr texinfo-defun-type)))
3484 (data-type (car parsed-args))
3485 (name (car (cdr parsed-args)))
3486 (args (cdr (cdr parsed-args))))
3487 (insert " -- " category ": " data-type " " name)
3488 (while args
3489 (insert " " (car args))
3490 (setq args (cdr args)))))
3492 ;; @defop: Generalized object-oriented
3493 (put 'defop 'texinfo-deffn-formatting-property 'texinfo-format-defop)
3494 (put 'defopx 'texinfo-deffn-formatting-property 'texinfo-format-defop)
3495 (defun texinfo-format-defop (parsed-args)
3496 ;; Generalized object oriented entity:
3497 ;; @defop category class name args...
3498 ;; In Info, `Category on class: name ARG'
3499 ;; Note: args in upper case; use of `on'
3500 (let ((category (car parsed-args))
3501 (class (car (cdr parsed-args)))
3502 (name (car (cdr (cdr parsed-args))))
3503 (args (cdr (cdr (cdr parsed-args)))))
3504 (insert " -- " category " on " class ": " name)
3505 (while args
3506 (insert " " (upcase (car args)))
3507 (setq args (cdr args)))))
3509 ;; @defcv: Generalized object-oriented
3510 (put 'defcv 'texinfo-deffn-formatting-property 'texinfo-format-defcv)
3511 (put 'defcvx 'texinfo-deffn-formatting-property 'texinfo-format-defcv)
3512 (defun texinfo-format-defcv (parsed-args)
3513 ;; Generalized object oriented entity:
3514 ;; @defcv category class name
3515 ;; In Info, `Category of class: name'
3516 ;; Note: args in upper case; use of `of'
3517 (let ((category (car parsed-args))
3518 (class (car (cdr parsed-args)))
3519 (name (car (cdr (cdr parsed-args))))
3520 (args (cdr (cdr (cdr parsed-args)))))
3521 (insert " -- " category " of " class ": " name)
3522 (while args
3523 (insert " " (upcase (car args)))
3524 (setq args (cdr args)))))
3526 ;; @defmethod: Specialized object-oriented
3527 (put 'defmethod 'texinfo-deffn-formatting-property 'texinfo-format-defmethod)
3528 (put 'defmethodx 'texinfo-deffn-formatting-property 'texinfo-format-defmethod)
3529 (defun texinfo-format-defmethod (parsed-args)
3530 ;; Specialized object oriented entity:
3531 ;; @defmethod class name args...
3532 ;; In Info, `Method on class: name ARGS'
3533 ;; Note: args in upper case; use of `on'
3534 ;; Use cdr of texinfo-defun-type to determine category:
3535 (let ((category (car (cdr texinfo-defun-type)))
3536 (class (car parsed-args))
3537 (name (car (cdr parsed-args)))
3538 (args (cdr (cdr parsed-args))))
3539 (insert " -- " category " on " class ": " name)
3540 (while args
3541 (insert " " (upcase (car args)))
3542 (setq args (cdr args)))))
3544 ;; @defivar: Specialized object-oriented
3545 (put 'defivar 'texinfo-deffn-formatting-property 'texinfo-format-defivar)
3546 (put 'defivarx 'texinfo-deffn-formatting-property 'texinfo-format-defivar)
3547 (defun texinfo-format-defivar (parsed-args)
3548 ;; Specialized object oriented entity:
3549 ;; @defivar class name
3550 ;; In Info, `Instance variable of class: name'
3551 ;; Note: args in upper case; use of `of'
3552 ;; Use cdr of texinfo-defun-type to determine category:
3553 (let ((category (car (cdr texinfo-defun-type)))
3554 (class (car parsed-args))
3555 (name (car (cdr parsed-args)))
3556 (args (cdr (cdr parsed-args))))
3557 (insert " -- " category " of " class ": " name)
3558 (while args
3559 (insert " " (upcase (car args)))
3560 (setq args (cdr args)))))
3563 ;;; Indexing for definitions
3565 ;; An index entry has three parts: the `entry proper', the node name, and the
3566 ;; line number. Depending on the which command is used, the entry is
3567 ;; formatted differently:
3569 ;; @defun,
3570 ;; @defmac,
3571 ;; @defspec,
3572 ;; @defvar,
3573 ;; @defopt all use their 1st argument as the entry-proper
3575 ;; @deffn,
3576 ;; @defvr,
3577 ;; @deftp
3578 ;; @deftypefun
3579 ;; @deftypevar all use their 2nd argument as the entry-proper
3581 ;; @deftypefn,
3582 ;; @deftypevr both use their 3rd argument as the entry-proper
3584 ;; @defmethod uses its 2nd and 1st arguments as an entry-proper
3585 ;; formatted: NAME on CLASS
3587 ;; @defop uses its 3rd and 2nd arguments as an entry-proper
3588 ;; formatted: NAME on CLASS
3590 ;; @defivar uses its 2nd and 1st arguments as an entry-proper
3591 ;; formatted: NAME of CLASS
3593 ;; @defcv uses its 3rd and 2nd argument as an entry-proper
3594 ;; formatted: NAME of CLASS
3596 (put 'defun 'texinfo-defun-indexing-property 'texinfo-index-defun)
3597 (put 'defunx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3598 (put 'defmac 'texinfo-defun-indexing-property 'texinfo-index-defun)
3599 (put 'defmacx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3600 (put 'defspec 'texinfo-defun-indexing-property 'texinfo-index-defun)
3601 (put 'defspecx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3602 (put 'defvar 'texinfo-defun-indexing-property 'texinfo-index-defun)
3603 (put 'defvarx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3604 (put 'defopt 'texinfo-defun-indexing-property 'texinfo-index-defun)
3605 (put 'defoptx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3606 (defun texinfo-index-defun (parsed-args)
3607 ;; use 1st parsed-arg as entry-proper
3608 ;; `index-list' will be texinfo-findex or the like
3609 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3610 (set index-list
3611 (cons
3612 ;; Three elements: entry-proper, node-name, line-number
3613 (list
3614 (car parsed-args)
3615 texinfo-last-node
3616 ;; Region formatting may not provide last node position.
3617 (if texinfo-last-node-pos
3618 (1+ (count-lines texinfo-last-node-pos (point)))
3620 (symbol-value index-list)))))
3622 (put 'deffn 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3623 (put 'deffnx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3624 (put 'defvr 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3625 (put 'defvrx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3626 (put 'deftp 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3627 (put 'deftpx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3628 (put 'deftypefun 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3629 (put 'deftypefunx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3630 (put 'deftypevar 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3631 (put 'deftypevarx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3632 (defun texinfo-index-deffn (parsed-args)
3633 ;; use 2nd parsed-arg as entry-proper
3634 ;; `index-list' will be texinfo-findex or the like
3635 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3636 (set index-list
3637 (cons
3638 ;; Three elements: entry-proper, node-name, line-number
3639 (list
3640 (car (cdr parsed-args))
3641 texinfo-last-node
3642 ;; Region formatting may not provide last node position.
3643 (if texinfo-last-node-pos
3644 (1+ (count-lines texinfo-last-node-pos (point)))
3646 (symbol-value index-list)))))
3648 (put 'deftypefn 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
3649 (put 'deftypefnx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
3650 (put 'deftypevr 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
3651 (put 'deftypevrx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
3652 (defun texinfo-index-deftypefn (parsed-args)
3653 ;; use 3rd parsed-arg as entry-proper
3654 ;; `index-list' will be texinfo-findex or the like
3655 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3656 (set index-list
3657 (cons
3658 ;; Three elements: entry-proper, node-name, line-number
3659 (list
3660 (car (cdr (cdr parsed-args)))
3661 texinfo-last-node
3662 ;; Region formatting may not provide last node position.
3663 (if texinfo-last-node-pos
3664 (1+ (count-lines texinfo-last-node-pos (point)))
3666 (symbol-value index-list)))))
3668 (put 'defmethod 'texinfo-defun-indexing-property 'texinfo-index-defmethod)
3669 (put 'defmethodx 'texinfo-defun-indexing-property 'texinfo-index-defmethod)
3670 (defun texinfo-index-defmethod (parsed-args)
3671 ;; use 2nd on 1st parsed-arg as entry-proper
3672 ;; `index-list' will be texinfo-findex or the like
3673 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3674 (set index-list
3675 (cons
3676 ;; Three elements: entry-proper, node-name, line-number
3677 (list
3678 (format "%s on %s"
3679 (car (cdr parsed-args))
3680 (car parsed-args))
3681 texinfo-last-node
3682 ;; Region formatting may not provide last node position.
3683 (if texinfo-last-node-pos
3684 (1+ (count-lines texinfo-last-node-pos (point)))
3686 (symbol-value index-list)))))
3688 (put 'defop 'texinfo-defun-indexing-property 'texinfo-index-defop)
3689 (put 'defopx 'texinfo-defun-indexing-property 'texinfo-index-defop)
3690 (defun texinfo-index-defop (parsed-args)
3691 ;; use 3rd on 2nd parsed-arg as entry-proper
3692 ;; `index-list' will be texinfo-findex or the like
3693 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3694 (set index-list
3695 (cons
3696 ;; Three elements: entry-proper, node-name, line-number
3697 (list
3698 (format "%s on %s"
3699 (car (cdr (cdr parsed-args)))
3700 (car (cdr parsed-args)))
3701 texinfo-last-node
3702 ;; Region formatting may not provide last node position.
3703 (if texinfo-last-node-pos
3704 (1+ (count-lines texinfo-last-node-pos (point)))
3706 (symbol-value index-list)))))
3708 (put 'defivar 'texinfo-defun-indexing-property 'texinfo-index-defivar)
3709 (put 'defivarx 'texinfo-defun-indexing-property 'texinfo-index-defivar)
3710 (defun texinfo-index-defivar (parsed-args)
3711 ;; use 2nd of 1st parsed-arg as entry-proper
3712 ;; `index-list' will be texinfo-findex or the like
3713 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3714 (set index-list
3715 (cons
3716 ;; Three elements: entry-proper, node-name, line-number
3717 (list
3718 (format "%s of %s"
3719 (car (cdr parsed-args))
3720 (car parsed-args))
3721 texinfo-last-node
3722 ;; Region formatting may not provide last node position.
3723 (if texinfo-last-node-pos
3724 (1+ (count-lines texinfo-last-node-pos (point)))
3726 (symbol-value index-list)))))
3728 (put 'defcv 'texinfo-defun-indexing-property 'texinfo-index-defcv)
3729 (put 'defcvx 'texinfo-defun-indexing-property 'texinfo-index-defcv)
3730 (defun texinfo-index-defcv (parsed-args)
3731 ;; use 3rd of 2nd parsed-arg as entry-proper
3732 ;; `index-list' will be texinfo-findex or the like
3733 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3734 (set index-list
3735 (cons
3736 ;; Three elements: entry-proper, node-name, line-number
3737 (list
3738 (format "%s of %s"
3739 (car (cdr (cdr parsed-args)))
3740 (car (cdr parsed-args)))
3741 texinfo-last-node
3742 ;; Region formatting may not provide last node position.
3743 (if texinfo-last-node-pos
3744 (1+ (count-lines texinfo-last-node-pos (point)))
3746 (symbol-value index-list)))))
3749 ;;; Properties for definitions
3751 ;; Each definition command has six properties:
3753 ;; 1. texinfo-deffn-formatting-property to format definition line
3754 ;; 2. texinfo-defun-indexing-property to create index entry
3755 ;; 3. texinfo-format formatting command
3756 ;; 4. texinfo-end end formatting command
3757 ;; 5. texinfo-defun-type type of deffn to format
3758 ;; 6. texinfo-defun-index type of index to use
3760 ;; The `x' forms of each definition command are used for the second
3761 ;; and subsequent header lines.
3763 ;; The texinfo-deffn-formatting-property and texinfo-defun-indexing-property
3764 ;; are listed just before the appropriate formatting and indexing commands.
3766 (put 'deffn 'texinfo-format 'texinfo-format-defun)
3767 (put 'deffnx 'texinfo-format 'texinfo-format-defunx)
3768 (put 'deffn 'texinfo-end 'texinfo-end-defun)
3769 (put 'deffn 'texinfo-defun-type '('deffn-type nil))
3770 (put 'deffnx 'texinfo-defun-type '('deffn-type nil))
3771 (put 'deffn 'texinfo-defun-index 'texinfo-findex)
3772 (put 'deffnx 'texinfo-defun-index 'texinfo-findex)
3774 (put 'defun 'texinfo-format 'texinfo-format-defun)
3775 (put 'defunx 'texinfo-format 'texinfo-format-defunx)
3776 (put 'defun 'texinfo-end 'texinfo-end-defun)
3777 (put 'defun 'texinfo-defun-type '('defun-type "Function"))
3778 (put 'defunx 'texinfo-defun-type '('defun-type "Function"))
3779 (put 'defun 'texinfo-defun-index 'texinfo-findex)
3780 (put 'defunx 'texinfo-defun-index 'texinfo-findex)
3782 (put 'defmac 'texinfo-format 'texinfo-format-defun)
3783 (put 'defmacx 'texinfo-format 'texinfo-format-defunx)
3784 (put 'defmac 'texinfo-end 'texinfo-end-defun)
3785 (put 'defmac 'texinfo-defun-type '('defun-type "Macro"))
3786 (put 'defmacx 'texinfo-defun-type '('defun-type "Macro"))
3787 (put 'defmac 'texinfo-defun-index 'texinfo-findex)
3788 (put 'defmacx 'texinfo-defun-index 'texinfo-findex)
3790 (put 'defspec 'texinfo-format 'texinfo-format-defun)
3791 (put 'defspecx 'texinfo-format 'texinfo-format-defunx)
3792 (put 'defspec 'texinfo-end 'texinfo-end-defun)
3793 (put 'defspec 'texinfo-defun-type '('defun-type "Special form"))
3794 (put 'defspecx 'texinfo-defun-type '('defun-type "Special form"))
3795 (put 'defspec 'texinfo-defun-index 'texinfo-findex)
3796 (put 'defspecx 'texinfo-defun-index 'texinfo-findex)
3798 (put 'defvr 'texinfo-format 'texinfo-format-defun)
3799 (put 'defvrx 'texinfo-format 'texinfo-format-defunx)
3800 (put 'defvr 'texinfo-end 'texinfo-end-defun)
3801 (put 'defvr 'texinfo-defun-type '('deffn-type nil))
3802 (put 'defvrx 'texinfo-defun-type '('deffn-type nil))
3803 (put 'defvr 'texinfo-defun-index 'texinfo-vindex)
3804 (put 'defvrx 'texinfo-defun-index 'texinfo-vindex)
3806 (put 'defvar 'texinfo-format 'texinfo-format-defun)
3807 (put 'defvarx 'texinfo-format 'texinfo-format-defunx)
3808 (put 'defvar 'texinfo-end 'texinfo-end-defun)
3809 (put 'defvar 'texinfo-defun-type '('defun-type "Variable"))
3810 (put 'defvarx 'texinfo-defun-type '('defun-type "Variable"))
3811 (put 'defvar 'texinfo-defun-index 'texinfo-vindex)
3812 (put 'defvarx 'texinfo-defun-index 'texinfo-vindex)
3814 (put 'defconst 'texinfo-format 'texinfo-format-defun)
3815 (put 'defconstx 'texinfo-format 'texinfo-format-defunx)
3816 (put 'defconst 'texinfo-end 'texinfo-end-defun)
3817 (put 'defconst 'texinfo-defun-type '('defun-type "Constant"))
3818 (put 'defconstx 'texinfo-defun-type '('defun-type "Constant"))
3819 (put 'defconst 'texinfo-defun-index 'texinfo-vindex)
3820 (put 'defconstx 'texinfo-defun-index 'texinfo-vindex)
3822 (put 'defcmd 'texinfo-format 'texinfo-format-defun)
3823 (put 'defcmdx 'texinfo-format 'texinfo-format-defunx)
3824 (put 'defcmd 'texinfo-end 'texinfo-end-defun)
3825 (put 'defcmd 'texinfo-defun-type '('defun-type "Command"))
3826 (put 'defcmdx 'texinfo-defun-type '('defun-type "Command"))
3827 (put 'defcmd 'texinfo-defun-index 'texinfo-findex)
3828 (put 'defcmdx 'texinfo-defun-index 'texinfo-findex)
3830 (put 'defopt 'texinfo-format 'texinfo-format-defun)
3831 (put 'defoptx 'texinfo-format 'texinfo-format-defunx)
3832 (put 'defopt 'texinfo-end 'texinfo-end-defun)
3833 (put 'defopt 'texinfo-defun-type '('defun-type "User Option"))
3834 (put 'defoptx 'texinfo-defun-type '('defun-type "User Option"))
3835 (put 'defopt 'texinfo-defun-index 'texinfo-vindex)
3836 (put 'defoptx 'texinfo-defun-index 'texinfo-vindex)
3838 (put 'deftp 'texinfo-format 'texinfo-format-defun)
3839 (put 'deftpx 'texinfo-format 'texinfo-format-defunx)
3840 (put 'deftp 'texinfo-end 'texinfo-end-defun)
3841 (put 'deftp 'texinfo-defun-type '('deftp-type nil))
3842 (put 'deftpx 'texinfo-defun-type '('deftp-type nil))
3843 (put 'deftp 'texinfo-defun-index 'texinfo-tindex)
3844 (put 'deftpx 'texinfo-defun-index 'texinfo-tindex)
3846 ;;; Object-oriented stuff is a little hairier.
3848 (put 'defop 'texinfo-format 'texinfo-format-defun)
3849 (put 'defopx 'texinfo-format 'texinfo-format-defunx)
3850 (put 'defop 'texinfo-end 'texinfo-end-defun)
3851 (put 'defop 'texinfo-defun-type '('defop-type nil))
3852 (put 'defopx 'texinfo-defun-type '('defop-type nil))
3853 (put 'defop 'texinfo-defun-index 'texinfo-findex)
3854 (put 'defopx 'texinfo-defun-index 'texinfo-findex)
3856 (put 'defmethod 'texinfo-format 'texinfo-format-defun)
3857 (put 'defmethodx 'texinfo-format 'texinfo-format-defunx)
3858 (put 'defmethod 'texinfo-end 'texinfo-end-defun)
3859 (put 'defmethod 'texinfo-defun-type '('defmethod-type "Method"))
3860 (put 'defmethodx 'texinfo-defun-type '('defmethod-type "Method"))
3861 (put 'defmethod 'texinfo-defun-index 'texinfo-findex)
3862 (put 'defmethodx 'texinfo-defun-index 'texinfo-findex)
3864 (put 'defcv 'texinfo-format 'texinfo-format-defun)
3865 (put 'defcvx 'texinfo-format 'texinfo-format-defunx)
3866 (put 'defcv 'texinfo-end 'texinfo-end-defun)
3867 (put 'defcv 'texinfo-defun-type '('defop-type nil))
3868 (put 'defcvx 'texinfo-defun-type '('defop-type nil))
3869 (put 'defcv 'texinfo-defun-index 'texinfo-vindex)
3870 (put 'defcvx 'texinfo-defun-index 'texinfo-vindex)
3872 (put 'defivar 'texinfo-format 'texinfo-format-defun)
3873 (put 'defivarx 'texinfo-format 'texinfo-format-defunx)
3874 (put 'defivar 'texinfo-end 'texinfo-end-defun)
3875 (put 'defivar 'texinfo-defun-type '('defmethod-type "Instance variable"))
3876 (put 'defivarx 'texinfo-defun-type '('defmethod-type "Instance variable"))
3877 (put 'defivar 'texinfo-defun-index 'texinfo-vindex)
3878 (put 'defivarx 'texinfo-defun-index 'texinfo-vindex)
3880 ;;; Typed functions and variables
3882 (put 'deftypefn 'texinfo-format 'texinfo-format-defun)
3883 (put 'deftypefnx 'texinfo-format 'texinfo-format-defunx)
3884 (put 'deftypefn 'texinfo-end 'texinfo-end-defun)
3885 (put 'deftypefn 'texinfo-defun-type '('deftypefn-type nil))
3886 (put 'deftypefnx 'texinfo-defun-type '('deftypefn-type nil))
3887 (put 'deftypefn 'texinfo-defun-index 'texinfo-findex)
3888 (put 'deftypefnx 'texinfo-defun-index 'texinfo-findex)
3890 (put 'deftypefun 'texinfo-format 'texinfo-format-defun)
3891 (put 'deftypefunx 'texinfo-format 'texinfo-format-defunx)
3892 (put 'deftypefun 'texinfo-end 'texinfo-end-defun)
3893 (put 'deftypefun 'texinfo-defun-type '('deftypefun-type "Function"))
3894 (put 'deftypefunx 'texinfo-defun-type '('deftypefun-type "Function"))
3895 (put 'deftypefun 'texinfo-defun-index 'texinfo-findex)
3896 (put 'deftypefunx 'texinfo-defun-index 'texinfo-findex)
3898 (put 'deftypevr 'texinfo-format 'texinfo-format-defun)
3899 (put 'deftypevrx 'texinfo-format 'texinfo-format-defunx)
3900 (put 'deftypevr 'texinfo-end 'texinfo-end-defun)
3901 (put 'deftypevr 'texinfo-defun-type '('deftypefn-type nil))
3902 (put 'deftypevrx 'texinfo-defun-type '('deftypefn-type nil))
3903 (put 'deftypevr 'texinfo-defun-index 'texinfo-vindex)
3904 (put 'deftypevrx 'texinfo-defun-index 'texinfo-vindex)
3906 (put 'deftypevar 'texinfo-format 'texinfo-format-defun)
3907 (put 'deftypevarx 'texinfo-format 'texinfo-format-defunx)
3908 (put 'deftypevar 'texinfo-end 'texinfo-end-defun)
3909 (put 'deftypevar 'texinfo-defun-type '('deftypevar-type "Variable"))
3910 (put 'deftypevarx 'texinfo-defun-type '('deftypevar-type "Variable"))
3911 (put 'deftypevar 'texinfo-defun-index 'texinfo-vindex)
3912 (put 'deftypevarx 'texinfo-defun-index 'texinfo-vindex)
3915 ;;; @set, @clear, @ifset, @ifclear
3917 ;; If a flag is set with @set FLAG, then text between @ifset and @end
3918 ;; ifset is formatted normally, but if the flag is is cleared with
3919 ;; @clear FLAG, then the text is not formatted; it is ignored.
3921 ;; If a flag is cleared with @clear FLAG, then text between @ifclear
3922 ;; and @end ifclear is formatted normally, but if the flag is is set with
3923 ;; @set FLAG, then the text is not formatted; it is ignored. @ifclear
3924 ;; is the opposite of @ifset.
3926 ;; If a flag is set to a string with @set FLAG,
3927 ;; replace @value{FLAG} with the string.
3928 ;; If a flag with a value is cleared,
3929 ;; @value{FLAG} is invalid,
3930 ;; as if there had never been any @set FLAG previously.
3932 (put 'clear 'texinfo-format 'texinfo-clear)
3933 (defun texinfo-clear ()
3934 "Clear the value of the flag."
3935 (let* ((arg (texinfo-parse-arg-discard))
3936 (flag (car (read-from-string arg)))
3937 (value (substring arg (cdr (read-from-string arg)))))
3938 (put flag 'texinfo-whether-setp 'flag-cleared)
3939 (put flag 'texinfo-set-value "")))
3941 (put 'set 'texinfo-format 'texinfo-set)
3942 (defun texinfo-set ()
3943 "Set the value of the flag, optionally to a string.
3944 The command `@set foo This is a string.'
3945 sets flag foo to the value: `This is a string.'
3946 The command `@value{foo}' expands to the value."
3947 (let* ((arg (texinfo-parse-arg-discard))
3948 (flag (car (read-from-string arg)))
3949 (value (substring arg (cdr (read-from-string arg)))))
3950 (if (string-match "^[ \t]+" value)
3951 (setq value (substring value (match-end 0))))
3952 (put flag 'texinfo-whether-setp 'flag-set)
3953 (put flag 'texinfo-set-value value)))
3955 (put 'value 'texinfo-format 'texinfo-value)
3956 (defun texinfo-value ()
3957 "Insert the string to which the flag is set.
3958 The command `@set foo This is a string.'
3959 sets flag foo to the value: `This is a string.'
3960 The command `@value{foo}' expands to the value."
3961 (let ((arg (texinfo-parse-arg-discard)))
3962 (cond ((and
3963 (eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3964 'flag-set)
3965 (get (car (read-from-string arg)) 'texinfo-set-value))
3966 (insert (get (car (read-from-string arg)) 'texinfo-set-value)))
3967 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3968 'flag-cleared)
3969 (insert (format "{No value for \"%s\"}" arg)))
3970 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) nil)
3971 (insert (format "{No value for \"%s\"}" arg))))))
3973 (put 'ifset 'texinfo-end 'texinfo-discard-command)
3974 (put 'ifset 'texinfo-format 'texinfo-if-set)
3975 (defun texinfo-if-set ()
3976 "If set, continue formatting; else do not format region up to @end ifset."
3977 (let ((arg (texinfo-parse-arg-discard)))
3978 (cond
3979 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3980 'flag-set)
3981 ;; Format the text (i.e., do not remove it); do nothing here.
3983 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3984 'flag-cleared)
3985 ;; Clear region (i.e., cause the text to be ignored).
3986 (delete-region texinfo-command-start
3987 (re-search-forward "@end ifset[ \t]*\n")))
3988 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3989 nil)
3990 ;; In this case flag is neither set nor cleared.
3991 ;; Act as if set, i.e. do nothing.
3992 ()))))
3994 (put 'ifclear 'texinfo-end 'texinfo-discard-command)
3995 (put 'ifclear 'texinfo-format 'texinfo-if-clear)
3996 (defun texinfo-if-clear ()
3997 "If clear, continue formatting; if set, do not format up to @end ifset."
3998 (let ((arg (texinfo-parse-arg-discard)))
3999 (cond
4000 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
4001 'flag-set)
4002 ;; Clear region (i.e., cause the text to be ignored).
4003 (delete-region texinfo-command-start
4004 (re-search-forward "@end ifclear[ \t]*\n")))
4005 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
4006 'flag-cleared)
4007 ;; Format the text (i.e., do not remove it); do nothing here.
4009 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
4010 nil)
4011 ;; In this case flag is neither set nor cleared.
4012 ;; Act as if clear, i.e. do nothing.
4013 ()))))
4015 ;;; @ifeq
4017 (put 'ifeq 'texinfo-format 'texinfo-format-ifeq)
4018 (defun texinfo-format-ifeq ()
4019 "If ARG1 and ARG2 caselessly string compare to same string, perform COMMAND.
4020 Otherwise produces no output.
4022 Thus:
4023 @ifeq{ arg1 , arg1 , @code{foo}} bar
4025 ==> `foo' bar.
4027 @ifeq{ arg1 , arg2 , @code{foo}} bar
4029 ==> bar
4031 Note that the Texinfo command and its arguments must be arguments to
4032 the @ifeq command."
4033 ;; compare-buffer-substrings does not exist in version 18; don't use
4034 (goto-char texinfo-command-end)
4035 (let* ((case-fold-search t)
4036 (stop (save-excursion (forward-sexp 1) (point)))
4037 start end
4038 ;; @ifeq{arg1, arg2, @command{optional-args}}
4039 (arg1
4040 (progn
4041 (forward-char 1)
4042 (skip-chars-forward " ")
4043 (setq start (point))
4044 (search-forward "," stop t)
4045 (skip-chars-backward ", ")
4046 (buffer-substring-no-properties start (point))))
4047 (arg2
4048 (progn
4049 (search-forward "," stop t)
4050 (skip-chars-forward " ")
4051 (setq start (point))
4052 (search-forward "," stop t)
4053 (skip-chars-backward ", ")
4054 (buffer-substring-no-properties start (point))))
4055 (texinfo-command
4056 (progn
4057 (search-forward "," stop t)
4058 (skip-chars-forward " ")
4059 (setq start (point))
4060 (goto-char (1- stop))
4061 (skip-chars-backward " ")
4062 (buffer-substring-no-properties start (point)))))
4063 (delete-region texinfo-command-start stop)
4064 (if (equal arg1 arg2)
4065 (insert texinfo-command))
4066 (goto-char texinfo-command-start)))
4069 ;;; Process included files: `@include' command
4071 ;; Updated 19 October 1990
4072 ;; In the original version, include files were ignored by Info but
4073 ;; incorporated in to the printed manual. To make references to the
4074 ;; included file, the Texinfo source file has to refer to the included
4075 ;; files using the `(filename)nodename' format for referring to other
4076 ;; Info files. Also, the included files had to be formatted on their
4077 ;; own. It was just like they were another file.
4079 ;; Currently, include files are inserted into the buffer that is
4080 ;; formatted for Info. If large, the resulting info file is split and
4081 ;; tagified. For current include files to work, the master menu must
4082 ;; refer to all the nodes, and the highest level nodes in the include
4083 ;; files must have the correct next, prev, and up pointers.
4085 ;; The included file may have an @setfilename and even an @settitle,
4086 ;; but not an `\input texinfo' line.
4088 ;; Updated 24 March 1993
4089 ;; In order for @raisesections and @lowersections to work, included
4090 ;; files must be inserted into the buffer holding the outer file
4091 ;; before other Info formatting takes place. So @include is no longer
4092 ;; is treated like other @-commands.
4093 (put 'include 'texinfo-format 'texinfo-format-noop)
4095 ;; Original definition:
4096 ;; (defun texinfo-format-include ()
4097 ;; (let ((filename (texinfo-parse-arg-discard))
4098 ;; (default-directory input-directory)
4099 ;; subindex)
4100 ;; (setq subindex
4101 ;; (save-excursion
4102 ;; (progn (find-file
4103 ;; (cond ((file-readable-p (concat filename ".texinfo"))
4104 ;; (concat filename ".texinfo"))
4105 ;; ((file-readable-p (concat filename ".texi"))
4106 ;; (concat filename ".texi"))
4107 ;; ((file-readable-p (concat filename ".tex"))
4108 ;; (concat filename ".tex"))
4109 ;; ((file-readable-p filename)
4110 ;; filename)
4111 ;; (t (error "@include'd file %s not found"
4112 ;; filename))))
4113 ;; (texinfo-format-buffer-1))))
4114 ;; (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex))
4115 ;; (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex))
4116 ;; (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex))
4117 ;; (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex))
4118 ;; (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex))
4119 ;; (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex))))
4121 ;;(defun texinfo-subindex (indexvar file content)
4122 ;; (set indexvar (cons (list 'recurse file content)
4123 ;; (symbol-value indexvar))))
4125 ;; Second definition:
4126 ;; (put 'include 'texinfo-format 'texinfo-format-include)
4127 ;; (defun texinfo-format-include ()
4128 ;; (let ((filename (concat input-directory
4129 ;; (texinfo-parse-arg-discard)))
4130 ;; (default-directory input-directory))
4131 ;; (message "Reading: %s" filename)
4132 ;; (save-excursion
4133 ;; (save-restriction
4134 ;; (narrow-to-region
4135 ;; (point)
4136 ;; (+ (point) (car (cdr (insert-file-contents filename)))))
4137 ;; (goto-char (point-min))
4138 ;; (texinfo-append-refill)
4139 ;; (texinfo-format-convert (point-min) (point-max))))
4140 ;; (setq last-input-buffer input-buffer) ; to bypass setfilename
4141 ;; ))
4144 ;;; Numerous commands do nothing in Info
4145 ;; These commands are defined in texinfo.tex for printed output.
4148 ;;; various noops, such as @b{foo}, that take arguments in braces
4150 (put 'b 'texinfo-format 'texinfo-format-noop)
4151 (put 'i 'texinfo-format 'texinfo-format-noop)
4152 (put 'r 'texinfo-format 'texinfo-format-noop)
4153 (put 't 'texinfo-format 'texinfo-format-noop)
4154 (put 'w 'texinfo-format 'texinfo-format-noop)
4155 (put 'asis 'texinfo-format 'texinfo-format-noop)
4156 (put 'dmn 'texinfo-format 'texinfo-format-noop)
4157 (put 'math 'texinfo-format 'texinfo-format-noop)
4158 (put 'titlefont 'texinfo-format 'texinfo-format-noop)
4159 (defun texinfo-format-noop ()
4160 (insert (texinfo-parse-arg-discard))
4161 (goto-char texinfo-command-start))
4163 ;; @hyphenation command discards an argument within braces
4164 (put 'hyphenation 'texinfo-format 'texinfo-discard-command-and-arg)
4165 (defun texinfo-discard-command-and-arg ()
4166 "Discard both @-command and its argument in braces."
4167 (goto-char texinfo-command-end)
4168 (forward-list 1)
4169 (setq texinfo-command-end (point))
4170 (delete-region texinfo-command-start texinfo-command-end))
4173 ;;; Do nothing commands, such as @smallbook, that have no args and no braces
4174 ;; These must appear on a line of their own
4176 (put 'bye 'texinfo-format 'texinfo-discard-line)
4177 (put 'smallbook 'texinfo-format 'texinfo-discard-line)
4178 (put 'finalout 'texinfo-format 'texinfo-discard-line)
4179 (put 'overfullrule 'texinfo-format 'texinfo-discard-line)
4180 (put 'smallbreak 'texinfo-format 'texinfo-discard-line)
4181 (put 'medbreak 'texinfo-format 'texinfo-discard-line)
4182 (put 'bigbreak 'texinfo-format 'texinfo-discard-line)
4183 (put 'afourpaper 'texinfo-format 'texinfo-discard-line)
4184 (put 'afivepaper 'texinfo-format 'texinfo-discard-line)
4185 (put 'afourlatex 'texinfo-format 'texinfo-discard-line)
4186 (put 'afourwide 'texinfo-format 'texinfo-discard-line)
4189 ;;; These noop commands discard the rest of the line.
4191 (put 'c 'texinfo-format 'texinfo-discard-line-with-args)
4192 (put 'comment 'texinfo-format 'texinfo-discard-line-with-args)
4193 (put 'contents 'texinfo-format 'texinfo-discard-line-with-args)
4194 (put 'group 'texinfo-end 'texinfo-discard-line-with-args)
4195 (put 'group 'texinfo-format 'texinfo-discard-line-with-args)
4196 (put 'headings 'texinfo-format 'texinfo-discard-line-with-args)
4197 (put 'setchapterstyle 'texinfo-format 'texinfo-discard-line-with-args)
4198 (put 'hsize 'texinfo-format 'texinfo-discard-line-with-args)
4199 (put 'itemindent 'texinfo-format 'texinfo-discard-line-with-args)
4200 (put 'lispnarrowing 'texinfo-format 'texinfo-discard-line-with-args)
4201 (put 'need 'texinfo-format 'texinfo-discard-line-with-args)
4202 (put 'nopara 'texinfo-format 'texinfo-discard-line-with-args)
4204 ;; @novalidate suppresses cross-reference checking and auxiliary file
4205 ;; creation with TeX. The Info-validate command checks that every
4206 ;; node pointer points to an existing node. Since this Info command
4207 ;; is not invoked automatically, the @novalidate command is irrelevant
4208 ;; and not supported by texinfmt.el
4209 (put 'novalidate 'texinfo-format 'texinfo-discard-line-with-args)
4211 (put 'page 'texinfo-format 'texinfo-discard-line-with-args)
4212 (put 'pagesizes 'texinfo-format 'texinfo-discard-line-with-args)
4213 (put 'parindent 'texinfo-format 'texinfo-discard-line-with-args)
4214 (put 'setchapternewpage 'texinfo-format 'texinfo-discard-line-with-args)
4215 (put 'setq 'texinfo-format 'texinfo-discard-line-with-args)
4217 (put 'setcontentsaftertitlepage
4218 'texinfo-format 'texinfo-discard-line-with-args)
4219 (put 'setshortcontentsaftertitlepage
4220 'texinfo-format 'texinfo-discard-line-with-args)
4222 (put 'settitle 'texinfo-format 'texinfo-discard-line-with-args)
4223 (put 'setx 'texinfo-format 'texinfo-discard-line-with-args)
4224 (put 'shortcontents 'texinfo-format 'texinfo-discard-line-with-args)
4225 (put 'shorttitlepage 'texinfo-format 'texinfo-discard-line-with-args)
4226 (put 'summarycontents 'texinfo-format 'texinfo-discard-line-with-args)
4227 (put 'input 'texinfo-format 'texinfo-discard-line-with-args)
4229 (put 'documentlanguage 'texinfo-format 'texinfo-discard-line-with-args)
4230 (put 'documentencoding 'texinfo-format 'texinfo-discard-line-with-args)
4234 ;;; Some commands cannot be handled
4236 (defun texinfo-unsupported ()
4237 (error "%s is not handled by texinfo"
4238 (buffer-substring-no-properties texinfo-command-start texinfo-command-end)))
4240 ;;; Batch formatting
4242 (defun batch-texinfo-format ()
4243 "Run `texinfo-format-buffer' on the files remaining on the command line.
4244 Must be used only with -batch, and kills Emacs on completion.
4245 Each file will be processed even if an error occurred previously.
4246 For example, invoke
4247 \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"."
4248 (if (not noninteractive)
4249 (error "batch-texinfo-format may only be used -batch"))
4250 (let ((version-control t)
4251 (auto-save-default nil)
4252 (find-file-run-dired nil)
4253 (kept-old-versions 259259)
4254 (kept-new-versions 259259))
4255 (let ((error 0)
4256 file
4257 (files ()))
4258 (while command-line-args-left
4259 (setq file (expand-file-name (car command-line-args-left)))
4260 (cond ((not (file-exists-p file))
4261 (message ">> %s does not exist!" file)
4262 (setq error 1
4263 command-line-args-left (cdr command-line-args-left)))
4264 ((file-directory-p file)
4265 (setq command-line-args-left
4266 (nconc (directory-files file)
4267 (cdr command-line-args-left))))
4269 (push file files)
4270 (setq command-line-args-left (cdr command-line-args-left)))))
4271 (while files
4272 (setq file (car files)
4273 files (cdr files))
4274 (condition-case err
4275 (progn
4276 (if buffer-file-name (kill-buffer (current-buffer)))
4277 (find-file file)
4278 (buffer-disable-undo (current-buffer))
4279 (set-buffer-modified-p nil)
4280 (texinfo-mode)
4281 (message "texinfo formatting %s..." file)
4282 (texinfo-format-buffer nil)
4283 (if (buffer-modified-p)
4284 (progn (message "Saving modified %s" (buffer-file-name))
4285 (save-buffer))))
4286 (error
4287 (message ">> Error: %s" (prin1-to-string err))
4288 (message ">> point at")
4289 (let ((s (buffer-substring-no-properties (point)
4290 (min (+ (point) 100)
4291 (point-max))))
4292 (tem 0))
4293 (while (setq tem (string-match "\n+" s tem))
4294 (setq s (concat (substring s 0 (match-beginning 0))
4295 "\n>> "
4296 (substring s (match-end 0)))
4297 tem (1+ tem)))
4298 (message ">> %s" s))
4299 (setq error 1))))
4300 (kill-emacs error))))
4303 ;;; Place `provide' at end of file.
4304 (provide 'texinfmt)
4306 ;; arch-tag: 1e8d9a2d-bca0-40a0-ac6c-dab01bc6f725
4307 ;;; texinfmt.el ends here