1 ;;; texinfmt.el --- format Texinfo files into Info files
3 ;; Copyright (C) 1985-1986, 1988, 1990-1998, 2000-2016 Free Software
6 ;; Maintainer: Robert J. Chassell <bug-texinfo@gnu.org>
7 ;; Keywords: maint, tex, docs
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;;; Emacs lisp functions to convert Texinfo files to Info files.
30 (defvar texinfmt-version
"2.42 of 7 Jul 2006")
32 (defun texinfmt-version (&optional here
)
33 "Show the version of texinfmt.el in the minibuffer.
34 If optional argument HERE is non-nil, insert info at point."
37 (format-message "Version of `texinfmt.el': %s" texinfmt-version
)))
39 (insert version-string
)
40 (if (called-interactively-p 'interactive
)
41 (message "%s" version-string
)
45 ;;; Variable definitions
47 (require 'texinfo
) ; So `texinfo-footnote-style' is defined.
48 (require 'texnfo-upd
) ; So `texinfo-section-types-regexp' is defined.
50 (defvar texinfo-vindex
)
51 (defvar texinfo-findex
)
52 (defvar texinfo-cindex
)
53 (defvar texinfo-pindex
)
54 (defvar texinfo-tindex
)
55 (defvar texinfo-kindex
)
56 (defvar texinfo-last-node
)
57 (defvar texinfo-node-names
)
58 (defvar texinfo-enclosure-list
)
59 (defvar texinfo-alias-list
)
60 (defvar texinfo-fold-nodename-case nil
)
62 (defvar texinfo-command-start
)
63 (defvar texinfo-command-end
)
64 (defvar texinfo-command-name
)
65 (defvar texinfo-defun-type
)
66 (defvar texinfo-last-node-pos
)
67 (defvar texinfo-stack
)
68 (defvar texinfo-short-index-cmds-alist
)
69 (defvar texinfo-short-index-format-cmds-alist
)
70 (defvar texinfo-format-filename
)
71 (defvar texinfo-footnote-number
)
73 (defvar texinfo-raisesections-alist
74 '((@chapter .
@chapter
) ; Cannot go higher
75 (@unnumbered .
@unnumbered
)
76 (@centerchap .
@unnumbered
)
78 (@majorheading .
@majorheading
)
79 (@chapheading .
@chapheading
)
80 (@appendix .
@appendix
)
83 (@unnumberedsec .
@unnumbered
)
84 (@heading .
@chapheading
)
85 (@appendixsec .
@appendix
)
87 (@subsection .
@section
)
88 (@unnumberedsubsec .
@unnumberedsec
)
89 (@subheading .
@heading
)
90 (@appendixsubsec .
@appendixsec
)
92 (@subsubsection .
@subsection
)
93 (@unnumberedsubsubsec .
@unnumberedsubsec
)
94 (@subsubheading .
@subheading
)
95 (@appendixsubsubsec .
@appendixsubsec
))
96 "An alist of next higher levels for chapters, sections, etc...
97 For example, section to chapter, subsection to section.
98 Used by `texinfo-raise-lower-sections'.
99 The keys specify types of section; the values correspond to the next
102 (defvar texinfo-lowersections-alist
103 '((@chapter .
@section
)
104 (@unnumbered .
@unnumberedsec
)
105 (@centerchap .
@unnumberedsec
)
106 (@majorheading .
@heading
)
107 (@chapheading .
@heading
)
108 (@appendix .
@appendixsec
)
110 (@section .
@subsection
)
111 (@unnumberedsec .
@unnumberedsubsec
)
112 (@heading .
@subheading
)
113 (@appendixsec .
@appendixsubsec
)
115 (@subsection .
@subsubsection
)
116 (@unnumberedsubsec .
@unnumberedsubsubsec
)
117 (@subheading .
@subsubheading
)
118 (@appendixsubsec .
@appendixsubsubsec
)
120 (@subsubsection .
@subsubsection
) ; Cannot go lower.
121 (@unnumberedsubsubsec .
@unnumberedsubsubsec
)
122 (@subsubheading .
@subsubheading
)
123 (@appendixsubsubsec .
@appendixsubsubsec
))
124 "An alist of next lower levels for chapters, sections, etc...
125 For example, chapter to section, section to subsection.
126 Used by `texinfo-raise-lower-sections'.
127 The keys specify types of section; the values correspond to the next
132 (defvar texinfo-format-syntax-table
133 (let ((st (make-syntax-table)))
134 (modify-syntax-entry ?
\" " " st
)
135 (modify-syntax-entry ?
\\ " " st
)
136 (modify-syntax-entry ?
@ "\\" st
)
137 (modify-syntax-entry ?\^q
"\\" st
)
138 (modify-syntax-entry ?\
[ "." 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
)
148 ;;; Top level buffer and region formatting functions
151 (defun texinfo-format-buffer (&optional nosplit
)
152 "Process the current buffer as texinfo code, into an Info file.
153 The Info file output is generated in a buffer visiting the Info file
154 name specified in the @setfilename command.
156 Non-nil argument (prefix, if interactive) means don't make tag table
157 and don't split the file if large. You can use `Info-tagify' and
158 `Info-split' to do these manually."
160 (let ((lastmessage "Formatting Info file...")
161 (coding-system-for-write buffer-file-coding-system
))
162 (message lastmessage
)
164 (texinfo-format-buffer-1)
168 (if (> (buffer-size) (+ 50000 Info-split-threshold
))
170 (message (setq lastmessage
"Splitting Info file..."))
172 (message (concat lastmessage
173 (if (called-interactively-p 'interactive
)
174 "done. Now save it." "done.")))))
176 (defvar texinfo-region-buffer-name
"*Info Region*"
177 "Name of the temporary buffer used by \\[texinfo-format-region].")
179 (defvar texinfo-pre-format-hook nil
180 "Hook called before the conversion of the Texinfo file to Info format.
181 The functions on this hook are called with argument BUFFER, the buffer
182 containing the Texinfo file.")
184 ;; These come from tex-mode.el.
185 (defvar tex-start-of-header
)
186 (defvar tex-end-of-header
)
189 (defun texinfo-format-region (region-beginning region-end
)
190 "Convert the current region of the Texinfo file to Info format.
191 This lets you see what that part of the file will look like in Info.
192 The command is bound to \\[texinfo-format-region]. The text that is
193 converted to Info is stored in a temporary buffer."
195 (message "Converting region to Info format...")
196 (let (texinfo-command-start
206 (texinfo-format-filename "")
207 texinfo-example-start
208 texinfo-last-node-pos
211 (texinfo-footnote-number 0)
213 (fill-column-for-info fill-column
)
214 (input-buffer (current-buffer))
215 (input-directory default-directory
)
220 ;;; Copy lines between beginning and end of header lines,
221 ;;; if any, or else copy the `@setfilename' line, if any.
225 (goto-char (point-min))
226 (let ((search-end (line-beginning-position 101)))
228 ;; Either copy header text.
231 (search-forward tex-start-of-header search-end t
)
233 ;; Mark beginning of header.
234 (setq header-beginning
(point)))
236 (search-forward tex-end-of-header nil t
)
238 ;; Mark end of header
239 (setq header-end
(point))))
240 ;; Or copy @filename line.
242 (goto-char (point-min))
243 (search-forward "@setfilename" search-end t
)
245 (setq header-beginning
(point))
247 (setq header-end
(point))))
251 (buffer-substring-no-properties
252 (min header-beginning region-beginning
)
255 ;;; Find a buffer to use.
256 (switch-to-buffer (get-buffer-create texinfo-region-buffer-name
))
257 (setq buffer-read-only t
)
258 (let ((inhibit-read-only t
))
260 ;; Insert the header into the buffer.
262 ;; Insert the region into the buffer.
263 (insert-buffer-substring
265 (max region-beginning header-end
)
267 (run-hook-with-args 'texinfo-pre-format-hook input-buffer
)
268 ;; Make sure region ends in a newline.
269 (or (= (preceding-char) ?
\n)
272 (goto-char (point-min))
274 (message "Converting region to Info format...")
275 (setq fill-column fill-column-for-info
)
276 ;; Install a syntax table useful for scanning command operands.
277 (set-syntax-table texinfo-format-syntax-table
)
279 ;; Insert @include files so `texinfo-raise-lower-sections' can
280 ;; work on them without losing track of multiple
281 ;; @raise/@lowersections commands.
282 (while (re-search-forward "^@include" nil t
)
283 (setq texinfo-command-end
(point))
284 (let ((filename (concat input-directory
285 (texinfo-parse-line-arg))))
286 (re-search-backward "^@include")
287 (delete-region (point) (line-beginning-position 2))
288 (message "Reading included file: %s" filename
)
293 (+ (point) (car (cdr (insert-file-contents filename
)))))
294 (goto-char (point-min))
295 ;; Remove `@setfilename' line from included file, if any,
296 ;; so @setfilename command not duplicated.
297 (if (re-search-forward "^@setfilename" (line-end-position 100) t
)
298 (delete-region (line-beginning-position 1)
299 (line-beginning-position 2)))))))
301 ;; Raise or lower level of each section, if necessary.
302 (goto-char (point-min))
303 (texinfo-raise-lower-sections)
304 ;; Append @refill to appropriate paragraphs for filling.
305 (goto-char (point-min))
306 (texinfo-append-refill)
307 ;; If the region includes the effective end of the data,
308 ;; discard everything after that.
309 (goto-char (point-max))
310 (if (re-search-backward "^@bye" nil t
)
311 (delete-region (point) (point-max)))
312 ;; Make sure buffer ends in a newline.
313 (or (= (preceding-char) ?
\n)
315 ;; Don't use a previous value of texinfo-enclosure-list.
316 (setq texinfo-enclosure-list nil
)
317 (setq texinfo-alias-list nil
)
319 (goto-char (point-min))
320 (if (looking-at "\\\\input[ \t]+texinfo")
321 (delete-region (point) (line-beginning-position 2)))
323 ;; Insert Info region title text.
324 (goto-char (point-min))
325 (if (search-forward "@setfilename" (line-beginning-position 101) t
)
327 (setq texinfo-command-end
(point))
329 (setq texinfo-command-start
(point))
330 (let ((arg (texinfo-parse-arg-discard)))
332 texinfo-region-buffer-name
333 (format-message " buffer for: `"))
334 (insert (file-name-nondirectory (expand-file-name arg
)))
335 (insert (format-message "', -*-Text-*-\n"))))
336 ;; Else no `@setfilename' line
338 texinfo-region-buffer-name
339 " buffer -*-Text-*-\n"))
340 (insert (format-message "produced by `texinfo-format-region'\n")
342 (if (buffer-file-name input-buffer
)
343 (format-message "`%s'"
344 (file-name-sans-versions
345 (file-name-nondirectory
346 (buffer-file-name input-buffer
))))
347 (format-message "buffer `%s'" (buffer-name input-buffer
)))
348 (format-message "\nusing `texinfmt.el' version ")
352 ;; Now convert for real.
353 (goto-char (point-min))
354 (texinfo-format-scan)
355 (goto-char (point-min))
356 (Info-tagify input-buffer
)
357 (goto-char (point-min))
361 (defun texi2info (&optional nosplit
)
362 "Convert the current buffer (written in Texinfo code) into an Info file.
363 The Info file output is generated in a buffer visiting the Info file
364 names specified in the @setfilename command.
366 This function automatically updates all node pointers and menus, and
367 creates a master menu. This work is done on a temporary buffer that
368 is automatically removed when the Info file is created. The original
369 Texinfo source buffer is not changed.
371 Non-nil argument (prefix, if interactive) means don't split the file
372 if large. You can use `Info-split' to do this manually."
374 (let ((temp-buffer (concat "*--" (buffer-name) "--temporary-buffer*" )))
375 (message "First updating nodes and menus, then creating Info file.")
377 (copy-to-buffer temp-buffer
(point-min) (point-max))
378 (switch-to-buffer temp-buffer
)
379 (texinfo-master-menu t
)
380 (message "Now creating Info file.")
382 (texinfo-format-buffer nosplit
)
384 (kill-buffer temp-buffer
)))
387 ;;; Primary internal formatting function for the whole buffer.
389 (defun texinfo-format-buffer-1 ()
390 (let (texinfo-format-filename
391 texinfo-example-start
392 texinfo-command-start
396 texinfo-last-node-pos
405 (texinfo-footnote-number 0)
408 (fill-column-for-info fill-column
)
409 (input-buffer (current-buffer))
410 (input-directory default-directory
))
411 (setq texinfo-enclosure-list nil
)
412 (setq texinfo-alias-list nil
)
414 (goto-char (point-min))
415 (or (search-forward "@setfilename" nil t
)
416 (error "Texinfo file needs an `@setfilename FILENAME' line"))
417 (setq texinfo-command-end
(point))
418 (setq outfile
(texinfo-parse-line-arg)))
423 (buffer-disable-undo)
425 (message "Formatting Info file: %s" outfile
)
426 (setq texinfo-format-filename
427 (file-name-nondirectory (expand-file-name outfile
)))
429 (setq fill-column fill-column-for-info
)
430 (set-syntax-table texinfo-format-syntax-table
)
432 (insert-buffer-substring input-buffer
)
433 (run-hook-with-args 'texinfo-pre-format-hook input-buffer
)
434 (message "Converting %s to Info format..." (buffer-name input-buffer
))
436 ;; Insert @include files so `texinfo-raise-lower-sections' can
437 ;; work on them without losing track of multiple
438 ;; @raise/@lowersections commands.
439 (goto-char (point-min))
440 (while (re-search-forward "^@include" nil t
)
441 (setq texinfo-command-end
(point))
442 (let ((filename (concat input-directory
443 (texinfo-parse-line-arg))))
444 (re-search-backward "^@include")
445 (delete-region (point) (line-beginning-position 2))
446 (message "Reading included file: %s" filename
)
451 (+ (point) (car (cdr (insert-file-contents filename
)))))
452 (goto-char (point-min))
453 ;; Remove `@setfilename' line from included file, if any,
454 ;; so @setfilename command not duplicated.
455 (if (re-search-forward "^@setfilename" (line-end-position 100) t
)
456 (delete-region (line-beginning-position 1)
457 (line-beginning-position 2)))))))
458 ;; Raise or lower level of each section, if necessary.
459 (goto-char (point-min))
460 (texinfo-raise-lower-sections)
461 ;; Append @refill to appropriate paragraphs
462 (goto-char (point-min))
463 (texinfo-append-refill)
464 (goto-char (point-min))
465 (search-forward "@setfilename")
467 (delete-region (point-min) (point))
468 ;; Remove @bye at end of file, if it is there.
469 (goto-char (point-max))
470 (if (search-backward "@bye" nil t
)
471 (delete-region (point) (point-max)))
472 ;; Make sure buffer ends in a newline.
473 (or (= (preceding-char) ?
\n)
475 ;; Scan the whole buffer, converting to Info format.
476 (texinfo-format-scan)
477 (goto-char (point-min))
478 ;; Insert info about how this file was made.
479 (insert "Info file: "
480 texinfo-format-filename
", -*-Text-*-\n"
481 (format-message "produced by `texinfo-format-buffer'\n")
482 ;; Date string removed so that regression testing is easier.
484 ;; (insert (format-time-string "%e %b %Y")) " "
486 (if (buffer-file-name input-buffer
)
487 (format-message " `%s'"
488 (file-name-sans-versions
489 (file-name-nondirectory
490 (buffer-file-name input-buffer
))))
491 (format-message "buffer `%s'" (buffer-name input-buffer
)))
492 (format-message "\nusing `texinfmt.el' version ")
495 ;; Return data for indices.
497 texinfo-vindex texinfo-findex texinfo-cindex
498 texinfo-pindex texinfo-tindex texinfo-kindex
)))
501 ;;; Perform non-@-command file conversions: quotes and hyphens
503 (defun texinfo-format-convert (min max
)
504 ;; Convert left and right quotes to typewriter font quotes.
506 (while (search-forward "``" max t
)
507 (replace-match "\""))
509 (while (search-forward "''" max t
)
510 (replace-match "\""))
511 ;; Convert three hyphens in a row to two.
513 (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t
)
514 (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning 2)))))
517 ;;; Handle paragraph filling
519 ;; Keep as concatenated lists for ease of maintenance
521 (defvar texinfo-no-refill-regexp
525 ;; add "itemize\\|" (from experiment of 2001 Nov 28)
526 ;; because of a problem with @end itemize@refill
527 ;; I don't know if this causes other problems.
528 ;; I suspect itemized lists don't get filled properly and a
529 ;; more precise fix is required. Bob
530 ;; commented out on 2005 Feb 28 by Bob
551 "Regexp specifying environments in which paragraphs are not filled.")
553 (defvar texinfo-accent-commands
586 (defvar texinfo-part-of-para-regexp
621 "@-\\|" ; @- is a discretionary hyphen (not an accent) (a noop).
622 texinfo-accent-commands
625 "Regexp specifying @-commands found within paragraphs.")
627 (defun texinfo-append-refill ()
628 "Append @refill at end of each paragraph that should be filled.
629 Do not append @refill to paragraphs within @example and similar environments.
630 Do not append @refill to paragraphs containing @w{TEXT} or @*."
632 ;; It is necessary to append @refill before other processing because
633 ;; the other processing removes information that tells Texinfo
634 ;; whether the text should or should not be filled.
636 (while (< (point) (point-max))
637 (let ((refill-blank-lines "^[ \t\n]*$")
638 (case-fold-search nil
)) ; Don't confuse @TeX and @tex....
640 ;; 1. Skip over blank lines;
641 ;; skip over lines beginning with @-commands,
642 ;; but do not skip over lines
643 ;; that are no-refill environments such as @example or
644 ;; that begin with within-paragraph @-commands such as @code.
645 (while (and (looking-at (concat "^@\\|^\\\\\\|" refill-blank-lines
))
649 texinfo-no-refill-regexp
651 texinfo-part-of-para-regexp
653 (< (point) (point-max)))
655 ;; 2. Skip over @example and similar no-refill environments.
656 (if (looking-at texinfo-no-refill-regexp
)
657 (let ((environment (match-string-no-properties 1)))
658 (progn (re-search-forward (concat "^@end " environment
) nil t
)
661 ;; 3. Do not refill a paragraph containing @w or @*, or ending
662 ;; with @<newline> followed by a newline.
663 (if (or (>= (point) (point-max))
666 (save-excursion (forward-paragraph)
667 (line-beginning-position 2))
669 ;; Go to end of paragraph and do nothing.
671 ;; 4. Else go to end of paragraph and insert @refill
674 (let ((line-beg (point)))
678 (save-excursion (skip-chars-backward " \t") (point)))
680 (unless (re-search-backward "@c[ \t\n]\\|@comment[ \t\n]" line-beg t
)
682 (unless (re-search-backward "@refill\\|^[ \t]*@" line-beg t
)
684 (forward-line 1))))))
687 ;;; Handle `@raisesections' and `@lowersections' commands
689 ;; These commands change the hierarchical level of chapter structuring
692 ;; @raisesections changes @subsection to @section,
693 ;; @section to @chapter,
696 ;; @lowersections changes @chapter to @section
697 ;; @subsection to @subsubsection,
700 ;; An @raisesections/@lowersections command changes only those
701 ;; structuring commands that follow the @raisesections/@lowersections
704 ;; Repeated @raisesections/@lowersections continue to raise or lower
705 ;; the heading level.
707 ;; An @lowersections command cancels an @raisesections command, and
710 ;; You cannot raise or lower "beyond" chapters or subsubsections, but
711 ;; trying to do so does not elicit an error---you just get more
712 ;; headings that mean the same thing as you keep raising or lowering
713 ;; (for example, after a single @raisesections, both @chapter and
714 ;; @section produce chapter headings).
716 (defun texinfo-raise-lower-sections ()
717 "Raise or lower the hierarchical level of chapters, sections, etc.
719 This function acts according to `@raisesections' and `@lowersections'
720 commands in the Texinfo file.
722 For example, an `@lowersections' command is useful if you wish to
723 include what is written as an outer or standalone Texinfo file in
724 another Texinfo file as an inner, included file. The `@lowersections'
725 command changes chapters to sections, sections to subsections and so
728 @raisesections changes @subsection to @section,
729 @section to @chapter,
730 @heading to @chapheading,
733 @lowersections changes @chapter to @section,
734 @subsection to @subsubsection,
735 @heading to @subheading,
738 An `@raisesections' or `@lowersections' command changes only those
739 structuring commands that follow the `@raisesections' or
740 `@lowersections' command.
742 An `@lowersections' command cancels an `@raisesections' command, and
745 Repeated use of the commands continue to raise or lower the hierarchical
746 level a step at a time.
748 An attempt to raise above `chapters' reproduces chapter commands; an
749 attempt to lower below subsubsections reproduces subsubsection
752 ;; `texinfo-section-types-regexp' is defined in `texnfo-upd.el';
753 ;; it is a regexp matching chapter, section, other headings
754 ;; (but not the top node).
756 (let (type (level 0))
760 "\\(\\(^@\\(raise\\|lower\\)sections\\)\\|\\("
761 texinfo-section-types-regexp
765 (save-excursion (setq type
(read (current-buffer))))
768 ;; 1. Increment level
769 ((eq type
'@raisesections
)
770 (setq level
(1+ level
))
772 (point) (line-beginning-position 2)))
774 ;; 2. Decrement level
775 ((eq type
'@lowersections
)
776 (setq level
(1- level
))
778 (point) (line-beginning-position 2)))
780 ;; Now handle structuring commands
783 ;; 3. Raise level when positive
789 (cdr (assq new-level texinfo-raisesections-alist
)))
790 (setq count
(1- count
)))
792 (insert (symbol-name new-level
))))
794 ;; 4. Do nothing except move point when level is zero
795 ((= level
0) (forward-line 1))
797 ;; 5. Lower level when positive
803 (cdr (assq new-level texinfo-lowersections-alist
)))
804 (setq count
(1+ count
)))
806 (insert (symbol-name new-level
))))))))))
808 ;;; Perform those texinfo-to-info conversions that apply to the whole input
811 (defun texinfo-format-scan ()
812 (texinfo-format-convert (point-min) (point-max))
813 ;; Search for @copying, which has to be first since the
814 ;; @insertcopying command then inserts the text elsewhere.
815 (goto-char (point-min))
816 (when (search-forward "@copying" nil t
)
818 (while (search-forward "@insertcopying" nil t
)
819 (delete-region (match-beginning 0) (match-end 0))
821 (texinfo-insertcopying))
822 ;; Scan for other @-commands.
823 (goto-char (point-min))
824 (while (search-forward "@" nil t
)
826 ;; These are the single-character accent commands: @^ @` @' @" @= @~
827 ;; In Info, they are simply quoted and the @ deleted.
828 ;; Other single-character commands:
829 ;; @* forces a line break,
830 ;; @- is a discretionary hyphenation point; does nothing in Info.
831 ;; @<space>, @<tab>, @<newline> each produce a single space,
832 ;; unless followed by a newline.
834 ;; Old version 2.34 expression: (looking-at "[@{}^'` *\"?!]")
835 (if (looking-at "[@{}^'`\"=~ \t\n*?!-]")
836 ;; @*, causes a line break.
839 ((= (following-char) ?
*)
841 (delete-region (1- (point)) (1+ (point)))
842 ;; insert return if not at end of line;
843 ;; else line is already broken.
844 (if (not (= (following-char) ?
\n))
847 ((= (following-char) ?-
)
848 (delete-region (1- (point)) (1+ (point))))
849 ;; @<space>, @<tab>, @<newline>: produce a single space,
850 ;; unless followed by a newline.
851 ((= (following-char) ?
)
852 (delete-region (1- (point)) (1+ (point)))
853 ;; insert single space if not at end of line;
854 ;; else line is already broken.
855 (if (not (= (following-char) ?
\n))
857 ((= (following-char) ?
\t)
858 (delete-region (1- (point)) (1+ (point)))
859 ;; insert single space if not at end of line;
860 ;; else line is already broken.
861 (if (not (= (following-char) ?
\n))
863 ;; following char is a carriage return
864 ((= (following-char) ?
\n)
866 (delete-region (1- (point)) (1+ (point)))
867 ;; insert single space if not at end of line;
868 ;; else line is already broken.
869 (if (not (= (following-char) ?
\n))
871 ;; Otherwise: the other characters are simply quoted. Delete the @.
874 ;; Be compatible with makeinfo: if @' and its ilk are
875 ;; followed by a @ without a brace, barf.
876 (if (looking-at "[\"'^`~=]")
878 (if (= (char-after (1+ (point))) ?
@)
879 (error "Use braces to give a command as an argument to @%c"
882 ;; @' etc. can optionally accept their argument in
883 ;; braces (makeinfo supports that).
884 (when (looking-at "{")
885 (let ((start (point)))
891 ;; @ is followed by a command-word; find the end of the word.
892 (setq texinfo-command-start
(1- (point)))
893 (if (= (char-syntax (following-char)) ?w
)
896 (setq texinfo-command-end
(point))
897 ;; Detect the case of two @-commands in a row;
898 ;; process just the first one.
899 (goto-char (1+ texinfo-command-start
))
900 (skip-chars-forward "^@" texinfo-command-end
)
901 (setq texinfo-command-end
(point))
902 ;; Handle let aliasing
903 (setq texinfo-command-name
906 (buffer-substring-no-properties
907 (1+ texinfo-command-start
) texinfo-command-end
)))
908 (while (setq trial
(assoc cmdname texinfo-alias-list
))
909 (setq cmdname
(cdr trial
)))
911 ;; Call the handler for this command.
912 (let ((enclosure-type
914 (symbol-name texinfo-command-name
)
915 texinfo-enclosure-list
)))
919 (car (car (cdr enclosure-type
)))
920 (texinfo-parse-arg-discard)
921 (car (cdr (car (cdr enclosure-type
)))))
922 (goto-char texinfo-command-start
))
923 (let ((cmd (get texinfo-command-name
'texinfo-format
)))
924 (if cmd
(funcall cmd
) (texinfo-unsupported)))))))
927 (goto-char (nth 2 (car texinfo-stack
)))
928 (error "Unterminated @%s" (car (car texinfo-stack
)))))
930 ;; Remove excess whitespace
931 (let ((whitespace-silent t
))
932 (whitespace-cleanup)))
934 (defvar texinfo-copying-text
""
935 "Text of the copyright notice and copying permissions.")
937 (defun texinfo-copying ()
938 "Copy the copyright notice and copying permissions from the Texinfo file,
939 as indicated by the @copying ... @end copying command;
940 insert the text with the @insertcopying command."
941 (let ((beg (progn (beginning-of-line) (point)))
942 (end (progn (re-search-forward "^@end copying[ \t]*\n") (point))))
943 (setq texinfo-copying-text
944 (buffer-substring-no-properties
945 (save-excursion (goto-char beg
) (line-beginning-position 2))
946 (save-excursion (goto-char end
) (line-beginning-position 0))))
947 (delete-region beg end
)))
949 (defun texinfo-insertcopying ()
950 "Insert the copyright notice and copying permissions from the Texinfo file,
951 which are indicated by the @copying ... @end copying command."
952 (insert (concat "\n" texinfo-copying-text
)))
954 (put 'begin
'texinfo-format
'texinfo-format-begin
)
955 (defun texinfo-format-begin ()
956 (texinfo-format-begin-end 'texinfo-format
))
958 (put 'end
'texinfo-format
'texinfo-format-end
)
959 (defun texinfo-format-end ()
960 (texinfo-format-begin-end 'texinfo-end
))
962 (defun texinfo-format-begin-end (prop)
963 (setq texinfo-command-name
(intern (texinfo-parse-line-arg)))
964 (let ((cmd (get texinfo-command-name prop
)))
965 (if cmd
(funcall cmd
)
966 (texinfo-unsupported))))
968 ;;; Parsing functions
970 (defun texinfo-parse-line-arg ()
971 "Return argument of @-command as string.
972 Argument is separated from command either by a space or by a brace.
973 If a space, return rest of line, with beginning and ending white
974 space removed. If a brace, return string between braces.
975 Leave point after argument."
976 (goto-char texinfo-command-end
)
977 (let ((start (point)))
978 (cond ((looking-at " ")
979 (skip-chars-forward " ")
982 (skip-chars-backward " ")
983 (delete-region (point) (progn (end-of-line) (point)))
984 (setq texinfo-command-end
(1+ (point))))
986 (setq start
(1+ (point)))
988 (setq texinfo-command-end
(point))
991 (error "Invalid texinfo command arg format")))
992 (prog1 (buffer-substring-no-properties start
(point))
993 (if (eolp) (forward-char 1)))))
995 (defun texinfo-parse-expanded-arg ()
996 (goto-char texinfo-command-end
)
997 (let ((start (point))
999 (cond ((looking-at " ")
1000 (skip-chars-forward " ")
1001 (setq start
(point))
1003 (setq texinfo-command-end
(1+ (point))))
1005 (setq start
(1+ (point)))
1007 (setq texinfo-command-end
(point))
1010 (error "Invalid texinfo command arg format")))
1011 (setq marker
(move-marker (make-marker) texinfo-command-end
))
1012 (texinfo-format-expand-region start
(point))
1013 (setq texinfo-command-end
(marker-position marker
))
1014 (move-marker marker nil
)
1015 (prog1 (buffer-substring-no-properties start
(point))
1016 (if (eolp) (forward-char 1)))))
1018 (defun texinfo-format-expand-region (start end
)
1020 (narrow-to-region start end
)
1021 (let (texinfo-command-start
1023 texinfo-command-name
1025 (texinfo-format-scan))
1026 (goto-char (point-max))))
1028 (defun texinfo-parse-arg-discard ()
1029 "Delete command and argument; return argument of command."
1030 (prog1 (texinfo-parse-line-arg)
1031 (texinfo-discard-command)))
1033 (defun texinfo-discard-command ()
1034 (delete-region texinfo-command-start texinfo-command-end
))
1036 (defun texinfo-optional-braces-discard ()
1037 "Discard braces following command, if any."
1038 (goto-char texinfo-command-end
)
1039 (let ((start (point)))
1040 (cond ((looking-at "[ \t]*\n")) ; do nothing
1041 ((looking-at "{") ; remove braces, if any
1043 (setq texinfo-command-end
(point)))
1046 "Invalid `texinfo-optional-braces-discard' format (need braces?)")))
1047 (delete-region texinfo-command-start texinfo-command-end
)))
1049 (defun texinfo-format-parse-line-args ()
1050 (let ((start (1- (point)))
1053 (skip-chars-forward " ")
1056 (re-search-forward "[\n,]")
1058 (if (bolp) (setq next
(1- next
)))
1060 (skip-chars-backward " ")
1062 (push (if (> end beg
) (buffer-substring-no-properties beg end
))
1065 (skip-chars-forward " "))
1066 (if (eolp) (forward-char 1))
1067 (setq texinfo-command-end
(point))
1070 (defun texinfo-format-parse-args ()
1071 (let ((start (1- (point)))
1074 (search-forward "{")
1076 (texinfo-format-expand-region
1078 (save-excursion (up-list 1) (1- (point)))))
1079 ;; The following does not handle cross references of the form:
1080 ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the
1081 ;; re-search-forward finds the first right brace after the second
1083 (while (/= (preceding-char) ?\
})
1084 (skip-chars-forward " \t\n")
1086 (re-search-forward "[},]")
1089 (skip-chars-backward " \t\n")
1093 (while (search-forward "\n" end t
)
1094 (replace-match " "))))
1095 (push (if (> end beg
) (buffer-substring-no-properties beg end
))
1098 ;;(if (eolp) (forward-char 1))
1099 (setq texinfo-command-end
(point))
1102 (defun texinfo-format-parse-defun-args ()
1103 (goto-char texinfo-command-end
)
1104 (let ((start (point)))
1106 (setq texinfo-command-end
(1+ (point)))
1107 (let ((marker (move-marker (make-marker) texinfo-command-end
)))
1108 (texinfo-format-expand-region start
(point))
1109 (setq texinfo-command-end
(marker-position marker
))
1110 (move-marker marker nil
))
1114 (skip-chars-forward " ")
1116 (cond ((looking-at "{")
1117 (setq beg
(1+ (point)))
1119 (setq end
(1- (point))))
1122 (re-search-forward "[\n ]")
1124 (setq end
(point))))
1125 (push (buffer-substring-no-properties beg end
) args
)
1126 (skip-chars-forward " "))
1130 (defun texinfo-discard-line ()
1131 (goto-char texinfo-command-end
)
1132 (skip-chars-forward " \t")
1134 (error "Extraneous text at end of command line"))
1135 (goto-char texinfo-command-start
)
1137 (error "Extraneous text at beginning of command line"))
1138 (delete-region (point) (progn (forward-line 1) (point))))
1140 (defun texinfo-discard-line-with-args ()
1141 (goto-char texinfo-command-start
)
1142 (delete-region (point) (progn (forward-line 1) (point))))
1147 ;; Only `texinfo-format-buffer' handles @setfilename with this
1148 ;; definition; `texinfo-format-region' handles @setfilename, if any,
1150 (put 'setfilename
'texinfo-format
'texinfo-format-setfilename
)
1151 (defun texinfo-format-setfilename ()
1152 (texinfo-parse-arg-discard))
1154 ;;; @node, @menu, @detailmenu
1156 (put 'node
'texinfo-format
'texinfo-format-node
)
1157 (put 'nwnode
'texinfo-format
'texinfo-format-node
)
1158 (defun texinfo-format-node ()
1159 (let* ((args (texinfo-format-parse-line-args))
1164 (texinfo-discard-command)
1165 (setq texinfo-last-node name
)
1166 (let ((tem (if texinfo-fold-nodename-case
(downcase name
) name
)))
1167 (if (assoc tem texinfo-node-names
)
1168 (error "Duplicate node name: %s" name
)
1169 (push (list tem
) texinfo-node-names
)))
1170 (setq texinfo-footnote-number
0)
1171 ;; insert "\n\^_" unconditionally since this is what info is looking for
1172 (insert "\n\^_\nFile: " texinfo-format-filename
1175 (insert ", Next: " next
))
1177 (insert ", Prev: " prev
))
1179 (insert ", Up: " up
))
1181 (setq texinfo-last-node-pos
(point))))
1183 (put 'anchor
'texinfo-format
'texinfo-anchor
)
1184 (defun texinfo-anchor ()
1186 (here (- (point) 7)) ; save location of beginning of `@anchor'
1187 (arg (texinfo-parse-arg-discard)))
1188 (if (looking-at " ") ; since a space may be left after -discard
1191 (let ((end (point)))
1194 (search-forward "@refill" end t
))
1195 (setq anchor-string
"@anchor-yes-refill")
1196 (setq anchor-string
"@anchor-no-refill")))
1198 (insert anchor-string
"{" arg
"}")))
1200 (put 'menu
'texinfo-format
'texinfo-format-menu
)
1201 (defun texinfo-format-menu ()
1202 (texinfo-discard-line)
1203 (insert "* Menu:\n\n"))
1205 (put 'menu
'texinfo-end
'texinfo-discard-command
)
1207 ;; The @detailmenu should be removed eventually.
1209 ;; According to Karl Berry, 31 August 1996:
1211 ;; You don't like, I don't like it. I agree, it would be better just to
1212 ;; fix the bug [in `makeinfo']. .. At this point, since inserting those
1213 ;; two commands in the Elisp fn is trivial, I don't especially want to
1214 ;; expend more effort...
1216 ;; I added a couple sentences of documentation to the manual (putting the
1217 ;; blame on makeinfo where it belongs :-().
1219 (put 'detailmenu
'texinfo-format
'texinfo-discard-line
)
1220 (put 'detailmenu
'texinfo-end
'texinfo-discard-command
)
1222 ;; (Also see `texnfo-upd.el')
1225 ;;; Cross references
1227 ;; @xref {NODE, FNAME, NAME, FILE, DOCUMENT}
1228 ;; -> *Note FNAME: (FILE)NODE
1229 ;; If FILE is missing,
1230 ;; *Note FNAME: NODE
1231 ;; If FNAME is empty and NAME is present
1233 ;; If both NAME and FNAME are missing
1235 ;; texinfo ignores the DOCUMENT argument.
1236 ;; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1237 ;; If FILE is specified, (FILE)NODE is used for xrefs.
1238 ;; If fifth argument DOCUMENT is specified, produces
1239 ;; See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1242 ;; @ref a reference that does not put `See' or `see' in
1243 ;; the hardcopy and is the same as @xref in Info
1244 (put 'ref
'texinfo-format
'texinfo-format-xref
)
1246 (put 'xref
'texinfo-format
'texinfo-format-xref
)
1247 (defun texinfo-format-xref ()
1248 (let ((args (texinfo-format-parse-args)))
1249 (texinfo-discard-command)
1251 (let ((fname (or (nth 1 args
) (nth 2 args
))))
1252 (if (null (or fname
(nth 3 args
)))
1253 (insert (car args
) "::")
1254 (insert (or fname
(car args
)) ": ")
1256 (insert "(" (nth 3 args
) ")"))
1257 (and (car args
) (insert (car args
)))))))
1259 (put 'pxref
'texinfo-format
'texinfo-format-pxref
)
1260 (defun texinfo-format-pxref ()
1261 (texinfo-format-xref)
1267 ;; @inforef{NODE, FNAME, FILE}
1268 ;; Like @xref{NODE, FNAME,,FILE} in texinfo.
1269 ;; In Tex, generates "See Info file FILE, node NODE"
1270 (put 'inforef
'texinfo-format
'texinfo-format-inforef
)
1271 (defun texinfo-format-inforef ()
1272 (let ((args (texinfo-format-parse-args)))
1273 (texinfo-discard-command)
1275 (insert "*Note " (nth 1 args
) ": (" (nth 2 args
) ")" (car args
))
1276 (insert "*Note " "(" (nth 2 args
) ")" (car args
) "::"))))
1279 ;;; URL Reference: @uref
1281 ;; @uref produces a reference to a uniform resource locator (URL).
1282 ;; It takes one mandatory argument, the URL, and one optional argument,
1283 ;; the text to display (the default is the URL itself).
1285 (put 'uref
'texinfo-format
'texinfo-format-uref
)
1286 (defun texinfo-format-uref ()
1287 "Format URL and optional URL-TITLE.
1288 Insert \\=` ... \\=' around URL if no URL-TITLE argument;
1289 otherwise, insert URL-TITLE followed by URL in parentheses."
1290 (let ((args (texinfo-format-parse-args)))
1291 (texinfo-discard-command)
1294 (insert (nth 1 args
) " (" (nth 0 args
) ")")
1295 (insert "`" (nth 0 args
) "'"))
1296 (goto-char texinfo-command-start
)))
1299 ;;; Section headings
1301 (put 'majorheading
'texinfo-format
'texinfo-format-chapter
)
1302 (put 'chapheading
'texinfo-format
'texinfo-format-chapter
)
1303 (put 'ichapter
'texinfo-format
'texinfo-format-chapter
)
1304 (put 'chapter
'texinfo-format
'texinfo-format-chapter
)
1305 (put 'iappendix
'texinfo-format
'texinfo-format-chapter
)
1306 (put 'appendix
'texinfo-format
'texinfo-format-chapter
)
1307 (put 'iunnumbered
'texinfo-format
'texinfo-format-chapter
)
1308 (put 'top
'texinfo-format
'texinfo-format-chapter
)
1309 (put 'unnumbered
'texinfo-format
'texinfo-format-chapter
)
1310 (put 'centerchap
'texinfo-format
'texinfo-format-chapter
)
1311 (defun texinfo-format-chapter ()
1312 (texinfo-format-chapter-1 ?
*))
1314 (put 'heading
'texinfo-format
'texinfo-format-section
)
1315 (put 'isection
'texinfo-format
'texinfo-format-section
)
1316 (put 'section
'texinfo-format
'texinfo-format-section
)
1317 (put 'iappendixsection
'texinfo-format
'texinfo-format-section
)
1318 (put 'appendixsection
'texinfo-format
'texinfo-format-section
)
1319 (put 'iappendixsec
'texinfo-format
'texinfo-format-section
)
1320 (put 'appendixsec
'texinfo-format
'texinfo-format-section
)
1321 (put 'iunnumberedsec
'texinfo-format
'texinfo-format-section
)
1322 (put 'unnumberedsec
'texinfo-format
'texinfo-format-section
)
1323 (defun texinfo-format-section ()
1324 (texinfo-format-chapter-1 ?
=))
1326 (put 'subheading
'texinfo-format
'texinfo-format-subsection
)
1327 (put 'isubsection
'texinfo-format
'texinfo-format-subsection
)
1328 (put 'subsection
'texinfo-format
'texinfo-format-subsection
)
1329 (put 'iappendixsubsec
'texinfo-format
'texinfo-format-subsection
)
1330 (put 'appendixsubsec
'texinfo-format
'texinfo-format-subsection
)
1331 (put 'iunnumberedsubsec
'texinfo-format
'texinfo-format-subsection
)
1332 (put 'unnumberedsubsec
'texinfo-format
'texinfo-format-subsection
)
1333 (defun texinfo-format-subsection ()
1334 (texinfo-format-chapter-1 ?-
))
1336 (put 'subsubheading
'texinfo-format
'texinfo-format-subsubsection
)
1337 (put 'isubsubsection
'texinfo-format
'texinfo-format-subsubsection
)
1338 (put 'subsubsection
'texinfo-format
'texinfo-format-subsubsection
)
1339 (put 'iappendixsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1340 (put 'appendixsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1341 (put 'iunnumberedsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1342 (put 'unnumberedsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1343 (defun texinfo-format-subsubsection ()
1344 (texinfo-format-chapter-1 ?.
))
1346 (defun texinfo-format-chapter-1 (belowchar)
1347 (let ((arg (texinfo-parse-arg-discard)))
1348 (message "Formatting: %s ... " arg
) ; So we can see where we are.
1349 (insert ?
\n arg ?
\n "@SectionPAD " belowchar ?
\n)
1352 (put 'SectionPAD
'texinfo-format
'texinfo-format-sectionpad
)
1353 (defun texinfo-format-sectionpad ()
1354 (let ((str (texinfo-parse-arg-discard)))
1356 (let ((column (current-column)))
1360 (setq column
(1- column
))))
1364 ;;; Space controlling commands: @. and @:, and the soft hyphen.
1366 (put '\.
'texinfo-format
'texinfo-format-\.
)
1367 (defun texinfo-format-\.
()
1368 (texinfo-discard-command)
1371 (put '\
: 'texinfo-format
'texinfo-format-\
:)
1372 (defun texinfo-format-\
: ()
1373 (texinfo-discard-command))
1375 (put '\-
'texinfo-format
'texinfo-format-soft-hyphen
)
1376 (defun texinfo-format-soft-hyphen ()
1377 (texinfo-discard-command))
1380 ;;; @kbdinputstyle, @vskip, headings & footings
1381 ;; These commands for not for Info and should never
1382 ;; appear in an Info environment; but if they do,
1383 ;; this causes them to be discarded.
1386 (put 'kbdinputstyle
'texinfo-format
'texinfo-discard-line-with-args
)
1389 (put 'vskip
'texinfo-format
'texinfo-discard-line-with-args
)
1391 ;; headings & footings
1392 (put 'evenfooting
'texinfo-format
'texinfo-discard-line-with-args
)
1393 (put 'evenheading
'texinfo-format
'texinfo-discard-line-with-args
)
1394 (put 'oddfooting
'texinfo-format
'texinfo-discard-line-with-args
)
1395 (put 'oddheading
'texinfo-format
'texinfo-discard-line-with-args
)
1396 (put 'everyfooting
'texinfo-format
'texinfo-discard-line-with-args
)
1397 (put 'everyheading
'texinfo-format
'texinfo-discard-line-with-args
)
1400 ;;; @documentdescription ... @end documentdescription
1401 ;; This command is for HTML output and should never
1402 ;; appear in an Info environment; but if it does,
1403 ;; this causes it to be discarded.
1405 (put 'documentdescription
'texinfo-format
'texinfo-format-documentdescription
)
1406 (defun texinfo-format-documentdescription ()
1407 (delete-region texinfo-command-start
1408 (progn (re-search-forward "^@end documentdescription[ \t]*\n")
1413 ;;; @center, @sp, and @br
1415 (put 'center
'texinfo-format
'texinfo-format-center
)
1416 (defun texinfo-format-center ()
1417 (let ((arg (texinfo-parse-expanded-arg)))
1418 (texinfo-discard-command)
1422 (goto-char (1- (point)))
1423 (let ((indent-tabs-mode nil
))
1426 (put 'sp
'texinfo-format
'texinfo-format-sp
)
1427 (defun texinfo-format-sp ()
1428 (let* ((arg (texinfo-parse-arg-discard))
1430 (insert-char ?
\n num
)))
1432 (put 'br
'texinfo-format
'texinfo-format-paragraph-break
)
1433 (defun texinfo-format-paragraph-break ()
1434 "Force a paragraph break.
1435 If used within a line, follow `@br' with braces."
1436 (texinfo-optional-braces-discard)
1437 ;; insert one return if at end of line;
1438 ;; else insert two returns, to generate a blank line.
1439 (if (= (following-char) ?
\n)
1441 (insert-char ?
\n 2)))
1444 ;;; @footnote and @footnotestyle
1446 ;; In Texinfo, footnotes are created with the `@footnote' command.
1447 ;; This command is followed immediately by a left brace, then by the text of
1448 ;; the footnote, and then by a terminating right brace. The
1449 ;; template for a footnote is:
1453 ;; Info has two footnote styles:
1455 ;; * In the End of node style, all the footnotes for a single node
1456 ;; are placed at the end of that node. The footnotes are
1457 ;; separated from the rest of the node by a line of dashes with
1458 ;; the word `Footnotes' within it.
1460 ;; * In the Separate node style, all the footnotes for a single node
1461 ;; are placed in an automatically constructed node of their own.
1463 ;; Footnote style is specified by the @footnotestyle command, either
1464 ;; @footnotestyle separate
1466 ;; @footnotestyle end
1468 ;; The default is separate
1470 (defvar texinfo-footnote-style
"separate"
1471 "Footnote style, either separate or end.")
1473 (put 'footnotestyle
'texinfo-format
'texinfo-footnotestyle
)
1474 (defun texinfo-footnotestyle ()
1475 "Specify whether footnotes are at end of node or in separate nodes.
1476 Argument is either end or separate."
1477 (setq texinfo-footnote-style
(texinfo-parse-arg-discard)))
1479 (put 'footnote
'texinfo-format
'texinfo-format-footnote
)
1480 (defun texinfo-format-footnote ()
1481 "Format a footnote in either end of node or separate node style.
1482 The texinfo-footnote-style variable controls which style is used."
1483 (setq texinfo-footnote-number
(1+ texinfo-footnote-number
))
1484 (cond ((string= texinfo-footnote-style
"end")
1485 (texinfo-format-end-node))
1486 ((string= texinfo-footnote-style
"separate")
1487 (texinfo-format-separate-node))))
1489 (defun texinfo-format-separate-node ()
1490 "Format footnote in Separate node style, with notes in own node.
1491 The node is constructed automatically."
1493 (arg (texinfo-parse-line-arg))
1494 (node-name-beginning
1497 "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:")
1501 (buffer-substring-no-properties
1502 (progn (goto-char node-name-beginning
) ; skip over node command
1503 (skip-chars-forward " \t") ; and over spaces
1505 (if (search-forward "," (line-end-position) t
) ; bound search
1507 (end-of-line) (point))))))
1508 (texinfo-discard-command) ; remove or insert whitespace, as needed
1509 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1511 (insert (format " (%d) (*Note %s-Footnotes::)"
1512 texinfo-footnote-number node-name
))
1513 (fill-paragraph nil
)
1515 (if (re-search-forward "^@node" nil
'move
)
1518 ;; two cases: for the first footnote, we must insert a node header;
1519 ;; for the second and subsequent footnotes, we need only insert
1520 ;; the text of the footnote.
1524 (concat node-name
"-Footnotes, Up: ")
1527 (progn ; already at least one footnote
1528 (setq start
(point))
1529 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1530 (fill-region start
(point)))
1531 ;; else not yet a footnote
1532 (insert "\n\^_\nFile: " texinfo-format-filename
1533 " Node: " node-name
"-Footnotes, Up: " node-name
"\n")
1534 (setq start
(point))
1535 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1536 (narrow-to-region (save-excursion (goto-char start
) (point)) (point))
1537 (fill-region (point-min) (point-max))
1540 (defun texinfo-format-end-node ()
1541 "Format footnote in the End of node style, with notes at end of node."
1543 (arg (texinfo-parse-line-arg)))
1544 (texinfo-discard-command) ; remove or insert whitespace, as needed
1545 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1547 (insert (format " (%d) " texinfo-footnote-number
))
1548 (fill-paragraph nil
)
1550 (if (search-forward "\n--------- Footnotes ---------\n" nil t
)
1551 (progn ; already have footnote, put new one before end of node
1552 (if (re-search-forward "^@node" nil
'move
)
1554 (setq start
(point))
1555 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1556 (fill-region start
(point)))
1557 ;; else no prior footnote
1558 (if (re-search-forward "^@node" nil
'move
)
1560 (insert "\n--------- Footnotes ---------\n")
1561 (setq start
(point))
1562 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))))))
1565 ;;; @itemize, @enumerate, and similar commands
1567 ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.
1568 ;; @enumerate pushes (enumerate 0 STARTPOS).
1569 ;; @item dispatches to the texinfo-item prop of the first elt of the list.
1570 ;; For itemize, this puts in and rescans the COMMANDS.
1571 ;; For enumerate, this increments the number and puts it in.
1572 ;; In either case, it puts a Backspace at the front of the line
1573 ;; which marks it not to be indented later.
1574 ;; All other lines get indented by 5 when the @end is reached.
1576 (defvar texinfo-stack-depth
0
1577 "Count of number of unpopped texinfo-push-stack calls.
1578 Used by @refill indenting command to avoid indenting within lists, etc.")
1580 (defun texinfo-push-stack (check arg
)
1581 (setq texinfo-stack-depth
(1+ texinfo-stack-depth
))
1582 (push (list check arg texinfo-command-start
)
1585 (defun texinfo-pop-stack (check)
1586 (setq texinfo-stack-depth
(1- texinfo-stack-depth
))
1587 (if (null texinfo-stack
)
1588 (error "Unmatched @end %s" check
))
1589 (if (not (eq (car (car texinfo-stack
)) check
))
1590 (error "@end %s matches @%s"
1591 check
(car (car texinfo-stack
))))
1592 (prog1 (cdr (car texinfo-stack
))
1593 (setq texinfo-stack
(cdr texinfo-stack
))))
1595 (put 'itemize
'texinfo-format
'texinfo-itemize
)
1596 (defun texinfo-itemize ()
1599 (progn (skip-chars-forward " \t")
1602 (texinfo-parse-line-arg))))
1603 (texinfo-discard-line-with-args)
1604 (setq fill-column
(- fill-column
5)))
1606 (put 'itemize
'texinfo-end
'texinfo-end-itemize
)
1607 (defun texinfo-end-itemize ()
1608 (setq fill-column
(+ fill-column
5))
1609 (texinfo-discard-command)
1611 (texinfo-pop-stack 'itemize
)))
1612 (texinfo-do-itemize (nth 1 stacktop
))))
1614 (put 'enumerate
'texinfo-format
'texinfo-enumerate
)
1615 (defun texinfo-enumerate ()
1618 (progn (skip-chars-forward " \t")
1621 (read (current-buffer)))))
1622 (if (and (symbolp (car (cdr (car texinfo-stack
))))
1623 (> 1 (length (symbol-name (car (cdr (car texinfo-stack
)))))))
1625 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." ))
1626 (texinfo-discard-line-with-args)
1627 (setq fill-column
(- fill-column
5)))
1629 (put 'enumerate
'texinfo-end
'texinfo-end-enumerate
)
1630 (defun texinfo-end-enumerate ()
1631 (setq fill-column
(+ fill-column
5))
1632 (texinfo-discard-command)
1634 (texinfo-pop-stack 'enumerate
)))
1635 (texinfo-do-itemize (nth 1 stacktop
))))
1637 ;; @alphaenumerate never became a standard part of Texinfo
1638 (put 'alphaenumerate
'texinfo-format
'texinfo-alphaenumerate
)
1639 (defun texinfo-alphaenumerate ()
1640 (texinfo-push-stack 'alphaenumerate
(1- ?a
))
1641 (setq fill-column
(- fill-column
5))
1642 (texinfo-discard-line))
1644 (put 'alphaenumerate
'texinfo-end
'texinfo-end-alphaenumerate
)
1645 (defun texinfo-end-alphaenumerate ()
1646 (setq fill-column
(+ fill-column
5))
1647 (texinfo-discard-command)
1649 (texinfo-pop-stack 'alphaenumerate
)))
1650 (texinfo-do-itemize (nth 1 stacktop
))))
1652 ;; @capsenumerate never became a standard part of Texinfo
1653 (put 'capsenumerate
'texinfo-format
'texinfo-capsenumerate
)
1654 (defun texinfo-capsenumerate ()
1655 (texinfo-push-stack 'capsenumerate
(1- ?A
))
1656 (setq fill-column
(- fill-column
5))
1657 (texinfo-discard-line))
1659 (put 'capsenumerate
'texinfo-end
'texinfo-end-capsenumerate
)
1660 (defun texinfo-end-capsenumerate ()
1661 (setq fill-column
(+ fill-column
5))
1662 (texinfo-discard-command)
1664 (texinfo-pop-stack 'capsenumerate
)))
1665 (texinfo-do-itemize (nth 1 stacktop
))))
1667 ;; At the @end, indent all the lines within the construct
1668 ;; except those marked with backspace. FROM says where
1669 ;; construct started.
1670 (defun texinfo-do-itemize (from)
1672 (while (progn (forward-line -
1)
1674 (if (= (following-char) ?
\b)
1679 (if (not (looking-at "[ \t]*$"))
1680 (save-excursion (insert " ")))))))
1682 (put 'item
'texinfo-format
'texinfo-item
)
1683 (put 'itemx
'texinfo-format
'texinfo-item
)
1684 (defun texinfo-item ()
1685 (funcall (get (car (car texinfo-stack
)) 'texinfo-item
)))
1687 (put 'itemize
'texinfo-item
'texinfo-itemize-item
)
1688 (defun texinfo-itemize-item ()
1689 ;; (texinfo-discard-line) ; Did not handle text on same line as @item.
1690 (delete-region (1+ (point)) (line-beginning-position))
1691 (if (looking-at "[ \t]*[^ \t\n]+")
1692 ;; Text on same line as @item command.
1693 (insert "\b " (nth 1 (car texinfo-stack
)) " \n")
1694 ;; Else text on next line.
1695 (insert "\b " (nth 1 (car texinfo-stack
)) " "))
1698 (put 'enumerate
'texinfo-item
'texinfo-enumerate-item
)
1699 (defun texinfo-enumerate-item ()
1700 (texinfo-discard-line)
1701 (let (enumerating-symbol)
1702 (cond ((integerp (car (cdr (car texinfo-stack
))))
1703 (setq enumerating-symbol
(car (cdr (car texinfo-stack
))))
1704 (insert ?
\b (format "%3d. " enumerating-symbol
) ?
\n)
1705 (setcar (cdr (car texinfo-stack
)) (1+ enumerating-symbol
)))
1706 ((symbolp (car (cdr (car texinfo-stack
))))
1707 (setq enumerating-symbol
1708 (symbol-name (car (cdr (car texinfo-stack
)))))
1709 (if (or (equal ?\
[ (string-to-char enumerating-symbol
))
1710 (equal ?\
{ (string-to-char enumerating-symbol
)))
1712 "Too many items in enumerated list; alphabet ends at Z."))
1713 (insert ?
\b (format "%3s. " enumerating-symbol
) ?
\n)
1714 (setcar (cdr (car texinfo-stack
))
1718 (string-to-char enumerating-symbol
))))))
1721 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." )))
1724 (put 'alphaenumerate
'texinfo-item
'texinfo-alphaenumerate-item
)
1725 (defun texinfo-alphaenumerate-item ()
1726 (texinfo-discard-line)
1727 (let ((next (1+ (car (cdr (car texinfo-stack
))))))
1729 (error "More than 26 items in @alphaenumerate; get a bigger alphabet"))
1730 (setcar (cdr (car texinfo-stack
)) next
)
1731 (insert "\b " next
". \n"))
1734 (put 'capsenumerate
'texinfo-item
'texinfo-capsenumerate-item
)
1735 (defun texinfo-capsenumerate-item ()
1736 (texinfo-discard-line)
1737 (let ((next (1+ (car (cdr (car texinfo-stack
))))))
1739 (error "More than 26 items in @capsenumerate; get a bigger alphabet"))
1740 (setcar (cdr (car texinfo-stack
)) next
)
1741 (insert "\b " next
". \n"))
1747 ;; The `@table' command produces two-column tables.
1749 (put 'table
'texinfo-format
'texinfo-table
)
1750 (defun texinfo-table ()
1753 (progn (skip-chars-forward " \t")
1756 (texinfo-parse-line-arg))))
1757 (texinfo-discard-line-with-args)
1758 (setq fill-column
(- fill-column
5)))
1760 (put 'table
'texinfo-item
'texinfo-table-item
)
1761 (defun texinfo-table-item ()
1762 (let ((arg (texinfo-parse-arg-discard))
1763 (itemfont (car (cdr (car texinfo-stack
)))))
1764 (insert ?
\b itemfont ?\
{ arg
"}\n \n"))
1767 (put 'table
'texinfo-end
'texinfo-end-table
)
1768 (defun texinfo-end-table ()
1769 (setq fill-column
(+ fill-column
5))
1770 (texinfo-discard-command)
1772 (texinfo-pop-stack 'table
)))
1773 (texinfo-do-itemize (nth 1 stacktop
))))
1775 ;; @description appears to be an undocumented variant on @table that
1776 ;; does not require an arg. It fails in texinfo.tex 2.58 and is not
1777 ;; part of makeinfo.c The command appears to be a relic of the past.
1778 (put 'description
'texinfo-end
'texinfo-end-table
)
1779 (put 'description
'texinfo-format
'texinfo-description
)
1780 (defun texinfo-description ()
1781 (texinfo-push-stack 'table
"@asis")
1782 (setq fill-column
(- fill-column
5))
1783 (texinfo-discard-line))
1786 ;;; @ftable, @vtable
1788 ;; The `@ftable' and `@vtable' commands are like the `@table' command
1789 ;; but they also insert each entry in the first column of the table
1790 ;; into the function or variable index.
1792 ;; Handle the @ftable and @vtable commands:
1794 (put 'ftable
'texinfo-format
'texinfo-ftable
)
1795 (put 'vtable
'texinfo-format
'texinfo-vtable
)
1797 (defun texinfo-ftable () (texinfo-indextable 'ftable
))
1798 (defun texinfo-vtable () (texinfo-indextable 'vtable
))
1800 (defun texinfo-indextable (table-type)
1801 (texinfo-push-stack table-type
(texinfo-parse-arg-discard))
1802 (setq fill-column
(- fill-column
5)))
1804 ;; Handle the @item commands within ftable and vtable:
1806 (put 'ftable
'texinfo-item
'texinfo-ftable-item
)
1807 (put 'vtable
'texinfo-item
'texinfo-vtable-item
)
1809 (defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex
))
1810 (defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex
))
1812 (defun texinfo-indextable-item (index-type)
1813 (let ((item (texinfo-parse-arg-discard))
1814 (itemfont (car (cdr (car texinfo-stack
))))
1815 (indexvar index-type
))
1816 (insert ?
\b itemfont ?\
{ item
"}\n \n")
1819 (list item texinfo-last-node
)
1820 (symbol-value indexvar
)))
1823 ;; Handle @end ftable, @end vtable
1825 (put 'ftable
'texinfo-end
'texinfo-end-ftable
)
1826 (put 'vtable
'texinfo-end
'texinfo-end-vtable
)
1828 (defun texinfo-end-ftable () (texinfo-end-indextable 'ftable
))
1829 (defun texinfo-end-vtable () (texinfo-end-indextable 'vtable
))
1831 (defun texinfo-end-indextable (table-type)
1832 (setq fill-column
(+ fill-column
5))
1833 (texinfo-discard-command)
1835 (texinfo-pop-stack table-type
)))
1836 (texinfo-do-itemize (nth 1 stacktop
))))
1839 ;;; @multitable ... @end multitable
1841 ;; Produce a multi-column table, with as many columns as desired.
1843 ;; A multi-column table has this template:
1845 ;; @multitable {A1} {A2} {A3}
1846 ;; @item A1 @tab A2 @tab A3
1847 ;; @item B1 @tab B2 @tab B3
1848 ;; @item C1 @tab C2 @tab C3
1851 ;; where the width of the text in brackets specifies the width of the
1852 ;; respective column.
1856 ;; @multitable @columnfractions .25 .3 .45
1857 ;; @item A1 @tab A2 @tab A3
1858 ;; @item B1 @tab B2 @tab B3
1861 ;; where the fractions specify the width of each column as a percent
1862 ;; of the current width of the text (i.e., of the fill-column).
1864 ;; Long lines of text are filled within columns.
1866 ;; Using the Emacs Lisp formatter, texinfmt.el,
1867 ;; the whitespace between columns can be increased by setting
1868 ;; `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1869 ;; there is at least one blank space between columns.
1871 ;; The Emacs Lisp formatter, texinfmt.el, ignores the following four
1872 ;; commands that are defined in texinfo.tex for printed output.
1874 ;; @multitableparskip,
1875 ;; @multitableparindent,
1876 ;; @multitablecolmargin,
1877 ;; @multitablelinespace.
1879 ;; How @multitable works.
1880 ;; =====================
1882 ;; `texinfo-multitable' reads the @multitable line and determines from it
1883 ;; how wide each column should be.
1885 ;; Also, it pushes this information, along with an identifying symbol,
1886 ;; onto the `texinfo-stack'. At the @end multitable command, the stack
1887 ;; is checked for its matching @multitable command, and then popped, or
1888 ;; else an error is signaled. Also, this command pushes the location of
1889 ;; the start of the table onto the stack.
1891 ;; `texinfo-end-multitable' checks the `texinfo-stack' that the @end
1892 ;; multitable truly is ending a corresponding beginning, and if it is,
1895 ;; `texinfo-multitable-widths' is called by `texinfo-multitable'.
1896 ;; The function returns a list of the widths of each column in a
1897 ;; multi-column table, based on the information supplied by the arguments
1898 ;; to the @multitable command (by arguments, I mean the text on the rest
1899 ;; of the @multitable line, not the remainder of the multi-column table
1902 ;; `texinfo-multitable-item' formats a row within a multicolumn table.
1903 ;; This command is executed when texinfmt sees @item inside @multitable.
1904 ;; Cells in row are separated by `@tab's. Widths of cells are specified
1905 ;; by the arguments in the @multitable line. Cells are filled. All cells
1906 ;; are made to be the same height by padding their bottoms, as needed,
1909 ;; `texinfo-multitable-extract-row' is called by `texinfo-multitable-item'.
1910 ;; This function returns the text in a multitable row, as a string.
1911 ;; The start of a row is marked by an @item and the end of row is the
1912 ;; beginning of next @item or beginning of the @end multitable line.
1913 ;; Cells within a row are separated by @tab.
1915 ;; Note that @tab, the cell separators, are not treated as independent
1916 ;; Texinfo commands.
1918 (defvar texinfo-extra-inter-column-width
0
1919 "Number of extra spaces between entries (columns) in @multitable.")
1921 (defvar texinfo-multitable-buffer-name
"*multitable-temporary-buffer*")
1922 (defvar texinfo-multitable-rectangle-name
"texinfo-multitable-temp-")
1924 ;; These commands are defined in texinfo.tex for printed output.
1925 (put 'multitableparskip
'texinfo-format
'texinfo-discard-line-with-args
)
1926 (put 'multitableparindent
'texinfo-format
'texinfo-discard-line-with-args
)
1927 (put 'multitablecolmargin
'texinfo-format
'texinfo-discard-line-with-args
)
1928 (put 'multitablelinespace
'texinfo-format
'texinfo-discard-line-with-args
)
1930 (put 'multitable
'texinfo-format
'texinfo-multitable
)
1932 (defun texinfo-multitable ()
1933 "Produce multi-column tables.
1935 A multi-column table has this template:
1937 @multitable {A1} {A2} {A3}
1938 @item A1 @tab A2 @tab A3
1939 @item B1 @tab B2 @tab B3
1940 @item C1 @tab C2 @tab C3
1943 where the width of the text in brackets specifies the width of the
1948 @multitable @columnfractions .25 .3 .45
1949 @item A1 @tab A2 @tab A3
1950 @item B1 @tab B2 @tab B3
1953 where the fractions specify the width of each column as a percent
1954 of the current width of the text (i.e., of the `fill-column').
1956 Long lines of text are filled within columns.
1958 Using the Emacs Lisp formatter, texinfmt.el,
1959 the whitespace between columns can be increased by setting
1960 `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1961 there is at least one blank space between columns.
1963 The Emacs Lisp formatter, texinfmt.el, ignores the following four
1964 commands that are defined in texinfo.tex for printed output.
1967 @multitableparindent,
1968 @multitablecolmargin,
1969 @multitablelinespace."
1971 ;; This function pushes information onto the `texinfo-stack'.
1972 ;; A stack element consists of:
1973 ;; - type-of-command, i.e., multitable
1974 ;; - the information about column widths, and
1975 ;; - the position of texinfo-command-start.
1976 ;; e.g., ('multitable (1 2 3 4) 123)
1977 ;; The command line is then deleted.
1980 ;; push width information on stack
1981 (texinfo-multitable-widths))
1982 (texinfo-discard-line-with-args))
1984 (put 'multitable
'texinfo-end
'texinfo-end-multitable
)
1985 (defun texinfo-end-multitable ()
1986 "Discard the @end multitable line and pop the stack of multitable."
1987 (texinfo-discard-command)
1988 (texinfo-pop-stack 'multitable
))
1990 (defun texinfo-multitable-widths ()
1991 "Return list of widths of each column in a multi-column table."
1992 (let (texinfo-multitable-width-list)
1993 ;; Fractions format:
1994 ;; @multitable @columnfractions .25 .3 .45
1997 ;; @multitable {Column 1 template} {Column 2} {Column 3 example}
1998 ;; Place point before first argument
1999 (skip-chars-forward " \t")
2001 ;; Check for common misspelling
2002 ((looking-at "@columnfraction ")
2003 (error "In @multitable, @columnfractions misspelled"))
2004 ;; Case 1: @columnfractions .25 .3 .45
2005 ((looking-at "@columnfractions")
2010 (* fill-column
(read (get-buffer (current-buffer))))))
2011 texinfo-multitable-width-list
)))
2013 ;; Case 2: {Column 1 template} {Column 2} {Column 3 example}
2015 (let ((start-of-templates (point)))
2017 (skip-chars-forward " \t")
2018 (let* ((start-of-template (1+ (point)))
2020 ;; forward-sexp works with braces in Texinfo mode
2021 (progn (forward-sexp 1) (1- (point)))))
2022 (push (- end-of-template start-of-template
)
2023 texinfo-multitable-width-list
)
2024 ;; Remove carriage return from within a template, if any.
2025 ;; This helps those those who want to use more than
2026 ;; one line's worth of words in @multitable line.
2027 (narrow-to-region start-of-template end-of-template
)
2028 (goto-char (point-min))
2029 (while (search-forward "
2032 (goto-char (point-max))
2034 (forward-char 1)))))
2039 "You probably need to specify column widths for @multitable correctly.")))
2040 ;; Check whether columns fit on page.
2041 (let ((desired-columns
2043 ;; between column spaces
2044 (length texinfo-multitable-width-list
)
2045 ;; additional between column spaces, if any
2046 texinfo-extra-inter-column-width
2047 ;; sum of spaces for each entry
2048 (apply '+ texinfo-multitable-width-list
))))
2049 (if (> desired-columns fill-column
)
2051 "Multi-column table width, %d chars, is greater than page width, %d chars."
2052 desired-columns fill-column
)))
2053 texinfo-multitable-width-list
))
2055 ;; @item A1 @tab A2 @tab A3
2056 (defun texinfo-multitable-extract-row ()
2057 "Return multitable row, as a string.
2058 End of row is beginning of next @item or beginning of @end.
2059 Cells within rows are separated by @tab."
2060 (skip-chars-forward " \t")
2061 (let* ((start (point))
2063 (re-search-forward "@item\\|@end")
2064 (match-beginning 0)))
2065 (row (progn (goto-char end
)
2066 (skip-chars-backward " ")
2067 ;; remove whitespace at end of argument
2068 (delete-region (point) end
)
2069 (buffer-substring-no-properties start
(point)))))
2070 (delete-region texinfo-command-start end
)
2073 (put 'multitable
'texinfo-item
'texinfo-multitable-item
)
2074 (defun texinfo-multitable-item ()
2075 "Format a row within a multicolumn table.
2076 Cells in row are separated by @tab.
2077 Widths of cells are specified by the arguments in the @multitable line.
2078 All cells are made to be the same height.
2079 This command is executed when texinfmt sees @item inside @multitable."
2080 (let ((original-buffer (current-buffer))
2081 (table-widths (reverse (car (cdr (car texinfo-stack
)))))
2082 (existing-fill-column fill-column
)
2086 (table-entry-height 0)
2087 ;; unformatted row looks like: A1 @tab A2 @tab A3
2088 ;; extract-row command deletes the source line in the table.
2089 (unformatted-row (texinfo-multitable-extract-row)))
2090 ;; Use a temporary buffer
2091 (set-buffer (get-buffer-create texinfo-multitable-buffer-name
))
2092 (delete-region (point-min) (point-max))
2093 (insert unformatted-row
)
2094 (goto-char (point-min))
2095 ;; 1. Check for correct number of @tab in line.
2096 (let ((tab-number 1)) ; one @tab between two columns
2097 (while (search-forward "@tab" nil t
)
2098 (setq tab-number
(1+ tab-number
)))
2099 (let ((needed-tabs (- (length table-widths
) tab-number
)))
2100 (when (> needed-tabs
0)
2101 (goto-char (point-min))
2103 (while (> needed-tabs
0)
2104 (insert "@w{ }\n@tab")
2105 (setq needed-tabs
(1- needed-tabs
))
2107 "Added @tabs and empty spaces to a @multitable row")))))
2108 (goto-char (point-min))
2109 ;; 2. Format each cell, and copy to a rectangle
2110 ;; buffer looks like this: A1 @tab A2 @tab A3
2111 ;; Cell #1: format up to @tab
2112 ;; Cell #2: format up to @tab
2113 ;; Cell #3: format up to eob
2115 (setq start
(point))
2116 (setq end
(save-excursion
2117 (if (search-forward "@tab" nil
'move
)
2118 ;; Delete the @tab command, including the @-sign
2121 (progn (forward-word -
1) (1- (point)))))
2123 ;; Set fill-column *wider* than needed to produce inter-column space
2124 (setq fill-column
(+ 1
2125 texinfo-extra-inter-column-width
2126 (nth table-column table-widths
)))
2127 (narrow-to-region start end
)
2128 ;; Remove whitespace before and after entry.
2129 (skip-chars-forward " ")
2130 (delete-region (point) (line-beginning-position))
2131 (goto-char (point-max))
2132 (skip-chars-backward " ")
2133 (delete-region (point) (line-end-position))
2134 ;; Temporarily set texinfo-stack to nil so texinfo-format-scan
2135 ;; does not see an unterminated @multitable.
2136 (let (texinfo-stack) ; nil
2137 (texinfo-format-scan))
2138 (let (fill-prefix) ; no fill prefix
2139 (fill-region (point-min) (point-max)))
2140 (setq table-entry-height
2141 (max table-entry-height
(count-lines (point-min) (point-max))))
2142 ;; 3. Move point to end of bottom line, and pad that line to fill column.
2143 (goto-char (point-min))
2144 (forward-line (1- table-entry-height
))
2145 (let* ((beg (point)) ; beginning of line
2146 ;; add one more space for inter-column spacing
2151 (progn (end-of-line) (point)) ; end of existing line
2153 (insert (make-string
2154 (if (> needed-whitespace
0) needed-whitespace
1)
2156 ;; now, put formatted cell into a rectangle
2157 (set (intern (concat texinfo-multitable-rectangle-name
2158 (int-to-string table-column
)))
2159 (extract-rectangle (point-min) (point)))
2160 (delete-region (point-min) (point))
2161 (goto-char (point-max))
2162 (setq table-column
(1+ table-column
))
2164 ;; 4. Add extra lines to rectangles so all are of same height
2165 (let ((total-number-of-columns table-column
)
2168 (while (> table-column
0)
2169 (let ((this-rectangle (int-to-string table-column
)))
2170 (while (< (length this-rectangle
) table-entry-height
)
2171 (setq this-rectangle
(append this-rectangle
'("")))))
2172 (setq table-column
(1- table-column
)))
2173 ;; 5. Insert formatted rectangles in original buffer
2174 (switch-to-buffer original-buffer
)
2175 (open-line table-entry-height
)
2176 (while (< column-number total-number-of-columns
)
2180 (concat texinfo-multitable-rectangle-name
2181 (int-to-string column-number
)))))
2184 (setq column-number
(1+ column-number
))))
2185 (kill-buffer texinfo-multitable-buffer-name
)
2186 (setq fill-column existing-fill-column
)))
2190 ;; Use only the FILENAME argument to the command.
2191 ;; In Info, ignore the other arguments.
2193 (put 'image
'texinfo-format
'texinfo-format-image
)
2194 (defun texinfo-format-image ()
2195 "Insert an image from a file ending in .txt.
2196 Use only the FILENAME arg; for Info, ignore the other arguments to @image."
2197 (let ((args (texinfo-format-parse-args))
2199 (when (null (nth 0 args
))
2200 (error "Invalid image command"))
2201 (texinfo-discard-command)
2202 ;; makeinfo uses FILENAME.txt
2203 (setq filename
(format "%s.txt" (nth 0 args
)))
2204 (message "Reading included file: %s" filename
)
2205 ;; verbatim for Info output
2206 (goto-char (+ (point) (cadr (insert-file-contents filename
))))
2207 (message "Reading included file: %s...done" filename
)))
2210 ;;; @ifinfo, @iftex, @tex, @ifhtml, @html, @ifplaintext, @ifxml, @xml
2211 ;; @ifnottex, @ifnotinfo, @ifnothtml, @ifnotplaintext, @ifnotxml
2213 (put 'ifinfo
'texinfo-format
'texinfo-discard-line
)
2214 (put 'ifinfo
'texinfo-end
'texinfo-discard-command
)
2216 (put 'iftex
'texinfo-format
'texinfo-format-iftex
)
2217 (defun texinfo-format-iftex ()
2218 (delete-region texinfo-command-start
2219 (re-search-forward "@end iftex[ \t]*\n")))
2221 (put 'ifhtml
'texinfo-format
'texinfo-format-ifhtml
)
2222 (defun texinfo-format-ifhtml ()
2223 (delete-region texinfo-command-start
2224 (re-search-forward "@end ifhtml[ \t]*\n")))
2226 (put 'ifplaintext
'texinfo-format
'texinfo-format-ifplaintext
)
2227 (defun texinfo-format-ifplaintext ()
2228 (delete-region texinfo-command-start
2229 (re-search-forward "@end ifplaintext[ \t]*\n")))
2231 (put 'ifxml
'texinfo-format
'texinfo-format-ifxml
)
2232 (defun texinfo-format-ifxml ()
2233 (delete-region texinfo-command-start
2234 (progn (re-search-forward "^@end ifxml[ \t]*\n")
2237 (put 'tex
'texinfo-format
'texinfo-format-tex
)
2238 (defun texinfo-format-tex ()
2239 (delete-region texinfo-command-start
2240 (re-search-forward "@end tex[ \t]*\n")))
2242 (put 'html
'texinfo-format
'texinfo-format-html
)
2243 (defun texinfo-format-html ()
2244 (delete-region texinfo-command-start
2245 (re-search-forward "@end html[ \t]*\n")))
2247 (put 'xml
'texinfo-format
'texinfo-format-xml
)
2248 (defun texinfo-format-xml ()
2249 (delete-region texinfo-command-start
2250 (progn (re-search-forward "^@end xml[ \t]*\n")
2253 (put 'ifnotinfo
'texinfo-format
'texinfo-format-ifnotinfo
)
2254 (defun texinfo-format-ifnotinfo ()
2255 (delete-region texinfo-command-start
2256 (re-search-forward "@end ifnotinfo[ \t]*\n")))
2258 (put 'ifnotplaintext
'texinfo-format
'texinfo-discard-line
)
2259 (put 'ifnotplaintext
'texinfo-end
'texinfo-discard-command
)
2261 (put 'ifnottex
'texinfo-format
'texinfo-discard-line
)
2262 (put 'ifnottex
'texinfo-end
'texinfo-discard-command
)
2264 (put 'ifnothtml
'texinfo-format
'texinfo-discard-line
)
2265 (put 'ifnothtml
'texinfo-end
'texinfo-discard-command
)
2267 (put 'ifnotxml
'texinfo-format
'texinfo-discard-line
)
2268 (put 'ifnotxml
'texinfo-end
'texinfo-discard-command
)
2273 (put 'titlepage
'texinfo-format
'texinfo-format-titlepage
)
2274 (defun texinfo-format-titlepage ()
2275 (delete-region texinfo-command-start
2276 (re-search-forward "@end titlepage[ \t]*\n")))
2278 (put 'endtitlepage
'texinfo-format
'texinfo-discard-line
)
2280 ;; @titlespec an alternative titling command; ignored by Info
2282 (put 'titlespec
'texinfo-format
'texinfo-format-titlespec
)
2283 (defun texinfo-format-titlespec ()
2284 (delete-region texinfo-command-start
2285 (re-search-forward "@end titlespec[ \t]*\n")))
2287 (put 'endtitlespec
'texinfo-format
'texinfo-discard-line
)
2292 (put 'today
'texinfo-format
'texinfo-format-today
)
2294 ;; Produces Day Month Year style of output. eg `1 Jan 1900'
2295 ;; The `@today{}' command requires a pair of braces, like `@dots{}'.
2296 (defun texinfo-format-today ()
2297 (texinfo-parse-arg-discard)
2298 (insert (format-time-string "%e %b %Y")))
2302 ;; Produce `Day Month Year Hour:Min' style of output.
2303 ;; eg `1 Jan 1900 13:52'
2305 (put 'timestamp
'texinfo-format
'texinfo-format-timestamp
)
2307 ;; The `@timestamp{}' command requires a pair of braces, like `@dots{}'.
2308 (defun texinfo-format-timestamp ()
2309 "Insert the current local time and date."
2310 (texinfo-parse-arg-discard)
2311 ;; For seconds and time zone, replace format string with "%e %b %Y %T %Z"
2312 (insert (format-time-string "%e %b %Y %R")))
2317 (put 'ignore
'texinfo-format
'texinfo-format-ignore
)
2318 (defun texinfo-format-ignore ()
2319 (delete-region texinfo-command-start
2320 (re-search-forward "@end ignore[ \t]*\n")))
2322 (put 'endignore
'texinfo-format
'texinfo-discard-line
)
2325 ;;; Define the Info enclosure command: @definfoenclose
2327 ;; A `@definfoenclose' command may be used to define a highlighting
2328 ;; command for Info, but not for TeX. A command defined using
2329 ;; `@definfoenclose' marks text by enclosing it in strings that precede
2330 ;; and follow the text.
2332 ;; Presumably, if you define a command with `@definfoenclose` for Info,
2333 ;; you will also define the same command in the TeX definitions file,
2334 ;; `texinfo.tex' in a manner appropriate for typesetting.
2336 ;; Write a `@definfoenclose' command on a line and follow it with three
2337 ;; arguments separated by commas (commas are used as separators in an
2338 ;; `@node' line in the same way). The first argument to
2339 ;; `@definfoenclose' is the @-command name (without the `@'); the
2340 ;; second argument is the Info start delimiter string; and the third
2341 ;; argument is the Info end delimiter string. The latter two arguments
2342 ;; enclose the highlighted text in the Info file. A delimiter string
2343 ;; may contain spaces. Neither the start nor end delimiter is
2344 ;; required. However, if you do not provide a start delimiter, you
2345 ;; must follow the command name with two commas in a row; otherwise,
2346 ;; the Info formatting commands will misinterpret the end delimiter
2347 ;; string as a start delimiter string.
2349 ;; If you do a @definfoenclose{} on the name of a pre-defined macro (such
2350 ;; as @emph{}, @strong{}, @tt{}, or @i{}) the enclosure definition will
2351 ;; override the built-in definition.
2353 ;; An enclosure command defined this way takes one argument in braces.
2355 ;; For example, you can write:
2358 ;; @definfoenclose phoo, //, \\
2361 ;; near the beginning of a Texinfo file at the beginning of the lines
2362 ;; to define `@phoo' as an Info formatting command that inserts `//'
2363 ;; before and `\\' after the argument to `@phoo'. You can then write
2364 ;; `@phoo{bar}' wherever you want `//bar\\' highlighted in Info.
2366 ;; Also, for TeX formatting, you could write
2369 ;; @global@let@phoo=@i
2372 ;; to define `@phoo' as a command that causes TeX to typeset
2373 ;; the argument to `@phoo' in italics.
2375 ;; Note that each definition applies to its own formatter: one for TeX,
2376 ;; the other for texinfo-format-buffer or texinfo-format-region.
2378 ;; Here is another example: write
2380 ;; @definfoenclose headword, , :
2382 ;; near the beginning of the file, to define `@headword' as an Info
2383 ;; formatting command that inserts nothing before and a colon after the
2384 ;; argument to `@headword'.
2386 (put 'definfoenclose
'texinfo-format
'texinfo-define-info-enclosure
)
2387 (defun texinfo-define-info-enclosure ()
2388 (let* ((args (texinfo-format-parse-line-args))
2389 (command-name (nth 0 args
))
2390 (beginning-delimiter (or (nth 1 args
) ""))
2391 (end-delimiter (or (nth 2 args
) "")))
2392 (texinfo-discard-command)
2393 (push (list command-name
2397 texinfo-enclosure-list
)))
2402 (put 'alias
'texinfo-format
'texinfo-alias
)
2403 (defun texinfo-alias ()
2404 (let ((start (1- (point)))
2406 (skip-chars-forward " ")
2407 (setq texinfo-command-end
(line-end-position))
2408 (if (not (looking-at "\\([^=]+\\)=\\(.*\\)"))
2409 (error "Invalid alias command")
2411 (match-string-no-properties 1)
2412 (match-string-no-properties 2))
2414 (texinfo-discard-command))))
2417 ;;; @var, @code and the like
2419 (put 'var
'texinfo-format
'texinfo-format-var
)
2420 ;; @sc a small caps font for TeX; formatted as `var' in Info
2421 (put 'sc
'texinfo-format
'texinfo-format-var
)
2422 ;; @acronym for abbreviations in all caps, such as `NASA'.
2423 ;; Convert all letters to uppercase if they are not already.
2424 (put 'acronym
'texinfo-format
'texinfo-format-var
)
2425 (defun texinfo-format-var ()
2426 (let ((arg (texinfo-parse-expanded-arg)))
2427 (texinfo-discard-command)
2428 (insert (upcase arg
))))
2430 (put 'cite
'texinfo-format
'texinfo-format-code
)
2431 (put 'code
'texinfo-format
'texinfo-format-code
)
2432 ;; @command (for command names)
2433 (put 'command
'texinfo-format
'texinfo-format-code
)
2434 ;; @env (for environment variables)
2435 (put 'env
'texinfo-format
'texinfo-format-code
)
2436 (put 'file
'texinfo-format
'texinfo-format-code
)
2437 (put 'samp
'texinfo-format
'texinfo-format-code
)
2438 (put 'url
'texinfo-format
'texinfo-format-code
)
2439 (defun texinfo-format-code ()
2440 (insert "`" (texinfo-parse-arg-discard) "'")
2441 (goto-char texinfo-command-start
))
2443 ;; @option (for command-line options) must be different from @code
2444 ;; because of its special formatting in @table; namely that it does
2445 ;; not lead to inserted ` ... ' in a table, but does elsewhere.
2446 (put 'option
'texinfo-format
'texinfo-format-option
)
2447 (defun texinfo-format-option ()
2448 "Insert \\=` ... \\=' around arg unless inside a table; in that case, no quotes."
2449 ;; `looking-at-backward' not available in v. 18.57, 20.2
2450 (if (not (search-backward "\b" ; searched-for character is a control-H
2451 (line-beginning-position)
2453 (insert "`" (texinfo-parse-arg-discard) "'")
2454 (insert (texinfo-parse-arg-discard)))
2455 (goto-char texinfo-command-start
))
2457 (put 'emph
'texinfo-format
'texinfo-format-emph
)
2458 (put 'strong
'texinfo-format
'texinfo-format-emph
)
2459 (defun texinfo-format-emph ()
2460 (insert "*" (texinfo-parse-arg-discard) "*")
2461 (goto-char texinfo-command-start
))
2463 (put 'dfn
'texinfo-format
'texinfo-format-defn
)
2464 (put 'defn
'texinfo-format
'texinfo-format-defn
)
2465 (defun texinfo-format-defn ()
2466 (insert "\"" (texinfo-parse-arg-discard) "\"")
2467 (goto-char texinfo-command-start
))
2469 (put 'email
'texinfo-format
'texinfo-format-email
)
2470 (defun texinfo-format-email ()
2471 "Format email address and optional following full name.
2472 Insert full name, if present, followed by email address
2473 surrounded by in angle brackets."
2474 (let ((args (texinfo-format-parse-args)))
2475 (texinfo-discard-command)
2478 (insert (nth 1 args
) " "))
2479 (insert "<" (nth 0 args
) ">")))
2481 (put 'key
'texinfo-format
'texinfo-format-key
)
2482 ;; I've decided not want to have angle brackets around these -- rms.
2483 (defun texinfo-format-key ()
2484 (insert (texinfo-parse-arg-discard))
2485 (goto-char texinfo-command-start
))
2487 ;; @verb{<char>TEXT<char>} (in `makeinfo' 4.1 and later)
2488 (put 'verb
'texinfo-format
'texinfo-format-verb
)
2489 (defun texinfo-format-verb ()
2490 "Format text between non-quoted unique delimiter characters verbatim.
2491 Enclose the verbatim text, including the delimiters, in braces. Print
2492 text exactly as written (but not the delimiters) in a fixed-width.
2494 For example, @verb{|@|} results in @ and
2495 @verb{+@\\='e?\\=`!\\=`+} results in @\\='e?\\=`!\\=`."
2497 (let ((delimiter (buffer-substring-no-properties
2498 (1+ texinfo-command-end
) (+ 2 texinfo-command-end
))))
2499 (unless (looking-at "{")
2500 (error "Not found: @verb start brace"))
2501 (delete-region texinfo-command-start
(+ 2 texinfo-command-end
))
2502 (search-forward delimiter
))
2504 (unless (looking-at "}")
2505 (error "Not found: @verb end brace"))
2508 ;; as of 2002 Dec 10
2509 ;; see (texinfo)Block Enclosing Commands
2512 ;; as of 2002 Dec 10
2513 ;; see (texinfo)verbatiminclude
2514 ;; need: @verbatiminclude FILENAME
2516 (put 'bullet
'texinfo-format
'texinfo-format-bullet
)
2517 (defun texinfo-format-bullet ()
2518 "Insert an asterisk.
2519 If used within a line, follow `@bullet' with braces."
2520 (texinfo-optional-braces-discard)
2526 ;; Inside of @example ... @end example and similar environments,
2527 ;; @kbd does nothing; but outside of such environments, it places
2528 ;; single quotation marks around its argument.
2530 (defvar texinfo-format-kbd-regexp
2540 "Regexp matching environments in which @kbd does not put `...' around arg.")
2542 (defvar texinfo-format-kbd-end-regexp
2552 "Regexp specifying end of environments in which @kbd does not put `...'
2553 around argument. (See `texinfo-format-kbd-regexp')")
2555 (put 'kbd
'texinfo-format
'texinfo-format-kbd
)
2556 (defun texinfo-format-kbd ()
2557 "Place single quote marks around arg, except in @example and similar."
2558 ;; Search forward for @end example closer than an @example.
2559 ;; Can stop search at nearest @node or texinfo-section-types-regexp
2563 (concat "^@node\\|\\(" texinfo-section-types-regexp
"\\)")
2565 'move-to-end
) ; if necessary, return point at end of buffer
2569 (re-search-forward texinfo-format-kbd-regexp stop
'move-to-end
)
2571 (end-example-location
2573 (re-search-forward texinfo-format-kbd-end-regexp stop
'move-to-end
)
2575 ;; If inside @example, @end example will be closer than @example
2576 ;; or end of search i.e., end-example-location less than example-location
2577 (if (>= end-example-location example-location
)
2578 ;; outside an @example or equivalent
2579 (insert "`" (texinfo-parse-arg-discard) "'")
2580 ;; else, in @example; do not surround with `...'
2581 (insert (texinfo-parse-arg-discard)))
2582 (goto-char texinfo-command-start
)))
2585 ;;; @example, @lisp, @quotation, @display, @smalllisp, @smallexample,
2588 (put 'display
'texinfo-format
'texinfo-format-example
)
2589 (put 'smalldisplay
'texinfo-format
'texinfo-format-example
)
2590 (put 'example
'texinfo-format
'texinfo-format-example
)
2591 (put 'lisp
'texinfo-format
'texinfo-format-example
)
2592 (put 'quotation
'texinfo-format
'texinfo-format-example
)
2593 (put 'smallexample
'texinfo-format
'texinfo-format-example
)
2594 (put 'smalllisp
'texinfo-format
'texinfo-format-example
)
2595 (defun texinfo-format-example ()
2596 (texinfo-push-stack 'example nil
)
2597 (setq fill-column
(- fill-column
5))
2598 (texinfo-discard-line))
2600 (put 'example
'texinfo-end
'texinfo-end-example
)
2601 (put 'display
'texinfo-end
'texinfo-end-example
)
2602 (put 'smalldisplay
'texinfo-end
'texinfo-end-example
)
2603 (put 'lisp
'texinfo-end
'texinfo-end-example
)
2604 (put 'quotation
'texinfo-end
'texinfo-end-example
)
2605 (put 'smallexample
'texinfo-end
'texinfo-end-example
)
2606 (put 'smalllisp
'texinfo-end
'texinfo-end-example
)
2607 (defun texinfo-end-example ()
2608 (setq fill-column
(+ fill-column
5))
2609 (texinfo-discard-command)
2611 (texinfo-pop-stack 'example
)))
2612 (texinfo-do-itemize (nth 1 stacktop
))))
2614 (put 'exdent
'texinfo-format
'texinfo-format-exdent
)
2615 (defun texinfo-format-exdent ()
2616 (texinfo-discard-command)
2617 (delete-region (point)
2619 (skip-chars-forward " ")
2622 ;; Cancel out the deletion that texinfo-do-itemize
2623 ;; is going to do at the end of this line.
2629 ;; @direntry and @dircategory
2631 (put 'direntry
'texinfo-format
'texinfo-format-direntry
)
2632 (defun texinfo-format-direntry ()
2633 (texinfo-push-stack 'direntry nil
)
2634 (texinfo-discard-line)
2635 (insert "START-INFO-DIR-ENTRY\n"))
2637 (put 'direntry
'texinfo-end
'texinfo-end-direntry
)
2638 (defun texinfo-end-direntry ()
2639 (texinfo-discard-command)
2640 (insert "END-INFO-DIR-ENTRY\n\n")
2641 (texinfo-pop-stack 'direntry
))
2643 (put 'dircategory
'texinfo-format
'texinfo-format-dircategory
)
2644 (defun texinfo-format-dircategory ()
2645 (let ((str (texinfo-parse-arg-discard)))
2646 (delete-region (point)
2648 (skip-chars-forward " ")
2650 (insert "INFO-DIR-SECTION " str
"\n")))
2654 ;; The @cartouche command is a noop in Info; in a printed manual,
2655 ;; it makes a box with rounded corners.
2657 (put 'cartouche
'texinfo-format
'texinfo-discard-line
)
2658 (put 'cartouche
'texinfo-end
'texinfo-discard-command
)
2661 ;;; @flushleft and @format
2663 ;; The @flushleft command left justifies every line but leaves the
2664 ;; right end ragged. As far as Info is concerned, @flushleft is a
2665 ;; `do-nothing' command
2667 ;; The @format command is similar to @example except that it does not
2668 ;; indent; this means that in Info, @format is similar to @flushleft.
2670 (put 'format
'texinfo-format
'texinfo-format-flushleft
)
2671 (put 'smallformat
'texinfo-format
'texinfo-format-flushleft
)
2672 (put 'flushleft
'texinfo-format
'texinfo-format-flushleft
)
2673 (defun texinfo-format-flushleft ()
2674 (texinfo-discard-line))
2676 (put 'format
'texinfo-end
'texinfo-end-flushleft
)
2677 (put 'smallformat
'texinfo-end
'texinfo-end-flushleft
)
2678 (put 'flushleft
'texinfo-end
'texinfo-end-flushleft
)
2679 (defun texinfo-end-flushleft ()
2680 (texinfo-discard-command))
2685 ;; The @flushright command right justifies every line but leaves the
2686 ;; left end ragged. Spaces and tabs at the right ends of lines are
2687 ;; removed so that visible text lines up on the right side.
2689 (put 'flushright
'texinfo-format
'texinfo-format-flushright
)
2690 (defun texinfo-format-flushright ()
2691 (texinfo-push-stack 'flushright nil
)
2692 (texinfo-discard-line))
2694 (put 'flushright
'texinfo-end
'texinfo-end-flushright
)
2695 (defun texinfo-end-flushright ()
2696 (texinfo-discard-command)
2699 (texinfo-pop-stack 'flushright
)))
2701 (texinfo-do-flushright (nth 1 stacktop
))))
2703 (defun texinfo-do-flushright (from)
2705 (while (progn (forward-line -
1)
2714 (skip-chars-backward " \t")
2715 (delete-region (point) (progn (end-of-line) (point)))
2720 ;;; @ctrl, @TeX, @copyright, @minus, @dots, @enddots, @pounds
2722 (put 'ctrl
'texinfo-format
'texinfo-format-ctrl
)
2723 (defun texinfo-format-ctrl ()
2724 (let ((str (texinfo-parse-arg-discard)))
2725 (insert (logand 31 (aref str
0)))))
2727 (put 'TeX
'texinfo-format
'texinfo-format-TeX
)
2728 (defun texinfo-format-TeX ()
2729 (texinfo-parse-arg-discard)
2732 (put 'copyright
'texinfo-format
'texinfo-format-copyright
)
2733 (defun texinfo-format-copyright ()
2734 (texinfo-parse-arg-discard)
2737 (put 'minus
'texinfo-format
'texinfo-format-minus
)
2738 (defun texinfo-format-minus ()
2739 "Insert a minus sign.
2740 If used within a line, follow `@minus' with braces."
2741 (texinfo-optional-braces-discard)
2744 (put 'dots
'texinfo-format
'texinfo-format-dots
)
2745 (defun texinfo-format-dots ()
2746 (texinfo-parse-arg-discard)
2749 (put 'enddots
'texinfo-format
'texinfo-format-enddots
)
2750 (defun texinfo-format-enddots ()
2751 (texinfo-parse-arg-discard)
2754 (put 'pounds
'texinfo-format
'texinfo-format-pounds
)
2755 (defun texinfo-format-pounds ()
2756 (texinfo-parse-arg-discard)
2760 ;;; Refilling and indenting: @refill, @paragraphindent, @noindent
2762 ;; Indent only those paragraphs that are refilled as a result of an
2765 ;; * If the value is `asis', do not change the existing indentation at
2766 ;; the starts of paragraphs.
2768 ;; * If the value zero, delete any existing indentation.
2770 ;; * If the value is greater than zero, indent each paragraph by that
2771 ;; number of spaces.
2773 ;; But do not refill paragraphs with an @refill command that are
2774 ;; preceded by @noindent or are part of a table, list, or deffn.
2776 (defvar texinfo-paragraph-indent
"asis"
2777 "Number of spaces for @refill to indent a paragraph; else to leave as is.")
2779 (put 'paragraphindent
'texinfo-format
'texinfo-paragraphindent
)
2781 (defun texinfo-paragraphindent ()
2782 "Specify the number of spaces for @refill to indent a paragraph.
2783 Default is to leave the number of spaces as is."
2784 (let ((arg (texinfo-parse-arg-discard)))
2785 (if (string= "asis" arg
)
2786 (setq texinfo-paragraph-indent
"asis")
2787 (setq texinfo-paragraph-indent
(string-to-number arg
)))))
2789 (put 'refill
'texinfo-format
'texinfo-format-refill
)
2790 (defun texinfo-format-refill ()
2791 "Refill paragraph. Also, indent first line as set by @paragraphindent.
2792 Default is to leave paragraph indentation as is."
2793 (texinfo-discard-command)
2794 (let ((position (point-marker)))
2795 (forward-paragraph -
1)
2796 (if (looking-at "[ \t\n]*$") (forward-line 1))
2797 ;; Do not indent if an entry in a list, table, or deffn,
2798 ;; or if paragraph is preceded by @noindent.
2799 ;; Otherwise, indent
2801 ;; delete a @noindent line and do not indent paragraph
2802 ((save-excursion (forward-line -
1)
2803 (looking-at "^@noindent"))
2805 (delete-region (point) (progn (forward-line 1) (point))))
2806 ;; do nothing if "asis"
2807 ((equal texinfo-paragraph-indent
"asis"))
2808 ;; do no indenting in list, etc.
2809 ((> texinfo-stack-depth
0))
2810 ;; otherwise delete existing whitespace and indent
2812 (delete-region (point) (progn (skip-chars-forward " \t") (point)))
2813 (insert (make-string texinfo-paragraph-indent ?
))))
2814 (forward-paragraph 1)
2817 ;; Do not fill a section title line with asterisks, hyphens, etc. that
2818 ;; are used to underline it. This could occur if the line following
2819 ;; the underlining is not an index entry and has text within it.
2820 (let* ((previous-paragraph-separate paragraph-separate
)
2822 (concat paragraph-separate
"\\|[-=.]+\\|\\*\\*+"))
2823 (previous-paragraph-start paragraph-start
)
2825 (concat paragraph-start
"\\|[-=.]+\\|\\*\\*+")))
2827 (fill-paragraph nil
)
2828 (setq paragraph-separate previous-paragraph-separate
)
2829 (setq paragraph-start previous-paragraph-start
)))
2830 (goto-char position
)))
2832 (put 'noindent
'texinfo-format
'texinfo-noindent
)
2833 (defun texinfo-noindent ()
2835 (forward-paragraph 1)
2836 (if (search-backward "@refill" (line-beginning-position 0) t
)
2837 () ; leave @noindent command so @refill command knows not to indent
2839 (texinfo-discard-line))))
2842 ;;; Index generation
2844 (put 'vindex
'texinfo-format
'texinfo-format-vindex
)
2845 (defun texinfo-format-vindex ()
2846 (texinfo-index 'texinfo-vindex
))
2848 (put 'cindex
'texinfo-format
'texinfo-format-cindex
)
2849 (defun texinfo-format-cindex ()
2850 (texinfo-index 'texinfo-cindex
))
2852 (put 'findex
'texinfo-format
'texinfo-format-findex
)
2853 (defun texinfo-format-findex ()
2854 (texinfo-index 'texinfo-findex
))
2856 (put 'pindex
'texinfo-format
'texinfo-format-pindex
)
2857 (defun texinfo-format-pindex ()
2858 (texinfo-index 'texinfo-pindex
))
2860 (put 'tindex
'texinfo-format
'texinfo-format-tindex
)
2861 (defun texinfo-format-tindex ()
2862 (texinfo-index 'texinfo-tindex
))
2864 (put 'kindex
'texinfo-format
'texinfo-format-kindex
)
2865 (defun texinfo-format-kindex ()
2866 (texinfo-index 'texinfo-kindex
))
2868 (defun texinfo-index (indexvar)
2869 (let ((arg (texinfo-parse-expanded-arg)))
2870 (texinfo-discard-command)
2874 ;; Region formatting may not provide last node position.
2875 (if texinfo-last-node-pos
2876 (1+ (count-lines texinfo-last-node-pos
(point)))
2878 (symbol-value indexvar
)))))
2880 (defvar texinfo-indexvar-alist
2881 '(("cp" . texinfo-cindex
)
2882 ("fn" . texinfo-findex
)
2883 ("vr" . texinfo-vindex
)
2884 ("tp" . texinfo-tindex
)
2885 ("pg" . texinfo-pindex
)
2886 ("ky" . texinfo-kindex
)))
2889 ;;; @defindex @defcodeindex
2890 (put 'defindex
'texinfo-format
'texinfo-format-defindex
)
2891 (put 'defcodeindex
'texinfo-format
'texinfo-format-defindex
)
2893 (defun texinfo-format-defindex ()
2894 (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa'
2895 (indexing-command (intern (concat index-name
"index")))
2896 (index-formatting-command ; eg: `texinfo-format-aaindex'
2897 (intern (concat "texinfo-format-" index-name
"index")))
2898 (index-alist-name ; eg: `texinfo-aaindex'
2899 (intern (concat "texinfo-" index-name
"index"))))
2901 (set index-alist-name nil
)
2903 (put indexing-command
; eg, aaindex
2905 index-formatting-command
) ; eg, texinfo-format-aaindex
2907 ;; eg: "aa" . texinfo-aaindex
2908 (or (assoc index-name texinfo-indexvar-alist
)
2909 (push (cons index-name
2911 texinfo-indexvar-alist
))
2913 (fset index-formatting-command
2915 (list 'texinfo-index
2916 (list 'quote index-alist-name
))))))
2919 ;;; @synindex @syncodeindex
2921 (put 'synindex
'texinfo-format
'texinfo-format-synindex
)
2922 (put 'syncodeindex
'texinfo-format
'texinfo-format-synindex
)
2924 (defun texinfo-format-synindex ()
2925 (let* ((args (texinfo-parse-arg-discard))
2926 (second (cdr (read-from-string args
)))
2927 (joiner (symbol-name (car (read-from-string args
))))
2928 (joined (symbol-name (car (read-from-string args second
)))))
2930 (if (assoc joiner texinfo-short-index-cmds-alist
)
2932 (cdr (assoc joiner texinfo-short-index-cmds-alist
))
2934 (or (cdr (assoc joined texinfo-short-index-format-cmds-alist
))
2935 (intern (concat "texinfo-format-" joined
"index"))))
2937 (intern (concat joiner
"index"))
2939 (or (cdr(assoc joined texinfo-short-index-format-cmds-alist
))
2940 (intern (concat "texinfo-format-" joined
"index")))))))
2942 (defconst texinfo-short-index-cmds-alist
2950 (defconst texinfo-short-index-format-cmds-alist
2951 '(("cp" . texinfo-format-cindex
)
2952 ("fn" . texinfo-format-findex
)
2953 ("vr" . texinfo-format-vindex
)
2954 ("tp" . texinfo-format-tindex
)
2955 ("pg" . texinfo-format-pindex
)
2956 ("ky" . texinfo-format-kindex
)))
2961 ;; Sort an index which is in the current buffer between START and END.
2962 (defun texinfo-sort-region (start end
)
2965 (narrow-to-region start end
)
2966 (goto-char (point-min))
2967 (sort-subr nil
'forward-line
'end-of-line
'texinfo-sort-startkeyfun
)))
2969 ;; Subroutine for sorting an index.
2970 ;; At start of a line, return a string to sort the line under.
2971 (defun texinfo-sort-startkeyfun ()
2972 (let ((line (buffer-substring-no-properties (point) (line-end-position))))
2973 ;; Canonicalize whitespace and eliminate funny chars.
2974 (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line
)
2975 (setq line
(concat (substring line
0 (match-beginning 0))
2977 (substring line
(match-end 0)))))
2983 (put 'printindex
'texinfo-format
'texinfo-format-printindex
)
2985 (defun texinfo-format-printindex ()
2986 (let* ((arg (texinfo-parse-arg-discard))
2987 (fmt (cdr (assoc arg texinfo-short-index-format-cmds-alist
)))
2988 (index-list (delq nil
(mapcar (lambda (e)
2989 (and (eq fmt
(get (cdr e
) 'texinfo-format
))
2990 (cdr (assoc (car e
) texinfo-indexvar-alist
))))
2991 texinfo-short-index-cmds-alist
)))
2992 (indexelts (apply #'append nil
(mapcar #'symbol-value index-list
)))
2994 (insert "\n* Menu:\n\n")
2995 (setq opoint
(point))
2996 (texinfo-print-index nil indexelts
)
2997 (texinfo-sort-region opoint
(point))))
2999 (defun texinfo-print-index (file indexelts
)
3001 (if (stringp (car (car indexelts
)))
3003 (insert "* " (car (car indexelts
)) ": " )
3006 (if file
(concat "(" file
")") "")
3007 (nth 1 (car indexelts
)) ".")
3010 (if (nth 2 (car indexelts
))
3011 (format " (line %3d)" (1+ (nth 2 (car indexelts
))))
3014 ;; index entries from @include'd file
3015 (texinfo-print-index (nth 1 (car indexelts
))
3016 (nth 2 (car indexelts
))))
3017 (setq indexelts
(cdr indexelts
))))
3020 ;;; Glyphs: @equiv, @error, etc
3022 ;; @equiv to show that two expressions are equivalent
3023 ;; @error to show an error message
3024 ;; @expansion to show what a macro expands to
3025 ;; @point to show the location of point in an example
3026 ;; @print to show what an evaluated expression prints
3027 ;; @result to indicate the value returned by an expression
3029 (put 'equiv
'texinfo-format
'texinfo-format-equiv
)
3030 (defun texinfo-format-equiv ()
3031 (texinfo-parse-arg-discard)
3034 (put 'error
'texinfo-format
'texinfo-format-error
)
3035 (defun texinfo-format-error ()
3036 (texinfo-parse-arg-discard)
3037 (insert "error-->"))
3039 (put 'expansion
'texinfo-format
'texinfo-format-expansion
)
3040 (defun texinfo-format-expansion ()
3041 (texinfo-parse-arg-discard)
3044 (put 'point
'texinfo-format
'texinfo-format-point
)
3045 (defun texinfo-format-point ()
3046 (texinfo-parse-arg-discard)
3049 (put 'print
'texinfo-format
'texinfo-format-print
)
3050 (defun texinfo-format-print ()
3051 (texinfo-parse-arg-discard)
3054 (put 'result
'texinfo-format
'texinfo-format-result
)
3055 (defun texinfo-format-result ()
3056 (texinfo-parse-arg-discard)
3062 ;; Info presumes a plain ASCII output, so the accented characters do
3063 ;; not look as they would if typeset, or output with a different
3066 ;; See the `texinfo-accent-commands' variable
3067 ;; in the section for `texinfo-append-refill'.
3068 ;; Also, see the defun for `texinfo-format-scan'
3069 ;; for single-character accent commands.
3071 ;; Command Info output Name
3073 ;; These do not have braces:
3074 ;; @^ ==> ^ circumflex accent
3075 ;; @` ==> ` grave accent
3076 ;; @' ==> ' acute accent
3077 ;; @" ==> " umlaut accent
3078 ;; @= ==> = overbar accent
3079 ;; @~ ==> ~ tilde accent
3081 ;; These have braces, but take no argument:
3082 ;; @OE{} ==> OE French-OE-ligature
3084 ;; @AA{} ==> AA Scandinavian-A-with-circle
3086 ;; @AE{} ==> AE Latin-Scandinavian-AE
3088 ;; @ss{} ==> ss German-sharp-S
3090 ;; @questiondown{} ==> ? upside-down-question-mark
3091 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
3092 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
3093 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
3094 ;; @O{} ==> O/ Scandinavian O-with-slash
3095 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
3097 ;; These have braces, and take an argument:
3098 ;; @,{c} ==> c, cedilla accent
3099 ;; @dotaccent{o} ==> .o overdot-accent
3100 ;; @ubaraccent{o} ==> _o underbar-accent
3101 ;; @udotaccent{o} ==> o-. underdot-accent
3102 ;; @H{o} ==> ""o long Hungarian umlaut
3103 ;; @ringaccent{o} ==> *o ring accent
3104 ;; @tieaccent{oo} ==> [oo tie after accent
3105 ;; @u{o} ==> (o breve accent
3106 ;; @v{o} ==> <o hacek accent
3107 ;; @dotless{i} ==> i dotless i and dotless j
3111 ;; Note: The defun texinfo-format-scan
3112 ;; looks at "[@{}^'`\",=~ *?!-]"
3113 ;; In the case of @*, a line break is inserted;
3114 ;; in the other cases, the characters are simply quoted and the @ is deleted.
3115 ;; Thus, `texinfo-format-scan' handles the following
3116 ;; single-character accent commands: @^ @` @' @" @, @- @= @~
3118 ;; @^ ==> ^ circumflex accent
3119 ;; (put '^ 'texinfo-format 'texinfo-format-circumflex-accent)
3120 ;; (defun texinfo-format-circumflex-accent ()
3121 ;; (texinfo-discard-command)
3124 ;; @` ==> ` grave accent
3125 ;; (put '\` 'texinfo-format 'texinfo-format-grave-accent)
3126 ;; (defun texinfo-format-grave-accent ()
3127 ;; (texinfo-discard-command)
3130 ;; @' ==> ' acute accent
3131 ;; (put '\' 'texinfo-format 'texinfo-format-acute-accent)
3132 ;; (defun texinfo-format-acute-accent ()
3133 ;; (texinfo-discard-command)
3136 ;; @" ==> " umlaut accent
3137 ;; (put '\" 'texinfo-format 'texinfo-format-umlaut-accent)
3138 ;; (defun texinfo-format-umlaut-accent ()
3139 ;; (texinfo-discard-command)
3142 ;; @= ==> = overbar accent
3143 ;; (put '= 'texinfo-format 'texinfo-format-overbar-accent)
3144 ;; (defun texinfo-format-overbar-accent ()
3145 ;; (texinfo-discard-command)
3148 ;; @~ ==> ~ tilde accent
3149 ;; (put '~ 'texinfo-format 'texinfo-format-tilde-accent)
3150 ;; (defun texinfo-format-tilde-accent ()
3151 ;; (texinfo-discard-command)
3154 ;; @OE{} ==> OE French-OE-ligature
3155 (put 'OE
'texinfo-format
'texinfo-format-French-OE-ligature
)
3156 (defun texinfo-format-French-OE-ligature ()
3157 (insert "OE" (texinfo-parse-arg-discard))
3158 (goto-char texinfo-command-start
))
3161 (put 'oe
'texinfo-format
'texinfo-format-French-oe-ligature
)
3162 (defun texinfo-format-French-oe-ligature () ; lower case
3163 (insert "oe" (texinfo-parse-arg-discard))
3164 (goto-char texinfo-command-start
))
3166 ;; @AA{} ==> AA Scandinavian-A-with-circle
3167 (put 'AA
'texinfo-format
'texinfo-format-Scandinavian-A-with-circle
)
3168 (defun texinfo-format-Scandinavian-A-with-circle ()
3169 (insert "AA" (texinfo-parse-arg-discard))
3170 (goto-char texinfo-command-start
))
3173 (put 'aa
'texinfo-format
'texinfo-format-Scandinavian-a-with-circle
)
3174 (defun texinfo-format-Scandinavian-a-with-circle () ; lower case
3175 (insert "aa" (texinfo-parse-arg-discard))
3176 (goto-char texinfo-command-start
))
3178 ;; @AE{} ==> AE Latin-Scandinavian-AE
3179 (put 'AE
'texinfo-format
'texinfo-format-Latin-Scandinavian-AE
)
3180 (defun texinfo-format-Latin-Scandinavian-AE ()
3181 (insert "AE" (texinfo-parse-arg-discard))
3182 (goto-char texinfo-command-start
))
3185 (put 'ae
'texinfo-format
'texinfo-format-Latin-Scandinavian-ae
)
3186 (defun texinfo-format-Latin-Scandinavian-ae () ; lower case
3187 (insert "ae" (texinfo-parse-arg-discard))
3188 (goto-char texinfo-command-start
))
3190 ;; @ss{} ==> ss German-sharp-S
3191 (put 'ss
'texinfo-format
'texinfo-format-German-sharp-S
)
3192 (defun texinfo-format-German-sharp-S ()
3193 (insert "ss" (texinfo-parse-arg-discard))
3194 (goto-char texinfo-command-start
))
3196 ;; @questiondown{} ==> ? upside-down-question-mark
3197 (put 'questiondown
'texinfo-format
'texinfo-format-upside-down-question-mark
)
3198 (defun texinfo-format-upside-down-question-mark ()
3199 (insert "?" (texinfo-parse-arg-discard))
3200 (goto-char texinfo-command-start
))
3202 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
3203 (put 'exclamdown
'texinfo-format
'texinfo-format-upside-down-exclamation-mark
)
3204 (defun texinfo-format-upside-down-exclamation-mark ()
3205 (insert "!" (texinfo-parse-arg-discard))
3206 (goto-char texinfo-command-start
))
3208 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
3209 (put 'L
'texinfo-format
'texinfo-format-Polish-suppressed-L
)
3210 (defun texinfo-format-Polish-suppressed-L ()
3211 (insert (texinfo-parse-arg-discard) "/L")
3212 (goto-char texinfo-command-start
))
3214 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
3215 (put 'l
'texinfo-format
'texinfo-format-Polish-suppressed-l-lower-case
)
3216 (defun texinfo-format-Polish-suppressed-l-lower-case ()
3217 (insert (texinfo-parse-arg-discard) "/l")
3218 (goto-char texinfo-command-start
))
3221 ;; @O{} ==> O/ Scandinavian O-with-slash
3222 (put 'O
'texinfo-format
'texinfo-format-Scandinavian-O-with-slash
)
3223 (defun texinfo-format-Scandinavian-O-with-slash ()
3224 (insert (texinfo-parse-arg-discard) "O/")
3225 (goto-char texinfo-command-start
))
3227 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
3228 (put 'o
'texinfo-format
'texinfo-format-Scandinavian-o-with-slash-lower-case
)
3229 (defun texinfo-format-Scandinavian-o-with-slash-lower-case ()
3230 (insert (texinfo-parse-arg-discard) "o/")
3231 (goto-char texinfo-command-start
))
3235 ;; @,{c} ==> c, cedilla accent
3236 (put '\
, 'texinfo-format
'texinfo-format-cedilla-accent
)
3237 (defun texinfo-format-cedilla-accent ()
3238 (insert (texinfo-parse-arg-discard) ",")
3239 (goto-char texinfo-command-start
))
3242 ;; @dotaccent{o} ==> .o overdot-accent
3243 (put 'dotaccent
'texinfo-format
'texinfo-format-overdot-accent
)
3244 (defun texinfo-format-overdot-accent ()
3245 (insert "." (texinfo-parse-arg-discard))
3246 (goto-char texinfo-command-start
))
3248 ;; @ubaraccent{o} ==> _o underbar-accent
3249 (put 'ubaraccent
'texinfo-format
'texinfo-format-underbar-accent
)
3250 (defun texinfo-format-underbar-accent ()
3251 (insert "_" (texinfo-parse-arg-discard))
3252 (goto-char texinfo-command-start
))
3254 ;; @udotaccent{o} ==> o-. underdot-accent
3255 (put 'udotaccent
'texinfo-format
'texinfo-format-underdot-accent
)
3256 (defun texinfo-format-underdot-accent ()
3257 (insert (texinfo-parse-arg-discard) "-.")
3258 (goto-char texinfo-command-start
))
3260 ;; @H{o} ==> ""o long Hungarian umlaut
3261 (put 'H
'texinfo-format
'texinfo-format-long-Hungarian-umlaut
)
3262 (defun texinfo-format-long-Hungarian-umlaut ()
3263 (insert "\"\"" (texinfo-parse-arg-discard))
3264 (goto-char texinfo-command-start
))
3266 ;; @ringaccent{o} ==> *o ring accent
3267 (put 'ringaccent
'texinfo-format
'texinfo-format-ring-accent
)
3268 (defun texinfo-format-ring-accent ()
3269 (insert "*" (texinfo-parse-arg-discard))
3270 (goto-char texinfo-command-start
))
3272 ;; @tieaccent{oo} ==> [oo tie after accent
3273 (put 'tieaccent
'texinfo-format
'texinfo-format-tie-after-accent
)
3274 (defun texinfo-format-tie-after-accent ()
3275 (insert "[" (texinfo-parse-arg-discard))
3276 (goto-char texinfo-command-start
))
3279 ;; @u{o} ==> (o breve accent
3280 (put 'u
'texinfo-format
'texinfo-format-breve-accent
)
3281 (defun texinfo-format-breve-accent ()
3282 (insert "(" (texinfo-parse-arg-discard))
3283 (goto-char texinfo-command-start
))
3285 ;; @v{o} ==> <o hacek accent
3286 (put 'v
'texinfo-format
'texinfo-format-hacek-accent
)
3287 (defun texinfo-format-hacek-accent ()
3288 (insert "<" (texinfo-parse-arg-discard))
3289 (goto-char texinfo-command-start
))
3292 ;; @dotless{i} ==> i dotless i and dotless j
3293 (put 'dotless
'texinfo-format
'texinfo-format-dotless
)
3294 (defun texinfo-format-dotless ()
3295 (insert (texinfo-parse-arg-discard))
3296 (goto-char texinfo-command-start
))
3299 ;;; Definition formatting: @deffn, @defun, etc
3301 ;; What definition formatting produces:
3303 ;; @deffn category name args...
3304 ;; In Info, `Category: name ARGS'
3305 ;; In index: name: node. line#.
3307 ;; @defvr category name
3308 ;; In Info, `Category: name'
3309 ;; In index: name: node. line#.
3311 ;; @deftp category name attributes...
3312 ;; `category name attributes...' Note: @deftp args in lower case.
3313 ;; In index: name: node. line#.
3315 ;; Specialized function-like or variable-like entity:
3317 ;; @defun, @defmac, @defspec, @defvar, @defopt
3319 ;; @defun name args In Info, `Function: name ARGS'
3320 ;; @defmac name args In Info, `Macro: name ARGS'
3321 ;; @defvar name In Info, `Variable: name'
3323 ;; In index: name: node. line#.
3325 ;; Generalized typed-function-like or typed-variable-like entity:
3326 ;; @deftypefn category data-type name args...
3327 ;; In Info, `Category: data-type name args...'
3328 ;; @deftypevr category data-type name
3329 ;; In Info, `Category: data-type name'
3330 ;; In index: name: node. line#.
3332 ;; Specialized typed-function-like or typed-variable-like entity:
3333 ;; @deftypefun data-type name args...
3334 ;; In Info, `Function: data-type name ARGS'
3335 ;; In index: name: node. line#.
3337 ;; @deftypevar data-type name
3338 ;; In Info, `Variable: data-type name'
3339 ;; In index: name: node. line#. but include args after name!?
3341 ;; Generalized object oriented entity:
3342 ;; @defop category class name args...
3343 ;; In Info, `Category on class: name ARG'
3344 ;; In index: name on class: node. line#.
3346 ;; @defcv category class name
3347 ;; In Info, `Category of class: name'
3348 ;; In index: name of class: node. line#.
3350 ;; Specialized object oriented entity:
3351 ;; @defmethod class name args...
3352 ;; In Info, `Method on class: name ARGS'
3353 ;; In index: name on class: node. line#.
3355 ;; @defivar class name
3356 ;; In Info, `Instance variable of class: name'
3357 ;; In index: name of class: node. line#.
3360 ;;; The definition formatting functions
3362 (defun texinfo-format-defun ()
3363 (texinfo-push-stack 'defun
nil)
3364 (setq fill-column
(- fill-column
5))
3365 (texinfo-format-defun-1 t
))
3367 (defun texinfo-end-defun ()
3368 (setq fill-column
(+ fill-column
5))
3369 (texinfo-discard-command)
3370 (let ((start (nth 1 (texinfo-pop-stack 'defun
))))
3371 (texinfo-do-itemize start
)
3372 ;; Delete extra newline inserted after header.
3377 (defun texinfo-format-defunx ()
3378 (texinfo-format-defun-1 nil
))
3380 (defun texinfo-format-defun-1 (first-p)
3381 (let ((parse-args (texinfo-format-parse-defun-args))
3382 (texinfo-defun-type (get texinfo-command-name
'texinfo-defun-type
)))
3383 (texinfo-discard-command)
3384 ;; Delete extra newline inserted after previous header line.
3388 (get texinfo-command-name
'texinfo-deffn-formatting-property
) parse-args
)
3389 ;; Insert extra newline so that paragraph filling does not mess
3390 ;; with header line.
3392 (rplaca (cdr (cdr (car texinfo-stack
))) (point))
3394 (get texinfo-command-name
'texinfo-defun-indexing-property
) parse-args
)))
3396 ;;; Formatting the first line of a definition
3398 ;; @deffn, @defvr, @deftp
3399 (put 'deffn
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3400 (put 'deffnx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3401 (put 'defvr
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3402 (put 'defvrx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3403 (put 'deftp
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3404 (put 'deftpx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3405 (defun texinfo-format-deffn (parsed-args)
3406 ;; Generalized function-like, variable-like, or generic data-type entity:
3407 ;; @deffn category name args...
3408 ;; In Info, `Category: name ARGS'
3409 ;; @deftp category name attributes...
3410 ;; `category name attributes...' Note: @deftp args in lower case.
3411 (let ((category (car parsed-args
))
3412 (name (car (cdr parsed-args
)))
3413 (args (cdr (cdr parsed-args
))))
3414 (insert " -- " category
": " name
)
3417 (if (or (= ?
& (aref (car args
) 0))
3418 (eq (eval (car texinfo-defun-type
)) 'deftp-type
))
3420 (upcase (car args
))))
3421 (setq args
(cdr args
)))))
3423 ;; @defun, @defmac, @defspec, @defvar, @defopt: Specialized, simple
3424 (put 'defun
'texinfo-deffn-formatting-property
3425 'texinfo-format-specialized-defun
)
3426 (put 'defunx
'texinfo-deffn-formatting-property
3427 'texinfo-format-specialized-defun
)
3428 (put 'defmac
'texinfo-deffn-formatting-property
3429 'texinfo-format-specialized-defun
)
3430 (put 'defmacx
'texinfo-deffn-formatting-property
3431 'texinfo-format-specialized-defun
)
3432 (put 'defspec
'texinfo-deffn-formatting-property
3433 'texinfo-format-specialized-defun
)
3434 (put 'defspecx
'texinfo-deffn-formatting-property
3435 'texinfo-format-specialized-defun
)
3436 (put 'defvar
'texinfo-deffn-formatting-property
3437 'texinfo-format-specialized-defun
)
3438 (put 'defvarx
'texinfo-deffn-formatting-property
3439 'texinfo-format-specialized-defun
)
3440 (put 'defopt
'texinfo-deffn-formatting-property
3441 'texinfo-format-specialized-defun
)
3442 (put 'defoptx
'texinfo-deffn-formatting-property
3443 'texinfo-format-specialized-defun
)
3444 (defun texinfo-format-specialized-defun (parsed-args)
3445 ;; Specialized function-like or variable-like entity:
3446 ;; @defun name args In Info, `Function: Name ARGS'
3447 ;; @defmac name args In Info, `Macro: Name ARGS'
3448 ;; @defvar name In Info, `Variable: Name'
3449 ;; Use cdr of texinfo-defun-type to determine category:
3450 (let ((category (car (cdr texinfo-defun-type
)))
3451 (name (car parsed-args
))
3452 (args (cdr parsed-args
)))
3453 (insert " -- " category
": " name
)
3456 (if (= ?
& (aref (car args
) 0))
3458 (upcase (car args
))))
3459 (setq args
(cdr args
)))))
3461 ;; @deftypefn, @deftypevr: Generalized typed
3462 (put 'deftypefn
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3463 (put 'deftypefnx
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3464 (put 'deftypevr
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3465 (put 'deftypevrx
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3466 (defun texinfo-format-deftypefn (parsed-args)
3467 ;; Generalized typed-function-like or typed-variable-like entity:
3468 ;; @deftypefn category data-type name args...
3469 ;; In Info, `Category: data-type name args...'
3470 ;; @deftypevr category data-type name
3471 ;; In Info, `Category: data-type name'
3472 ;; Note: args in lower case, unless modified in command line.
3473 (let ((category (car parsed-args
))
3474 (data-type (car (cdr parsed-args
)))
3475 (name (car (cdr (cdr parsed-args
))))
3476 (args (cdr (cdr (cdr parsed-args
)))))
3477 (insert " -- " category
": " data-type
" " name
)
3479 (insert " " (car args
))
3480 (setq args
(cdr args
)))))
3482 ;; @deftypefun, @deftypevar: Specialized typed
3483 (put 'deftypefun
'texinfo-deffn-formatting-property
'texinfo-format-deftypefun
)
3484 (put 'deftypefunx
'texinfo-deffn-formatting-property
3485 'texinfo-format-deftypefun
)
3486 (put 'deftypevar
'texinfo-deffn-formatting-property
'texinfo-format-deftypefun
)
3487 (put 'deftypevarx
'texinfo-deffn-formatting-property
3488 'texinfo-format-deftypefun
)
3489 (defun texinfo-format-deftypefun (parsed-args)
3490 ;; Specialized typed-function-like or typed-variable-like entity:
3491 ;; @deftypefun data-type name args...
3492 ;; In Info, `Function: data-type name ARGS'
3493 ;; @deftypevar data-type name
3494 ;; In Info, `Variable: data-type name'
3495 ;; Note: args in lower case, unless modified in command line.
3496 ;; Use cdr of texinfo-defun-type to determine category:
3497 (let ((category (car (cdr texinfo-defun-type
)))
3498 (data-type (car parsed-args
))
3499 (name (car (cdr parsed-args
)))
3500 (args (cdr (cdr parsed-args
))))
3501 (insert " -- " category
": " data-type
" " name
)
3503 (insert " " (car args
))
3504 (setq args
(cdr args
)))))
3506 ;; @defop: Generalized object-oriented
3507 (put 'defop
'texinfo-deffn-formatting-property
'texinfo-format-defop
)
3508 (put 'defopx
'texinfo-deffn-formatting-property
'texinfo-format-defop
)
3509 (defun texinfo-format-defop (parsed-args)
3510 ;; Generalized object oriented entity:
3511 ;; @defop category class name args...
3512 ;; In Info, `Category on class: name ARG'
3513 ;; Note: args in upper case; use of `on'
3514 (let ((category (car parsed-args
))
3515 (class (car (cdr parsed-args
)))
3516 (name (car (cdr (cdr parsed-args
))))
3517 (args (cdr (cdr (cdr parsed-args
)))))
3518 (insert " -- " category
" on " class
": " name
)
3520 (insert " " (upcase (car args
)))
3521 (setq args
(cdr args
)))))
3523 ;; @defcv: Generalized object-oriented
3524 (put 'defcv
'texinfo-deffn-formatting-property
'texinfo-format-defcv
)
3525 (put 'defcvx
'texinfo-deffn-formatting-property
'texinfo-format-defcv
)
3526 (defun texinfo-format-defcv (parsed-args)
3527 ;; Generalized object oriented entity:
3528 ;; @defcv category class name
3529 ;; In Info, `Category of class: name'
3530 ;; Note: args in upper case; use of `of'
3531 (let ((category (car parsed-args
))
3532 (class (car (cdr parsed-args
)))
3533 (name (car (cdr (cdr parsed-args
))))
3534 (args (cdr (cdr (cdr parsed-args
)))))
3535 (insert " -- " category
" of " class
": " name
)
3537 (insert " " (upcase (car args
)))
3538 (setq args
(cdr args
)))))
3540 ;; @defmethod: Specialized object-oriented
3541 (put 'defmethod
'texinfo-deffn-formatting-property
'texinfo-format-defmethod
)
3542 (put 'defmethodx
'texinfo-deffn-formatting-property
'texinfo-format-defmethod
)
3543 (defun texinfo-format-defmethod (parsed-args)
3544 ;; Specialized object oriented entity:
3545 ;; @defmethod class name args...
3546 ;; In Info, `Method on class: name ARGS'
3547 ;; Note: args in upper case; use of `on'
3548 ;; Use cdr of texinfo-defun-type to determine category:
3549 (let ((category (car (cdr texinfo-defun-type
)))
3550 (class (car parsed-args
))
3551 (name (car (cdr parsed-args
)))
3552 (args (cdr (cdr parsed-args
))))
3553 (insert " -- " category
" on " class
": " name
)
3555 (insert " " (upcase (car args
)))
3556 (setq args
(cdr args
)))))
3558 ;; @defivar: Specialized object-oriented
3559 (put 'defivar
'texinfo-deffn-formatting-property
'texinfo-format-defivar
)
3560 (put 'defivarx
'texinfo-deffn-formatting-property
'texinfo-format-defivar
)
3561 (defun texinfo-format-defivar (parsed-args)
3562 ;; Specialized object oriented entity:
3563 ;; @defivar class name
3564 ;; In Info, `Instance variable of class: name'
3565 ;; Note: args in upper case; use of `of'
3566 ;; Use cdr of texinfo-defun-type to determine category:
3567 (let ((category (car (cdr texinfo-defun-type
)))
3568 (class (car parsed-args
))
3569 (name (car (cdr parsed-args
)))
3570 (args (cdr (cdr parsed-args
))))
3571 (insert " -- " category
" of " class
": " name
)
3573 (insert " " (upcase (car args
)))
3574 (setq args
(cdr args
)))))
3577 ;;; Indexing for definitions
3579 ;; An index entry has three parts: the `entry proper', the node name, and the
3580 ;; line number. Depending on the which command is used, the entry is
3581 ;; formatted differently:
3587 ;; @defopt all use their 1st argument as the entry-proper
3593 ;; @deftypevar all use their 2nd argument as the entry-proper
3596 ;; @deftypevr both use their 3rd argument as the entry-proper
3598 ;; @defmethod uses its 2nd and 1st arguments as an entry-proper
3599 ;; formatted: NAME on CLASS
3601 ;; @defop uses its 3rd and 2nd arguments as an entry-proper
3602 ;; formatted: NAME on CLASS
3604 ;; @defivar uses its 2nd and 1st arguments as an entry-proper
3605 ;; formatted: NAME of CLASS
3607 ;; @defcv uses its 3rd and 2nd argument as an entry-proper
3608 ;; formatted: NAME of CLASS
3610 (put 'defun
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3611 (put 'defunx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3612 (put 'defmac
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3613 (put 'defmacx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3614 (put 'defspec
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3615 (put 'defspecx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3616 (put 'defvar
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3617 (put 'defvarx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3618 (put 'defopt
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3619 (put 'defoptx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3620 (defun texinfo-index-defun (parsed-args)
3621 ;; use 1st parsed-arg as entry-proper
3622 ;; `index-list' will be texinfo-findex or the like
3623 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3626 ;; Three elements: entry-proper, node-name, line-number
3630 ;; Region formatting may not provide last node position.
3631 (if texinfo-last-node-pos
3632 (1+ (count-lines texinfo-last-node-pos
(point)))
3634 (symbol-value index-list
)))))
3636 (put 'deffn
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3637 (put 'deffnx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3638 (put 'defvr
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3639 (put 'defvrx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3640 (put 'deftp
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3641 (put 'deftpx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3642 (put 'deftypefun
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3643 (put 'deftypefunx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3644 (put 'deftypevar
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3645 (put 'deftypevarx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3646 (defun texinfo-index-deffn (parsed-args)
3647 ;; use 2nd parsed-arg as entry-proper
3648 ;; `index-list' will be texinfo-findex or the like
3649 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3652 ;; Three elements: entry-proper, node-name, line-number
3654 (car (cdr parsed-args
))
3656 ;; Region formatting may not provide last node position.
3657 (if texinfo-last-node-pos
3658 (1+ (count-lines texinfo-last-node-pos
(point)))
3660 (symbol-value index-list
)))))
3662 (put 'deftypefn
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3663 (put 'deftypefnx
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3664 (put 'deftypevr
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3665 (put 'deftypevrx
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3666 (defun texinfo-index-deftypefn (parsed-args)
3667 ;; use 3rd parsed-arg as entry-proper
3668 ;; `index-list' will be texinfo-findex or the like
3669 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3672 ;; Three elements: entry-proper, node-name, line-number
3674 (car (cdr (cdr parsed-args
)))
3676 ;; Region formatting may not provide last node position.
3677 (if texinfo-last-node-pos
3678 (1+ (count-lines texinfo-last-node-pos
(point)))
3680 (symbol-value index-list
)))))
3682 (put 'defmethod
'texinfo-defun-indexing-property
'texinfo-index-defmethod
)
3683 (put 'defmethodx
'texinfo-defun-indexing-property
'texinfo-index-defmethod
)
3684 (defun texinfo-index-defmethod (parsed-args)
3685 ;; use 2nd on 1st parsed-arg as entry-proper
3686 ;; `index-list' will be texinfo-findex or the like
3687 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3690 ;; Three elements: entry-proper, node-name, line-number
3693 (car (cdr parsed-args
))
3696 ;; Region formatting may not provide last node position.
3697 (if texinfo-last-node-pos
3698 (1+ (count-lines texinfo-last-node-pos
(point)))
3700 (symbol-value index-list
)))))
3702 (put 'defop
'texinfo-defun-indexing-property
'texinfo-index-defop
)
3703 (put 'defopx
'texinfo-defun-indexing-property
'texinfo-index-defop
)
3704 (defun texinfo-index-defop (parsed-args)
3705 ;; use 3rd on 2nd parsed-arg as entry-proper
3706 ;; `index-list' will be texinfo-findex or the like
3707 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3710 ;; Three elements: entry-proper, node-name, line-number
3713 (car (cdr (cdr parsed-args
)))
3714 (car (cdr parsed-args
)))
3716 ;; Region formatting may not provide last node position.
3717 (if texinfo-last-node-pos
3718 (1+ (count-lines texinfo-last-node-pos
(point)))
3720 (symbol-value index-list
)))))
3722 (put 'defivar
'texinfo-defun-indexing-property
'texinfo-index-defivar
)
3723 (put 'defivarx
'texinfo-defun-indexing-property
'texinfo-index-defivar
)
3724 (defun texinfo-index-defivar (parsed-args)
3725 ;; use 2nd of 1st parsed-arg as entry-proper
3726 ;; `index-list' will be texinfo-findex or the like
3727 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3730 ;; Three elements: entry-proper, node-name, line-number
3733 (car (cdr parsed-args
))
3736 ;; Region formatting may not provide last node position.
3737 (if texinfo-last-node-pos
3738 (1+ (count-lines texinfo-last-node-pos
(point)))
3740 (symbol-value index-list
)))))
3742 (put 'defcv
'texinfo-defun-indexing-property
'texinfo-index-defcv
)
3743 (put 'defcvx
'texinfo-defun-indexing-property
'texinfo-index-defcv
)
3744 (defun texinfo-index-defcv (parsed-args)
3745 ;; use 3rd of 2nd parsed-arg as entry-proper
3746 ;; `index-list' will be texinfo-findex or the like
3747 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3750 ;; Three elements: entry-proper, node-name, line-number
3753 (car (cdr (cdr parsed-args
)))
3754 (car (cdr parsed-args
)))
3756 ;; Region formatting may not provide last node position.
3757 (if texinfo-last-node-pos
3758 (1+ (count-lines texinfo-last-node-pos
(point)))
3760 (symbol-value index-list
)))))
3763 ;;; Properties for definitions
3765 ;; Each definition command has six properties:
3767 ;; 1. texinfo-deffn-formatting-property to format definition line
3768 ;; 2. texinfo-defun-indexing-property to create index entry
3769 ;; 3. texinfo-format formatting command
3770 ;; 4. texinfo-end end formatting command
3771 ;; 5. texinfo-defun-type type of deffn to format
3772 ;; 6. texinfo-defun-index type of index to use
3774 ;; The `x' forms of each definition command are used for the second
3775 ;; and subsequent header lines.
3777 ;; The texinfo-deffn-formatting-property and texinfo-defun-indexing-property
3778 ;; are listed just before the appropriate formatting and indexing commands.
3780 (put 'deffn
'texinfo-format
'texinfo-format-defun
)
3781 (put 'deffnx
'texinfo-format
'texinfo-format-defunx
)
3782 (put 'deffn
'texinfo-end
'texinfo-end-defun
)
3783 (put 'deffn
'texinfo-defun-type
'('deffn-type nil
))
3784 (put 'deffnx
'texinfo-defun-type
'('deffn-type nil
))
3785 (put 'deffn
'texinfo-defun-index
'texinfo-findex
)
3786 (put 'deffnx
'texinfo-defun-index
'texinfo-findex
)
3788 (put 'defun
'texinfo-format
'texinfo-format-defun
)
3789 (put 'defunx
'texinfo-format
'texinfo-format-defunx
)
3790 (put 'defun
'texinfo-end
'texinfo-end-defun
)
3791 (put 'defun
'texinfo-defun-type
'('defun-type
"Function"))
3792 (put 'defunx
'texinfo-defun-type
'('defun-type
"Function"))
3793 (put 'defun
'texinfo-defun-index
'texinfo-findex
)
3794 (put 'defunx
'texinfo-defun-index
'texinfo-findex
)
3796 (put 'defmac
'texinfo-format
'texinfo-format-defun
)
3797 (put 'defmacx
'texinfo-format
'texinfo-format-defunx
)
3798 (put 'defmac
'texinfo-end
'texinfo-end-defun
)
3799 (put 'defmac
'texinfo-defun-type
'('defun-type
"Macro"))
3800 (put 'defmacx
'texinfo-defun-type
'('defun-type
"Macro"))
3801 (put 'defmac
'texinfo-defun-index
'texinfo-findex
)
3802 (put 'defmacx
'texinfo-defun-index
'texinfo-findex
)
3804 (put 'defspec
'texinfo-format
'texinfo-format-defun
)
3805 (put 'defspecx
'texinfo-format
'texinfo-format-defunx
)
3806 (put 'defspec
'texinfo-end
'texinfo-end-defun
)
3807 (put 'defspec
'texinfo-defun-type
'('defun-type
"Special form"))
3808 (put 'defspecx
'texinfo-defun-type
'('defun-type
"Special form"))
3809 (put 'defspec
'texinfo-defun-index
'texinfo-findex
)
3810 (put 'defspecx
'texinfo-defun-index
'texinfo-findex
)
3812 (put 'defvr
'texinfo-format
'texinfo-format-defun
)
3813 (put 'defvrx
'texinfo-format
'texinfo-format-defunx
)
3814 (put 'defvr
'texinfo-end
'texinfo-end-defun
)
3815 (put 'defvr
'texinfo-defun-type
'('deffn-type nil
))
3816 (put 'defvrx
'texinfo-defun-type
'('deffn-type nil
))
3817 (put 'defvr
'texinfo-defun-index
'texinfo-vindex
)
3818 (put 'defvrx
'texinfo-defun-index
'texinfo-vindex
)
3820 (put 'defvar
'texinfo-format
'texinfo-format-defun
)
3821 (put 'defvarx
'texinfo-format
'texinfo-format-defunx
)
3822 (put 'defvar
'texinfo-end
'texinfo-end-defun
)
3823 (put 'defvar
'texinfo-defun-type
'('defun-type
"Variable"))
3824 (put 'defvarx
'texinfo-defun-type
'('defun-type
"Variable"))
3825 (put 'defvar
'texinfo-defun-index
'texinfo-vindex
)
3826 (put 'defvarx
'texinfo-defun-index
'texinfo-vindex
)
3828 (put 'defconst
'texinfo-format
'texinfo-format-defun
)
3829 (put 'defconstx
'texinfo-format
'texinfo-format-defunx
)
3830 (put 'defconst
'texinfo-end
'texinfo-end-defun
)
3831 (put 'defconst
'texinfo-defun-type
'('defun-type
"Constant"))
3832 (put 'defconstx
'texinfo-defun-type
'('defun-type
"Constant"))
3833 (put 'defconst
'texinfo-defun-index
'texinfo-vindex
)
3834 (put 'defconstx
'texinfo-defun-index
'texinfo-vindex
)
3836 (put 'defcmd
'texinfo-format
'texinfo-format-defun
)
3837 (put 'defcmdx
'texinfo-format
'texinfo-format-defunx
)
3838 (put 'defcmd
'texinfo-end
'texinfo-end-defun
)
3839 (put 'defcmd
'texinfo-defun-type
'('defun-type
"Command"))
3840 (put 'defcmdx
'texinfo-defun-type
'('defun-type
"Command"))
3841 (put 'defcmd
'texinfo-defun-index
'texinfo-findex
)
3842 (put 'defcmdx
'texinfo-defun-index
'texinfo-findex
)
3844 (put 'defopt
'texinfo-format
'texinfo-format-defun
)
3845 (put 'defoptx
'texinfo-format
'texinfo-format-defunx
)
3846 (put 'defopt
'texinfo-end
'texinfo-end-defun
)
3847 (put 'defopt
'texinfo-defun-type
'('defun-type
"User Option"))
3848 (put 'defoptx
'texinfo-defun-type
'('defun-type
"User Option"))
3849 (put 'defopt
'texinfo-defun-index
'texinfo-vindex
)
3850 (put 'defoptx
'texinfo-defun-index
'texinfo-vindex
)
3852 (put 'deftp
'texinfo-format
'texinfo-format-defun
)
3853 (put 'deftpx
'texinfo-format
'texinfo-format-defunx
)
3854 (put 'deftp
'texinfo-end
'texinfo-end-defun
)
3855 (put 'deftp
'texinfo-defun-type
'('deftp-type nil
))
3856 (put 'deftpx
'texinfo-defun-type
'('deftp-type nil
))
3857 (put 'deftp
'texinfo-defun-index
'texinfo-tindex
)
3858 (put 'deftpx
'texinfo-defun-index
'texinfo-tindex
)
3860 ;;; Object-oriented stuff is a little hairier.
3862 (put 'defop
'texinfo-format
'texinfo-format-defun
)
3863 (put 'defopx
'texinfo-format
'texinfo-format-defunx
)
3864 (put 'defop
'texinfo-end
'texinfo-end-defun
)
3865 (put 'defop
'texinfo-defun-type
'('defop-type nil
))
3866 (put 'defopx
'texinfo-defun-type
'('defop-type nil
))
3867 (put 'defop
'texinfo-defun-index
'texinfo-findex
)
3868 (put 'defopx
'texinfo-defun-index
'texinfo-findex
)
3870 (put 'defmethod
'texinfo-format
'texinfo-format-defun
)
3871 (put 'defmethodx
'texinfo-format
'texinfo-format-defunx
)
3872 (put 'defmethod
'texinfo-end
'texinfo-end-defun
)
3873 (put 'defmethod
'texinfo-defun-type
'('defmethod-type
"Method"))
3874 (put 'defmethodx
'texinfo-defun-type
'('defmethod-type
"Method"))
3875 (put 'defmethod
'texinfo-defun-index
'texinfo-findex
)
3876 (put 'defmethodx
'texinfo-defun-index
'texinfo-findex
)
3878 (put 'defcv
'texinfo-format
'texinfo-format-defun
)
3879 (put 'defcvx
'texinfo-format
'texinfo-format-defunx
)
3880 (put 'defcv
'texinfo-end
'texinfo-end-defun
)
3881 (put 'defcv
'texinfo-defun-type
'('defop-type nil
))
3882 (put 'defcvx
'texinfo-defun-type
'('defop-type nil
))
3883 (put 'defcv
'texinfo-defun-index
'texinfo-vindex
)
3884 (put 'defcvx
'texinfo-defun-index
'texinfo-vindex
)
3886 (put 'defivar
'texinfo-format
'texinfo-format-defun
)
3887 (put 'defivarx
'texinfo-format
'texinfo-format-defunx
)
3888 (put 'defivar
'texinfo-end
'texinfo-end-defun
)
3889 (put 'defivar
'texinfo-defun-type
'('defmethod-type
"Instance variable"))
3890 (put 'defivarx
'texinfo-defun-type
'('defmethod-type
"Instance variable"))
3891 (put 'defivar
'texinfo-defun-index
'texinfo-vindex
)
3892 (put 'defivarx
'texinfo-defun-index
'texinfo-vindex
)
3894 ;;; Typed functions and variables
3896 (put 'deftypefn
'texinfo-format
'texinfo-format-defun
)
3897 (put 'deftypefnx
'texinfo-format
'texinfo-format-defunx
)
3898 (put 'deftypefn
'texinfo-end
'texinfo-end-defun
)
3899 (put 'deftypefn
'texinfo-defun-type
'('deftypefn-type nil
))
3900 (put 'deftypefnx
'texinfo-defun-type
'('deftypefn-type nil
))
3901 (put 'deftypefn
'texinfo-defun-index
'texinfo-findex
)
3902 (put 'deftypefnx
'texinfo-defun-index
'texinfo-findex
)
3904 (put 'deftypefun
'texinfo-format
'texinfo-format-defun
)
3905 (put 'deftypefunx
'texinfo-format
'texinfo-format-defunx
)
3906 (put 'deftypefun
'texinfo-end
'texinfo-end-defun
)
3907 (put 'deftypefun
'texinfo-defun-type
'('deftypefun-type
"Function"))
3908 (put 'deftypefunx
'texinfo-defun-type
'('deftypefun-type
"Function"))
3909 (put 'deftypefun
'texinfo-defun-index
'texinfo-findex
)
3910 (put 'deftypefunx
'texinfo-defun-index
'texinfo-findex
)
3912 (put 'deftypevr
'texinfo-format
'texinfo-format-defun
)
3913 (put 'deftypevrx
'texinfo-format
'texinfo-format-defunx
)
3914 (put 'deftypevr
'texinfo-end
'texinfo-end-defun
)
3915 (put 'deftypevr
'texinfo-defun-type
'('deftypefn-type nil
))
3916 (put 'deftypevrx
'texinfo-defun-type
'('deftypefn-type nil
))
3917 (put 'deftypevr
'texinfo-defun-index
'texinfo-vindex
)
3918 (put 'deftypevrx
'texinfo-defun-index
'texinfo-vindex
)
3920 (put 'deftypevar
'texinfo-format
'texinfo-format-defun
)
3921 (put 'deftypevarx
'texinfo-format
'texinfo-format-defunx
)
3922 (put 'deftypevar
'texinfo-end
'texinfo-end-defun
)
3923 (put 'deftypevar
'texinfo-defun-type
'('deftypevar-type
"Variable"))
3924 (put 'deftypevarx
'texinfo-defun-type
'('deftypevar-type
"Variable"))
3925 (put 'deftypevar
'texinfo-defun-index
'texinfo-vindex
)
3926 (put 'deftypevarx
'texinfo-defun-index
'texinfo-vindex
)
3929 ;;; @set, @clear, @ifset, @ifclear
3931 ;; If a flag is set with @set FLAG, then text between @ifset and @end
3932 ;; ifset is formatted normally, but if the flag is cleared with
3933 ;; @clear FLAG, then the text is not formatted; it is ignored.
3935 ;; If a flag is cleared with @clear FLAG, then text between @ifclear
3936 ;; and @end ifclear is formatted normally, but if the flag is set with
3937 ;; @set FLAG, then the text is not formatted; it is ignored. @ifclear
3938 ;; is the opposite of @ifset.
3940 ;; If a flag is set to a string with @set FLAG,
3941 ;; replace @value{FLAG} with the string.
3942 ;; If a flag with a value is cleared,
3943 ;; @value{FLAG} is invalid,
3944 ;; as if there had never been any @set FLAG previously.
3946 (put 'clear
'texinfo-format
'texinfo-clear
)
3947 (defun texinfo-clear ()
3948 "Clear the value of the flag."
3949 (let* ((arg (texinfo-parse-arg-discard))
3950 (flag (car (read-from-string arg
)))
3951 (value (substring arg
(cdr (read-from-string arg
)))))
3952 (put flag
'texinfo-whether-setp
'flag-cleared
)
3953 (put flag
'texinfo-set-value
"")))
3955 (put 'set
'texinfo-format
'texinfo-set
)
3956 (defun texinfo-set ()
3957 "Set the value of the flag, optionally to a string.
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 (flag (car (read-from-string arg
)))
3963 (value (substring arg
(cdr (read-from-string arg
)))))
3964 (if (string-match "^[ \t]+" value
)
3965 (setq value
(substring value
(match-end 0))))
3966 (put flag
'texinfo-whether-setp
'flag-set
)
3967 (put flag
'texinfo-set-value value
)))
3969 (put 'value
'texinfo-format
'texinfo-value
)
3970 (defun texinfo-value ()
3971 "Insert the string to which the flag is set.
3972 The command `@set foo This is a string.'
3973 sets flag foo to the value: `This is a string.'
3974 The command `@value{foo}' expands to the value."
3975 (let ((arg (texinfo-parse-arg-discard)))
3977 (eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3979 (get (car (read-from-string arg
)) 'texinfo-set-value
))
3980 (insert (get (car (read-from-string arg
)) 'texinfo-set-value
)))
3981 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3983 (insert (format "{No value for \"%s\"}" arg
)))
3984 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
) nil
)
3985 (insert (format "{No value for \"%s\"}" arg
))))))
3987 (put 'ifset
'texinfo-end
'texinfo-discard-command
)
3988 (put 'ifset
'texinfo-format
'texinfo-if-set
)
3989 (defun texinfo-if-set ()
3990 "If set, continue formatting; else do not format region up to @end ifset."
3991 (let ((arg (texinfo-parse-arg-discard)))
3993 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3995 ;; Format the text (i.e., do not remove it); do nothing here.
3997 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3999 ;; Clear region (i.e., cause the text to be ignored).
4000 (delete-region texinfo-command-start
4001 (re-search-forward "@end ifset[ \t]*\n")))
4002 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4004 ;; In this case flag is neither set nor cleared.
4005 ;; Act as if set, i.e. do nothing.
4008 (put 'ifclear
'texinfo-end
'texinfo-discard-command
)
4009 (put 'ifclear
'texinfo-format
'texinfo-if-clear
)
4010 (defun texinfo-if-clear ()
4011 "If clear, continue formatting; if set, do not format up to @end ifset."
4012 (let ((arg (texinfo-parse-arg-discard)))
4014 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4016 ;; Clear region (i.e., cause the text to be ignored).
4017 (delete-region texinfo-command-start
4018 (re-search-forward "@end ifclear[ \t]*\n")))
4019 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4021 ;; Format the text (i.e., do not remove it); do nothing here.
4023 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4025 ;; In this case flag is neither set nor cleared.
4026 ;; Act as if clear, i.e. do nothing.
4031 (put 'ifeq
'texinfo-format
'texinfo-format-ifeq
)
4032 (defun texinfo-format-ifeq ()
4033 "If ARG1 and ARG2 caselessly string compare to same string, perform COMMAND.
4034 Otherwise produces no output.
4037 @ifeq{ arg1 , arg1 , @code{foo}} bar
4041 @ifeq{ arg1 , arg2 , @code{foo}} bar
4045 Note that the Texinfo command and its arguments must be arguments to
4047 ;; compare-buffer-substrings does not exist in version 18; don't use
4048 (goto-char texinfo-command-end
)
4049 (let* ((case-fold-search t
)
4050 (stop (save-excursion (forward-sexp 1) (point)))
4052 ;; @ifeq{arg1, arg2, @command{optional-args}}
4056 (skip-chars-forward " ")
4057 (setq start
(point))
4058 (search-forward "," stop t
)
4059 (skip-chars-backward ", ")
4060 (buffer-substring-no-properties start
(point))))
4063 (search-forward "," stop t
)
4064 (skip-chars-forward " ")
4065 (setq start
(point))
4066 (search-forward "," stop t
)
4067 (skip-chars-backward ", ")
4068 (buffer-substring-no-properties start
(point))))
4071 (search-forward "," stop t
)
4072 (skip-chars-forward " ")
4073 (setq start
(point))
4074 (goto-char (1- stop
))
4075 (skip-chars-backward " ")
4076 (buffer-substring-no-properties start
(point)))))
4077 (delete-region texinfo-command-start stop
)
4078 (if (equal arg1 arg2
)
4079 (insert texinfo-command
))
4080 (goto-char texinfo-command-start
)))
4083 ;;; Process included files: `@include' command
4085 ;; Updated 19 October 1990
4086 ;; In the original version, include files were ignored by Info but
4087 ;; incorporated in to the printed manual. To make references to the
4088 ;; included file, the Texinfo source file has to refer to the included
4089 ;; files using the `(filename)nodename' format for referring to other
4090 ;; Info files. Also, the included files had to be formatted on their
4091 ;; own. It was just like they were another file.
4093 ;; Currently, include files are inserted into the buffer that is
4094 ;; formatted for Info. If large, the resulting info file is split and
4095 ;; tagified. For current include files to work, the master menu must
4096 ;; refer to all the nodes, and the highest level nodes in the include
4097 ;; files must have the correct next, prev, and up pointers.
4099 ;; The included file may have an @setfilename and even an @settitle,
4100 ;; but not an `\input texinfo' line.
4102 ;; Updated 24 March 1993
4103 ;; In order for @raisesections and @lowersections to work, included
4104 ;; files must be inserted into the buffer holding the outer file
4105 ;; before other Info formatting takes place. So @include is no longer
4106 ;; is treated like other @-commands.
4107 (put 'include
'texinfo-format
'texinfo-format-noop
)
4109 ;; Original definition:
4110 ;; (defun texinfo-format-include ()
4111 ;; (let ((filename (texinfo-parse-arg-discard))
4112 ;; (default-directory input-directory)
4116 ;; (progn (find-file
4117 ;; (cond ((file-readable-p (concat filename ".texinfo"))
4118 ;; (concat filename ".texinfo"))
4119 ;; ((file-readable-p (concat filename ".texi"))
4120 ;; (concat filename ".texi"))
4121 ;; ((file-readable-p (concat filename ".tex"))
4122 ;; (concat filename ".tex"))
4123 ;; ((file-readable-p filename)
4125 ;; (t (error "@include'd file %s not found"
4127 ;; (texinfo-format-buffer-1))))
4128 ;; (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex))
4129 ;; (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex))
4130 ;; (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex))
4131 ;; (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex))
4132 ;; (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex))
4133 ;; (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex))))
4135 ;;(defun texinfo-subindex (indexvar file content)
4136 ;; (set indexvar (cons (list 'recurse file content)
4137 ;; (symbol-value indexvar))))
4139 ;; Second definition:
4140 ;; (put 'include 'texinfo-format 'texinfo-format-include)
4141 ;; (defun texinfo-format-include ()
4142 ;; (let ((filename (concat input-directory
4143 ;; (texinfo-parse-arg-discard)))
4144 ;; (default-directory input-directory))
4145 ;; (message "Reading: %s" filename)
4147 ;; (save-restriction
4148 ;; (narrow-to-region
4150 ;; (+ (point) (car (cdr (insert-file-contents filename)))))
4151 ;; (goto-char (point-min))
4152 ;; (texinfo-append-refill)
4153 ;; (texinfo-format-convert (point-min) (point-max))))
4154 ;; (setq last-input-buffer input-buffer) ; to bypass setfilename
4158 ;;; Numerous commands do nothing in Info
4159 ;; These commands are defined in texinfo.tex for printed output.
4162 ;;; various noops, such as @b{foo}, that take arguments in braces
4164 (put 'b
'texinfo-format
'texinfo-format-noop
)
4165 (put 'i
'texinfo-format
'texinfo-format-noop
)
4166 (put 'r
'texinfo-format
'texinfo-format-noop
)
4167 (put 't
'texinfo-format
'texinfo-format-noop
)
4168 (put 'w
'texinfo-format
'texinfo-format-noop
)
4169 (put 'asis
'texinfo-format
'texinfo-format-noop
)
4170 (put 'dmn
'texinfo-format
'texinfo-format-noop
)
4171 (put 'math
'texinfo-format
'texinfo-format-noop
)
4172 (put 'titlefont
'texinfo-format
'texinfo-format-noop
)
4173 (defun texinfo-format-noop ()
4174 (insert (texinfo-parse-arg-discard))
4175 (goto-char texinfo-command-start
))
4177 ;; @hyphenation command discards an argument within braces
4178 (put 'hyphenation
'texinfo-format
'texinfo-discard-command-and-arg
)
4179 (defun texinfo-discard-command-and-arg ()
4180 "Discard both @-command and its argument in braces."
4181 (goto-char texinfo-command-end
)
4183 (setq texinfo-command-end
(point))
4184 (delete-region texinfo-command-start texinfo-command-end
))
4187 ;;; Do nothing commands, such as @smallbook, that have no args and no braces
4188 ;; These must appear on a line of their own
4190 (put 'bye
'texinfo-format
'texinfo-discard-line
)
4191 (put 'smallbook
'texinfo-format
'texinfo-discard-line
)
4192 (put 'finalout
'texinfo-format
'texinfo-discard-line
)
4193 (put 'overfullrule
'texinfo-format
'texinfo-discard-line
)
4194 (put 'smallbreak
'texinfo-format
'texinfo-discard-line
)
4195 (put 'medbreak
'texinfo-format
'texinfo-discard-line
)
4196 (put 'bigbreak
'texinfo-format
'texinfo-discard-line
)
4197 (put 'afourpaper
'texinfo-format
'texinfo-discard-line
)
4198 (put 'afivepaper
'texinfo-format
'texinfo-discard-line
)
4199 (put 'afourlatex
'texinfo-format
'texinfo-discard-line
)
4200 (put 'afourwide
'texinfo-format
'texinfo-discard-line
)
4203 ;;; These noop commands discard the rest of the line.
4205 (put 'c
'texinfo-format
'texinfo-discard-line-with-args
)
4206 (put 'comment
'texinfo-format
'texinfo-discard-line-with-args
)
4207 (put 'contents
'texinfo-format
'texinfo-discard-line-with-args
)
4208 (put 'group
'texinfo-end
'texinfo-discard-line-with-args
)
4209 (put 'group
'texinfo-format
'texinfo-discard-line-with-args
)
4210 (put 'headings
'texinfo-format
'texinfo-discard-line-with-args
)
4211 (put 'setchapterstyle
'texinfo-format
'texinfo-discard-line-with-args
)
4212 (put 'hsize
'texinfo-format
'texinfo-discard-line-with-args
)
4213 (put 'itemindent
'texinfo-format
'texinfo-discard-line-with-args
)
4214 (put 'lispnarrowing
'texinfo-format
'texinfo-discard-line-with-args
)
4215 (put 'need
'texinfo-format
'texinfo-discard-line-with-args
)
4216 (put 'nopara
'texinfo-format
'texinfo-discard-line-with-args
)
4218 ;; @novalidate suppresses cross-reference checking and auxiliary file
4219 ;; creation with TeX. The Info-validate command checks that every
4220 ;; node pointer points to an existing node. Since this Info command
4221 ;; is not invoked automatically, the @novalidate command is irrelevant
4222 ;; and not supported by texinfmt.el
4223 (put 'novalidate
'texinfo-format
'texinfo-discard-line-with-args
)
4225 (put 'page
'texinfo-format
'texinfo-discard-line-with-args
)
4226 (put 'pagesizes
'texinfo-format
'texinfo-discard-line-with-args
)
4227 (put 'parindent
'texinfo-format
'texinfo-discard-line-with-args
)
4228 (put 'setchapternewpage
'texinfo-format
'texinfo-discard-line-with-args
)
4229 (put 'setq
'texinfo-format
'texinfo-discard-line-with-args
)
4231 (put 'setcontentsaftertitlepage
4232 'texinfo-format
'texinfo-discard-line-with-args
)
4233 (put 'setshortcontentsaftertitlepage
4234 'texinfo-format
'texinfo-discard-line-with-args
)
4236 (put 'settitle
'texinfo-format
'texinfo-discard-line-with-args
)
4237 (put 'setx
'texinfo-format
'texinfo-discard-line-with-args
)
4238 (put 'shortcontents
'texinfo-format
'texinfo-discard-line-with-args
)
4239 (put 'shorttitlepage
'texinfo-format
'texinfo-discard-line-with-args
)
4240 (put 'summarycontents
'texinfo-format
'texinfo-discard-line-with-args
)
4241 (put 'input
'texinfo-format
'texinfo-discard-line-with-args
)
4243 (put 'documentlanguage
'texinfo-format
'texinfo-discard-line-with-args
)
4244 (put 'documentencoding
'texinfo-format
'texinfo-discard-line-with-args
)
4248 ;;; Some commands cannot be handled
4250 (defun texinfo-unsupported ()
4251 (error "%s is not handled by texinfo"
4252 (buffer-substring-no-properties texinfo-command-start texinfo-command-end
)))
4254 ;;; Batch formatting
4256 (defun batch-texinfo-format ()
4257 "Run `texinfo-format-buffer' on the files remaining on the command line.
4258 Must be used only with -batch, and kills Emacs on completion.
4259 Each file will be processed even if an error occurred previously.
4261 \"emacs -batch -l texinfmt -f batch-texinfo-format $docs/ ~/*.texinfo\"."
4262 (if (not noninteractive
)
4263 (error "batch-texinfo-format may only be used -batch"))
4264 (let ((version-control t
)
4265 (auto-save-default nil
)
4266 (find-file-run-dired nil
)
4267 (kept-old-versions 259259)
4268 (kept-new-versions 259259))
4272 (while command-line-args-left
4273 (setq file
(expand-file-name (car command-line-args-left
)))
4274 (cond ((not (file-exists-p file
))
4275 (message ">> %s does not exist!" file
)
4277 command-line-args-left
(cdr command-line-args-left
)))
4278 ((file-directory-p file
)
4279 (setq command-line-args-left
4280 (nconc (directory-files file
)
4281 (cdr command-line-args-left
))))
4284 (setq command-line-args-left
(cdr command-line-args-left
)))))
4286 (setq file
(car files
)
4290 (if buffer-file-name
(kill-buffer (current-buffer)))
4292 (buffer-disable-undo (current-buffer))
4293 (set-buffer-modified-p nil
)
4295 (message "texinfo formatting %s..." file
)
4296 (texinfo-format-buffer nil
)
4297 (if (buffer-modified-p)
4298 (progn (message "Saving modified %s" (buffer-file-name))
4301 (message ">> Error: %s" (prin1-to-string err
))
4302 (message ">> point at")
4303 (let ((s (buffer-substring-no-properties (point)
4304 (min (+ (point) 100)
4307 (while (setq tem
(string-match "\n+" s tem
))
4308 (setq s
(concat (substring s
0 (match-beginning 0))
4310 (substring s
(match-end 0)))
4312 (message ">> %s" s
))
4314 (kill-emacs error
))))
4317 ;;; Place `provide' at end of file.
4320 ;;; texinfmt.el ends here