1 ;;; texinfmt.el --- format Texinfo files into Info files
3 ;; Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
4 ;; 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
5 ;; 2008, 2009, 2010 Free Software Foundation, Inc.
7 ;; Maintainer: Robert J. Chassell <bug-texinfo@gnu.org>
8 ;; Keywords: maint, tex, docs
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
29 ;;; Emacs lisp functions to convert Texinfo files to Info files.
31 (defvar texinfmt-version
"2.42 of 7 Jul 2006")
33 (defun texinfmt-version (&optional here
)
34 "Show the version of texinfmt.el in the minibuffer.
35 If optional argument HERE is non-nil, insert info at point."
38 (format "Version of \`texinfmt.el\': %s" texinfmt-version
)))
40 (insert version-string
)
41 (if (called-interactively-p 'interactive
)
42 (message "%s" version-string
)
46 ;;; Variable definitions
48 (require 'texinfo
) ; So `texinfo-footnote-style' is defined.
49 (require 'texnfo-upd
) ; So `texinfo-section-types-regexp' is defined.
51 (defvar texinfo-vindex
)
52 (defvar texinfo-findex
)
53 (defvar texinfo-cindex
)
54 (defvar texinfo-pindex
)
55 (defvar texinfo-tindex
)
56 (defvar texinfo-kindex
)
57 (defvar texinfo-last-node
)
58 (defvar texinfo-node-names
)
59 (defvar texinfo-enclosure-list
)
60 (defvar texinfo-alias-list
)
61 (defvar texinfo-fold-nodename-case nil
)
63 (defvar texinfo-command-start
)
64 (defvar texinfo-command-end
)
65 (defvar texinfo-command-name
)
66 (defvar texinfo-defun-type
)
67 (defvar texinfo-last-node-pos
)
68 (defvar texinfo-stack
)
69 (defvar texinfo-short-index-cmds-alist
)
70 (defvar texinfo-short-index-format-cmds-alist
)
71 (defvar texinfo-format-filename
)
72 (defvar texinfo-footnote-number
)
74 (defvar texinfo-raisesections-alist
75 '((@chapter .
@chapter
) ; Cannot go higher
76 (@unnumbered .
@unnumbered
)
77 (@centerchap .
@unnumbered
)
79 (@majorheading .
@majorheading
)
80 (@chapheading .
@chapheading
)
81 (@appendix .
@appendix
)
84 (@unnumberedsec .
@unnumbered
)
85 (@heading .
@chapheading
)
86 (@appendixsec .
@appendix
)
88 (@subsection .
@section
)
89 (@unnumberedsubsec .
@unnumberedsec
)
90 (@subheading .
@heading
)
91 (@appendixsubsec .
@appendixsec
)
93 (@subsubsection .
@subsection
)
94 (@unnumberedsubsubsec .
@unnumberedsubsec
)
95 (@subsubheading .
@subheading
)
96 (@appendixsubsubsec .
@appendixsubsec
))
97 "*An alist of next higher levels for chapters, sections, etc...
98 For example, section to chapter, subsection to section.
99 Used by `texinfo-raise-lower-sections'.
100 The keys specify types of section; the values correspond to the next
103 (defvar texinfo-lowersections-alist
104 '((@chapter .
@section
)
105 (@unnumbered .
@unnumberedsec
)
106 (@centerchap .
@unnumberedsec
)
107 (@majorheading .
@heading
)
108 (@chapheading .
@heading
)
109 (@appendix .
@appendixsec
)
111 (@section .
@subsection
)
112 (@unnumberedsec .
@unnumberedsubsec
)
113 (@heading .
@subheading
)
114 (@appendixsec .
@appendixsubsec
)
116 (@subsection .
@subsubsection
)
117 (@unnumberedsubsec .
@unnumberedsubsubsec
)
118 (@subheading .
@subsubheading
)
119 (@appendixsubsec .
@appendixsubsubsec
)
121 (@subsubsection .
@subsubsection
) ; Cannot go lower.
122 (@unnumberedsubsubsec .
@unnumberedsubsubsec
)
123 (@subsubheading .
@subsubheading
)
124 (@appendixsubsubsec .
@appendixsubsubsec
))
125 "*An alist of next lower levels for chapters, sections, etc...
126 For example, chapter to section, section to subsection.
127 Used by `texinfo-raise-lower-sections'.
128 The keys specify types of section; the values correspond to the next
133 (defvar texinfo-format-syntax-table
134 (let ((st (make-syntax-table)))
135 (modify-syntax-entry ?
\" " " st
)
136 (modify-syntax-entry ?
\\ " " st
)
137 (modify-syntax-entry ?
@ "\\" st
)
138 (modify-syntax-entry ?\^q
"\\" st
)
139 (modify-syntax-entry ?\
[ "." st
)
140 (modify-syntax-entry ?\
] "." st
)
141 (modify-syntax-entry ?\
( "." st
)
142 (modify-syntax-entry ?\
) "." st
)
143 (modify-syntax-entry ?
{ "(}" st
)
144 (modify-syntax-entry ?
} "){" st
)
145 (modify-syntax-entry ?
\' "." st
)
149 ;;; Top level buffer and region formatting functions
152 (defun texinfo-format-buffer (&optional nosplit
)
153 "Process the current buffer as texinfo code, into an Info file.
154 The Info file output is generated in a buffer visiting the Info file
155 name specified in the @setfilename command.
157 Non-nil argument (prefix, if interactive) means don't make tag table
158 and don't split the file if large. You can use `Info-tagify' and
159 `Info-split' to do these manually."
161 (let ((lastmessage "Formatting Info file...")
162 (coding-system-for-write buffer-file-coding-system
))
163 (message lastmessage
)
165 (texinfo-format-buffer-1)
169 (if (> (buffer-size) (+ 50000 Info-split-threshold
))
171 (message (setq lastmessage
"Splitting Info file..."))
173 (message (concat lastmessage
174 (if (called-interactively-p 'interactive
)
175 "done. Now save it." "done.")))))
177 (defvar texinfo-region-buffer-name
"*Info Region*"
178 "*Name of the temporary buffer used by \\[texinfo-format-region].")
180 (defvar texinfo-pre-format-hook nil
181 "Hook called before the conversion of the Texinfo file to Info format.
182 The functions on this hook are called with argument BUFFER, the buffer
183 containing the Texinfo file.")
185 ;; These come from tex-mode.el.
186 (defvar tex-start-of-header
)
187 (defvar tex-end-of-header
)
190 (defun texinfo-format-region (region-beginning region-end
)
191 "Convert the current region of the Texinfo file to Info format.
192 This lets you see what that part of the file will look like in Info.
193 The command is bound to \\[texinfo-format-region]. The text that is
194 converted to Info is stored in a temporary buffer."
196 (message "Converting region to Info format...")
197 (let (texinfo-command-start
207 (texinfo-format-filename "")
208 texinfo-example-start
209 texinfo-last-node-pos
212 (texinfo-footnote-number 0)
214 (fill-column-for-info fill-column
)
215 (input-buffer (current-buffer))
216 (input-directory default-directory
)
221 ;;; Copy lines between beginning and end of header lines,
222 ;;; if any, or else copy the `@setfilename' line, if any.
226 (goto-char (point-min))
227 (let ((search-end (line-beginning-position 101)))
229 ;; Either copy header text.
232 (search-forward tex-start-of-header search-end t
)
234 ;; Mark beginning of header.
235 (setq header-beginning
(point)))
237 (search-forward tex-end-of-header nil t
)
239 ;; Mark end of header
240 (setq header-end
(point))))
241 ;; Or copy @filename line.
243 (goto-char (point-min))
244 (search-forward "@setfilename" search-end t
)
246 (setq header-beginning
(point))
248 (setq header-end
(point))))
252 (buffer-substring-no-properties
253 (min header-beginning region-beginning
)
256 ;;; Find a buffer to use.
257 (switch-to-buffer (get-buffer-create texinfo-region-buffer-name
))
258 (setq buffer-read-only t
)
259 (let ((inhibit-read-only t
))
261 ;; Insert the header into the buffer.
263 ;; Insert the region into the buffer.
264 (insert-buffer-substring
266 (max region-beginning header-end
)
268 (run-hook-with-args 'texinfo-pre-format-hook input-buffer
)
269 ;; Make sure region ends in a newline.
270 (or (= (preceding-char) ?
\n)
273 (goto-char (point-min))
275 (message "Converting region to Info format...")
276 (setq fill-column fill-column-for-info
)
277 ;; Install a syntax table useful for scanning command operands.
278 (set-syntax-table texinfo-format-syntax-table
)
280 ;; Insert @include files so `texinfo-raise-lower-sections' can
281 ;; work on them without losing track of multiple
282 ;; @raise/@lowersections commands.
283 (while (re-search-forward "^@include" nil t
)
284 (setq texinfo-command-end
(point))
285 (let ((filename (concat input-directory
286 (texinfo-parse-line-arg))))
287 (re-search-backward "^@include")
288 (delete-region (point) (line-beginning-position 2))
289 (message "Reading included file: %s" filename
)
294 (+ (point) (car (cdr (insert-file-contents filename
)))))
295 (goto-char (point-min))
296 ;; Remove `@setfilename' line from included file, if any,
297 ;; so @setfilename command not duplicated.
298 (if (re-search-forward "^@setfilename" (line-end-position 100) t
)
299 (delete-region (line-beginning-position 1)
300 (line-beginning-position 2)))))))
302 ;; Raise or lower level of each section, if necessary.
303 (goto-char (point-min))
304 (texinfo-raise-lower-sections)
305 ;; Append @refill to appropriate paragraphs for filling.
306 (goto-char (point-min))
307 (texinfo-append-refill)
308 ;; If the region includes the effective end of the data,
309 ;; discard everything after that.
310 (goto-char (point-max))
311 (if (re-search-backward "^@bye" nil t
)
312 (delete-region (point) (point-max)))
313 ;; Make sure buffer ends in a newline.
314 (or (= (preceding-char) ?
\n)
316 ;; Don't use a previous value of texinfo-enclosure-list.
317 (setq texinfo-enclosure-list nil
)
318 (setq texinfo-alias-list nil
)
320 (goto-char (point-min))
321 (if (looking-at "\\\\input[ \t]+texinfo")
322 (delete-region (point) (line-beginning-position 2)))
324 ;; Insert Info region title text.
325 (goto-char (point-min))
326 (if (search-forward "@setfilename" (line-beginning-position 101) t
)
328 (setq texinfo-command-end
(point))
330 (setq texinfo-command-start
(point))
331 (let ((arg (texinfo-parse-arg-discard)))
333 texinfo-region-buffer-name
335 (insert (file-name-nondirectory (expand-file-name arg
)))
336 (insert "', -*-Text-*-\n")))
337 ;; Else no `@setfilename' line
339 texinfo-region-buffer-name
340 " buffer -*-Text-*-\n"))
341 (insert "produced by `texinfo-format-region'\n"
343 (if (buffer-file-name input-buffer
)
345 (file-name-sans-versions
346 (file-name-nondirectory
347 (buffer-file-name input-buffer
)))
349 (concat "buffer `" (buffer-name input-buffer
) "'"))
350 "\nusing `texinfmt.el' version "
354 ;; Now convert for real.
355 (goto-char (point-min))
356 (texinfo-format-scan)
357 (goto-char (point-min))
358 (Info-tagify input-buffer
)
359 (goto-char (point-min))
363 (defun texi2info (&optional nosplit
)
364 "Convert the current buffer (written in Texinfo code) into an Info file.
365 The Info file output is generated in a buffer visiting the Info file
366 names specified in the @setfilename command.
368 This function automatically updates all node pointers and menus, and
369 creates a master menu. This work is done on a temporary buffer that
370 is automatically removed when the Info file is created. The original
371 Texinfo source buffer is not changed.
373 Non-nil argument (prefix, if interactive) means don't split the file
374 if large. You can use `Info-split' to do this manually."
376 (let ((temp-buffer (concat "*--" (buffer-name) "--temporary-buffer*" )))
377 (message "First updating nodes and menus, then creating Info file.")
379 (copy-to-buffer temp-buffer
(point-min) (point-max))
380 (switch-to-buffer temp-buffer
)
381 (texinfo-master-menu t
)
382 (message "Now creating Info file.")
384 (texinfo-format-buffer nosplit
)
386 (kill-buffer temp-buffer
)))
389 ;;; Primary internal formatting function for the whole buffer.
391 (defun texinfo-format-buffer-1 ()
392 (let (texinfo-format-filename
393 texinfo-example-start
394 texinfo-command-start
398 texinfo-last-node-pos
407 (texinfo-footnote-number 0)
410 (fill-column-for-info fill-column
)
411 (input-buffer (current-buffer))
412 (input-directory default-directory
))
413 (setq texinfo-enclosure-list nil
)
414 (setq texinfo-alias-list nil
)
416 (goto-char (point-min))
417 (or (search-forward "@setfilename" nil t
)
418 (error "Texinfo file needs an `@setfilename FILENAME' line"))
419 (setq texinfo-command-end
(point))
420 (setq outfile
(texinfo-parse-line-arg)))
425 (buffer-disable-undo)
427 (message "Formatting Info file: %s" outfile
)
428 (setq texinfo-format-filename
429 (file-name-nondirectory (expand-file-name outfile
)))
431 (setq fill-column fill-column-for-info
)
432 (set-syntax-table texinfo-format-syntax-table
)
434 (insert-buffer-substring input-buffer
)
435 (run-hook-with-args 'texinfo-pre-format-hook input-buffer
)
436 (message "Converting %s to Info format..." (buffer-name input-buffer
))
438 ;; Insert @include files so `texinfo-raise-lower-sections' can
439 ;; work on them without losing track of multiple
440 ;; @raise/@lowersections commands.
441 (goto-char (point-min))
442 (while (re-search-forward "^@include" nil t
)
443 (setq texinfo-command-end
(point))
444 (let ((filename (concat input-directory
445 (texinfo-parse-line-arg))))
446 (re-search-backward "^@include")
447 (delete-region (point) (line-beginning-position 2))
448 (message "Reading included file: %s" filename
)
453 (+ (point) (car (cdr (insert-file-contents filename
)))))
454 (goto-char (point-min))
455 ;; Remove `@setfilename' line from included file, if any,
456 ;; so @setfilename command not duplicated.
457 (if (re-search-forward "^@setfilename" (line-end-position 100) t
)
458 (delete-region (line-beginning-position 1)
459 (line-beginning-position 2)))))))
460 ;; Raise or lower level of each section, if necessary.
461 (goto-char (point-min))
462 (texinfo-raise-lower-sections)
463 ;; Append @refill to appropriate paragraphs
464 (goto-char (point-min))
465 (texinfo-append-refill)
466 (goto-char (point-min))
467 (search-forward "@setfilename")
469 (delete-region (point-min) (point))
470 ;; Remove @bye at end of file, if it is there.
471 (goto-char (point-max))
472 (if (search-backward "@bye" nil t
)
473 (delete-region (point) (point-max)))
474 ;; Make sure buffer ends in a newline.
475 (or (= (preceding-char) ?
\n)
477 ;; Scan the whole buffer, converting to Info format.
478 (texinfo-format-scan)
479 (goto-char (point-min))
480 ;; Insert info about how this file was made.
481 (insert "Info file: "
482 texinfo-format-filename
", -*-Text-*-\n"
483 "produced by `texinfo-format-buffer'\n"
484 ;; Date string removed so that regression testing is easier.
486 ;; (insert (format-time-string "%e %b %Y")) " "
488 (if (buffer-file-name input-buffer
)
490 (file-name-sans-versions
491 (file-name-nondirectory
492 (buffer-file-name input-buffer
)))
494 (concat "buffer `" (buffer-name input-buffer
) "'"))
495 "\nusing `texinfmt.el' version "
498 ;; Return data for indices.
500 texinfo-vindex texinfo-findex texinfo-cindex
501 texinfo-pindex texinfo-tindex texinfo-kindex
)))
504 ;;; Perform non-@-command file conversions: quotes and hyphens
506 (defun texinfo-format-convert (min max
)
507 ;; Convert left and right quotes to typewriter font quotes.
509 (while (search-forward "``" max t
)
510 (replace-match "\""))
512 (while (search-forward "''" max t
)
513 (replace-match "\""))
514 ;; Convert three hyphens in a row to two.
516 (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t
)
517 (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning 2)))))
520 ;;; Handle paragraph filling
522 ;; Keep as concatinated lists for ease of maintenance
524 (defvar texinfo-no-refill-regexp
528 ;; add "itemize\\|" (from experiment of 2001 Nov 28)
529 ;; because of a problem with @end itemize@refill
530 ;; I don't know if this causes other problems.
531 ;; I suspect itemized lists don't get filled properly and a
532 ;; more precise fix is required. Bob
533 ;; commented out on 2005 Feb 28 by Bob
554 "Regexp specifying environments in which paragraphs are not filled.")
556 (defvar texinfo-accent-commands
589 (defvar texinfo-part-of-para-regexp
624 "@-\\|" ; @- is a descretionary hyphen (not an accent) (a noop).
625 texinfo-accent-commands
628 "Regexp specifying @-commands found within paragraphs.")
630 (defun texinfo-append-refill ()
631 "Append @refill at end of each paragraph that should be filled.
632 Do not append @refill to paragraphs within @example and similar environments.
633 Do not append @refill to paragraphs containing @w{TEXT} or @*."
635 ;; It is necessary to append @refill before other processing because
636 ;; the other processing removes information that tells Texinfo
637 ;; whether the text should or should not be filled.
639 (while (< (point) (point-max))
640 (let ((refill-blank-lines "^[ \t\n]*$")
641 (case-fold-search nil
)) ; Don't confuse @TeX and @tex....
643 ;; 1. Skip over blank lines;
644 ;; skip over lines beginning with @-commands,
645 ;; but do not skip over lines
646 ;; that are no-refill environments such as @example or
647 ;; that begin with within-paragraph @-commands such as @code.
648 (while (and (looking-at (concat "^@\\|^\\\\\\|" refill-blank-lines
))
652 texinfo-no-refill-regexp
654 texinfo-part-of-para-regexp
656 (< (point) (point-max)))
658 ;; 2. Skip over @example and similar no-refill environments.
659 (if (looking-at texinfo-no-refill-regexp
)
660 (let ((environment (match-string-no-properties 1)))
661 (progn (re-search-forward (concat "^@end " environment
) nil t
)
664 ;; 3. Do not refill a paragraph containing @w or @*, or ending
665 ;; with @<newline> followed by a newline.
666 (if (or (>= (point) (point-max))
669 (save-excursion (forward-paragraph)
670 (line-beginning-position 2))
672 ;; Go to end of paragraph and do nothing.
674 ;; 4. Else go to end of paragraph and insert @refill
677 (let ((line-beg (point)))
681 (save-excursion (skip-chars-backward " \t") (point)))
683 (unless (re-search-backward "@c[ \t\n]\\|@comment[ \t\n]" line-beg t
)
685 (unless (re-search-backward "@refill\\|^[ \t]*@" line-beg t
)
687 (forward-line 1))))))
690 ;;; Handle `@raisesections' and `@lowersections' commands
692 ;; These commands change the hierarchical level of chapter structuring
695 ;; @raisesections changes @subsection to @section,
696 ;; @section to @chapter,
699 ;; @lowersections changes @chapter to @section
700 ;; @subsection to @subsubsection,
703 ;; An @raisesections/@lowersections command changes only those
704 ;; structuring commands that follow the @raisesections/@lowersections
707 ;; Repeated @raisesections/@lowersections continue to raise or lower
708 ;; the heading level.
710 ;; An @lowersections command cancels an @raisesections command, and
713 ;; You cannot raise or lower "beyond" chapters or subsubsections, but
714 ;; trying to do so does not elicit an error---you just get more
715 ;; headings that mean the same thing as you keep raising or lowering
716 ;; (for example, after a single @raisesections, both @chapter and
717 ;; @section produce chapter headings).
719 (defun texinfo-raise-lower-sections ()
720 "Raise or lower the hierarchical level of chapters, sections, etc.
722 This function acts according to `@raisesections' and `@lowersections'
723 commands in the Texinfo file.
725 For example, an `@lowersections' command is useful if you wish to
726 include what is written as an outer or standalone Texinfo file in
727 another Texinfo file as an inner, included file. The `@lowersections'
728 command changes chapters to sections, sections to subsections and so
731 @raisesections changes @subsection to @section,
732 @section to @chapter,
733 @heading to @chapheading,
736 @lowersections changes @chapter to @section,
737 @subsection to @subsubsection,
738 @heading to @subheading,
741 An `@raisesections' or `@lowersections' command changes only those
742 structuring commands that follow the `@raisesections' or
743 `@lowersections' command.
745 An `@lowersections' command cancels an `@raisesections' command, and
748 Repeated use of the commands continue to raise or lower the hierarchical
749 level a step at a time.
751 An attempt to raise above `chapters' reproduces chapter commands; an
752 attempt to lower below subsubsections reproduces subsubsection
755 ;; `texinfo-section-types-regexp' is defined in `texnfo-upd.el';
756 ;; it is a regexp matching chapter, section, other headings
757 ;; (but not the top node).
759 (let (type (level 0))
763 "\\(\\(^@\\(raise\\|lower\\)sections\\)\\|\\("
764 texinfo-section-types-regexp
768 (save-excursion (setq type
(read (current-buffer))))
771 ;; 1. Increment level
772 ((eq type
'@raisesections
)
773 (setq level
(1+ level
))
775 (point) (line-beginning-position 2)))
777 ;; 2. Decrement level
778 ((eq type
'@lowersections
)
779 (setq level
(1- level
))
781 (point) (line-beginning-position 2)))
783 ;; Now handle structuring commands
786 ;; 3. Raise level when positive
792 (cdr (assq new-level texinfo-raisesections-alist
)))
793 (setq count
(1- count
)))
795 (insert (symbol-name new-level
))))
797 ;; 4. Do nothing except move point when level is zero
798 ((= level
0) (forward-line 1))
800 ;; 5. Lower level when positive
806 (cdr (assq new-level texinfo-lowersections-alist
)))
807 (setq count
(1+ count
)))
809 (insert (symbol-name new-level
))))))))))
811 ;;; Perform those texinfo-to-info conversions that apply to the whole input
814 (defun texinfo-format-scan ()
815 (texinfo-format-convert (point-min) (point-max))
816 ;; Search for @copying, which has to be first since the
817 ;; @insertcopying command then inserts the text elsewhere.
818 (goto-char (point-min))
819 (when (search-forward "@copying" nil t
)
821 (while (search-forward "@insertcopying" nil t
)
822 (delete-region (match-beginning 0) (match-end 0))
824 (texinfo-insertcopying))
825 ;; Scan for other @-commands.
826 (goto-char (point-min))
827 (while (search-forward "@" nil t
)
829 ;; These are the single-character accent commands: @^ @` @' @" @= @~
830 ;; In Info, they are simply quoted and the @ deleted.
831 ;; Other single-character commands:
832 ;; @* forces a line break,
833 ;; @- is a discretionary hyphenation point; does nothing in Info.
834 ;; @<space>, @<tab>, @<newline> each produce a single space,
835 ;; unless followed by a newline.
837 ;; Old version 2.34 expression: (looking-at "[@{}^'` *\"?!]")
838 (if (looking-at "[@{}^'`\"=~ \t\n*?!-]")
839 ;; @*, causes a line break.
842 ((= (following-char) ?
*)
844 (delete-region (1- (point)) (1+ (point)))
845 ;; insert return if not at end of line;
846 ;; else line is already broken.
847 (if (not (= (following-char) ?
\n))
850 ((= (following-char) ?-
)
851 (delete-region (1- (point)) (1+ (point))))
852 ;; @<space>, @<tab>, @<newline>: produce a single space,
853 ;; unless followed by a newline.
854 ((= (following-char) ?
)
855 (delete-region (1- (point)) (1+ (point)))
856 ;; insert single space if not at end of line;
857 ;; else line is already broken.
858 (if (not (= (following-char) ?
\n))
860 ((= (following-char) ?
\t)
861 (delete-region (1- (point)) (1+ (point)))
862 ;; insert single space if not at end of line;
863 ;; else line is already broken.
864 (if (not (= (following-char) ?
\n))
866 ;; following char is a carriage return
867 ((= (following-char) ?
\n)
869 (delete-region (1- (point)) (1+ (point)))
870 ;; insert single space if not at end of line;
871 ;; else line is already broken.
872 (if (not (= (following-char) ?
\n))
874 ;; Otherwise: the other characters are simply quoted. Delete the @.
877 ;; Be compatible with makeinfo: if @' and its ilk are
878 ;; followed by a @ without a brace, barf.
879 (if (looking-at "[\"'^`~=]")
881 (if (= (char-after (1+ (point))) ?
@)
882 (error "Use braces to give a command as an argument to @%c"
885 ;; @' etc. can optionally accept their argument in
886 ;; braces (makeinfo supports that).
887 (when (looking-at "{")
888 (let ((start (point)))
894 ;; @ is followed by a command-word; find the end of the word.
895 (setq texinfo-command-start
(1- (point)))
896 (if (= (char-syntax (following-char)) ?w
)
899 (setq texinfo-command-end
(point))
900 ;; Detect the case of two @-commands in a row;
901 ;; process just the first one.
902 (goto-char (1+ texinfo-command-start
))
903 (skip-chars-forward "^@" texinfo-command-end
)
904 (setq texinfo-command-end
(point))
905 ;; Handle let aliasing
906 (setq texinfo-command-name
909 (buffer-substring-no-properties
910 (1+ texinfo-command-start
) texinfo-command-end
)))
911 (while (setq trial
(assoc cmdname texinfo-alias-list
))
912 (setq cmdname
(cdr trial
)))
914 ;; Call the handler for this command.
915 (let ((enclosure-type
917 (symbol-name texinfo-command-name
)
918 texinfo-enclosure-list
)))
922 (car (car (cdr enclosure-type
)))
923 (texinfo-parse-arg-discard)
924 (car (cdr (car (cdr enclosure-type
)))))
925 (goto-char texinfo-command-start
))
926 (let ((cmd (get texinfo-command-name
'texinfo-format
)))
927 (if cmd
(funcall cmd
) (texinfo-unsupported)))))))
930 (goto-char (nth 2 (car texinfo-stack
)))
931 (error "Unterminated @%s" (car (car texinfo-stack
)))))
933 ;; Remove excess whitespace
934 (let ((whitespace-silent t
))
935 (whitespace-cleanup)))
937 (defvar texinfo-copying-text
""
938 "Text of the copyright notice and copying permissions.")
940 (defun texinfo-copying ()
941 "Copy the copyright notice and copying permissions from the Texinfo file,
942 as indicated by the @copying ... @end copying command;
943 insert the text with the @insertcopying command."
944 (let ((beg (progn (beginning-of-line) (point)))
945 (end (progn (re-search-forward "^@end copying[ \t]*\n") (point))))
946 (setq texinfo-copying-text
947 (buffer-substring-no-properties
948 (save-excursion (goto-char beg
) (line-beginning-position 2))
949 (save-excursion (goto-char end
) (line-beginning-position 0))))
950 (delete-region beg end
)))
952 (defun texinfo-insertcopying ()
953 "Insert the copyright notice and copying permissions from the Texinfo file,
954 which are indicated by the @copying ... @end copying command."
955 (insert (concat "\n" texinfo-copying-text
)))
957 (put 'begin
'texinfo-format
'texinfo-format-begin
)
958 (defun texinfo-format-begin ()
959 (texinfo-format-begin-end 'texinfo-format
))
961 (put 'end
'texinfo-format
'texinfo-format-end
)
962 (defun texinfo-format-end ()
963 (texinfo-format-begin-end 'texinfo-end
))
965 (defun texinfo-format-begin-end (prop)
966 (setq texinfo-command-name
(intern (texinfo-parse-line-arg)))
967 (let ((cmd (get texinfo-command-name prop
)))
968 (if cmd
(funcall cmd
)
969 (texinfo-unsupported))))
971 ;;; Parsing functions
973 (defun texinfo-parse-line-arg ()
974 "Return argument of @-command as string.
975 Argument is separated from command either by a space or by a brace.
976 If a space, return rest of line, with beginning and ending white
977 space removed. If a brace, return string between braces.
978 Leave point after argument."
979 (goto-char texinfo-command-end
)
980 (let ((start (point)))
981 (cond ((looking-at " ")
982 (skip-chars-forward " ")
985 (skip-chars-backward " ")
986 (delete-region (point) (progn (end-of-line) (point)))
987 (setq texinfo-command-end
(1+ (point))))
989 (setq start
(1+ (point)))
991 (setq texinfo-command-end
(point))
994 (error "Invalid texinfo command arg format")))
995 (prog1 (buffer-substring-no-properties start
(point))
996 (if (eolp) (forward-char 1)))))
998 (defun texinfo-parse-expanded-arg ()
999 (goto-char texinfo-command-end
)
1000 (let ((start (point))
1002 (cond ((looking-at " ")
1003 (skip-chars-forward " ")
1004 (setq start
(point))
1006 (setq texinfo-command-end
(1+ (point))))
1008 (setq start
(1+ (point)))
1010 (setq texinfo-command-end
(point))
1013 (error "Invalid texinfo command arg format")))
1014 (setq marker
(move-marker (make-marker) texinfo-command-end
))
1015 (texinfo-format-expand-region start
(point))
1016 (setq texinfo-command-end
(marker-position marker
))
1017 (move-marker marker nil
)
1018 (prog1 (buffer-substring-no-properties start
(point))
1019 (if (eolp) (forward-char 1)))))
1021 (defun texinfo-format-expand-region (start end
)
1023 (narrow-to-region start end
)
1024 (let (texinfo-command-start
1026 texinfo-command-name
1028 (texinfo-format-scan))
1029 (goto-char (point-max))))
1031 (defun texinfo-parse-arg-discard ()
1032 "Delete command and argument; return argument of command."
1033 (prog1 (texinfo-parse-line-arg)
1034 (texinfo-discard-command)))
1036 (defun texinfo-discard-command ()
1037 (delete-region texinfo-command-start texinfo-command-end
))
1039 (defun texinfo-optional-braces-discard ()
1040 "Discard braces following command, if any."
1041 (goto-char texinfo-command-end
)
1042 (let ((start (point)))
1043 (cond ((looking-at "[ \t]*\n")) ; do nothing
1044 ((looking-at "{") ; remove braces, if any
1046 (setq texinfo-command-end
(point)))
1049 "Invalid `texinfo-optional-braces-discard' format \(need braces?\)")))
1050 (delete-region texinfo-command-start texinfo-command-end
)))
1052 (defun texinfo-format-parse-line-args ()
1053 (let ((start (1- (point)))
1056 (skip-chars-forward " ")
1059 (re-search-forward "[\n,]")
1061 (if (bolp) (setq next
(1- next
)))
1063 (skip-chars-backward " ")
1065 (push (if (> end beg
) (buffer-substring-no-properties beg end
))
1068 (skip-chars-forward " "))
1069 (if (eolp) (forward-char 1))
1070 (setq texinfo-command-end
(point))
1073 (defun texinfo-format-parse-args ()
1074 (let ((start (1- (point)))
1077 (search-forward "{")
1079 (texinfo-format-expand-region
1081 (save-excursion (up-list 1) (1- (point)))))
1082 ;; The following does not handle cross references of the form:
1083 ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the
1084 ;; re-search-forward finds the first right brace after the second
1086 (while (/= (preceding-char) ?\
})
1087 (skip-chars-forward " \t\n")
1089 (re-search-forward "[},]")
1092 (skip-chars-backward " \t\n")
1096 (while (search-forward "\n" end t
)
1097 (replace-match " "))))
1098 (push (if (> end beg
) (buffer-substring-no-properties beg end
))
1101 ;;(if (eolp) (forward-char 1))
1102 (setq texinfo-command-end
(point))
1105 (defun texinfo-format-parse-defun-args ()
1106 (goto-char texinfo-command-end
)
1107 (let ((start (point)))
1109 (setq texinfo-command-end
(1+ (point)))
1110 (let ((marker (move-marker (make-marker) texinfo-command-end
)))
1111 (texinfo-format-expand-region start
(point))
1112 (setq texinfo-command-end
(marker-position marker
))
1113 (move-marker marker nil
))
1117 (skip-chars-forward " ")
1119 (cond ((looking-at "{")
1120 (setq beg
(1+ (point)))
1122 (setq end
(1- (point))))
1125 (re-search-forward "[\n ]")
1127 (setq end
(point))))
1128 (push (buffer-substring-no-properties beg end
) args
)
1129 (skip-chars-forward " "))
1133 (defun texinfo-discard-line ()
1134 (goto-char texinfo-command-end
)
1135 (skip-chars-forward " \t")
1137 (error "Extraneous text at end of command line"))
1138 (goto-char texinfo-command-start
)
1140 (error "Extraneous text at beginning of command line"))
1141 (delete-region (point) (progn (forward-line 1) (point))))
1143 (defun texinfo-discard-line-with-args ()
1144 (goto-char texinfo-command-start
)
1145 (delete-region (point) (progn (forward-line 1) (point))))
1150 ;; Only `texinfo-format-buffer' handles @setfilename with this
1151 ;; definition; `texinfo-format-region' handles @setfilename, if any,
1153 (put 'setfilename
'texinfo-format
'texinfo-format-setfilename
)
1154 (defun texinfo-format-setfilename ()
1155 (texinfo-parse-arg-discard))
1157 ;;; @node, @menu, @detailmenu
1159 (put 'node
'texinfo-format
'texinfo-format-node
)
1160 (put 'nwnode
'texinfo-format
'texinfo-format-node
)
1161 (defun texinfo-format-node ()
1162 (let* ((args (texinfo-format-parse-line-args))
1167 (texinfo-discard-command)
1168 (setq texinfo-last-node name
)
1169 (let ((tem (if texinfo-fold-nodename-case
(downcase name
) name
)))
1170 (if (assoc tem texinfo-node-names
)
1171 (error "Duplicate node name: %s" name
)
1172 (push (list tem
) texinfo-node-names
)))
1173 (setq texinfo-footnote-number
0)
1174 ;; insert "\n\^_" unconditionally since this is what info is looking for
1175 (insert "\n\^_\nFile: " texinfo-format-filename
1178 (insert ", Next: " next
))
1180 (insert ", Prev: " prev
))
1182 (insert ", Up: " up
))
1184 (setq texinfo-last-node-pos
(point))))
1186 (put 'anchor
'texinfo-format
'texinfo-anchor
)
1187 (defun texinfo-anchor ()
1189 (here (- (point) 7)) ; save location of beginning of `@anchor'
1190 (arg (texinfo-parse-arg-discard)))
1191 (if (looking-at " ") ; since a space may be left after -discard
1194 (let ((end (point)))
1197 (search-forward "@refill" end t
))
1198 (setq anchor-string
"@anchor-yes-refill")
1199 (setq anchor-string
"@anchor-no-refill")))
1201 (insert anchor-string
"{" arg
"}")))
1203 (put 'menu
'texinfo-format
'texinfo-format-menu
)
1204 (defun texinfo-format-menu ()
1205 (texinfo-discard-line)
1206 (insert "* Menu:\n\n"))
1208 (put 'menu
'texinfo-end
'texinfo-discard-command
)
1210 ;; The @detailmenu should be removed eventually.
1212 ;; According to Karl Berry, 31 August 1996:
1214 ;; You don't like, I don't like it. I agree, it would be better just to
1215 ;; fix the bug [in `makeinfo']. .. At this point, since inserting those
1216 ;; two commands in the Elisp fn is trivial, I don't especially want to
1217 ;; expend more effort...
1219 ;; I added a couple sentences of documentation to the manual (putting the
1220 ;; blame on makeinfo where it belongs :-().
1222 (put 'detailmenu
'texinfo-format
'texinfo-discard-line
)
1223 (put 'detailmenu
'texinfo-end
'texinfo-discard-command
)
1225 ;; (Also see `texnfo-upd.el')
1228 ;;; Cross references
1230 ;; @xref {NODE, FNAME, NAME, FILE, DOCUMENT}
1231 ;; -> *Note FNAME: (FILE)NODE
1232 ;; If FILE is missing,
1233 ;; *Note FNAME: NODE
1234 ;; If FNAME is empty and NAME is present
1236 ;; If both NAME and FNAME are missing
1238 ;; texinfo ignores the DOCUMENT argument.
1239 ;; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1240 ;; If FILE is specified, (FILE)NODE is used for xrefs.
1241 ;; If fifth argument DOCUMENT is specified, produces
1242 ;; See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1245 ;; @ref a reference that does not put `See' or `see' in
1246 ;; the hardcopy and is the same as @xref in Info
1247 (put 'ref
'texinfo-format
'texinfo-format-xref
)
1249 (put 'xref
'texinfo-format
'texinfo-format-xref
)
1250 (defun texinfo-format-xref ()
1251 (let ((args (texinfo-format-parse-args)))
1252 (texinfo-discard-command)
1254 (let ((fname (or (nth 1 args
) (nth 2 args
))))
1255 (if (null (or fname
(nth 3 args
)))
1256 (insert (car args
) "::")
1257 (insert (or fname
(car args
)) ": ")
1259 (insert "(" (nth 3 args
) ")"))
1260 (and (car args
) (insert (car args
)))))))
1262 (put 'pxref
'texinfo-format
'texinfo-format-pxref
)
1263 (defun texinfo-format-pxref ()
1264 (texinfo-format-xref)
1270 ;; @inforef{NODE, FNAME, FILE}
1271 ;; Like @xref{NODE, FNAME,,FILE} in texinfo.
1272 ;; In Tex, generates "See Info file FILE, node NODE"
1273 (put 'inforef
'texinfo-format
'texinfo-format-inforef
)
1274 (defun texinfo-format-inforef ()
1275 (let ((args (texinfo-format-parse-args)))
1276 (texinfo-discard-command)
1278 (insert "*Note " (nth 1 args
) ": (" (nth 2 args
) ")" (car args
))
1279 (insert "*Note " "(" (nth 2 args
) ")" (car args
) "::"))))
1282 ;;; URL Reference: @uref
1284 ;; @uref produces a reference to a uniform resource locator (URL).
1285 ;; It takes one mandatory argument, the URL, and one optional argument,
1286 ;; the text to display (the default is the URL itself).
1288 (put 'uref
'texinfo-format
'texinfo-format-uref
)
1289 (defun texinfo-format-uref ()
1290 "Format URL and optional URL-TITLE.
1291 Insert ` ... ' around URL if no URL-TITLE argument;
1292 otherwise, insert URL-TITLE followed by URL in parentheses."
1293 (let ((args (texinfo-format-parse-args)))
1294 (texinfo-discard-command)
1297 (insert (nth 1 args
) " (" (nth 0 args
) ")")
1298 (insert "`" (nth 0 args
) "'"))
1299 (goto-char texinfo-command-start
)))
1302 ;;; Section headings
1304 (put 'majorheading
'texinfo-format
'texinfo-format-chapter
)
1305 (put 'chapheading
'texinfo-format
'texinfo-format-chapter
)
1306 (put 'ichapter
'texinfo-format
'texinfo-format-chapter
)
1307 (put 'chapter
'texinfo-format
'texinfo-format-chapter
)
1308 (put 'iappendix
'texinfo-format
'texinfo-format-chapter
)
1309 (put 'appendix
'texinfo-format
'texinfo-format-chapter
)
1310 (put 'iunnumbered
'texinfo-format
'texinfo-format-chapter
)
1311 (put 'top
'texinfo-format
'texinfo-format-chapter
)
1312 (put 'unnumbered
'texinfo-format
'texinfo-format-chapter
)
1313 (put 'centerchap
'texinfo-format
'texinfo-format-chapter
)
1314 (defun texinfo-format-chapter ()
1315 (texinfo-format-chapter-1 ?
*))
1317 (put 'heading
'texinfo-format
'texinfo-format-section
)
1318 (put 'isection
'texinfo-format
'texinfo-format-section
)
1319 (put 'section
'texinfo-format
'texinfo-format-section
)
1320 (put 'iappendixsection
'texinfo-format
'texinfo-format-section
)
1321 (put 'appendixsection
'texinfo-format
'texinfo-format-section
)
1322 (put 'iappendixsec
'texinfo-format
'texinfo-format-section
)
1323 (put 'appendixsec
'texinfo-format
'texinfo-format-section
)
1324 (put 'iunnumberedsec
'texinfo-format
'texinfo-format-section
)
1325 (put 'unnumberedsec
'texinfo-format
'texinfo-format-section
)
1326 (defun texinfo-format-section ()
1327 (texinfo-format-chapter-1 ?
=))
1329 (put 'subheading
'texinfo-format
'texinfo-format-subsection
)
1330 (put 'isubsection
'texinfo-format
'texinfo-format-subsection
)
1331 (put 'subsection
'texinfo-format
'texinfo-format-subsection
)
1332 (put 'iappendixsubsec
'texinfo-format
'texinfo-format-subsection
)
1333 (put 'appendixsubsec
'texinfo-format
'texinfo-format-subsection
)
1334 (put 'iunnumberedsubsec
'texinfo-format
'texinfo-format-subsection
)
1335 (put 'unnumberedsubsec
'texinfo-format
'texinfo-format-subsection
)
1336 (defun texinfo-format-subsection ()
1337 (texinfo-format-chapter-1 ?-
))
1339 (put 'subsubheading
'texinfo-format
'texinfo-format-subsubsection
)
1340 (put 'isubsubsection
'texinfo-format
'texinfo-format-subsubsection
)
1341 (put 'subsubsection
'texinfo-format
'texinfo-format-subsubsection
)
1342 (put 'iappendixsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1343 (put 'appendixsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1344 (put 'iunnumberedsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1345 (put 'unnumberedsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1346 (defun texinfo-format-subsubsection ()
1347 (texinfo-format-chapter-1 ?.
))
1349 (defun texinfo-format-chapter-1 (belowchar)
1350 (let ((arg (texinfo-parse-arg-discard)))
1351 (message "Formatting: %s ... " arg
) ; So we can see where we are.
1352 (insert ?
\n arg ?
\n "@SectionPAD " belowchar ?
\n)
1355 (put 'SectionPAD
'texinfo-format
'texinfo-format-sectionpad
)
1356 (defun texinfo-format-sectionpad ()
1357 (let ((str (texinfo-parse-arg-discard)))
1359 (let ((column (current-column)))
1363 (setq column
(1- column
))))
1367 ;;; Space controlling commands: @. and @:, and the soft hyphen.
1369 (put '\.
'texinfo-format
'texinfo-format-\.
)
1370 (defun texinfo-format-\.
()
1371 (texinfo-discard-command)
1374 (put '\
: 'texinfo-format
'texinfo-format-\
:)
1375 (defun texinfo-format-\
: ()
1376 (texinfo-discard-command))
1378 (put '\-
'texinfo-format
'texinfo-format-soft-hyphen
)
1379 (defun texinfo-format-soft-hyphen ()
1380 (texinfo-discard-command))
1383 ;;; @kbdinputstyle, @vskip, headings & footings
1384 ;; These commands for not for Info and should never
1385 ;; appear in an Info environment; but if they do,
1386 ;; this causes them to be discarded.
1389 (put 'kbdinputstyle
'texinfo-format
'texinfo-discard-line-with-args
)
1392 (put 'vskip
'texinfo-format
'texinfo-discard-line-with-args
)
1394 ;; headings & footings
1395 (put 'evenfooting
'texinfo-format
'texinfo-discard-line-with-args
)
1396 (put 'evenheading
'texinfo-format
'texinfo-discard-line-with-args
)
1397 (put 'oddfooting
'texinfo-format
'texinfo-discard-line-with-args
)
1398 (put 'oddheading
'texinfo-format
'texinfo-discard-line-with-args
)
1399 (put 'everyfooting
'texinfo-format
'texinfo-discard-line-with-args
)
1400 (put 'everyheading
'texinfo-format
'texinfo-discard-line-with-args
)
1403 ;;; @documentdescription ... @end documentdescription
1404 ;; This command is for HTML output and should never
1405 ;; appear in an Info environment; but if it does,
1406 ;; this causes it to be discarded.
1408 (put 'documentdescription
'texinfo-format
'texinfo-format-documentdescription
)
1409 (defun texinfo-format-documentdescription ()
1410 (delete-region texinfo-command-start
1411 (progn (re-search-forward "^@end documentdescription[ \t]*\n")
1416 ;;; @center, @sp, and @br
1418 (put 'center
'texinfo-format
'texinfo-format-center
)
1419 (defun texinfo-format-center ()
1420 (let ((arg (texinfo-parse-expanded-arg)))
1421 (texinfo-discard-command)
1425 (goto-char (1- (point)))
1426 (let ((indent-tabs-mode nil
))
1429 (put 'sp
'texinfo-format
'texinfo-format-sp
)
1430 (defun texinfo-format-sp ()
1431 (let* ((arg (texinfo-parse-arg-discard))
1433 (insert-char ?
\n num
)))
1435 (put 'br
'texinfo-format
'texinfo-format-paragraph-break
)
1436 (defun texinfo-format-paragraph-break ()
1437 "Force a paragraph break.
1438 If used within a line, follow `@br' with braces."
1439 (texinfo-optional-braces-discard)
1440 ;; insert one return if at end of line;
1441 ;; else insert two returns, to generate a blank line.
1442 (if (= (following-char) ?
\n)
1444 (insert-char ?
\n 2)))
1447 ;;; @footnote and @footnotestyle
1449 ;; In Texinfo, footnotes are created with the `@footnote' command.
1450 ;; This command is followed immediately by a left brace, then by the text of
1451 ;; the footnote, and then by a terminating right brace. The
1452 ;; template for a footnote is:
1456 ;; Info has two footnote styles:
1458 ;; * In the End of node style, all the footnotes for a single node
1459 ;; are placed at the end of that node. The footnotes are
1460 ;; separated from the rest of the node by a line of dashes with
1461 ;; the word `Footnotes' within it.
1463 ;; * In the Separate node style, all the footnotes for a single node
1464 ;; are placed in an automatically constructed node of their own.
1466 ;; Footnote style is specified by the @footnotestyle command, either
1467 ;; @footnotestyle separate
1469 ;; @footnotestyle end
1471 ;; The default is separate
1473 (defvar texinfo-footnote-style
"separate"
1474 "Footnote style, either separate or end.")
1476 (put 'footnotestyle
'texinfo-format
'texinfo-footnotestyle
)
1477 (defun texinfo-footnotestyle ()
1478 "Specify whether footnotes are at end of node or in separate nodes.
1479 Argument is either end or separate."
1480 (setq texinfo-footnote-style
(texinfo-parse-arg-discard)))
1482 (put 'footnote
'texinfo-format
'texinfo-format-footnote
)
1483 (defun texinfo-format-footnote ()
1484 "Format a footnote in either end of node or separate node style.
1485 The texinfo-footnote-style variable controls which style is used."
1486 (setq texinfo-footnote-number
(1+ texinfo-footnote-number
))
1487 (cond ((string= texinfo-footnote-style
"end")
1488 (texinfo-format-end-node))
1489 ((string= texinfo-footnote-style
"separate")
1490 (texinfo-format-separate-node))))
1492 (defun texinfo-format-separate-node ()
1493 "Format footnote in Separate node style, with notes in own node.
1494 The node is constructed automatically."
1496 (arg (texinfo-parse-line-arg))
1497 (node-name-beginning
1500 "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:")
1504 (buffer-substring-no-properties
1505 (progn (goto-char node-name-beginning
) ; skip over node command
1506 (skip-chars-forward " \t") ; and over spaces
1508 (if (search-forward "," (line-end-position) t
) ; bound search
1510 (end-of-line) (point))))))
1511 (texinfo-discard-command) ; remove or insert whitespace, as needed
1512 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1514 (insert (format " (%d) (*Note %s-Footnotes::)"
1515 texinfo-footnote-number node-name
))
1516 (fill-paragraph nil
)
1518 (if (re-search-forward "^@node" nil
'move
)
1521 ;; two cases: for the first footnote, we must insert a node header;
1522 ;; for the second and subsequent footnotes, we need only insert
1523 ;; the text of the footnote.
1527 (concat node-name
"-Footnotes, Up: ")
1530 (progn ; already at least one footnote
1531 (setq start
(point))
1532 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1533 (fill-region start
(point)))
1534 ;; else not yet a footnote
1535 (insert "\n\^_\nFile: " texinfo-format-filename
1536 " Node: " node-name
"-Footnotes, Up: " node-name
"\n")
1537 (setq start
(point))
1538 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1539 (narrow-to-region (save-excursion (goto-char start
) (point)) (point))
1540 (fill-region (point-min) (point-max))
1543 (defun texinfo-format-end-node ()
1544 "Format footnote in the End of node style, with notes at end of node."
1546 (arg (texinfo-parse-line-arg)))
1547 (texinfo-discard-command) ; remove or insert whitespace, as needed
1548 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1550 (insert (format " (%d) " texinfo-footnote-number
))
1551 (fill-paragraph nil
)
1553 (if (search-forward "\n--------- Footnotes ---------\n" nil t
)
1554 (progn ; already have footnote, put new one before end of node
1555 (if (re-search-forward "^@node" nil
'move
)
1557 (setq start
(point))
1558 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1559 (fill-region start
(point)))
1560 ;; else no prior footnote
1561 (if (re-search-forward "^@node" nil
'move
)
1563 (insert "\n--------- Footnotes ---------\n")
1564 (setq start
(point))
1565 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))))))
1568 ;;; @itemize, @enumerate, and similar commands
1570 ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.
1571 ;; @enumerate pushes (enumerate 0 STARTPOS).
1572 ;; @item dispatches to the texinfo-item prop of the first elt of the list.
1573 ;; For itemize, this puts in and rescans the COMMANDS.
1574 ;; For enumerate, this increments the number and puts it in.
1575 ;; In either case, it puts a Backspace at the front of the line
1576 ;; which marks it not to be indented later.
1577 ;; All other lines get indented by 5 when the @end is reached.
1579 (defvar texinfo-stack-depth
0
1580 "Count of number of unpopped texinfo-push-stack calls.
1581 Used by @refill indenting command to avoid indenting within lists, etc.")
1583 (defun texinfo-push-stack (check arg
)
1584 (setq texinfo-stack-depth
(1+ texinfo-stack-depth
))
1585 (push (list check arg texinfo-command-start
)
1588 (defun texinfo-pop-stack (check)
1589 (setq texinfo-stack-depth
(1- texinfo-stack-depth
))
1590 (if (null texinfo-stack
)
1591 (error "Unmatched @end %s" check
))
1592 (if (not (eq (car (car texinfo-stack
)) check
))
1593 (error "@end %s matches @%s"
1594 check
(car (car texinfo-stack
))))
1595 (prog1 (cdr (car texinfo-stack
))
1596 (setq texinfo-stack
(cdr texinfo-stack
))))
1598 (put 'itemize
'texinfo-format
'texinfo-itemize
)
1599 (defun texinfo-itemize ()
1602 (progn (skip-chars-forward " \t")
1605 (texinfo-parse-line-arg))))
1606 (texinfo-discard-line-with-args)
1607 (setq fill-column
(- fill-column
5)))
1609 (put 'itemize
'texinfo-end
'texinfo-end-itemize
)
1610 (defun texinfo-end-itemize ()
1611 (setq fill-column
(+ fill-column
5))
1612 (texinfo-discard-command)
1614 (texinfo-pop-stack 'itemize
)))
1615 (texinfo-do-itemize (nth 1 stacktop
))))
1617 (put 'enumerate
'texinfo-format
'texinfo-enumerate
)
1618 (defun texinfo-enumerate ()
1621 (progn (skip-chars-forward " \t")
1624 (read (current-buffer)))))
1625 (if (and (symbolp (car (cdr (car texinfo-stack
))))
1626 (> 1 (length (symbol-name (car (cdr (car texinfo-stack
)))))))
1628 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." ))
1629 (texinfo-discard-line-with-args)
1630 (setq fill-column
(- fill-column
5)))
1632 (put 'enumerate
'texinfo-end
'texinfo-end-enumerate
)
1633 (defun texinfo-end-enumerate ()
1634 (setq fill-column
(+ fill-column
5))
1635 (texinfo-discard-command)
1637 (texinfo-pop-stack 'enumerate
)))
1638 (texinfo-do-itemize (nth 1 stacktop
))))
1640 ;; @alphaenumerate never became a standard part of Texinfo
1641 (put 'alphaenumerate
'texinfo-format
'texinfo-alphaenumerate
)
1642 (defun texinfo-alphaenumerate ()
1643 (texinfo-push-stack 'alphaenumerate
(1- ?a
))
1644 (setq fill-column
(- fill-column
5))
1645 (texinfo-discard-line))
1647 (put 'alphaenumerate
'texinfo-end
'texinfo-end-alphaenumerate
)
1648 (defun texinfo-end-alphaenumerate ()
1649 (setq fill-column
(+ fill-column
5))
1650 (texinfo-discard-command)
1652 (texinfo-pop-stack 'alphaenumerate
)))
1653 (texinfo-do-itemize (nth 1 stacktop
))))
1655 ;; @capsenumerate never became a standard part of Texinfo
1656 (put 'capsenumerate
'texinfo-format
'texinfo-capsenumerate
)
1657 (defun texinfo-capsenumerate ()
1658 (texinfo-push-stack 'capsenumerate
(1- ?A
))
1659 (setq fill-column
(- fill-column
5))
1660 (texinfo-discard-line))
1662 (put 'capsenumerate
'texinfo-end
'texinfo-end-capsenumerate
)
1663 (defun texinfo-end-capsenumerate ()
1664 (setq fill-column
(+ fill-column
5))
1665 (texinfo-discard-command)
1667 (texinfo-pop-stack 'capsenumerate
)))
1668 (texinfo-do-itemize (nth 1 stacktop
))))
1670 ;; At the @end, indent all the lines within the construct
1671 ;; except those marked with backspace. FROM says where
1672 ;; construct started.
1673 (defun texinfo-do-itemize (from)
1675 (while (progn (forward-line -
1)
1677 (if (= (following-char) ?
\b)
1682 (if (not (looking-at "[ \t]*$"))
1683 (save-excursion (insert " ")))))))
1685 (put 'item
'texinfo-format
'texinfo-item
)
1686 (put 'itemx
'texinfo-format
'texinfo-item
)
1687 (defun texinfo-item ()
1688 (funcall (get (car (car texinfo-stack
)) 'texinfo-item
)))
1690 (put 'itemize
'texinfo-item
'texinfo-itemize-item
)
1691 (defun texinfo-itemize-item ()
1692 ;; (texinfo-discard-line) ; Did not handle text on same line as @item.
1693 (delete-region (1+ (point)) (line-beginning-position))
1694 (if (looking-at "[ \t]*[^ \t\n]+")
1695 ;; Text on same line as @item command.
1696 (insert "\b " (nth 1 (car texinfo-stack
)) " \n")
1697 ;; Else text on next line.
1698 (insert "\b " (nth 1 (car texinfo-stack
)) " "))
1701 (put 'enumerate
'texinfo-item
'texinfo-enumerate-item
)
1702 (defun texinfo-enumerate-item ()
1703 (texinfo-discard-line)
1704 (let (enumerating-symbol)
1705 (cond ((integerp (car (cdr (car texinfo-stack
))))
1706 (setq enumerating-symbol
(car (cdr (car texinfo-stack
))))
1707 (insert ?
\b (format "%3d. " enumerating-symbol
) ?
\n)
1708 (setcar (cdr (car texinfo-stack
)) (1+ enumerating-symbol
)))
1709 ((symbolp (car (cdr (car texinfo-stack
))))
1710 (setq enumerating-symbol
1711 (symbol-name (car (cdr (car texinfo-stack
)))))
1712 (if (or (equal ?\
[ (string-to-char enumerating-symbol
))
1713 (equal ?\
{ (string-to-char enumerating-symbol
)))
1715 "Too many items in enumerated list; alphabet ends at Z."))
1716 (insert ?
\b (format "%3s. " enumerating-symbol
) ?
\n)
1717 (setcar (cdr (car texinfo-stack
))
1721 (string-to-char enumerating-symbol
))))))
1724 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." )))
1727 (put 'alphaenumerate
'texinfo-item
'texinfo-alphaenumerate-item
)
1728 (defun texinfo-alphaenumerate-item ()
1729 (texinfo-discard-line)
1730 (let ((next (1+ (car (cdr (car texinfo-stack
))))))
1732 (error "More than 26 items in @alphaenumerate; get a bigger alphabet"))
1733 (setcar (cdr (car texinfo-stack
)) next
)
1734 (insert "\b " next
". \n"))
1737 (put 'capsenumerate
'texinfo-item
'texinfo-capsenumerate-item
)
1738 (defun texinfo-capsenumerate-item ()
1739 (texinfo-discard-line)
1740 (let ((next (1+ (car (cdr (car texinfo-stack
))))))
1742 (error "More than 26 items in @capsenumerate; get a bigger alphabet"))
1743 (setcar (cdr (car texinfo-stack
)) next
)
1744 (insert "\b " next
". \n"))
1750 ;; The `@table' command produces two-column tables.
1752 (put 'table
'texinfo-format
'texinfo-table
)
1753 (defun texinfo-table ()
1756 (progn (skip-chars-forward " \t")
1759 (texinfo-parse-line-arg))))
1760 (texinfo-discard-line-with-args)
1761 (setq fill-column
(- fill-column
5)))
1763 (put 'table
'texinfo-item
'texinfo-table-item
)
1764 (defun texinfo-table-item ()
1765 (let ((arg (texinfo-parse-arg-discard))
1766 (itemfont (car (cdr (car texinfo-stack
)))))
1767 (insert ?
\b itemfont ?\
{ arg
"}\n \n"))
1770 (put 'table
'texinfo-end
'texinfo-end-table
)
1771 (defun texinfo-end-table ()
1772 (setq fill-column
(+ fill-column
5))
1773 (texinfo-discard-command)
1775 (texinfo-pop-stack 'table
)))
1776 (texinfo-do-itemize (nth 1 stacktop
))))
1778 ;; @description appears to be an undocumented variant on @table that
1779 ;; does not require an arg. It fails in texinfo.tex 2.58 and is not
1780 ;; part of makeinfo.c The command appears to be a relic of the past.
1781 (put 'description
'texinfo-end
'texinfo-end-table
)
1782 (put 'description
'texinfo-format
'texinfo-description
)
1783 (defun texinfo-description ()
1784 (texinfo-push-stack 'table
"@asis")
1785 (setq fill-column
(- fill-column
5))
1786 (texinfo-discard-line))
1789 ;;; @ftable, @vtable
1791 ;; The `@ftable' and `@vtable' commands are like the `@table' command
1792 ;; but they also insert each entry in the first column of the table
1793 ;; into the function or variable index.
1795 ;; Handle the @ftable and @vtable commands:
1797 (put 'ftable
'texinfo-format
'texinfo-ftable
)
1798 (put 'vtable
'texinfo-format
'texinfo-vtable
)
1800 (defun texinfo-ftable () (texinfo-indextable 'ftable
))
1801 (defun texinfo-vtable () (texinfo-indextable 'vtable
))
1803 (defun texinfo-indextable (table-type)
1804 (texinfo-push-stack table-type
(texinfo-parse-arg-discard))
1805 (setq fill-column
(- fill-column
5)))
1807 ;; Handle the @item commands within ftable and vtable:
1809 (put 'ftable
'texinfo-item
'texinfo-ftable-item
)
1810 (put 'vtable
'texinfo-item
'texinfo-vtable-item
)
1812 (defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex
))
1813 (defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex
))
1815 (defun texinfo-indextable-item (index-type)
1816 (let ((item (texinfo-parse-arg-discard))
1817 (itemfont (car (cdr (car texinfo-stack
))))
1818 (indexvar index-type
))
1819 (insert ?
\b itemfont ?\
{ item
"}\n \n")
1822 (list item texinfo-last-node
)
1823 (symbol-value indexvar
)))
1826 ;; Handle @end ftable, @end vtable
1828 (put 'ftable
'texinfo-end
'texinfo-end-ftable
)
1829 (put 'vtable
'texinfo-end
'texinfo-end-vtable
)
1831 (defun texinfo-end-ftable () (texinfo-end-indextable 'ftable
))
1832 (defun texinfo-end-vtable () (texinfo-end-indextable 'vtable
))
1834 (defun texinfo-end-indextable (table-type)
1835 (setq fill-column
(+ fill-column
5))
1836 (texinfo-discard-command)
1838 (texinfo-pop-stack table-type
)))
1839 (texinfo-do-itemize (nth 1 stacktop
))))
1842 ;;; @multitable ... @end multitable
1844 ;; Produce a multi-column table, with as many columns as desired.
1846 ;; A multi-column table has this template:
1848 ;; @multitable {A1} {A2} {A3}
1849 ;; @item A1 @tab A2 @tab A3
1850 ;; @item B1 @tab B2 @tab B3
1851 ;; @item C1 @tab C2 @tab C3
1854 ;; where the width of the text in brackets specifies the width of the
1855 ;; respective column.
1859 ;; @multitable @columnfractions .25 .3 .45
1860 ;; @item A1 @tab A2 @tab A3
1861 ;; @item B1 @tab B2 @tab B3
1864 ;; where the fractions specify the width of each column as a percent
1865 ;; of the current width of the text (i.e., of the fill-column).
1867 ;; Long lines of text are filled within columns.
1869 ;; Using the Emacs Lisp formatter, texinfmt.el,
1870 ;; the whitespace between columns can be increased by setting
1871 ;; `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1872 ;; there is at least one blank space between columns.
1874 ;; The Emacs Lisp formatter, texinfmt.el, ignores the following four
1875 ;; commands that are defined in texinfo.tex for printed output.
1877 ;; @multitableparskip,
1878 ;; @multitableparindent,
1879 ;; @multitablecolmargin,
1880 ;; @multitablelinespace.
1882 ;; How @multitable works.
1883 ;; =====================
1885 ;; `texinfo-multitable' reads the @multitable line and determines from it
1886 ;; how wide each column should be.
1888 ;; Also, it pushes this information, along with an identifying symbol,
1889 ;; onto the `texinfo-stack'. At the @end multitable command, the stack
1890 ;; is checked for its matching @multitable command, and then popped, or
1891 ;; else an error is signaled. Also, this command pushes the location of
1892 ;; the start of the table onto the stack.
1894 ;; `texinfo-end-multitable' checks the `texinfo-stack' that the @end
1895 ;; multitable truly is ending a corresponding beginning, and if it is,
1898 ;; `texinfo-multitable-widths' is called by `texinfo-multitable'.
1899 ;; The function returns a list of the widths of each column in a
1900 ;; multi-column table, based on the information supplied by the arguments
1901 ;; to the @multitable command (by arguments, I mean the text on the rest
1902 ;; of the @multitable line, not the remainder of the multi-column table
1905 ;; `texinfo-multitable-item' formats a row within a multicolumn table.
1906 ;; This command is executed when texinfmt sees @item inside @multitable.
1907 ;; Cells in row are separated by `@tab's. Widths of cells are specified
1908 ;; by the arguments in the @multitable line. Cells are filled. All cells
1909 ;; are made to be the same height by padding their bottoms, as needed,
1912 ;; `texinfo-multitable-extract-row' is called by `texinfo-multitable-item'.
1913 ;; This function returns the text in a multitable row, as a string.
1914 ;; The start of a row is marked by an @item and the end of row is the
1915 ;; beginning of next @item or beginning of the @end multitable line.
1916 ;; Cells within a row are separated by @tab.
1918 ;; Note that @tab, the cell separators, are not treated as independent
1919 ;; Texinfo commands.
1921 (defvar texinfo-extra-inter-column-width
0
1922 "*Number of extra spaces between entries (columns) in @multitable.")
1924 (defvar texinfo-multitable-buffer-name
"*multitable-temporary-buffer*")
1925 (defvar texinfo-multitable-rectangle-name
"texinfo-multitable-temp-")
1927 ;; These commands are defined in texinfo.tex for printed output.
1928 (put 'multitableparskip
'texinfo-format
'texinfo-discard-line-with-args
)
1929 (put 'multitableparindent
'texinfo-format
'texinfo-discard-line-with-args
)
1930 (put 'multitablecolmargin
'texinfo-format
'texinfo-discard-line-with-args
)
1931 (put 'multitablelinespace
'texinfo-format
'texinfo-discard-line-with-args
)
1933 (put 'multitable
'texinfo-format
'texinfo-multitable
)
1935 (defun texinfo-multitable ()
1936 "Produce multi-column tables.
1938 A multi-column table has this template:
1940 @multitable {A1} {A2} {A3}
1941 @item A1 @tab A2 @tab A3
1942 @item B1 @tab B2 @tab B3
1943 @item C1 @tab C2 @tab C3
1946 where the width of the text in brackets specifies the width of the
1951 @multitable @columnfractions .25 .3 .45
1952 @item A1 @tab A2 @tab A3
1953 @item B1 @tab B2 @tab B3
1956 where the fractions specify the width of each column as a percent
1957 of the current width of the text (i.e., of the `fill-column').
1959 Long lines of text are filled within columns.
1961 Using the Emacs Lisp formatter, texinfmt.el,
1962 the whitespace between columns can be increased by setting
1963 `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1964 there is at least one blank space between columns.
1966 The Emacs Lisp formatter, texinfmt.el, ignores the following four
1967 commands that are defined in texinfo.tex for printed output.
1970 @multitableparindent,
1971 @multitablecolmargin,
1972 @multitablelinespace."
1974 ;; This function pushes information onto the `texinfo-stack'.
1975 ;; A stack element consists of:
1976 ;; - type-of-command, i.e., multitable
1977 ;; - the information about column widths, and
1978 ;; - the position of texinfo-command-start.
1979 ;; e.g., ('multitable (1 2 3 4) 123)
1980 ;; The command line is then deleted.
1983 ;; push width information on stack
1984 (texinfo-multitable-widths))
1985 (texinfo-discard-line-with-args))
1987 (put 'multitable
'texinfo-end
'texinfo-end-multitable
)
1988 (defun texinfo-end-multitable ()
1989 "Discard the @end multitable line and pop the stack of multitable."
1990 (texinfo-discard-command)
1991 (texinfo-pop-stack 'multitable
))
1993 (defun texinfo-multitable-widths ()
1994 "Return list of widths of each column in a multi-column table."
1995 (let (texinfo-multitable-width-list)
1996 ;; Fractions format:
1997 ;; @multitable @columnfractions .25 .3 .45
2000 ;; @multitable {Column 1 template} {Column 2} {Column 3 example}
2001 ;; Place point before first argument
2002 (skip-chars-forward " \t")
2004 ;; Check for common misspelling
2005 ((looking-at "@columnfraction ")
2006 (error "In @multitable, @columnfractions misspelled"))
2007 ;; Case 1: @columnfractions .25 .3 .45
2008 ((looking-at "@columnfractions")
2013 (* fill-column
(read (get-buffer (current-buffer))))))
2014 texinfo-multitable-width-list
)))
2016 ;; Case 2: {Column 1 template} {Column 2} {Column 3 example}
2018 (let ((start-of-templates (point)))
2020 (skip-chars-forward " \t")
2021 (let* ((start-of-template (1+ (point)))
2023 ;; forward-sexp works with braces in Texinfo mode
2024 (progn (forward-sexp 1) (1- (point)))))
2025 (push (- end-of-template start-of-template
)
2026 texinfo-multitable-width-list
)
2027 ;; Remove carriage return from within a template, if any.
2028 ;; This helps those those who want to use more than
2029 ;; one line's worth of words in @multitable line.
2030 (narrow-to-region start-of-template end-of-template
)
2031 (goto-char (point-min))
2032 (while (search-forward "
2035 (goto-char (point-max))
2037 (forward-char 1)))))
2042 "You probably need to specify column widths for @multitable correctly.")))
2043 ;; Check whether columns fit on page.
2044 (let ((desired-columns
2046 ;; between column spaces
2047 (length texinfo-multitable-width-list
)
2048 ;; additional between column spaces, if any
2049 texinfo-extra-inter-column-width
2050 ;; sum of spaces for each entry
2051 (apply '+ texinfo-multitable-width-list
))))
2052 (if (> desired-columns fill-column
)
2054 "Multi-column table width, %d chars, is greater than page width, %d chars."
2055 desired-columns fill-column
)))
2056 texinfo-multitable-width-list
))
2058 ;; @item A1 @tab A2 @tab A3
2059 (defun texinfo-multitable-extract-row ()
2060 "Return multitable row, as a string.
2061 End of row is beginning of next @item or beginning of @end.
2062 Cells within rows are separated by @tab."
2063 (skip-chars-forward " \t")
2064 (let* ((start (point))
2066 (re-search-forward "@item\\|@end")
2067 (match-beginning 0)))
2068 (row (progn (goto-char end
)
2069 (skip-chars-backward " ")
2070 ;; remove whitespace at end of argument
2071 (delete-region (point) end
)
2072 (buffer-substring-no-properties start
(point)))))
2073 (delete-region texinfo-command-start end
)
2076 (put 'multitable
'texinfo-item
'texinfo-multitable-item
)
2077 (defun texinfo-multitable-item ()
2078 "Format a row within a multicolumn table.
2079 Cells in row are separated by @tab.
2080 Widths of cells are specified by the arguments in the @multitable line.
2081 All cells are made to be the same height.
2082 This command is executed when texinfmt sees @item inside @multitable."
2083 (let ((original-buffer (current-buffer))
2084 (table-widths (reverse (car (cdr (car texinfo-stack
)))))
2085 (existing-fill-column fill-column
)
2089 (table-entry-height 0)
2090 ;; unformatted row looks like: A1 @tab A2 @tab A3
2091 ;; extract-row command deletes the source line in the table.
2092 (unformated-row (texinfo-multitable-extract-row)))
2093 ;; Use a temporary buffer
2094 (set-buffer (get-buffer-create texinfo-multitable-buffer-name
))
2095 (delete-region (point-min) (point-max))
2096 (insert unformated-row
)
2097 (goto-char (point-min))
2098 ;; 1. Check for correct number of @tab in line.
2099 (let ((tab-number 1)) ; one @tab between two columns
2100 (while (search-forward "@tab" nil t
)
2101 (setq tab-number
(1+ tab-number
)))
2102 (let ((needed-tabs (- (length table-widths
) tab-number
)))
2103 (when (> needed-tabs
0)
2104 (goto-char (point-min))
2106 (while (> needed-tabs
0)
2107 (insert "@w{ }\n@tab")
2108 (setq needed-tabs
(1- needed-tabs
))
2110 "Added @tabs and empty spaces to a @multitable row")))))
2111 (goto-char (point-min))
2112 ;; 2. Format each cell, and copy to a rectangle
2113 ;; buffer looks like this: A1 @tab A2 @tab A3
2114 ;; Cell #1: format up to @tab
2115 ;; Cell #2: format up to @tab
2116 ;; Cell #3: format up to eob
2118 (setq start
(point))
2119 (setq end
(save-excursion
2120 (if (search-forward "@tab" nil
'move
)
2121 ;; Delete the @tab command, including the @-sign
2124 (progn (forward-word -
1) (1- (point)))))
2126 ;; Set fill-column *wider* than needed to produce inter-column space
2127 (setq fill-column
(+ 1
2128 texinfo-extra-inter-column-width
2129 (nth table-column table-widths
)))
2130 (narrow-to-region start end
)
2131 ;; Remove whitespace before and after entry.
2132 (skip-chars-forward " ")
2133 (delete-region (point) (line-beginning-position))
2134 (goto-char (point-max))
2135 (skip-chars-backward " ")
2136 (delete-region (point) (line-end-position))
2137 ;; Temporarily set texinfo-stack to nil so texinfo-format-scan
2138 ;; does not see an unterminated @multitable.
2139 (let (texinfo-stack) ; nil
2140 (texinfo-format-scan))
2141 (let (fill-prefix) ; no fill prefix
2142 (fill-region (point-min) (point-max)))
2143 (setq table-entry-height
2144 (max table-entry-height
(count-lines (point-min) (point-max))))
2145 ;; 3. Move point to end of bottom line, and pad that line to fill column.
2146 (goto-char (point-min))
2147 (forward-line (1- table-entry-height
))
2148 (let* ((beg (point)) ; beginning of line
2149 ;; add one more space for inter-column spacing
2154 (progn (end-of-line) (point)) ; end of existing line
2156 (insert (make-string
2157 (if (> needed-whitespace
0) needed-whitespace
1)
2159 ;; now, put formatted cell into a rectangle
2160 (set (intern (concat texinfo-multitable-rectangle-name
2161 (int-to-string table-column
)))
2162 (extract-rectangle (point-min) (point)))
2163 (delete-region (point-min) (point))
2164 (goto-char (point-max))
2165 (setq table-column
(1+ table-column
))
2167 ;; 4. Add extra lines to rectangles so all are of same height
2168 (let ((total-number-of-columns table-column
)
2171 (while (> table-column
0)
2172 (let ((this-rectangle (int-to-string table-column
)))
2173 (while (< (length this-rectangle
) table-entry-height
)
2174 (setq this-rectangle
(append this-rectangle
'("")))))
2175 (setq table-column
(1- table-column
)))
2176 ;; 5. Insert formatted rectangles in original buffer
2177 (switch-to-buffer original-buffer
)
2178 (open-line table-entry-height
)
2179 (while (< column-number total-number-of-columns
)
2183 (concat texinfo-multitable-rectangle-name
2184 (int-to-string column-number
)))))
2187 (setq column-number
(1+ column-number
))))
2188 (kill-buffer texinfo-multitable-buffer-name
)
2189 (setq fill-column existing-fill-column
)))
2193 ;; Use only the FILENAME argument to the command.
2194 ;; In Info, ignore the other arguments.
2196 (put 'image
'texinfo-format
'texinfo-format-image
)
2197 (defun texinfo-format-image ()
2198 "Insert an image from an an file ending in .txt.
2199 Use only the FILENAME arg; for Info, ignore the other arguments to @image."
2200 (let ((args (texinfo-format-parse-args))
2202 (when (null (nth 0 args
))
2203 (error "Invalid image command"))
2204 (texinfo-discard-command)
2205 ;; makeinfo uses FILENAME.txt
2206 (setq filename
(format "%s.txt" (nth 0 args
)))
2207 (message "Reading included file: %s" filename
)
2208 ;; verbatim for Info output
2209 (goto-char (+ (point) (cadr (insert-file-contents filename
))))
2210 (message "Reading included file: %s...done" filename
)))
2213 ;;; @ifinfo, @iftex, @tex, @ifhtml, @html, @ifplaintext, @ifxml, @xml
2214 ;; @ifnottex, @ifnotinfo, @ifnothtml, @ifnotplaintext, @ifnotxml
2216 (put 'ifinfo
'texinfo-format
'texinfo-discard-line
)
2217 (put 'ifinfo
'texinfo-end
'texinfo-discard-command
)
2219 (put 'iftex
'texinfo-format
'texinfo-format-iftex
)
2220 (defun texinfo-format-iftex ()
2221 (delete-region texinfo-command-start
2222 (re-search-forward "@end iftex[ \t]*\n")))
2224 (put 'ifhtml
'texinfo-format
'texinfo-format-ifhtml
)
2225 (defun texinfo-format-ifhtml ()
2226 (delete-region texinfo-command-start
2227 (re-search-forward "@end ifhtml[ \t]*\n")))
2229 (put 'ifplaintext
'texinfo-format
'texinfo-format-ifplaintext
)
2230 (defun texinfo-format-ifplaintext ()
2231 (delete-region texinfo-command-start
2232 (re-search-forward "@end ifplaintext[ \t]*\n")))
2234 (put 'ifxml
'texinfo-format
'texinfo-format-ifxml
)
2235 (defun texinfo-format-ifxml ()
2236 (delete-region texinfo-command-start
2237 (progn (re-search-forward "^@end ifxml[ \t]*\n")
2240 (put 'tex
'texinfo-format
'texinfo-format-tex
)
2241 (defun texinfo-format-tex ()
2242 (delete-region texinfo-command-start
2243 (re-search-forward "@end tex[ \t]*\n")))
2245 (put 'html
'texinfo-format
'texinfo-format-html
)
2246 (defun texinfo-format-html ()
2247 (delete-region texinfo-command-start
2248 (re-search-forward "@end html[ \t]*\n")))
2250 (put 'xml
'texinfo-format
'texinfo-format-xml
)
2251 (defun texinfo-format-xml ()
2252 (delete-region texinfo-command-start
2253 (progn (re-search-forward "^@end xml[ \t]*\n")
2256 (put 'ifnotinfo
'texinfo-format
'texinfo-format-ifnotinfo
)
2257 (defun texinfo-format-ifnotinfo ()
2258 (delete-region texinfo-command-start
2259 (re-search-forward "@end ifnotinfo[ \t]*\n")))
2261 (put 'ifnotplaintext
'texinfo-format
'texinfo-discard-line
)
2262 (put 'ifnotplaintext
'texinfo-end
'texinfo-discard-command
)
2264 (put 'ifnottex
'texinfo-format
'texinfo-discard-line
)
2265 (put 'ifnottex
'texinfo-end
'texinfo-discard-command
)
2267 (put 'ifnothtml
'texinfo-format
'texinfo-discard-line
)
2268 (put 'ifnothtml
'texinfo-end
'texinfo-discard-command
)
2270 (put 'ifnotxml
'texinfo-format
'texinfo-discard-line
)
2271 (put 'ifnotxml
'texinfo-end
'texinfo-discard-command
)
2276 (put 'titlepage
'texinfo-format
'texinfo-format-titlepage
)
2277 (defun texinfo-format-titlepage ()
2278 (delete-region texinfo-command-start
2279 (re-search-forward "@end titlepage[ \t]*\n")))
2281 (put 'endtitlepage
'texinfo-format
'texinfo-discard-line
)
2283 ;; @titlespec an alternative titling command; ignored by Info
2285 (put 'titlespec
'texinfo-format
'texinfo-format-titlespec
)
2286 (defun texinfo-format-titlespec ()
2287 (delete-region texinfo-command-start
2288 (re-search-forward "@end titlespec[ \t]*\n")))
2290 (put 'endtitlespec
'texinfo-format
'texinfo-discard-line
)
2295 (put 'today
'texinfo-format
'texinfo-format-today
)
2297 ;; Produces Day Month Year style of output. eg `1 Jan 1900'
2298 ;; The `@today{}' command requires a pair of braces, like `@dots{}'.
2299 (defun texinfo-format-today ()
2300 (texinfo-parse-arg-discard)
2301 (insert (format-time-string "%e %b %Y")))
2305 ;; Produce `Day Month Year Hour:Min' style of output.
2306 ;; eg `1 Jan 1900 13:52'
2308 (put 'timestamp
'texinfo-format
'texinfo-format-timestamp
)
2310 ;; The `@timestamp{}' command requires a pair of braces, like `@dots{}'.
2311 (defun texinfo-format-timestamp ()
2312 "Insert the current local time and date."
2313 (texinfo-parse-arg-discard)
2314 ;; For seconds and time zone, replace format string with "%e %b %Y %T %Z"
2315 (insert (format-time-string "%e %b %Y %R")))
2320 (put 'ignore
'texinfo-format
'texinfo-format-ignore
)
2321 (defun texinfo-format-ignore ()
2322 (delete-region texinfo-command-start
2323 (re-search-forward "@end ignore[ \t]*\n")))
2325 (put 'endignore
'texinfo-format
'texinfo-discard-line
)
2328 ;;; Define the Info enclosure command: @definfoenclose
2330 ;; A `@definfoenclose' command may be used to define a highlighting
2331 ;; command for Info, but not for TeX. A command defined using
2332 ;; `@definfoenclose' marks text by enclosing it in strings that precede
2333 ;; and follow the text.
2335 ;; Presumably, if you define a command with `@definfoenclose` for Info,
2336 ;; you will also define the same command in the TeX definitions file,
2337 ;; `texinfo.tex' in a manner appropriate for typesetting.
2339 ;; Write a `@definfoenclose' command on a line and follow it with three
2340 ;; arguments separated by commas (commas are used as separators in an
2341 ;; `@node' line in the same way). The first argument to
2342 ;; `@definfoenclose' is the @-command name \(without the `@'\); the
2343 ;; second argument is the Info start delimiter string; and the third
2344 ;; argument is the Info end delimiter string. The latter two arguments
2345 ;; enclose the highlighted text in the Info file. A delimiter string
2346 ;; may contain spaces. Neither the start nor end delimiter is
2347 ;; required. However, if you do not provide a start delimiter, you
2348 ;; must follow the command name with two commas in a row; otherwise,
2349 ;; the Info formatting commands will misinterpret the end delimiter
2350 ;; string as a start delimiter string.
2352 ;; If you do a @definfoenclose{} on the name of a pre-defined macro (such
2353 ;; as @emph{}, @strong{}, @tt{}, or @i{}) the enclosure definition will
2354 ;; override the built-in definition.
2356 ;; An enclosure command defined this way takes one argument in braces.
2358 ;; For example, you can write:
2361 ;; @definfoenclose phoo, //, \\
2364 ;; near the beginning of a Texinfo file at the beginning of the lines
2365 ;; to define `@phoo' as an Info formatting command that inserts `//'
2366 ;; before and `\\' after the argument to `@phoo'. You can then write
2367 ;; `@phoo{bar}' wherever you want `//bar\\' highlighted in Info.
2369 ;; Also, for TeX formatting, you could write
2372 ;; @global@let@phoo=@i
2375 ;; to define `@phoo' as a command that causes TeX to typeset
2376 ;; the argument to `@phoo' in italics.
2378 ;; Note that each definition applies to its own formatter: one for TeX,
2379 ;; the other for texinfo-format-buffer or texinfo-format-region.
2381 ;; Here is another example: write
2383 ;; @definfoenclose headword, , :
2385 ;; near the beginning of the file, to define `@headword' as an Info
2386 ;; formatting command that inserts nothing before and a colon after the
2387 ;; argument to `@headword'.
2389 (put 'definfoenclose
'texinfo-format
'texinfo-define-info-enclosure
)
2390 (defun texinfo-define-info-enclosure ()
2391 (let* ((args (texinfo-format-parse-line-args))
2392 (command-name (nth 0 args
))
2393 (beginning-delimiter (or (nth 1 args
) ""))
2394 (end-delimiter (or (nth 2 args
) "")))
2395 (texinfo-discard-command)
2396 (push (list command-name
2400 texinfo-enclosure-list
)))
2405 (put 'alias
'texinfo-format
'texinfo-alias
)
2406 (defun texinfo-alias ()
2407 (let ((start (1- (point)))
2409 (skip-chars-forward " ")
2410 (setq texinfo-command-end
(line-end-position))
2411 (if (not (looking-at "\\([^=]+\\)=\\(.*\\)"))
2412 (error "Invalid alias command")
2414 (match-string-no-properties 1)
2415 (match-string-no-properties 2))
2417 (texinfo-discard-command))))
2420 ;;; @var, @code and the like
2422 (put 'var
'texinfo-format
'texinfo-format-var
)
2423 ;; @sc a small caps font for TeX; formatted as `var' in Info
2424 (put 'sc
'texinfo-format
'texinfo-format-var
)
2425 ;; @acronym for abbreviations in all caps, such as `NASA'.
2426 ;; Convert all letters to uppercase if they are not already.
2427 (put 'acronym
'texinfo-format
'texinfo-format-var
)
2428 (defun texinfo-format-var ()
2429 (let ((arg (texinfo-parse-expanded-arg)))
2430 (texinfo-discard-command)
2431 (insert (upcase arg
))))
2433 (put 'cite
'texinfo-format
'texinfo-format-code
)
2434 (put 'code
'texinfo-format
'texinfo-format-code
)
2435 ;; @command (for command names)
2436 (put 'command
'texinfo-format
'texinfo-format-code
)
2437 ;; @env (for environment variables)
2438 (put 'env
'texinfo-format
'texinfo-format-code
)
2439 (put 'file
'texinfo-format
'texinfo-format-code
)
2440 (put 'samp
'texinfo-format
'texinfo-format-code
)
2441 (put 'url
'texinfo-format
'texinfo-format-code
)
2442 (defun texinfo-format-code ()
2443 (insert "`" (texinfo-parse-arg-discard) "'")
2444 (goto-char texinfo-command-start
))
2446 ;; @option (for command-line options) must be different from @code
2447 ;; because of its special formatting in @table; namely that it does
2448 ;; not lead to inserted ` ... ' in a table, but does elsewhere.
2449 (put 'option
'texinfo-format
'texinfo-format-option
)
2450 (defun texinfo-format-option ()
2451 "Insert ` ... ' around arg unless inside a table; in that case, no quotes."
2452 ;; `looking-at-backward' not available in v. 18.57, 20.2
2453 (if (not (search-backward "\b" ; searched-for character is a control-H
2454 (line-beginning-position)
2456 (insert "`" (texinfo-parse-arg-discard) "'")
2457 (insert (texinfo-parse-arg-discard)))
2458 (goto-char texinfo-command-start
))
2460 (put 'emph
'texinfo-format
'texinfo-format-emph
)
2461 (put 'strong
'texinfo-format
'texinfo-format-emph
)
2462 (defun texinfo-format-emph ()
2463 (insert "*" (texinfo-parse-arg-discard) "*")
2464 (goto-char texinfo-command-start
))
2466 (put 'dfn
'texinfo-format
'texinfo-format-defn
)
2467 (put 'defn
'texinfo-format
'texinfo-format-defn
)
2468 (defun texinfo-format-defn ()
2469 (insert "\"" (texinfo-parse-arg-discard) "\"")
2470 (goto-char texinfo-command-start
))
2472 (put 'email
'texinfo-format
'texinfo-format-email
)
2473 (defun texinfo-format-email ()
2474 "Format email address and optional following full name.
2475 Insert full name, if present, followed by email address
2476 surrounded by in angle brackets."
2477 (let ((args (texinfo-format-parse-args)))
2478 (texinfo-discard-command)
2481 (insert (nth 1 args
) " "))
2482 (insert "<" (nth 0 args
) ">")))
2484 (put 'key
'texinfo-format
'texinfo-format-key
)
2485 ;; I've decided not want to have angle brackets around these -- rms.
2486 (defun texinfo-format-key ()
2487 (insert (texinfo-parse-arg-discard))
2488 (goto-char texinfo-command-start
))
2490 ;; @verb{<char>TEXT<char>} (in `makeinfo' 4.1 and later)
2491 (put 'verb
'texinfo-format
'texinfo-format-verb
)
2492 (defun texinfo-format-verb ()
2493 "Format text between non-quoted unique delimiter characters verbatim.
2494 Enclose the verbatim text, including the delimiters, in braces. Print
2495 text exactly as written (but not the delimiters) in a fixed-width.
2497 For example, @verb\{|@|\} results in @ and
2498 @verb\{+@'e?`!`+} results in @'e?`!`."
2500 (let ((delimiter (buffer-substring-no-properties
2501 (1+ texinfo-command-end
) (+ 2 texinfo-command-end
))))
2502 (unless (looking-at "{")
2503 (error "Not found: @verb start brace"))
2504 (delete-region texinfo-command-start
(+ 2 texinfo-command-end
))
2505 (search-forward delimiter
))
2507 (unless (looking-at "}")
2508 (error "Not found: @verb end brace"))
2511 ;; as of 2002 Dec 10
2512 ;; see (texinfo)Block Enclosing Commands
2515 ;; as of 2002 Dec 10
2516 ;; see (texinfo)verbatiminclude
2517 ;; need: @verbatiminclude FILENAME
2519 (put 'bullet
'texinfo-format
'texinfo-format-bullet
)
2520 (defun texinfo-format-bullet ()
2521 "Insert an asterisk.
2522 If used within a line, follow `@bullet' with braces."
2523 (texinfo-optional-braces-discard)
2529 ;; Inside of @example ... @end example and similar environments,
2530 ;; @kbd does nothing; but outside of such environments, it places
2531 ;; single quotation marks around its argument.
2533 (defvar texinfo-format-kbd-regexp
2543 "Regexp matching environments in which @kbd does not put `...' around arg.")
2545 (defvar texinfo-format-kbd-end-regexp
2555 "Regexp specifying end of environments in which @kbd does not put `...'
2556 around argument. (See `texinfo-format-kbd-regexp')")
2558 (put 'kbd
'texinfo-format
'texinfo-format-kbd
)
2559 (defun texinfo-format-kbd ()
2560 "Place single quote marks around arg, except in @example and similar."
2561 ;; Search forward for @end example closer than an @example.
2562 ;; Can stop search at nearest @node or texinfo-section-types-regexp
2566 (concat "^@node\\|\\(" texinfo-section-types-regexp
"\\)")
2568 'move-to-end
) ; if necessary, return point at end of buffer
2572 (re-search-forward texinfo-format-kbd-regexp stop
'move-to-end
)
2574 (end-example-location
2576 (re-search-forward texinfo-format-kbd-end-regexp stop
'move-to-end
)
2578 ;; If inside @example, @end example will be closer than @example
2579 ;; or end of search i.e., end-example-location less than example-location
2580 (if (>= end-example-location example-location
)
2581 ;; outside an @example or equivalent
2582 (insert "`" (texinfo-parse-arg-discard) "'")
2583 ;; else, in @example; do not surround with `...'
2584 (insert (texinfo-parse-arg-discard)))
2585 (goto-char texinfo-command-start
)))
2588 ;;; @example, @lisp, @quotation, @display, @smalllisp, @smallexample,
2591 (put 'display
'texinfo-format
'texinfo-format-example
)
2592 (put 'smalldisplay
'texinfo-format
'texinfo-format-example
)
2593 (put 'example
'texinfo-format
'texinfo-format-example
)
2594 (put 'lisp
'texinfo-format
'texinfo-format-example
)
2595 (put 'quotation
'texinfo-format
'texinfo-format-example
)
2596 (put 'smallexample
'texinfo-format
'texinfo-format-example
)
2597 (put 'smalllisp
'texinfo-format
'texinfo-format-example
)
2598 (defun texinfo-format-example ()
2599 (texinfo-push-stack 'example nil
)
2600 (setq fill-column
(- fill-column
5))
2601 (texinfo-discard-line))
2603 (put 'example
'texinfo-end
'texinfo-end-example
)
2604 (put 'display
'texinfo-end
'texinfo-end-example
)
2605 (put 'smalldisplay
'texinfo-end
'texinfo-end-example
)
2606 (put 'lisp
'texinfo-end
'texinfo-end-example
)
2607 (put 'quotation
'texinfo-end
'texinfo-end-example
)
2608 (put 'smallexample
'texinfo-end
'texinfo-end-example
)
2609 (put 'smalllisp
'texinfo-end
'texinfo-end-example
)
2610 (defun texinfo-end-example ()
2611 (setq fill-column
(+ fill-column
5))
2612 (texinfo-discard-command)
2614 (texinfo-pop-stack 'example
)))
2615 (texinfo-do-itemize (nth 1 stacktop
))))
2617 (put 'exdent
'texinfo-format
'texinfo-format-exdent
)
2618 (defun texinfo-format-exdent ()
2619 (texinfo-discard-command)
2620 (delete-region (point)
2622 (skip-chars-forward " ")
2625 ;; Cancel out the deletion that texinfo-do-itemize
2626 ;; is going to do at the end of this line.
2632 ;; @direntry and @dircategory
2634 (put 'direntry
'texinfo-format
'texinfo-format-direntry
)
2635 (defun texinfo-format-direntry ()
2636 (texinfo-push-stack 'direntry nil
)
2637 (texinfo-discard-line)
2638 (insert "START-INFO-DIR-ENTRY\n"))
2640 (put 'direntry
'texinfo-end
'texinfo-end-direntry
)
2641 (defun texinfo-end-direntry ()
2642 (texinfo-discard-command)
2643 (insert "END-INFO-DIR-ENTRY\n\n")
2644 (texinfo-pop-stack 'direntry
))
2646 (put 'dircategory
'texinfo-format
'texinfo-format-dircategory
)
2647 (defun texinfo-format-dircategory ()
2648 (let ((str (texinfo-parse-arg-discard)))
2649 (delete-region (point)
2651 (skip-chars-forward " ")
2653 (insert "INFO-DIR-SECTION " str
"\n")))
2657 ;; The @cartouche command is a noop in Info; in a printed manual,
2658 ;; it makes a box with rounded corners.
2660 (put 'cartouche
'texinfo-format
'texinfo-discard-line
)
2661 (put 'cartouche
'texinfo-end
'texinfo-discard-command
)
2664 ;;; @flushleft and @format
2666 ;; The @flushleft command left justifies every line but leaves the
2667 ;; right end ragged. As far as Info is concerned, @flushleft is a
2668 ;; `do-nothing' command
2670 ;; The @format command is similar to @example except that it does not
2671 ;; indent; this means that in Info, @format is similar to @flushleft.
2673 (put 'format
'texinfo-format
'texinfo-format-flushleft
)
2674 (put 'smallformat
'texinfo-format
'texinfo-format-flushleft
)
2675 (put 'flushleft
'texinfo-format
'texinfo-format-flushleft
)
2676 (defun texinfo-format-flushleft ()
2677 (texinfo-discard-line))
2679 (put 'format
'texinfo-end
'texinfo-end-flushleft
)
2680 (put 'smallformat
'texinfo-end
'texinfo-end-flushleft
)
2681 (put 'flushleft
'texinfo-end
'texinfo-end-flushleft
)
2682 (defun texinfo-end-flushleft ()
2683 (texinfo-discard-command))
2688 ;; The @flushright command right justifies every line but leaves the
2689 ;; left end ragged. Spaces and tabs at the right ends of lines are
2690 ;; removed so that visible text lines up on the right side.
2692 (put 'flushright
'texinfo-format
'texinfo-format-flushright
)
2693 (defun texinfo-format-flushright ()
2694 (texinfo-push-stack 'flushright nil
)
2695 (texinfo-discard-line))
2697 (put 'flushright
'texinfo-end
'texinfo-end-flushright
)
2698 (defun texinfo-end-flushright ()
2699 (texinfo-discard-command)
2702 (texinfo-pop-stack 'flushright
)))
2704 (texinfo-do-flushright (nth 1 stacktop
))))
2706 (defun texinfo-do-flushright (from)
2708 (while (progn (forward-line -
1)
2717 (skip-chars-backward " \t")
2718 (delete-region (point) (progn (end-of-line) (point)))
2723 ;;; @ctrl, @TeX, @copyright, @minus, @dots, @enddots, @pounds
2725 (put 'ctrl
'texinfo-format
'texinfo-format-ctrl
)
2726 (defun texinfo-format-ctrl ()
2727 (let ((str (texinfo-parse-arg-discard)))
2728 (insert (logand 31 (aref str
0)))))
2730 (put 'TeX
'texinfo-format
'texinfo-format-TeX
)
2731 (defun texinfo-format-TeX ()
2732 (texinfo-parse-arg-discard)
2735 (put 'copyright
'texinfo-format
'texinfo-format-copyright
)
2736 (defun texinfo-format-copyright ()
2737 (texinfo-parse-arg-discard)
2740 (put 'minus
'texinfo-format
'texinfo-format-minus
)
2741 (defun texinfo-format-minus ()
2742 "Insert a minus sign.
2743 If used within a line, follow `@minus' with braces."
2744 (texinfo-optional-braces-discard)
2747 (put 'dots
'texinfo-format
'texinfo-format-dots
)
2748 (defun texinfo-format-dots ()
2749 (texinfo-parse-arg-discard)
2752 (put 'enddots
'texinfo-format
'texinfo-format-enddots
)
2753 (defun texinfo-format-enddots ()
2754 (texinfo-parse-arg-discard)
2757 (put 'pounds
'texinfo-format
'texinfo-format-pounds
)
2758 (defun texinfo-format-pounds ()
2759 (texinfo-parse-arg-discard)
2763 ;;; Refilling and indenting: @refill, @paragraphindent, @noindent
2765 ;; Indent only those paragraphs that are refilled as a result of an
2768 ;; * If the value is `asis', do not change the existing indentation at
2769 ;; the starts of paragraphs.
2771 ;; * If the value zero, delete any existing indentation.
2773 ;; * If the value is greater than zero, indent each paragraph by that
2774 ;; number of spaces.
2776 ;; But do not refill paragraphs with an @refill command that are
2777 ;; preceded by @noindent or are part of a table, list, or deffn.
2779 (defvar texinfo-paragraph-indent
"asis"
2780 "Number of spaces for @refill to indent a paragraph; else to leave as is.")
2782 (put 'paragraphindent
'texinfo-format
'texinfo-paragraphindent
)
2784 (defun texinfo-paragraphindent ()
2785 "Specify the number of spaces for @refill to indent a paragraph.
2786 Default is to leave the number of spaces as is."
2787 (let ((arg (texinfo-parse-arg-discard)))
2788 (if (string= "asis" arg
)
2789 (setq texinfo-paragraph-indent
"asis")
2790 (setq texinfo-paragraph-indent
(string-to-number arg
)))))
2792 (put 'refill
'texinfo-format
'texinfo-format-refill
)
2793 (defun texinfo-format-refill ()
2794 "Refill paragraph. Also, indent first line as set by @paragraphindent.
2795 Default is to leave paragraph indentation as is."
2796 (texinfo-discard-command)
2797 (let ((position (point-marker)))
2798 (forward-paragraph -
1)
2799 (if (looking-at "[ \t\n]*$") (forward-line 1))
2800 ;; Do not indent if an entry in a list, table, or deffn,
2801 ;; or if paragraph is preceded by @noindent.
2802 ;; Otherwise, indent
2804 ;; delete a @noindent line and do not indent paragraph
2805 ((save-excursion (forward-line -
1)
2806 (looking-at "^@noindent"))
2808 (delete-region (point) (progn (forward-line 1) (point))))
2809 ;; do nothing if "asis"
2810 ((equal texinfo-paragraph-indent
"asis"))
2811 ;; do no indenting in list, etc.
2812 ((> texinfo-stack-depth
0))
2813 ;; otherwise delete existing whitespace and indent
2815 (delete-region (point) (progn (skip-chars-forward " \t") (point)))
2816 (insert (make-string texinfo-paragraph-indent ?
))))
2817 (forward-paragraph 1)
2820 ;; Do not fill a section title line with asterisks, hyphens, etc. that
2821 ;; are used to underline it. This could occur if the line following
2822 ;; the underlining is not an index entry and has text within it.
2823 (let* ((previous-paragraph-separate paragraph-separate
)
2825 (concat paragraph-separate
"\\|[-=.]+\\|\\*\\*+"))
2826 (previous-paragraph-start paragraph-start
)
2828 (concat paragraph-start
"\\|[-=.]+\\|\\*\\*+")))
2830 (fill-paragraph nil
)
2831 (setq paragraph-separate previous-paragraph-separate
)
2832 (setq paragraph-start previous-paragraph-start
)))
2833 (goto-char position
)))
2835 (put 'noindent
'texinfo-format
'texinfo-noindent
)
2836 (defun texinfo-noindent ()
2838 (forward-paragraph 1)
2839 (if (search-backward "@refill" (line-beginning-position 0) t
)
2840 () ; leave @noindent command so @refill command knows not to indent
2842 (texinfo-discard-line))))
2845 ;;; Index generation
2847 (put 'vindex
'texinfo-format
'texinfo-format-vindex
)
2848 (defun texinfo-format-vindex ()
2849 (texinfo-index 'texinfo-vindex
))
2851 (put 'cindex
'texinfo-format
'texinfo-format-cindex
)
2852 (defun texinfo-format-cindex ()
2853 (texinfo-index 'texinfo-cindex
))
2855 (put 'findex
'texinfo-format
'texinfo-format-findex
)
2856 (defun texinfo-format-findex ()
2857 (texinfo-index 'texinfo-findex
))
2859 (put 'pindex
'texinfo-format
'texinfo-format-pindex
)
2860 (defun texinfo-format-pindex ()
2861 (texinfo-index 'texinfo-pindex
))
2863 (put 'tindex
'texinfo-format
'texinfo-format-tindex
)
2864 (defun texinfo-format-tindex ()
2865 (texinfo-index 'texinfo-tindex
))
2867 (put 'kindex
'texinfo-format
'texinfo-format-kindex
)
2868 (defun texinfo-format-kindex ()
2869 (texinfo-index 'texinfo-kindex
))
2871 (defun texinfo-index (indexvar)
2872 (let ((arg (texinfo-parse-expanded-arg)))
2873 (texinfo-discard-command)
2877 ;; Region formatting may not provide last node position.
2878 (if texinfo-last-node-pos
2879 (1+ (count-lines texinfo-last-node-pos
(point)))
2881 (symbol-value indexvar
)))))
2883 (defvar texinfo-indexvar-alist
2884 '(("cp" . texinfo-cindex
)
2885 ("fn" . texinfo-findex
)
2886 ("vr" . texinfo-vindex
)
2887 ("tp" . texinfo-tindex
)
2888 ("pg" . texinfo-pindex
)
2889 ("ky" . texinfo-kindex
)))
2892 ;;; @defindex @defcodeindex
2893 (put 'defindex
'texinfo-format
'texinfo-format-defindex
)
2894 (put 'defcodeindex
'texinfo-format
'texinfo-format-defindex
)
2896 (defun texinfo-format-defindex ()
2897 (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa'
2898 (indexing-command (intern (concat index-name
"index")))
2899 (index-formatting-command ; eg: `texinfo-format-aaindex'
2900 (intern (concat "texinfo-format-" index-name
"index")))
2901 (index-alist-name ; eg: `texinfo-aaindex'
2902 (intern (concat "texinfo-" index-name
"index"))))
2904 (set index-alist-name nil
)
2906 (put indexing-command
; eg, aaindex
2908 index-formatting-command
) ; eg, texinfo-format-aaindex
2910 ;; eg: "aa" . texinfo-aaindex
2911 (or (assoc index-name texinfo-indexvar-alist
)
2912 (push (cons index-name
2914 texinfo-indexvar-alist
))
2916 (fset index-formatting-command
2918 (list 'texinfo-index
2919 (list 'quote index-alist-name
))))))
2922 ;;; @synindex @syncodeindex
2924 (put 'synindex
'texinfo-format
'texinfo-format-synindex
)
2925 (put 'syncodeindex
'texinfo-format
'texinfo-format-synindex
)
2927 (defun texinfo-format-synindex ()
2928 (let* ((args (texinfo-parse-arg-discard))
2929 (second (cdr (read-from-string args
)))
2930 (joiner (symbol-name (car (read-from-string args
))))
2931 (joined (symbol-name (car (read-from-string args second
)))))
2933 (if (assoc joiner texinfo-short-index-cmds-alist
)
2935 (cdr (assoc joiner texinfo-short-index-cmds-alist
))
2937 (or (cdr (assoc joined texinfo-short-index-format-cmds-alist
))
2938 (intern (concat "texinfo-format-" joined
"index"))))
2940 (intern (concat joiner
"index"))
2942 (or (cdr(assoc joined texinfo-short-index-format-cmds-alist
))
2943 (intern (concat "texinfo-format-" joined
"index")))))))
2945 (defconst texinfo-short-index-cmds-alist
2953 (defconst texinfo-short-index-format-cmds-alist
2954 '(("cp" . texinfo-format-cindex
)
2955 ("fn" . texinfo-format-findex
)
2956 ("vr" . texinfo-format-vindex
)
2957 ("tp" . texinfo-format-tindex
)
2958 ("pg" . texinfo-format-pindex
)
2959 ("ky" . texinfo-format-kindex
)))
2964 (put 'printindex
'texinfo-format
'texinfo-format-printindex
)
2966 (defun texinfo-format-printindex ()
2967 (let* ((arg (texinfo-parse-arg-discard))
2968 (fmt (cdr (assoc arg texinfo-short-index-format-cmds-alist
)))
2969 (index-list (delq nil
(mapcar (lambda (e)
2970 (and (eq fmt
(get (cdr e
) 'texinfo-format
))
2971 (cdr (assoc (car e
) texinfo-indexvar-alist
))))
2972 texinfo-short-index-cmds-alist
)))
2973 (indexelts (apply #'append nil
(mapcar #'symbol-value index-list
)))
2975 (insert "\n* Menu:\n\n")
2976 (setq opoint
(point))
2977 (texinfo-print-index nil indexelts
)
2978 (shell-command-on-region opoint
(point) "sort -fd" 1)))
2980 (defun texinfo-print-index (file indexelts
)
2982 (if (stringp (car (car indexelts
)))
2984 (insert "* " (car (car indexelts
)) ": " )
2987 (if file
(concat "(" file
")") "")
2988 (nth 1 (car indexelts
)) ".")
2991 (if (nth 2 (car indexelts
))
2992 (format " (line %3d)" (1+ (nth 2 (car indexelts
))))
2995 ;; index entries from @include'd file
2996 (texinfo-print-index (nth 1 (car indexelts
))
2997 (nth 2 (car indexelts
))))
2998 (setq indexelts
(cdr indexelts
))))
3001 ;;; Glyphs: @equiv, @error, etc
3003 ;; @equiv to show that two expressions are equivalent
3004 ;; @error to show an error message
3005 ;; @expansion to show what a macro expands to
3006 ;; @point to show the location of point in an example
3007 ;; @print to show what an evaluated expression prints
3008 ;; @result to indicate the value returned by an expression
3010 (put 'equiv
'texinfo-format
'texinfo-format-equiv
)
3011 (defun texinfo-format-equiv ()
3012 (texinfo-parse-arg-discard)
3015 (put 'error
'texinfo-format
'texinfo-format-error
)
3016 (defun texinfo-format-error ()
3017 (texinfo-parse-arg-discard)
3018 (insert "error-->"))
3020 (put 'expansion
'texinfo-format
'texinfo-format-expansion
)
3021 (defun texinfo-format-expansion ()
3022 (texinfo-parse-arg-discard)
3025 (put 'point
'texinfo-format
'texinfo-format-point
)
3026 (defun texinfo-format-point ()
3027 (texinfo-parse-arg-discard)
3030 (put 'print
'texinfo-format
'texinfo-format-print
)
3031 (defun texinfo-format-print ()
3032 (texinfo-parse-arg-discard)
3035 (put 'result
'texinfo-format
'texinfo-format-result
)
3036 (defun texinfo-format-result ()
3037 (texinfo-parse-arg-discard)
3043 ;; Info presumes a plain ASCII output, so the accented characters do
3044 ;; not look as they would if typeset, or output with a different
3047 ;; See the `texinfo-accent-commands' variable
3048 ;; in the section for `texinfo-append-refill'.
3049 ;; Also, see the defun for `texinfo-format-scan'
3050 ;; for single-character accent commands.
3052 ;; Command Info output Name
3054 ;; These do not have braces:
3055 ;; @^ ==> ^ circumflex accent
3056 ;; @` ==> ` grave accent
3057 ;; @' ==> ' acute accent
3058 ;; @" ==> " umlaut accent
3059 ;; @= ==> = overbar accent
3060 ;; @~ ==> ~ tilde accent
3062 ;; These have braces, but take no argument:
3063 ;; @OE{} ==> OE French-OE-ligature
3065 ;; @AA{} ==> AA Scandinavian-A-with-circle
3067 ;; @AE{} ==> AE Latin-Scandinavian-AE
3069 ;; @ss{} ==> ss German-sharp-S
3071 ;; @questiondown{} ==> ? upside-down-question-mark
3072 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
3073 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
3074 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
3075 ;; @O{} ==> O/ Scandinavian O-with-slash
3076 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
3078 ;; These have braces, and take an argument:
3079 ;; @,{c} ==> c, cedilla accent
3080 ;; @dotaccent{o} ==> .o overdot-accent
3081 ;; @ubaraccent{o} ==> _o underbar-accent
3082 ;; @udotaccent{o} ==> o-. underdot-accent
3083 ;; @H{o} ==> ""o long Hungarian umlaut
3084 ;; @ringaccent{o} ==> *o ring accent
3085 ;; @tieaccent{oo} ==> [oo tie after accent
3086 ;; @u{o} ==> (o breve accent
3087 ;; @v{o} ==> <o hacek accent
3088 ;; @dotless{i} ==> i dotless i and dotless j
3092 ;; Note: The defun texinfo-format-scan
3093 ;; looks at "[@{}^'`\",=~ *?!-]"
3094 ;; In the case of @*, a line break is inserted;
3095 ;; in the other cases, the characters are simply quoted and the @ is deleted.
3096 ;; Thus, `texinfo-format-scan' handles the following
3097 ;; single-character accent commands: @^ @` @' @" @, @- @= @~
3099 ;; @^ ==> ^ circumflex accent
3100 ;; (put '^ 'texinfo-format 'texinfo-format-circumflex-accent)
3101 ;; (defun texinfo-format-circumflex-accent ()
3102 ;; (texinfo-discard-command)
3105 ;; @` ==> ` grave accent
3106 ;; (put '\` 'texinfo-format 'texinfo-format-grave-accent)
3107 ;; (defun texinfo-format-grave-accent ()
3108 ;; (texinfo-discard-command)
3111 ;; @' ==> ' acute accent
3112 ;; (put '\' 'texinfo-format 'texinfo-format-acute-accent)
3113 ;; (defun texinfo-format-acute-accent ()
3114 ;; (texinfo-discard-command)
3117 ;; @" ==> " umlaut accent
3118 ;; (put '\" 'texinfo-format 'texinfo-format-umlaut-accent)
3119 ;; (defun texinfo-format-umlaut-accent ()
3120 ;; (texinfo-discard-command)
3123 ;; @= ==> = overbar accent
3124 ;; (put '= 'texinfo-format 'texinfo-format-overbar-accent)
3125 ;; (defun texinfo-format-overbar-accent ()
3126 ;; (texinfo-discard-command)
3129 ;; @~ ==> ~ tilde accent
3130 ;; (put '~ 'texinfo-format 'texinfo-format-tilde-accent)
3131 ;; (defun texinfo-format-tilde-accent ()
3132 ;; (texinfo-discard-command)
3135 ;; @OE{} ==> OE French-OE-ligature
3136 (put 'OE
'texinfo-format
'texinfo-format-French-OE-ligature
)
3137 (defun texinfo-format-French-OE-ligature ()
3138 (insert "OE" (texinfo-parse-arg-discard))
3139 (goto-char texinfo-command-start
))
3142 (put 'oe
'texinfo-format
'texinfo-format-French-oe-ligature
)
3143 (defun texinfo-format-French-oe-ligature () ; lower case
3144 (insert "oe" (texinfo-parse-arg-discard))
3145 (goto-char texinfo-command-start
))
3147 ;; @AA{} ==> AA Scandinavian-A-with-circle
3148 (put 'AA
'texinfo-format
'texinfo-format-Scandinavian-A-with-circle
)
3149 (defun texinfo-format-Scandinavian-A-with-circle ()
3150 (insert "AA" (texinfo-parse-arg-discard))
3151 (goto-char texinfo-command-start
))
3154 (put 'aa
'texinfo-format
'texinfo-format-Scandinavian-a-with-circle
)
3155 (defun texinfo-format-Scandinavian-a-with-circle () ; lower case
3156 (insert "aa" (texinfo-parse-arg-discard))
3157 (goto-char texinfo-command-start
))
3159 ;; @AE{} ==> AE Latin-Scandinavian-AE
3160 (put 'AE
'texinfo-format
'texinfo-format-Latin-Scandinavian-AE
)
3161 (defun texinfo-format-Latin-Scandinavian-AE ()
3162 (insert "AE" (texinfo-parse-arg-discard))
3163 (goto-char texinfo-command-start
))
3166 (put 'ae
'texinfo-format
'texinfo-format-Latin-Scandinavian-ae
)
3167 (defun texinfo-format-Latin-Scandinavian-ae () ; lower case
3168 (insert "ae" (texinfo-parse-arg-discard))
3169 (goto-char texinfo-command-start
))
3171 ;; @ss{} ==> ss German-sharp-S
3172 (put 'ss
'texinfo-format
'texinfo-format-German-sharp-S
)
3173 (defun texinfo-format-German-sharp-S ()
3174 (insert "ss" (texinfo-parse-arg-discard))
3175 (goto-char texinfo-command-start
))
3177 ;; @questiondown{} ==> ? upside-down-question-mark
3178 (put 'questiondown
'texinfo-format
'texinfo-format-upside-down-question-mark
)
3179 (defun texinfo-format-upside-down-question-mark ()
3180 (insert "?" (texinfo-parse-arg-discard))
3181 (goto-char texinfo-command-start
))
3183 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
3184 (put 'exclamdown
'texinfo-format
'texinfo-format-upside-down-exclamation-mark
)
3185 (defun texinfo-format-upside-down-exclamation-mark ()
3186 (insert "!" (texinfo-parse-arg-discard))
3187 (goto-char texinfo-command-start
))
3189 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
3190 (put 'L
'texinfo-format
'texinfo-format-Polish-suppressed-L
)
3191 (defun texinfo-format-Polish-suppressed-L ()
3192 (insert (texinfo-parse-arg-discard) "/L")
3193 (goto-char texinfo-command-start
))
3195 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
3196 (put 'l
'texinfo-format
'texinfo-format-Polish-suppressed-l-lower-case
)
3197 (defun texinfo-format-Polish-suppressed-l-lower-case ()
3198 (insert (texinfo-parse-arg-discard) "/l")
3199 (goto-char texinfo-command-start
))
3202 ;; @O{} ==> O/ Scandinavian O-with-slash
3203 (put 'O
'texinfo-format
'texinfo-format-Scandinavian-O-with-slash
)
3204 (defun texinfo-format-Scandinavian-O-with-slash ()
3205 (insert (texinfo-parse-arg-discard) "O/")
3206 (goto-char texinfo-command-start
))
3208 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
3209 (put 'o
'texinfo-format
'texinfo-format-Scandinavian-o-with-slash-lower-case
)
3210 (defun texinfo-format-Scandinavian-o-with-slash-lower-case ()
3211 (insert (texinfo-parse-arg-discard) "o/")
3212 (goto-char texinfo-command-start
))
3216 ;; @,{c} ==> c, cedilla accent
3217 (put '\
, 'texinfo-format
'texinfo-format-cedilla-accent
)
3218 (defun texinfo-format-cedilla-accent ()
3219 (insert (texinfo-parse-arg-discard) ",")
3220 (goto-char texinfo-command-start
))
3223 ;; @dotaccent{o} ==> .o overdot-accent
3224 (put 'dotaccent
'texinfo-format
'texinfo-format-overdot-accent
)
3225 (defun texinfo-format-overdot-accent ()
3226 (insert "." (texinfo-parse-arg-discard))
3227 (goto-char texinfo-command-start
))
3229 ;; @ubaraccent{o} ==> _o underbar-accent
3230 (put 'ubaraccent
'texinfo-format
'texinfo-format-underbar-accent
)
3231 (defun texinfo-format-underbar-accent ()
3232 (insert "_" (texinfo-parse-arg-discard))
3233 (goto-char texinfo-command-start
))
3235 ;; @udotaccent{o} ==> o-. underdot-accent
3236 (put 'udotaccent
'texinfo-format
'texinfo-format-underdot-accent
)
3237 (defun texinfo-format-underdot-accent ()
3238 (insert (texinfo-parse-arg-discard) "-.")
3239 (goto-char texinfo-command-start
))
3241 ;; @H{o} ==> ""o long Hungarian umlaut
3242 (put 'H
'texinfo-format
'texinfo-format-long-Hungarian-umlaut
)
3243 (defun texinfo-format-long-Hungarian-umlaut ()
3244 (insert "\"\"" (texinfo-parse-arg-discard))
3245 (goto-char texinfo-command-start
))
3247 ;; @ringaccent{o} ==> *o ring accent
3248 (put 'ringaccent
'texinfo-format
'texinfo-format-ring-accent
)
3249 (defun texinfo-format-ring-accent ()
3250 (insert "*" (texinfo-parse-arg-discard))
3251 (goto-char texinfo-command-start
))
3253 ;; @tieaccent{oo} ==> [oo tie after accent
3254 (put 'tieaccent
'texinfo-format
'texinfo-format-tie-after-accent
)
3255 (defun texinfo-format-tie-after-accent ()
3256 (insert "[" (texinfo-parse-arg-discard))
3257 (goto-char texinfo-command-start
))
3260 ;; @u{o} ==> (o breve accent
3261 (put 'u
'texinfo-format
'texinfo-format-breve-accent
)
3262 (defun texinfo-format-breve-accent ()
3263 (insert "(" (texinfo-parse-arg-discard))
3264 (goto-char texinfo-command-start
))
3266 ;; @v{o} ==> <o hacek accent
3267 (put 'v
'texinfo-format
'texinfo-format-hacek-accent
)
3268 (defun texinfo-format-hacek-accent ()
3269 (insert "<" (texinfo-parse-arg-discard))
3270 (goto-char texinfo-command-start
))
3273 ;; @dotless{i} ==> i dotless i and dotless j
3274 (put 'dotless
'texinfo-format
'texinfo-format-dotless
)
3275 (defun texinfo-format-dotless ()
3276 (insert (texinfo-parse-arg-discard))
3277 (goto-char texinfo-command-start
))
3280 ;;; Definition formatting: @deffn, @defun, etc
3282 ;; What definition formatting produces:
3284 ;; @deffn category name args...
3285 ;; In Info, `Category: name ARGS'
3286 ;; In index: name: node. line#.
3288 ;; @defvr category name
3289 ;; In Info, `Category: name'
3290 ;; In index: name: node. line#.
3292 ;; @deftp category name attributes...
3293 ;; `category name attributes...' Note: @deftp args in lower case.
3294 ;; In index: name: node. line#.
3296 ;; Specialized function-like or variable-like entity:
3298 ;; @defun, @defmac, @defspec, @defvar, @defopt
3300 ;; @defun name args In Info, `Function: name ARGS'
3301 ;; @defmac name args In Info, `Macro: name ARGS'
3302 ;; @defvar name In Info, `Variable: name'
3304 ;; In index: name: node. line#.
3306 ;; Generalized typed-function-like or typed-variable-like entity:
3307 ;; @deftypefn category data-type name args...
3308 ;; In Info, `Category: data-type name args...'
3309 ;; @deftypevr category data-type name
3310 ;; In Info, `Category: data-type name'
3311 ;; In index: name: node. line#.
3313 ;; Specialized typed-function-like or typed-variable-like entity:
3314 ;; @deftypefun data-type name args...
3315 ;; In Info, `Function: data-type name ARGS'
3316 ;; In index: name: node. line#.
3318 ;; @deftypevar data-type name
3319 ;; In Info, `Variable: data-type name'
3320 ;; In index: name: node. line#. but include args after name!?
3322 ;; Generalized object oriented entity:
3323 ;; @defop category class name args...
3324 ;; In Info, `Category on class: name ARG'
3325 ;; In index: name on class: node. line#.
3327 ;; @defcv category class name
3328 ;; In Info, `Category of class: name'
3329 ;; In index: name of class: node. line#.
3331 ;; Specialized object oriented entity:
3332 ;; @defmethod class name args...
3333 ;; In Info, `Method on class: name ARGS'
3334 ;; In index: name on class: node. line#.
3336 ;; @defivar class name
3337 ;; In Info, `Instance variable of class: name'
3338 ;; In index: name of class: node. line#.
3341 ;;; The definition formatting functions
3343 (defun texinfo-format-defun ()
3344 (texinfo-push-stack 'defun
nil)
3345 (setq fill-column
(- fill-column
5))
3346 (texinfo-format-defun-1 t
))
3348 (defun texinfo-end-defun ()
3349 (setq fill-column
(+ fill-column
5))
3350 (texinfo-discard-command)
3351 (let ((start (nth 1 (texinfo-pop-stack 'defun
))))
3352 (texinfo-do-itemize start
)
3353 ;; Delete extra newline inserted after header.
3358 (defun texinfo-format-defunx ()
3359 (texinfo-format-defun-1 nil
))
3361 (defun texinfo-format-defun-1 (first-p)
3362 (let ((parse-args (texinfo-format-parse-defun-args))
3363 (texinfo-defun-type (get texinfo-command-name
'texinfo-defun-type
)))
3364 (texinfo-discard-command)
3365 ;; Delete extra newline inserted after previous header line.
3369 (get texinfo-command-name
'texinfo-deffn-formatting-property
) parse-args
)
3370 ;; Insert extra newline so that paragraph filling does not mess
3371 ;; with header line.
3373 (rplaca (cdr (cdr (car texinfo-stack
))) (point))
3375 (get texinfo-command-name
'texinfo-defun-indexing-property
) parse-args
)))
3377 ;;; Formatting the first line of a definition
3379 ;; @deffn, @defvr, @deftp
3380 (put 'deffn
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3381 (put 'deffnx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3382 (put 'defvr
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3383 (put 'defvrx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3384 (put 'deftp
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3385 (put 'deftpx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3386 (defun texinfo-format-deffn (parsed-args)
3387 ;; Generalized function-like, variable-like, or generic data-type entity:
3388 ;; @deffn category name args...
3389 ;; In Info, `Category: name ARGS'
3390 ;; @deftp category name attributes...
3391 ;; `category name attributes...' Note: @deftp args in lower case.
3392 (let ((category (car parsed-args
))
3393 (name (car (cdr parsed-args
)))
3394 (args (cdr (cdr parsed-args
))))
3395 (insert " -- " category
": " name
)
3398 (if (or (= ?
& (aref (car args
) 0))
3399 (eq (eval (car texinfo-defun-type
)) 'deftp-type
))
3401 (upcase (car args
))))
3402 (setq args
(cdr args
)))))
3404 ;; @defun, @defmac, @defspec, @defvar, @defopt: Specialized, simple
3405 (put 'defun
'texinfo-deffn-formatting-property
3406 'texinfo-format-specialized-defun
)
3407 (put 'defunx
'texinfo-deffn-formatting-property
3408 'texinfo-format-specialized-defun
)
3409 (put 'defmac
'texinfo-deffn-formatting-property
3410 'texinfo-format-specialized-defun
)
3411 (put 'defmacx
'texinfo-deffn-formatting-property
3412 'texinfo-format-specialized-defun
)
3413 (put 'defspec
'texinfo-deffn-formatting-property
3414 'texinfo-format-specialized-defun
)
3415 (put 'defspecx
'texinfo-deffn-formatting-property
3416 'texinfo-format-specialized-defun
)
3417 (put 'defvar
'texinfo-deffn-formatting-property
3418 'texinfo-format-specialized-defun
)
3419 (put 'defvarx
'texinfo-deffn-formatting-property
3420 'texinfo-format-specialized-defun
)
3421 (put 'defopt
'texinfo-deffn-formatting-property
3422 'texinfo-format-specialized-defun
)
3423 (put 'defoptx
'texinfo-deffn-formatting-property
3424 'texinfo-format-specialized-defun
)
3425 (defun texinfo-format-specialized-defun (parsed-args)
3426 ;; Specialized function-like or variable-like entity:
3427 ;; @defun name args In Info, `Function: Name ARGS'
3428 ;; @defmac name args In Info, `Macro: Name ARGS'
3429 ;; @defvar name In Info, `Variable: Name'
3430 ;; Use cdr of texinfo-defun-type to determine category:
3431 (let ((category (car (cdr texinfo-defun-type
)))
3432 (name (car parsed-args
))
3433 (args (cdr parsed-args
)))
3434 (insert " -- " category
": " name
)
3437 (if (= ?
& (aref (car args
) 0))
3439 (upcase (car args
))))
3440 (setq args
(cdr args
)))))
3442 ;; @deftypefn, @deftypevr: Generalized typed
3443 (put 'deftypefn
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3444 (put 'deftypefnx
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3445 (put 'deftypevr
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3446 (put 'deftypevrx
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3447 (defun texinfo-format-deftypefn (parsed-args)
3448 ;; Generalized typed-function-like or typed-variable-like entity:
3449 ;; @deftypefn category data-type name args...
3450 ;; In Info, `Category: data-type name args...'
3451 ;; @deftypevr category data-type name
3452 ;; In Info, `Category: data-type name'
3453 ;; Note: args in lower case, unless modified in command line.
3454 (let ((category (car parsed-args
))
3455 (data-type (car (cdr parsed-args
)))
3456 (name (car (cdr (cdr parsed-args
))))
3457 (args (cdr (cdr (cdr parsed-args
)))))
3458 (insert " -- " category
": " data-type
" " name
)
3460 (insert " " (car args
))
3461 (setq args
(cdr args
)))))
3463 ;; @deftypefun, @deftypevar: Specialized typed
3464 (put 'deftypefun
'texinfo-deffn-formatting-property
'texinfo-format-deftypefun
)
3465 (put 'deftypefunx
'texinfo-deffn-formatting-property
3466 'texinfo-format-deftypefun
)
3467 (put 'deftypevar
'texinfo-deffn-formatting-property
'texinfo-format-deftypefun
)
3468 (put 'deftypevarx
'texinfo-deffn-formatting-property
3469 'texinfo-format-deftypefun
)
3470 (defun texinfo-format-deftypefun (parsed-args)
3471 ;; Specialized typed-function-like or typed-variable-like entity:
3472 ;; @deftypefun data-type name args...
3473 ;; In Info, `Function: data-type name ARGS'
3474 ;; @deftypevar data-type name
3475 ;; In Info, `Variable: data-type name'
3476 ;; Note: args in lower case, unless modified in command line.
3477 ;; Use cdr of texinfo-defun-type to determine category:
3478 (let ((category (car (cdr texinfo-defun-type
)))
3479 (data-type (car parsed-args
))
3480 (name (car (cdr parsed-args
)))
3481 (args (cdr (cdr parsed-args
))))
3482 (insert " -- " category
": " data-type
" " name
)
3484 (insert " " (car args
))
3485 (setq args
(cdr args
)))))
3487 ;; @defop: Generalized object-oriented
3488 (put 'defop
'texinfo-deffn-formatting-property
'texinfo-format-defop
)
3489 (put 'defopx
'texinfo-deffn-formatting-property
'texinfo-format-defop
)
3490 (defun texinfo-format-defop (parsed-args)
3491 ;; Generalized object oriented entity:
3492 ;; @defop category class name args...
3493 ;; In Info, `Category on class: name ARG'
3494 ;; Note: args in upper case; use of `on'
3495 (let ((category (car parsed-args
))
3496 (class (car (cdr parsed-args
)))
3497 (name (car (cdr (cdr parsed-args
))))
3498 (args (cdr (cdr (cdr parsed-args
)))))
3499 (insert " -- " category
" on " class
": " name
)
3501 (insert " " (upcase (car args
)))
3502 (setq args
(cdr args
)))))
3504 ;; @defcv: Generalized object-oriented
3505 (put 'defcv
'texinfo-deffn-formatting-property
'texinfo-format-defcv
)
3506 (put 'defcvx
'texinfo-deffn-formatting-property
'texinfo-format-defcv
)
3507 (defun texinfo-format-defcv (parsed-args)
3508 ;; Generalized object oriented entity:
3509 ;; @defcv category class name
3510 ;; In Info, `Category of class: name'
3511 ;; Note: args in upper case; use of `of'
3512 (let ((category (car parsed-args
))
3513 (class (car (cdr parsed-args
)))
3514 (name (car (cdr (cdr parsed-args
))))
3515 (args (cdr (cdr (cdr parsed-args
)))))
3516 (insert " -- " category
" of " class
": " name
)
3518 (insert " " (upcase (car args
)))
3519 (setq args
(cdr args
)))))
3521 ;; @defmethod: Specialized object-oriented
3522 (put 'defmethod
'texinfo-deffn-formatting-property
'texinfo-format-defmethod
)
3523 (put 'defmethodx
'texinfo-deffn-formatting-property
'texinfo-format-defmethod
)
3524 (defun texinfo-format-defmethod (parsed-args)
3525 ;; Specialized object oriented entity:
3526 ;; @defmethod class name args...
3527 ;; In Info, `Method on class: name ARGS'
3528 ;; Note: args in upper case; use of `on'
3529 ;; Use cdr of texinfo-defun-type to determine category:
3530 (let ((category (car (cdr texinfo-defun-type
)))
3531 (class (car parsed-args
))
3532 (name (car (cdr parsed-args
)))
3533 (args (cdr (cdr parsed-args
))))
3534 (insert " -- " category
" on " class
": " name
)
3536 (insert " " (upcase (car args
)))
3537 (setq args
(cdr args
)))))
3539 ;; @defivar: Specialized object-oriented
3540 (put 'defivar
'texinfo-deffn-formatting-property
'texinfo-format-defivar
)
3541 (put 'defivarx
'texinfo-deffn-formatting-property
'texinfo-format-defivar
)
3542 (defun texinfo-format-defivar (parsed-args)
3543 ;; Specialized object oriented entity:
3544 ;; @defivar class name
3545 ;; In Info, `Instance variable of class: name'
3546 ;; Note: args in upper case; use of `of'
3547 ;; Use cdr of texinfo-defun-type to determine category:
3548 (let ((category (car (cdr texinfo-defun-type
)))
3549 (class (car parsed-args
))
3550 (name (car (cdr parsed-args
)))
3551 (args (cdr (cdr parsed-args
))))
3552 (insert " -- " category
" of " class
": " name
)
3554 (insert " " (upcase (car args
)))
3555 (setq args
(cdr args
)))))
3558 ;;; Indexing for definitions
3560 ;; An index entry has three parts: the `entry proper', the node name, and the
3561 ;; line number. Depending on the which command is used, the entry is
3562 ;; formatted differently:
3568 ;; @defopt all use their 1st argument as the entry-proper
3574 ;; @deftypevar all use their 2nd argument as the entry-proper
3577 ;; @deftypevr both use their 3rd argument as the entry-proper
3579 ;; @defmethod uses its 2nd and 1st arguments as an entry-proper
3580 ;; formatted: NAME on CLASS
3582 ;; @defop uses its 3rd and 2nd arguments as an entry-proper
3583 ;; formatted: NAME on CLASS
3585 ;; @defivar uses its 2nd and 1st arguments as an entry-proper
3586 ;; formatted: NAME of CLASS
3588 ;; @defcv uses its 3rd and 2nd argument as an entry-proper
3589 ;; formatted: NAME of CLASS
3591 (put 'defun
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3592 (put 'defunx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3593 (put 'defmac
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3594 (put 'defmacx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3595 (put 'defspec
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3596 (put 'defspecx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3597 (put 'defvar
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3598 (put 'defvarx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3599 (put 'defopt
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3600 (put 'defoptx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3601 (defun texinfo-index-defun (parsed-args)
3602 ;; use 1st parsed-arg as entry-proper
3603 ;; `index-list' will be texinfo-findex or the like
3604 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3607 ;; Three elements: entry-proper, node-name, line-number
3611 ;; Region formatting may not provide last node position.
3612 (if texinfo-last-node-pos
3613 (1+ (count-lines texinfo-last-node-pos
(point)))
3615 (symbol-value index-list
)))))
3617 (put 'deffn
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3618 (put 'deffnx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3619 (put 'defvr
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3620 (put 'defvrx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3621 (put 'deftp
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3622 (put 'deftpx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3623 (put 'deftypefun
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3624 (put 'deftypefunx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3625 (put 'deftypevar
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3626 (put 'deftypevarx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3627 (defun texinfo-index-deffn (parsed-args)
3628 ;; use 2nd parsed-arg as entry-proper
3629 ;; `index-list' will be texinfo-findex or the like
3630 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3633 ;; Three elements: entry-proper, node-name, line-number
3635 (car (cdr parsed-args
))
3637 ;; Region formatting may not provide last node position.
3638 (if texinfo-last-node-pos
3639 (1+ (count-lines texinfo-last-node-pos
(point)))
3641 (symbol-value index-list
)))))
3643 (put 'deftypefn
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3644 (put 'deftypefnx
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3645 (put 'deftypevr
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3646 (put 'deftypevrx
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3647 (defun texinfo-index-deftypefn (parsed-args)
3648 ;; use 3rd parsed-arg as entry-proper
3649 ;; `index-list' will be texinfo-findex or the like
3650 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3653 ;; Three elements: entry-proper, node-name, line-number
3655 (car (cdr (cdr parsed-args
)))
3657 ;; Region formatting may not provide last node position.
3658 (if texinfo-last-node-pos
3659 (1+ (count-lines texinfo-last-node-pos
(point)))
3661 (symbol-value index-list
)))))
3663 (put 'defmethod
'texinfo-defun-indexing-property
'texinfo-index-defmethod
)
3664 (put 'defmethodx
'texinfo-defun-indexing-property
'texinfo-index-defmethod
)
3665 (defun texinfo-index-defmethod (parsed-args)
3666 ;; use 2nd on 1st parsed-arg as entry-proper
3667 ;; `index-list' will be texinfo-findex or the like
3668 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3671 ;; Three elements: entry-proper, node-name, line-number
3674 (car (cdr parsed-args
))
3677 ;; Region formatting may not provide last node position.
3678 (if texinfo-last-node-pos
3679 (1+ (count-lines texinfo-last-node-pos
(point)))
3681 (symbol-value index-list
)))))
3683 (put 'defop
'texinfo-defun-indexing-property
'texinfo-index-defop
)
3684 (put 'defopx
'texinfo-defun-indexing-property
'texinfo-index-defop
)
3685 (defun texinfo-index-defop (parsed-args)
3686 ;; use 3rd on 2nd parsed-arg as entry-proper
3687 ;; `index-list' will be texinfo-findex or the like
3688 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3691 ;; Three elements: entry-proper, node-name, line-number
3694 (car (cdr (cdr parsed-args
)))
3695 (car (cdr parsed-args
)))
3697 ;; Region formatting may not provide last node position.
3698 (if texinfo-last-node-pos
3699 (1+ (count-lines texinfo-last-node-pos
(point)))
3701 (symbol-value index-list
)))))
3703 (put 'defivar
'texinfo-defun-indexing-property
'texinfo-index-defivar
)
3704 (put 'defivarx
'texinfo-defun-indexing-property
'texinfo-index-defivar
)
3705 (defun texinfo-index-defivar (parsed-args)
3706 ;; use 2nd of 1st parsed-arg as entry-proper
3707 ;; `index-list' will be texinfo-findex or the like
3708 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3711 ;; Three elements: entry-proper, node-name, line-number
3714 (car (cdr parsed-args
))
3717 ;; Region formatting may not provide last node position.
3718 (if texinfo-last-node-pos
3719 (1+ (count-lines texinfo-last-node-pos
(point)))
3721 (symbol-value index-list
)))))
3723 (put 'defcv
'texinfo-defun-indexing-property
'texinfo-index-defcv
)
3724 (put 'defcvx
'texinfo-defun-indexing-property
'texinfo-index-defcv
)
3725 (defun texinfo-index-defcv (parsed-args)
3726 ;; use 3rd of 2nd parsed-arg as entry-proper
3727 ;; `index-list' will be texinfo-findex or the like
3728 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3731 ;; Three elements: entry-proper, node-name, line-number
3734 (car (cdr (cdr parsed-args
)))
3735 (car (cdr parsed-args
)))
3737 ;; Region formatting may not provide last node position.
3738 (if texinfo-last-node-pos
3739 (1+ (count-lines texinfo-last-node-pos
(point)))
3741 (symbol-value index-list
)))))
3744 ;;; Properties for definitions
3746 ;; Each definition command has six properties:
3748 ;; 1. texinfo-deffn-formatting-property to format definition line
3749 ;; 2. texinfo-defun-indexing-property to create index entry
3750 ;; 3. texinfo-format formatting command
3751 ;; 4. texinfo-end end formatting command
3752 ;; 5. texinfo-defun-type type of deffn to format
3753 ;; 6. texinfo-defun-index type of index to use
3755 ;; The `x' forms of each definition command are used for the second
3756 ;; and subsequent header lines.
3758 ;; The texinfo-deffn-formatting-property and texinfo-defun-indexing-property
3759 ;; are listed just before the appropriate formatting and indexing commands.
3761 (put 'deffn
'texinfo-format
'texinfo-format-defun
)
3762 (put 'deffnx
'texinfo-format
'texinfo-format-defunx
)
3763 (put 'deffn
'texinfo-end
'texinfo-end-defun
)
3764 (put 'deffn
'texinfo-defun-type
'('deffn-type nil
))
3765 (put 'deffnx
'texinfo-defun-type
'('deffn-type nil
))
3766 (put 'deffn
'texinfo-defun-index
'texinfo-findex
)
3767 (put 'deffnx
'texinfo-defun-index
'texinfo-findex
)
3769 (put 'defun
'texinfo-format
'texinfo-format-defun
)
3770 (put 'defunx
'texinfo-format
'texinfo-format-defunx
)
3771 (put 'defun
'texinfo-end
'texinfo-end-defun
)
3772 (put 'defun
'texinfo-defun-type
'('defun-type
"Function"))
3773 (put 'defunx
'texinfo-defun-type
'('defun-type
"Function"))
3774 (put 'defun
'texinfo-defun-index
'texinfo-findex
)
3775 (put 'defunx
'texinfo-defun-index
'texinfo-findex
)
3777 (put 'defmac
'texinfo-format
'texinfo-format-defun
)
3778 (put 'defmacx
'texinfo-format
'texinfo-format-defunx
)
3779 (put 'defmac
'texinfo-end
'texinfo-end-defun
)
3780 (put 'defmac
'texinfo-defun-type
'('defun-type
"Macro"))
3781 (put 'defmacx
'texinfo-defun-type
'('defun-type
"Macro"))
3782 (put 'defmac
'texinfo-defun-index
'texinfo-findex
)
3783 (put 'defmacx
'texinfo-defun-index
'texinfo-findex
)
3785 (put 'defspec
'texinfo-format
'texinfo-format-defun
)
3786 (put 'defspecx
'texinfo-format
'texinfo-format-defunx
)
3787 (put 'defspec
'texinfo-end
'texinfo-end-defun
)
3788 (put 'defspec
'texinfo-defun-type
'('defun-type
"Special form"))
3789 (put 'defspecx
'texinfo-defun-type
'('defun-type
"Special form"))
3790 (put 'defspec
'texinfo-defun-index
'texinfo-findex
)
3791 (put 'defspecx
'texinfo-defun-index
'texinfo-findex
)
3793 (put 'defvr
'texinfo-format
'texinfo-format-defun
)
3794 (put 'defvrx
'texinfo-format
'texinfo-format-defunx
)
3795 (put 'defvr
'texinfo-end
'texinfo-end-defun
)
3796 (put 'defvr
'texinfo-defun-type
'('deffn-type nil
))
3797 (put 'defvrx
'texinfo-defun-type
'('deffn-type nil
))
3798 (put 'defvr
'texinfo-defun-index
'texinfo-vindex
)
3799 (put 'defvrx
'texinfo-defun-index
'texinfo-vindex
)
3801 (put 'defvar
'texinfo-format
'texinfo-format-defun
)
3802 (put 'defvarx
'texinfo-format
'texinfo-format-defunx
)
3803 (put 'defvar
'texinfo-end
'texinfo-end-defun
)
3804 (put 'defvar
'texinfo-defun-type
'('defun-type
"Variable"))
3805 (put 'defvarx
'texinfo-defun-type
'('defun-type
"Variable"))
3806 (put 'defvar
'texinfo-defun-index
'texinfo-vindex
)
3807 (put 'defvarx
'texinfo-defun-index
'texinfo-vindex
)
3809 (put 'defconst
'texinfo-format
'texinfo-format-defun
)
3810 (put 'defconstx
'texinfo-format
'texinfo-format-defunx
)
3811 (put 'defconst
'texinfo-end
'texinfo-end-defun
)
3812 (put 'defconst
'texinfo-defun-type
'('defun-type
"Constant"))
3813 (put 'defconstx
'texinfo-defun-type
'('defun-type
"Constant"))
3814 (put 'defconst
'texinfo-defun-index
'texinfo-vindex
)
3815 (put 'defconstx
'texinfo-defun-index
'texinfo-vindex
)
3817 (put 'defcmd
'texinfo-format
'texinfo-format-defun
)
3818 (put 'defcmdx
'texinfo-format
'texinfo-format-defunx
)
3819 (put 'defcmd
'texinfo-end
'texinfo-end-defun
)
3820 (put 'defcmd
'texinfo-defun-type
'('defun-type
"Command"))
3821 (put 'defcmdx
'texinfo-defun-type
'('defun-type
"Command"))
3822 (put 'defcmd
'texinfo-defun-index
'texinfo-findex
)
3823 (put 'defcmdx
'texinfo-defun-index
'texinfo-findex
)
3825 (put 'defopt
'texinfo-format
'texinfo-format-defun
)
3826 (put 'defoptx
'texinfo-format
'texinfo-format-defunx
)
3827 (put 'defopt
'texinfo-end
'texinfo-end-defun
)
3828 (put 'defopt
'texinfo-defun-type
'('defun-type
"User Option"))
3829 (put 'defoptx
'texinfo-defun-type
'('defun-type
"User Option"))
3830 (put 'defopt
'texinfo-defun-index
'texinfo-vindex
)
3831 (put 'defoptx
'texinfo-defun-index
'texinfo-vindex
)
3833 (put 'deftp
'texinfo-format
'texinfo-format-defun
)
3834 (put 'deftpx
'texinfo-format
'texinfo-format-defunx
)
3835 (put 'deftp
'texinfo-end
'texinfo-end-defun
)
3836 (put 'deftp
'texinfo-defun-type
'('deftp-type nil
))
3837 (put 'deftpx
'texinfo-defun-type
'('deftp-type nil
))
3838 (put 'deftp
'texinfo-defun-index
'texinfo-tindex
)
3839 (put 'deftpx
'texinfo-defun-index
'texinfo-tindex
)
3841 ;;; Object-oriented stuff is a little hairier.
3843 (put 'defop
'texinfo-format
'texinfo-format-defun
)
3844 (put 'defopx
'texinfo-format
'texinfo-format-defunx
)
3845 (put 'defop
'texinfo-end
'texinfo-end-defun
)
3846 (put 'defop
'texinfo-defun-type
'('defop-type nil
))
3847 (put 'defopx
'texinfo-defun-type
'('defop-type nil
))
3848 (put 'defop
'texinfo-defun-index
'texinfo-findex
)
3849 (put 'defopx
'texinfo-defun-index
'texinfo-findex
)
3851 (put 'defmethod
'texinfo-format
'texinfo-format-defun
)
3852 (put 'defmethodx
'texinfo-format
'texinfo-format-defunx
)
3853 (put 'defmethod
'texinfo-end
'texinfo-end-defun
)
3854 (put 'defmethod
'texinfo-defun-type
'('defmethod-type
"Method"))
3855 (put 'defmethodx
'texinfo-defun-type
'('defmethod-type
"Method"))
3856 (put 'defmethod
'texinfo-defun-index
'texinfo-findex
)
3857 (put 'defmethodx
'texinfo-defun-index
'texinfo-findex
)
3859 (put 'defcv
'texinfo-format
'texinfo-format-defun
)
3860 (put 'defcvx
'texinfo-format
'texinfo-format-defunx
)
3861 (put 'defcv
'texinfo-end
'texinfo-end-defun
)
3862 (put 'defcv
'texinfo-defun-type
'('defop-type nil
))
3863 (put 'defcvx
'texinfo-defun-type
'('defop-type nil
))
3864 (put 'defcv
'texinfo-defun-index
'texinfo-vindex
)
3865 (put 'defcvx
'texinfo-defun-index
'texinfo-vindex
)
3867 (put 'defivar
'texinfo-format
'texinfo-format-defun
)
3868 (put 'defivarx
'texinfo-format
'texinfo-format-defunx
)
3869 (put 'defivar
'texinfo-end
'texinfo-end-defun
)
3870 (put 'defivar
'texinfo-defun-type
'('defmethod-type
"Instance variable"))
3871 (put 'defivarx
'texinfo-defun-type
'('defmethod-type
"Instance variable"))
3872 (put 'defivar
'texinfo-defun-index
'texinfo-vindex
)
3873 (put 'defivarx
'texinfo-defun-index
'texinfo-vindex
)
3875 ;;; Typed functions and variables
3877 (put 'deftypefn
'texinfo-format
'texinfo-format-defun
)
3878 (put 'deftypefnx
'texinfo-format
'texinfo-format-defunx
)
3879 (put 'deftypefn
'texinfo-end
'texinfo-end-defun
)
3880 (put 'deftypefn
'texinfo-defun-type
'('deftypefn-type nil
))
3881 (put 'deftypefnx
'texinfo-defun-type
'('deftypefn-type nil
))
3882 (put 'deftypefn
'texinfo-defun-index
'texinfo-findex
)
3883 (put 'deftypefnx
'texinfo-defun-index
'texinfo-findex
)
3885 (put 'deftypefun
'texinfo-format
'texinfo-format-defun
)
3886 (put 'deftypefunx
'texinfo-format
'texinfo-format-defunx
)
3887 (put 'deftypefun
'texinfo-end
'texinfo-end-defun
)
3888 (put 'deftypefun
'texinfo-defun-type
'('deftypefun-type
"Function"))
3889 (put 'deftypefunx
'texinfo-defun-type
'('deftypefun-type
"Function"))
3890 (put 'deftypefun
'texinfo-defun-index
'texinfo-findex
)
3891 (put 'deftypefunx
'texinfo-defun-index
'texinfo-findex
)
3893 (put 'deftypevr
'texinfo-format
'texinfo-format-defun
)
3894 (put 'deftypevrx
'texinfo-format
'texinfo-format-defunx
)
3895 (put 'deftypevr
'texinfo-end
'texinfo-end-defun
)
3896 (put 'deftypevr
'texinfo-defun-type
'('deftypefn-type nil
))
3897 (put 'deftypevrx
'texinfo-defun-type
'('deftypefn-type nil
))
3898 (put 'deftypevr
'texinfo-defun-index
'texinfo-vindex
)
3899 (put 'deftypevrx
'texinfo-defun-index
'texinfo-vindex
)
3901 (put 'deftypevar
'texinfo-format
'texinfo-format-defun
)
3902 (put 'deftypevarx
'texinfo-format
'texinfo-format-defunx
)
3903 (put 'deftypevar
'texinfo-end
'texinfo-end-defun
)
3904 (put 'deftypevar
'texinfo-defun-type
'('deftypevar-type
"Variable"))
3905 (put 'deftypevarx
'texinfo-defun-type
'('deftypevar-type
"Variable"))
3906 (put 'deftypevar
'texinfo-defun-index
'texinfo-vindex
)
3907 (put 'deftypevarx
'texinfo-defun-index
'texinfo-vindex
)
3910 ;;; @set, @clear, @ifset, @ifclear
3912 ;; If a flag is set with @set FLAG, then text between @ifset and @end
3913 ;; ifset is formatted normally, but if the flag is is cleared with
3914 ;; @clear FLAG, then the text is not formatted; it is ignored.
3916 ;; If a flag is cleared with @clear FLAG, then text between @ifclear
3917 ;; and @end ifclear is formatted normally, but if the flag is is set with
3918 ;; @set FLAG, then the text is not formatted; it is ignored. @ifclear
3919 ;; is the opposite of @ifset.
3921 ;; If a flag is set to a string with @set FLAG,
3922 ;; replace @value{FLAG} with the string.
3923 ;; If a flag with a value is cleared,
3924 ;; @value{FLAG} is invalid,
3925 ;; as if there had never been any @set FLAG previously.
3927 (put 'clear
'texinfo-format
'texinfo-clear
)
3928 (defun texinfo-clear ()
3929 "Clear the value of the flag."
3930 (let* ((arg (texinfo-parse-arg-discard))
3931 (flag (car (read-from-string arg
)))
3932 (value (substring arg
(cdr (read-from-string arg
)))))
3933 (put flag
'texinfo-whether-setp
'flag-cleared
)
3934 (put flag
'texinfo-set-value
"")))
3936 (put 'set
'texinfo-format
'texinfo-set
)
3937 (defun texinfo-set ()
3938 "Set the value of the flag, optionally to a string.
3939 The command `@set foo This is a string.'
3940 sets flag foo to the value: `This is a string.'
3941 The command `@value{foo}' expands to the value."
3942 (let* ((arg (texinfo-parse-arg-discard))
3943 (flag (car (read-from-string arg
)))
3944 (value (substring arg
(cdr (read-from-string arg
)))))
3945 (if (string-match "^[ \t]+" value
)
3946 (setq value
(substring value
(match-end 0))))
3947 (put flag
'texinfo-whether-setp
'flag-set
)
3948 (put flag
'texinfo-set-value value
)))
3950 (put 'value
'texinfo-format
'texinfo-value
)
3951 (defun texinfo-value ()
3952 "Insert the string to which the flag is set.
3953 The command `@set foo This is a string.'
3954 sets flag foo to the value: `This is a string.'
3955 The command `@value{foo}' expands to the value."
3956 (let ((arg (texinfo-parse-arg-discard)))
3958 (eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3960 (get (car (read-from-string arg
)) 'texinfo-set-value
))
3961 (insert (get (car (read-from-string arg
)) 'texinfo-set-value
)))
3962 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3964 (insert (format "{No value for \"%s\"}" arg
)))
3965 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
) nil
)
3966 (insert (format "{No value for \"%s\"}" arg
))))))
3968 (put 'ifset
'texinfo-end
'texinfo-discard-command
)
3969 (put 'ifset
'texinfo-format
'texinfo-if-set
)
3970 (defun texinfo-if-set ()
3971 "If set, continue formatting; else do not format region up to @end ifset."
3972 (let ((arg (texinfo-parse-arg-discard)))
3974 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3976 ;; Format the text (i.e., do not remove it); do nothing here.
3978 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3980 ;; Clear region (i.e., cause the text to be ignored).
3981 (delete-region texinfo-command-start
3982 (re-search-forward "@end ifset[ \t]*\n")))
3983 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3985 ;; In this case flag is neither set nor cleared.
3986 ;; Act as if set, i.e. do nothing.
3989 (put 'ifclear
'texinfo-end
'texinfo-discard-command
)
3990 (put 'ifclear
'texinfo-format
'texinfo-if-clear
)
3991 (defun texinfo-if-clear ()
3992 "If clear, continue formatting; if set, do not format up to @end ifset."
3993 (let ((arg (texinfo-parse-arg-discard)))
3995 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3997 ;; Clear region (i.e., cause the text to be ignored).
3998 (delete-region texinfo-command-start
3999 (re-search-forward "@end ifclear[ \t]*\n")))
4000 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4002 ;; Format the text (i.e., do not remove it); do nothing here.
4004 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4006 ;; In this case flag is neither set nor cleared.
4007 ;; Act as if clear, i.e. do nothing.
4012 (put 'ifeq
'texinfo-format
'texinfo-format-ifeq
)
4013 (defun texinfo-format-ifeq ()
4014 "If ARG1 and ARG2 caselessly string compare to same string, perform COMMAND.
4015 Otherwise produces no output.
4018 @ifeq{ arg1 , arg1 , @code{foo}} bar
4022 @ifeq{ arg1 , arg2 , @code{foo}} bar
4026 Note that the Texinfo command and its arguments must be arguments to
4028 ;; compare-buffer-substrings does not exist in version 18; don't use
4029 (goto-char texinfo-command-end
)
4030 (let* ((case-fold-search t
)
4031 (stop (save-excursion (forward-sexp 1) (point)))
4033 ;; @ifeq{arg1, arg2, @command{optional-args}}
4037 (skip-chars-forward " ")
4038 (setq start
(point))
4039 (search-forward "," stop t
)
4040 (skip-chars-backward ", ")
4041 (buffer-substring-no-properties start
(point))))
4044 (search-forward "," stop t
)
4045 (skip-chars-forward " ")
4046 (setq start
(point))
4047 (search-forward "," stop t
)
4048 (skip-chars-backward ", ")
4049 (buffer-substring-no-properties start
(point))))
4052 (search-forward "," stop t
)
4053 (skip-chars-forward " ")
4054 (setq start
(point))
4055 (goto-char (1- stop
))
4056 (skip-chars-backward " ")
4057 (buffer-substring-no-properties start
(point)))))
4058 (delete-region texinfo-command-start stop
)
4059 (if (equal arg1 arg2
)
4060 (insert texinfo-command
))
4061 (goto-char texinfo-command-start
)))
4064 ;;; Process included files: `@include' command
4066 ;; Updated 19 October 1990
4067 ;; In the original version, include files were ignored by Info but
4068 ;; incorporated in to the printed manual. To make references to the
4069 ;; included file, the Texinfo source file has to refer to the included
4070 ;; files using the `(filename)nodename' format for referring to other
4071 ;; Info files. Also, the included files had to be formatted on their
4072 ;; own. It was just like they were another file.
4074 ;; Currently, include files are inserted into the buffer that is
4075 ;; formatted for Info. If large, the resulting info file is split and
4076 ;; tagified. For current include files to work, the master menu must
4077 ;; refer to all the nodes, and the highest level nodes in the include
4078 ;; files must have the correct next, prev, and up pointers.
4080 ;; The included file may have an @setfilename and even an @settitle,
4081 ;; but not an `\input texinfo' line.
4083 ;; Updated 24 March 1993
4084 ;; In order for @raisesections and @lowersections to work, included
4085 ;; files must be inserted into the buffer holding the outer file
4086 ;; before other Info formatting takes place. So @include is no longer
4087 ;; is treated like other @-commands.
4088 (put 'include
'texinfo-format
'texinfo-format-noop
)
4090 ;; Original definition:
4091 ;; (defun texinfo-format-include ()
4092 ;; (let ((filename (texinfo-parse-arg-discard))
4093 ;; (default-directory input-directory)
4097 ;; (progn (find-file
4098 ;; (cond ((file-readable-p (concat filename ".texinfo"))
4099 ;; (concat filename ".texinfo"))
4100 ;; ((file-readable-p (concat filename ".texi"))
4101 ;; (concat filename ".texi"))
4102 ;; ((file-readable-p (concat filename ".tex"))
4103 ;; (concat filename ".tex"))
4104 ;; ((file-readable-p filename)
4106 ;; (t (error "@include'd file %s not found"
4108 ;; (texinfo-format-buffer-1))))
4109 ;; (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex))
4110 ;; (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex))
4111 ;; (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex))
4112 ;; (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex))
4113 ;; (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex))
4114 ;; (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex))))
4116 ;;(defun texinfo-subindex (indexvar file content)
4117 ;; (set indexvar (cons (list 'recurse file content)
4118 ;; (symbol-value indexvar))))
4120 ;; Second definition:
4121 ;; (put 'include 'texinfo-format 'texinfo-format-include)
4122 ;; (defun texinfo-format-include ()
4123 ;; (let ((filename (concat input-directory
4124 ;; (texinfo-parse-arg-discard)))
4125 ;; (default-directory input-directory))
4126 ;; (message "Reading: %s" filename)
4128 ;; (save-restriction
4129 ;; (narrow-to-region
4131 ;; (+ (point) (car (cdr (insert-file-contents filename)))))
4132 ;; (goto-char (point-min))
4133 ;; (texinfo-append-refill)
4134 ;; (texinfo-format-convert (point-min) (point-max))))
4135 ;; (setq last-input-buffer input-buffer) ; to bypass setfilename
4139 ;;; Numerous commands do nothing in Info
4140 ;; These commands are defined in texinfo.tex for printed output.
4143 ;;; various noops, such as @b{foo}, that take arguments in braces
4145 (put 'b
'texinfo-format
'texinfo-format-noop
)
4146 (put 'i
'texinfo-format
'texinfo-format-noop
)
4147 (put 'r
'texinfo-format
'texinfo-format-noop
)
4148 (put 't
'texinfo-format
'texinfo-format-noop
)
4149 (put 'w
'texinfo-format
'texinfo-format-noop
)
4150 (put 'asis
'texinfo-format
'texinfo-format-noop
)
4151 (put 'dmn
'texinfo-format
'texinfo-format-noop
)
4152 (put 'math
'texinfo-format
'texinfo-format-noop
)
4153 (put 'titlefont
'texinfo-format
'texinfo-format-noop
)
4154 (defun texinfo-format-noop ()
4155 (insert (texinfo-parse-arg-discard))
4156 (goto-char texinfo-command-start
))
4158 ;; @hyphenation command discards an argument within braces
4159 (put 'hyphenation
'texinfo-format
'texinfo-discard-command-and-arg
)
4160 (defun texinfo-discard-command-and-arg ()
4161 "Discard both @-command and its argument in braces."
4162 (goto-char texinfo-command-end
)
4164 (setq texinfo-command-end
(point))
4165 (delete-region texinfo-command-start texinfo-command-end
))
4168 ;;; Do nothing commands, such as @smallbook, that have no args and no braces
4169 ;; These must appear on a line of their own
4171 (put 'bye
'texinfo-format
'texinfo-discard-line
)
4172 (put 'smallbook
'texinfo-format
'texinfo-discard-line
)
4173 (put 'finalout
'texinfo-format
'texinfo-discard-line
)
4174 (put 'overfullrule
'texinfo-format
'texinfo-discard-line
)
4175 (put 'smallbreak
'texinfo-format
'texinfo-discard-line
)
4176 (put 'medbreak
'texinfo-format
'texinfo-discard-line
)
4177 (put 'bigbreak
'texinfo-format
'texinfo-discard-line
)
4178 (put 'afourpaper
'texinfo-format
'texinfo-discard-line
)
4179 (put 'afivepaper
'texinfo-format
'texinfo-discard-line
)
4180 (put 'afourlatex
'texinfo-format
'texinfo-discard-line
)
4181 (put 'afourwide
'texinfo-format
'texinfo-discard-line
)
4184 ;;; These noop commands discard the rest of the line.
4186 (put 'c
'texinfo-format
'texinfo-discard-line-with-args
)
4187 (put 'comment
'texinfo-format
'texinfo-discard-line-with-args
)
4188 (put 'contents
'texinfo-format
'texinfo-discard-line-with-args
)
4189 (put 'group
'texinfo-end
'texinfo-discard-line-with-args
)
4190 (put 'group
'texinfo-format
'texinfo-discard-line-with-args
)
4191 (put 'headings
'texinfo-format
'texinfo-discard-line-with-args
)
4192 (put 'setchapterstyle
'texinfo-format
'texinfo-discard-line-with-args
)
4193 (put 'hsize
'texinfo-format
'texinfo-discard-line-with-args
)
4194 (put 'itemindent
'texinfo-format
'texinfo-discard-line-with-args
)
4195 (put 'lispnarrowing
'texinfo-format
'texinfo-discard-line-with-args
)
4196 (put 'need
'texinfo-format
'texinfo-discard-line-with-args
)
4197 (put 'nopara
'texinfo-format
'texinfo-discard-line-with-args
)
4199 ;; @novalidate suppresses cross-reference checking and auxiliary file
4200 ;; creation with TeX. The Info-validate command checks that every
4201 ;; node pointer points to an existing node. Since this Info command
4202 ;; is not invoked automatically, the @novalidate command is irrelevant
4203 ;; and not supported by texinfmt.el
4204 (put 'novalidate
'texinfo-format
'texinfo-discard-line-with-args
)
4206 (put 'page
'texinfo-format
'texinfo-discard-line-with-args
)
4207 (put 'pagesizes
'texinfo-format
'texinfo-discard-line-with-args
)
4208 (put 'parindent
'texinfo-format
'texinfo-discard-line-with-args
)
4209 (put 'setchapternewpage
'texinfo-format
'texinfo-discard-line-with-args
)
4210 (put 'setq
'texinfo-format
'texinfo-discard-line-with-args
)
4212 (put 'setcontentsaftertitlepage
4213 'texinfo-format
'texinfo-discard-line-with-args
)
4214 (put 'setshortcontentsaftertitlepage
4215 'texinfo-format
'texinfo-discard-line-with-args
)
4217 (put 'settitle
'texinfo-format
'texinfo-discard-line-with-args
)
4218 (put 'setx
'texinfo-format
'texinfo-discard-line-with-args
)
4219 (put 'shortcontents
'texinfo-format
'texinfo-discard-line-with-args
)
4220 (put 'shorttitlepage
'texinfo-format
'texinfo-discard-line-with-args
)
4221 (put 'summarycontents
'texinfo-format
'texinfo-discard-line-with-args
)
4222 (put 'input
'texinfo-format
'texinfo-discard-line-with-args
)
4224 (put 'documentlanguage
'texinfo-format
'texinfo-discard-line-with-args
)
4225 (put 'documentencoding
'texinfo-format
'texinfo-discard-line-with-args
)
4229 ;;; Some commands cannot be handled
4231 (defun texinfo-unsupported ()
4232 (error "%s is not handled by texinfo"
4233 (buffer-substring-no-properties texinfo-command-start texinfo-command-end
)))
4235 ;;; Batch formatting
4237 (defun batch-texinfo-format ()
4238 "Run `texinfo-format-buffer' on the files remaining on the command line.
4239 Must be used only with -batch, and kills Emacs on completion.
4240 Each file will be processed even if an error occurred previously.
4242 \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"."
4243 (if (not noninteractive
)
4244 (error "batch-texinfo-format may only be used -batch"))
4245 (let ((version-control t
)
4246 (auto-save-default nil
)
4247 (find-file-run-dired nil
)
4248 (kept-old-versions 259259)
4249 (kept-new-versions 259259))
4253 (while command-line-args-left
4254 (setq file
(expand-file-name (car command-line-args-left
)))
4255 (cond ((not (file-exists-p file
))
4256 (message ">> %s does not exist!" file
)
4258 command-line-args-left
(cdr command-line-args-left
)))
4259 ((file-directory-p file
)
4260 (setq command-line-args-left
4261 (nconc (directory-files file
)
4262 (cdr command-line-args-left
))))
4265 (setq command-line-args-left
(cdr command-line-args-left
)))))
4267 (setq file
(car files
)
4271 (if buffer-file-name
(kill-buffer (current-buffer)))
4273 (buffer-disable-undo (current-buffer))
4274 (set-buffer-modified-p nil
)
4276 (message "texinfo formatting %s..." file
)
4277 (texinfo-format-buffer nil
)
4278 (if (buffer-modified-p)
4279 (progn (message "Saving modified %s" (buffer-file-name))
4282 (message ">> Error: %s" (prin1-to-string err
))
4283 (message ">> point at")
4284 (let ((s (buffer-substring-no-properties (point)
4285 (min (+ (point) 100)
4288 (while (setq tem
(string-match "\n+" s tem
))
4289 (setq s
(concat (substring s
0 (match-beginning 0))
4291 (substring s
(match-end 0)))
4293 (message ">> %s" s
))
4295 (kill-emacs error
))))
4298 ;;; Place `provide' at end of file.
4301 ;;; texinfmt.el ends here