1 ;;; texinfmt.el --- format Texinfo files into Info files
3 ;; Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993,
4 ;; 1994, 1995, 1996, 1997, 1998, 2000, 2001
5 ;; 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 2, or (at your option)
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; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 ;;; Emacs lisp functions to convert Texinfo files to Info files.
33 (or (fboundp 'defgroup
)
34 (defmacro defgroup
(&rest ignore
) nil
))
36 (or (fboundp 'defcustom
)
37 (defmacro defcustom
(var value doc
&rest ignore
)
38 `(defvar ,var
,value
,doc
)))
40 (defvar texinfmt-version
"2.40 of 6 Dec 2002")
42 (defun texinfmt-version (&optional here
)
43 "Show the version of texinfmt.el in the minibuffer.
44 If optional argument HERE is non-nil, insert info at point."
47 (format "Version of \`texinfmt.el\': %s" texinfmt-version
)))
49 (insert version-string
)
51 (message "%s" version-string
)
55 ;;; Variable definitions
57 (require 'texinfo
) ; So `texinfo-footnote-style' is defined.
58 (require 'texnfo-upd
) ; So `texinfo-section-types-regexp' is defined.
60 (defvar texinfo-format-syntax-table nil
)
62 (defvar texinfo-vindex
)
63 (defvar texinfo-findex
)
64 (defvar texinfo-cindex
)
65 (defvar texinfo-pindex
)
66 (defvar texinfo-tindex
)
67 (defvar texinfo-kindex
)
68 (defvar texinfo-last-node
)
69 (defvar texinfo-node-names
)
70 (defvar texinfo-enclosure-list
)
71 (defvar texinfo-alias-list
)
72 (defvar texinfo-fold-nodename-case nil
)
74 (defvar texinfo-command-start
)
75 (defvar texinfo-command-end
)
76 (defvar texinfo-command-name
)
77 (defvar texinfo-defun-type
)
78 (defvar texinfo-last-node-pos
)
79 (defvar texinfo-stack
)
80 (defvar texinfo-short-index-cmds-alist
)
81 (defvar texinfo-short-index-format-cmds-alist
)
82 (defvar texinfo-format-filename
)
83 (defvar texinfo-footnote-number
)
84 (defvar texinfo-start-of-header
)
85 (defvar texinfo-end-of-header
)
86 (defvar texinfo-raisesections-alist
)
87 (defvar texinfo-lowersections-alist
)
91 (if texinfo-format-syntax-table
93 (setq texinfo-format-syntax-table
(make-syntax-table))
94 (modify-syntax-entry ?
\" " " texinfo-format-syntax-table
)
95 (modify-syntax-entry ?
\\ " " texinfo-format-syntax-table
)
96 (modify-syntax-entry ?
@ "\\" texinfo-format-syntax-table
)
97 (modify-syntax-entry ?\^q
"\\" texinfo-format-syntax-table
)
98 (modify-syntax-entry ?\
[ "." texinfo-format-syntax-table
)
99 (modify-syntax-entry ?\
] "." texinfo-format-syntax-table
)
100 (modify-syntax-entry ?\
( "." texinfo-format-syntax-table
)
101 (modify-syntax-entry ?\
) "." texinfo-format-syntax-table
)
102 (modify-syntax-entry ?
{ "(}" texinfo-format-syntax-table
)
103 (modify-syntax-entry ?
} "){" texinfo-format-syntax-table
)
104 (modify-syntax-entry ?
\' "." texinfo-format-syntax-table
))
107 ;;; Top level buffer and region formatting functions
110 (defun texinfo-format-buffer (&optional nosplit
)
111 "Process the current buffer as texinfo code, into an Info file.
112 The Info file output is generated in a buffer visiting the Info file
113 name specified in the @setfilename command.
115 Non-nil argument (prefix, if interactive) means don't make tag table
116 and don't split the file if large. You can use Info-tagify and
117 Info-split to do these manually."
119 (let ((lastmessage "Formatting Info file...")
120 (coding-system-for-write buffer-file-coding-system
))
121 (message lastmessage
)
123 (texinfo-format-buffer-1)
127 (if (> (buffer-size) 100000)
129 (message (setq lastmessage
"Splitting Info file..."))
131 (message (concat lastmessage
132 (if (interactive-p) "done. Now save it." "done.")))))
134 (defvar texinfo-region-buffer-name
"*Info Region*"
135 "*Name of the temporary buffer used by \\[texinfo-format-region].")
137 (defvar texinfo-pre-format-hook nil
138 "Hook called before the conversion of the Texinfo file to Info format.
139 The functions on this hook are called with argument BUFFER, the buffer
140 containing the Texinfo file.")
142 ;; These come from tex-mode.el.
143 (defvar tex-start-of-header
)
144 (defvar tex-end-of-header
)
147 (defun texinfo-format-region (region-beginning region-end
)
148 "Convert the current region of the Texinfo file to Info format.
149 This lets you see what that part of the file will look like in Info.
150 The command is bound to \\[texinfo-format-region]. The text that is
151 converted to Info is stored in a temporary buffer."
153 (message "Converting region to Info format...")
154 (let (texinfo-command-start
164 (texinfo-format-filename "")
165 texinfo-example-start
166 texinfo-last-node-pos
169 (texinfo-footnote-number 0)
171 (fill-column-for-info fill-column
)
172 (input-buffer (current-buffer))
173 (input-directory default-directory
)
178 ;;; Copy lines between beginning and end of header lines,
179 ;;; if any, or else copy the `@setfilename' line, if any.
183 (goto-char (point-min))
184 (let ((search-end (save-excursion (forward-line 100) (point))))
186 ;; Either copy header text.
189 (search-forward tex-start-of-header search-end t
)
191 ;; Mark beginning of header.
192 (setq header-beginning
(point)))
194 (search-forward tex-end-of-header nil t
)
196 ;; Mark end of header
197 (setq header-end
(point))))
198 ;; Or copy @filename line.
200 (goto-char (point-min))
201 (search-forward "@setfilename" search-end t
)
203 (setq header-beginning
(point))
205 (setq header-end
(point))))
209 (buffer-substring-no-properties
210 (min header-beginning region-beginning
)
213 ;;; Find a buffer to use.
214 (switch-to-buffer (get-buffer-create texinfo-region-buffer-name
))
216 ;; Insert the header into the buffer.
218 ;; Insert the region into the buffer.
219 (insert-buffer-substring
221 (max region-beginning header-end
)
223 (run-hook-with-args 'texinfo-pre-format-hook input-buffer
)
224 ;; Make sure region ends in a newline.
225 (or (= (preceding-char) ?
\n)
228 (goto-char (point-min))
230 (message "Converting region to Info format...")
231 (setq fill-column fill-column-for-info
)
232 ;; Install a syntax table useful for scanning command operands.
233 (set-syntax-table texinfo-format-syntax-table
)
235 ;; Insert @include files so `texinfo-raise-lower-sections' can
236 ;; work on them without losing track of multiple
237 ;; @raise/@lowersections commands.
238 (while (re-search-forward "^@include" nil t
)
239 (setq texinfo-command-end
(point))
240 (let ((filename (concat input-directory
241 (texinfo-parse-line-arg))))
242 (re-search-backward "^@include")
243 (delete-region (point) (save-excursion (forward-line 1) (point)))
244 (message "Reading included file: %s" filename
)
249 (+ (point) (car (cdr (insert-file-contents filename
)))))
250 (goto-char (point-min))
251 ;; Remove `@setfilename' line from included file, if any,
252 ;; so @setfilename command not duplicated.
253 (if (re-search-forward "^@setfilename" (line-end-position 100) t
)
254 (delete-region (line-beginning-position 1)
255 (line-beginning-position 2)))))))
257 ;; Raise or lower level of each section, if necessary.
258 (goto-char (point-min))
259 (texinfo-raise-lower-sections)
260 ;; Append @refill to appropriate paragraphs for filling.
261 (goto-char (point-min))
262 (texinfo-append-refill)
263 ;; If the region includes the effective end of the data,
264 ;; discard everything after that.
265 (goto-char (point-max))
266 (if (re-search-backward "^@bye" nil t
)
267 (delete-region (point) (point-max)))
268 ;; Make sure buffer ends in a newline.
269 (or (= (preceding-char) ?
\n)
271 ;; Don't use a previous value of texinfo-enclosure-list.
272 (setq texinfo-enclosure-list nil
)
273 (setq texinfo-alias-list nil
)
275 (goto-char (point-min))
276 (if (looking-at "\\\\input[ \t]+texinfo")
277 (delete-region (point) (line-beginning-position 2)))
279 ;; Insert Info region title text.
280 (goto-char (point-min))
282 "@setfilename" (save-excursion (forward-line 100) (point)) t
)
284 (setq texinfo-command-end
(point))
286 (setq texinfo-command-start
(point))
287 (let ((arg (texinfo-parse-arg-discard)))
289 texinfo-region-buffer-name
291 (insert (file-name-nondirectory (expand-file-name arg
)))
292 (insert "', -*-Text-*-\n")))
293 ;; Else no `@setfilename' line
295 texinfo-region-buffer-name
296 " buffer -*-Text-*-\n"))
297 (insert "produced by `texinfo-format-region'\n"
299 (if (buffer-file-name input-buffer
)
301 (file-name-sans-versions
302 (file-name-nondirectory
303 (buffer-file-name input-buffer
)))
305 (concat "buffer `" (buffer-name input-buffer
) "'"))
306 "\nusing `texinfmt.el' version "
310 ;; Now convert for real.
311 (goto-char (point-min))
312 (texinfo-format-scan)
313 (goto-char (point-min))
314 (Info-tagify input-buffer
)
315 (goto-char (point-min))
319 (defun texi2info (&optional nosplit
)
320 "Convert the current buffer (written in Texinfo code) into an Info file.
321 The Info file output is generated in a buffer visiting the Info file
322 names specified in the @setfilename command.
324 This function automatically updates all node pointers and menus, and
325 creates a master menu. This work is done on a temporary buffer that
326 is automatically removed when the Info file is created. The original
327 Texinfo source buffer is not changed.
329 Non-nil argument (prefix, if interactive) means don't split the file
330 if large. You can use Info-split to do this manually."
332 (let ((temp-buffer (concat "*--" (buffer-name) "--temporary-buffer*" )))
333 (message "First updating nodes and menus, then creating Info file.")
335 (copy-to-buffer temp-buffer
(point-min) (point-max))
336 (switch-to-buffer temp-buffer
)
337 (texinfo-master-menu t
)
338 (message "Now creating Info file.")
340 (texinfo-format-buffer nosplit
)
342 (kill-buffer temp-buffer
)))
345 ;;; Primary internal formatting function for the whole buffer.
347 (defun texinfo-format-buffer-1 ()
348 (let (texinfo-format-filename
349 texinfo-example-start
350 texinfo-command-start
354 texinfo-last-node-pos
363 (texinfo-footnote-number 0)
366 (fill-column-for-info fill-column
)
367 (input-buffer (current-buffer))
368 (input-directory default-directory
))
369 (setq texinfo-enclosure-list nil
)
370 (setq texinfo-alias-list nil
)
372 (goto-char (point-min))
373 (or (search-forward "@setfilename" nil t
)
374 (error "Texinfo file needs an `@setfilename FILENAME' line"))
375 (setq texinfo-command-end
(point))
376 (setq outfile
(texinfo-parse-line-arg)))
381 (buffer-disable-undo)
383 (message "Formatting Info file: %s" outfile
)
384 (setq texinfo-format-filename
385 (file-name-nondirectory (expand-file-name outfile
)))
387 (setq fill-column fill-column-for-info
)
388 (set-syntax-table texinfo-format-syntax-table
)
390 (insert-buffer-substring input-buffer
)
391 (run-hook-with-args 'texinfo-pre-format-hook input-buffer
)
392 (message "Converting %s to Info format..." (buffer-name input-buffer
))
394 ;; Insert @include files so `texinfo-raise-lower-sections' can
395 ;; work on them without losing track of multiple
396 ;; @raise/@lowersections commands.
397 (goto-char (point-min))
398 (while (re-search-forward "^@include" nil t
)
399 (setq texinfo-command-end
(point))
400 (let ((filename (concat input-directory
401 (texinfo-parse-line-arg))))
402 (re-search-backward "^@include")
403 (delete-region (point) (line-beginning-position 2))
404 (message "Reading included file: %s" filename
)
409 (+ (point) (car (cdr (insert-file-contents filename
)))))
410 (goto-char (point-min))
411 ;; Remove `@setfilename' line from included file, if any,
412 ;; so @setfilename command not duplicated.
413 (if (re-search-forward "^@setfilename" (line-end-position 100) t
)
414 (delete-region (line-beginning-position 1)
415 (line-beginning-position 2)))))))
416 ;; Raise or lower level of each section, if necessary.
417 (goto-char (point-min))
418 (texinfo-raise-lower-sections)
419 ;; Append @refill to appropriate paragraphs
420 (goto-char (point-min))
421 (texinfo-append-refill)
422 (goto-char (point-min))
423 (search-forward "@setfilename")
425 (delete-region (point-min) (point))
426 ;; Remove @bye at end of file, if it is there.
427 (goto-char (point-max))
428 (if (search-backward "@bye" nil t
)
429 (delete-region (point) (point-max)))
430 ;; Make sure buffer ends in a newline.
431 (or (= (preceding-char) ?
\n)
433 ;; Scan the whole buffer, converting to Info format.
434 (texinfo-format-scan)
435 (goto-char (point-min))
436 ;; Insert info about how this file was made.
437 (insert "Info file: "
438 texinfo-format-filename
", -*-Text-*-\n"
439 "produced by `texinfo-format-buffer'\n"
440 ;; Date string removed so that regression testing is easier.
442 ;; (insert (format-time-string "%e %b %Y")) " "
444 (if (buffer-file-name input-buffer
)
446 (file-name-sans-versions
447 (file-name-nondirectory
448 (buffer-file-name input-buffer
)))
450 (concat "buffer `" (buffer-name input-buffer
) "'"))
451 "\nusing `texinfmt.el' version "
454 ;; Return data for indices.
456 texinfo-vindex texinfo-findex texinfo-cindex
457 texinfo-pindex texinfo-tindex texinfo-kindex
)))
460 ;;; Perform non-@-command file conversions: quotes and hyphens
462 (defun texinfo-format-convert (min max
)
463 ;; Convert left and right quotes to typewriter font quotes.
465 (while (search-forward "``" max t
)
466 (replace-match "\""))
468 (while (search-forward "''" max t
)
469 (replace-match "\""))
470 ;; Convert three hyphens in a row to two.
472 (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t
)
473 (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning 2)))))
476 ;;; Handle paragraph filling
478 ;; Keep as concatinated lists for ease of maintenance
480 (defvar texinfo-no-refill-regexp
484 ;; add "itemize\\|" (from experiment of 2001 Nov 28)
485 ;; because of a problem with @end itemize@refill
486 ;; I don't know if this causes other problems.
487 ;; I suspect itemized lists don't get filled properly and a
488 ;; more precise fix is required. Bob
509 "Regexp specifying environments in which paragraphs are not filled.")
511 (defvar texinfo-accent-commands
544 (defvar texinfo-part-of-para-regexp
579 "@-\\|" ; @- is a descretionary hyphen (not an accent) (a noop).
580 texinfo-accent-commands
583 "Regexp specifying @-commands found within paragraphs.")
585 (defun texinfo-append-refill ()
586 "Append @refill at end of each paragraph that should be filled.
587 Do not append @refill to paragraphs within @example and similar environments.
588 Do not append @refill to paragraphs containing @w{TEXT} or @*."
590 ;; It is necessary to append @refill before other processing because
591 ;; the other processing removes information that tells Texinfo
592 ;; whether the text should or should not be filled.
594 (while (< (point) (point-max))
595 (let ((refill-blank-lines "^[ \t\n]*$")
596 (case-fold-search nil
)) ; Don't confuse @TeX and @tex....
598 ;; 1. Skip over blank lines;
599 ;; skip over lines beginning with @-commands,
600 ;; but do not skip over lines
601 ;; that are no-refill environments such as @example or
602 ;; that begin with within-paragraph @-commands such as @code.
603 (while (and (looking-at (concat "^@\\|^\\\\\\|" refill-blank-lines
))
607 texinfo-no-refill-regexp
609 texinfo-part-of-para-regexp
611 (< (point) (point-max)))
613 ;; 2. Skip over @example and similar no-refill environments.
614 (if (looking-at texinfo-no-refill-regexp
)
615 (let ((environment (match-string-no-properties 1)))
616 (progn (re-search-forward (concat "^@end " environment
) nil t
)
619 ;; 3. Do not refill a paragraph containing @w or @*, or ending
620 ;; with @<newline> followed by a newline.
621 (if (or (>= (point) (point-max))
624 (save-excursion (forward-paragraph) (forward-line 1) (point))
626 ;; Go to end of paragraph and do nothing.
628 ;; 4. Else go to end of paragraph and insert @refill
631 (let ((line-beg (point)))
635 (save-excursion (skip-chars-backward " \t") (point)))
637 (unless (re-search-backward "@c[ \t\n]\\|@comment[ \t\n]" line-beg t
)
639 (unless (re-search-backward "@refill\\|@bye" line-beg t
)
641 (forward-line 1))))))
644 ;;; Handle `@raisesections' and `@lowersections' commands
646 ;; These commands change the hierarchical level of chapter structuring
649 ;; @raisesections changes @subsection to @section,
650 ;; @section to @chapter,
653 ;; @lowersections changes @chapter to @section
654 ;; @subsection to @subsubsection,
657 ;; An @raisesections/@lowersections command changes only those
658 ;; structuring commands that follow the @raisesections/@lowersections
661 ;; Repeated @raisesections/@lowersections continue to raise or lower
662 ;; the heading level.
664 ;; An @lowersections command cancels an @raisesections command, and
667 ;; You cannot raise or lower "beyond" chapters or subsubsections, but
668 ;; trying to do so does not elicit an error---you just get more
669 ;; headings that mean the same thing as you keep raising or lowering
670 ;; (for example, after a single @raisesections, both @chapter and
671 ;; @section produce chapter headings).
673 (defun texinfo-raise-lower-sections ()
674 "Raise or lower the hierarchical level of chapters, sections, etc.
676 This function acts according to `@raisesections' and `@lowersections'
677 commands in the Texinfo file.
679 For example, an `@lowersections' command is useful if you wish to
680 include what is written as an outer or standalone Texinfo file in
681 another Texinfo file as an inner, included file. The `@lowersections'
682 command changes chapters to sections, sections to subsections and so
685 @raisesections changes @subsection to @section,
686 @section to @chapter,
687 @heading to @chapheading,
690 @lowersections changes @chapter to @section,
691 @subsection to @subsubsection,
692 @heading to @subheading,
695 An `@raisesections' or `@lowersections' command changes only those
696 structuring commands that follow the `@raisesections' or
697 `@lowersections' command.
699 An `@lowersections' command cancels an `@raisesections' command, and
702 Repeated use of the commands continue to raise or lower the hierarchical
703 level a step at a time.
705 An attempt to raise above `chapters' reproduces chapter commands; an
706 attempt to lower below subsubsections reproduces subsubsection
709 ;; `texinfo-section-types-regexp' is defined in `texnfo-upd.el';
710 ;; it is a regexp matching chapter, section, other headings
711 ;; (but not the top node).
713 (let (type (level 0))
717 "\\(\\(^@\\(raise\\|lower\\)sections\\)\\|\\("
718 texinfo-section-types-regexp
722 (save-excursion (setq type
(read (current-buffer))))
725 ;; 1. Increment level
726 ((eq type
'@raisesections
)
727 (setq level
(1+ level
))
729 (point) (save-excursion (forward-line 1) (point))))
731 ;; 2. Decrement level
732 ((eq type
'@lowersections
)
733 (setq level
(1- level
))
735 (point) (save-excursion (forward-line 1) (point))))
737 ;; Now handle structuring commands
740 ;; 3. Raise level when positive
746 (cdr (assq new-level texinfo-raisesections-alist
)))
747 (setq count
(1- count
)))
749 (insert (symbol-name new-level
))))
751 ;; 4. Do nothing except move point when level is zero
752 ((= level
0) (forward-line 1))
754 ;; 5. Lower level when positive
760 (cdr (assq new-level texinfo-lowersections-alist
)))
761 (setq count
(1+ count
)))
763 (insert (symbol-name new-level
))))))))))
765 (defvar texinfo-raisesections-alist
766 '((@chapter .
@chapter
) ; Cannot go higher
767 (@unnumbered .
@unnumbered
)
768 (@centerchap .
@unnumbered
)
770 (@majorheading .
@majorheading
)
771 (@chapheading .
@chapheading
)
772 (@appendix .
@appendix
)
774 (@section .
@chapter
)
775 (@unnumberedsec .
@unnumbered
)
776 (@heading .
@chapheading
)
777 (@appendixsec .
@appendix
)
779 (@subsection .
@section
)
780 (@unnumberedsubsec .
@unnumberedsec
)
781 (@subheading .
@heading
)
782 (@appendixsubsec .
@appendixsec
)
784 (@subsubsection .
@subsection
)
785 (@unnumberedsubsubsec .
@unnumberedsubsec
)
786 (@subsubheading .
@subheading
)
787 (@appendixsubsubsec .
@appendixsubsec
))
788 "*An alist of next higher levels for chapters, sections. etc.
789 For example, section to chapter, subsection to section.
790 Used by `texinfo-raise-lower-sections'.
791 The keys specify types of section; the values correspond to the next
794 (defvar texinfo-lowersections-alist
795 '((@chapter .
@section
)
796 (@unnumbered .
@unnumberedsec
)
797 (@centerchap .
@unnumberedsec
)
798 (@majorheading .
@heading
)
799 (@chapheading .
@heading
)
800 (@appendix .
@appendixsec
)
802 (@section .
@subsection
)
803 (@unnumberedsec .
@unnumberedsubsec
)
804 (@heading .
@subheading
)
805 (@appendixsec .
@appendixsubsec
)
807 (@subsection .
@subsubsection
)
808 (@unnumberedsubsec .
@unnumberedsubsubsec
)
809 (@subheading .
@subsubheading
)
810 (@appendixsubsec .
@appendixsubsubsec
)
812 (@subsubsection .
@subsubsection
) ; Cannot go lower.
813 (@unnumberedsubsubsec .
@unnumberedsubsubsec
)
814 (@subsubheading .
@subsubheading
)
815 (@appendixsubsubsec .
@appendixsubsubsec
))
816 "*An alist of next lower levels for chapters, sections. etc.
817 For example, chapter to section, section to subsection.
818 Used by `texinfo-raise-lower-sections'.
819 The keys specify types of section; the values correspond to the next
823 ;;; Perform those texinfo-to-info conversions that apply to the whole input
826 (defun texinfo-format-scan ()
827 (texinfo-format-convert (point-min) (point-max))
828 ;; Search for @copying, which has to be first since the
829 ;; @insertcopying command then inserts the text elsewhere.
830 (goto-char (point-min))
831 (when (search-forward "@copying" nil t
)
833 (while (search-forward "@insertcopying" nil t
)
834 (delete-region (match-beginning 0) (match-end 0))
836 (texinfo-insertcopying))
837 ;; Scan for other @-commands.
838 (goto-char (point-min))
839 (while (search-forward "@" nil t
)
841 ;; These are the single-character accent commands: @^ @` @' @" @= @~
842 ;; In Info, they are simply quoted and the @ deleted.
843 ;; Other single-character commands:
844 ;; @* forces a line break,
845 ;; @- is a discretionary hyphenation point; does nothing in Info.
846 ;; @<space>, @<tab>, @<newline> each produce a single space,
847 ;; unless followed by a newline.
849 ;; Old version 2.34 expression: (looking-at "[@{}^'` *\"?!]")
850 (if (looking-at "[@{}^'`\"=~ \t\n*?!-]")
851 ;; @*, causes a line break.
854 ((= (following-char) ?
*)
856 (delete-region (1- (point)) (1+ (point)))
857 ;; insert return if not at end of line;
858 ;; else line is already broken.
859 (if (not (= (following-char) ?
\n))
862 ((= (following-char) ?-
)
863 (delete-region (1- (point)) (1+ (point))))
864 ;; @<space>, @<tab>, @<newline>: produce a single space,
865 ;; unless followed by a newline.
866 ((= (following-char) ?
)
867 (delete-region (1- (point)) (1+ (point)))
868 ;; insert single space if not at end of line;
869 ;; else line is already broken.
870 (if (not (= (following-char) ?
\n))
872 ((= (following-char) ?
\t)
873 (delete-region (1- (point)) (1+ (point)))
874 ;; insert single space if not at end of line;
875 ;; else line is already broken.
876 (if (not (= (following-char) ?
\n))
878 ;; following char is a carriage return
879 ((= (following-char) ?
\n)
881 (delete-region (1- (point)) (1+ (point)))
882 ;; insert single space if not at end of line;
883 ;; else line is already broken.
884 (if (not (= (following-char) ?
\n))
886 ;; Otherwise: the other characters are simply quoted. Delete the @.
889 ;; Be compatible with makeinfo: if @' and its ilk are
890 ;; followed by a @ without a brace, barf.
891 (if (looking-at "[\"'^`~=]")
893 (if (= (char-after (1+ (point))) ?
@)
894 (error "Use braces to give a command as an argument to @%c"
897 ;; @' etc. can optionally accept their argument in
898 ;; braces (makeinfo supports that).
899 (when (looking-at "{")
900 (let ((start (point)))
906 ;; @ is followed by a command-word; find the end of the word.
907 (setq texinfo-command-start
(1- (point)))
908 (if (= (char-syntax (following-char)) ?w
)
911 (setq texinfo-command-end
(point))
912 ;; Detect the case of two @-commands in a row;
913 ;; process just the first one.
914 (goto-char (1+ texinfo-command-start
))
915 (skip-chars-forward "^@" texinfo-command-end
)
916 (setq texinfo-command-end
(point))
917 ;; Handle let aliasing
918 (setq texinfo-command-name
921 (buffer-substring-no-properties
922 (1+ texinfo-command-start
) texinfo-command-end
)))
923 (while (setq trial
(assoc cmdname texinfo-alias-list
))
924 (setq cmdname
(cdr trial
)))
926 ;; Call the handler for this command.
927 (let ((enclosure-type
929 (symbol-name texinfo-command-name
)
930 texinfo-enclosure-list
)))
934 (car (car (cdr enclosure-type
)))
935 (texinfo-parse-arg-discard)
936 (car (cdr (car (cdr enclosure-type
)))))
937 (goto-char texinfo-command-start
))
938 (let ((cmd (get texinfo-command-name
'texinfo-format
)))
939 (if cmd
(funcall cmd
) (texinfo-unsupported)))))))
942 (goto-char (nth 2 (car texinfo-stack
)))
943 (error "Unterminated @%s" (car (car texinfo-stack
)))))
945 ;; Remove excess whitespace
946 (let ((whitespace-silent t
))
947 (whitespace-cleanup)))
949 (defvar texinfo-copying-text
""
950 "Text of the copyright notice and copying permissions.")
952 (defun texinfo-copying ()
953 "Copy the copyright notice and copying permissions from the Texinfo file,
954 as indicated by the @copying ... @end copying command;
955 insert the text with the @insertcopying command."
956 (let ((beg (progn (beginning-of-line) (point)))
957 (end (progn (re-search-forward "^@end copying[ \t]*\n") (point))))
958 (setq texinfo-copying-text
959 (buffer-substring-no-properties
960 (save-excursion (goto-char beg
) (forward-line 1) (point))
961 (save-excursion (goto-char end
) (forward-line -
1) (point))))
962 (delete-region beg end
)))
964 (defun texinfo-insertcopying ()
965 "Insert the copyright notice and copying permissions from the Texinfo file,
966 which are indicated by the @copying ... @end copying command."
967 (insert (concat "\n" texinfo-copying-text
)))
969 (put 'begin
'texinfo-format
'texinfo-format-begin
)
970 (defun texinfo-format-begin ()
971 (texinfo-format-begin-end 'texinfo-format
))
973 (put 'end
'texinfo-format
'texinfo-format-end
)
974 (defun texinfo-format-end ()
975 (texinfo-format-begin-end 'texinfo-end
))
977 (defun texinfo-format-begin-end (prop)
978 (setq texinfo-command-name
(intern (texinfo-parse-line-arg)))
979 (let ((cmd (get texinfo-command-name prop
)))
980 (if cmd
(funcall cmd
)
981 (texinfo-unsupported))))
983 ;;; Parsing functions
985 (defun texinfo-parse-line-arg ()
986 "Return argument of @-command as string.
987 Argument is separated from command either by a space or by a brace.
988 If a space, return rest of line, with beginning and ending white
989 space removed. If a brace, return string between braces.
990 Leave point after argument."
991 (goto-char texinfo-command-end
)
992 (let ((start (point)))
993 (cond ((looking-at " ")
994 (skip-chars-forward " ")
997 (skip-chars-backward " ")
998 (delete-region (point) (progn (end-of-line) (point)))
999 (setq texinfo-command-end
(1+ (point))))
1001 (setq start
(1+ (point)))
1003 (setq texinfo-command-end
(point))
1006 (error "Invalid texinfo command arg format")))
1007 (prog1 (buffer-substring-no-properties start
(point))
1008 (if (eolp) (forward-char 1)))))
1010 (defun texinfo-parse-expanded-arg ()
1011 (goto-char texinfo-command-end
)
1012 (let ((start (point))
1014 (cond ((looking-at " ")
1015 (skip-chars-forward " ")
1016 (setq start
(point))
1018 (setq texinfo-command-end
(1+ (point))))
1020 (setq start
(1+ (point)))
1022 (setq texinfo-command-end
(point))
1025 (error "Invalid texinfo command arg format")))
1026 (setq marker
(move-marker (make-marker) texinfo-command-end
))
1027 (texinfo-format-expand-region start
(point))
1028 (setq texinfo-command-end
(marker-position marker
))
1029 (move-marker marker nil
)
1030 (prog1 (buffer-substring-no-properties start
(point))
1031 (if (eolp) (forward-char 1)))))
1033 (defun texinfo-format-expand-region (start end
)
1035 (narrow-to-region start end
)
1036 (let (texinfo-command-start
1038 texinfo-command-name
1040 (texinfo-format-scan))
1041 (goto-char (point-max))))
1043 (defun texinfo-parse-arg-discard ()
1044 "Delete command and argument; return argument of command."
1045 (prog1 (texinfo-parse-line-arg)
1046 (texinfo-discard-command)))
1048 (defun texinfo-discard-command ()
1049 (delete-region texinfo-command-start texinfo-command-end
))
1051 (defun texinfo-optional-braces-discard ()
1052 "Discard braces following command, if any."
1053 (goto-char texinfo-command-end
)
1054 (let ((start (point)))
1055 (cond ((looking-at "[ \t]*\n")) ; do nothing
1056 ((looking-at "{") ; remove braces, if any
1058 (setq texinfo-command-end
(point)))
1061 "Invalid `texinfo-optional-braces-discard' format \(need braces?\)")))
1062 (delete-region texinfo-command-start texinfo-command-end
)))
1064 (defun texinfo-format-parse-line-args ()
1065 (let ((start (1- (point)))
1068 (skip-chars-forward " ")
1071 (re-search-forward "[\n,]")
1073 (if (bolp) (setq next
(1- next
)))
1075 (skip-chars-backward " ")
1077 (setq args
(cons (if (> end beg
) (buffer-substring-no-properties beg end
))
1080 (skip-chars-forward " "))
1081 (if (eolp) (forward-char 1))
1082 (setq texinfo-command-end
(point))
1085 (defun texinfo-format-parse-args ()
1086 (let ((start (1- (point)))
1089 (search-forward "{")
1091 (texinfo-format-expand-region
1093 (save-excursion (up-list 1) (1- (point)))))
1094 ;; The following does not handle cross references of the form:
1095 ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the
1096 ;; re-search-forward finds the first right brace after the second
1098 (while (/= (preceding-char) ?\
})
1099 (skip-chars-forward " \t\n")
1101 (re-search-forward "[},]")
1104 (skip-chars-backward " \t\n")
1108 (while (search-forward "\n" end t
)
1109 (replace-match " "))))
1110 (setq args
(cons (if (> end beg
) (buffer-substring-no-properties beg end
))
1113 ;;(if (eolp) (forward-char 1))
1114 (setq texinfo-command-end
(point))
1117 (defun texinfo-format-parse-defun-args ()
1118 (goto-char texinfo-command-end
)
1119 (let ((start (point)))
1121 (setq texinfo-command-end
(1+ (point)))
1122 (let ((marker (move-marker (make-marker) texinfo-command-end
)))
1123 (texinfo-format-expand-region start
(point))
1124 (setq texinfo-command-end
(marker-position marker
))
1125 (move-marker marker nil
))
1129 (skip-chars-forward " ")
1131 (cond ((looking-at "{")
1132 (setq beg
(1+ (point)))
1134 (setq end
(1- (point))))
1137 (re-search-forward "[\n ]")
1139 (setq end
(point))))
1140 (setq args
(cons (buffer-substring-no-properties beg end
) args
))
1141 (skip-chars-forward " "))
1145 (defun texinfo-discard-line ()
1146 (goto-char texinfo-command-end
)
1147 (skip-chars-forward " \t")
1149 (error "Extraneous text at end of command line"))
1150 (goto-char texinfo-command-start
)
1152 (error "Extraneous text at beginning of command line"))
1153 (delete-region (point) (progn (forward-line 1) (point))))
1155 (defun texinfo-discard-line-with-args ()
1156 (goto-char texinfo-command-start
)
1157 (delete-region (point) (progn (forward-line 1) (point))))
1162 ;; Only `texinfo-format-buffer' handles @setfilename with this
1163 ;; definition; `texinfo-format-region' handles @setfilename, if any,
1165 (put 'setfilename
'texinfo-format
'texinfo-format-setfilename
)
1166 (defun texinfo-format-setfilename ()
1167 (texinfo-parse-arg-discard))
1169 ;;; @node, @menu, @detailmenu
1171 (put 'node
'texinfo-format
'texinfo-format-node
)
1172 (put 'nwnode
'texinfo-format
'texinfo-format-node
)
1173 (defun texinfo-format-node ()
1174 (let* ((args (texinfo-format-parse-line-args))
1179 (texinfo-discard-command)
1180 (setq texinfo-last-node name
)
1181 (let ((tem (if texinfo-fold-nodename-case
(downcase name
) name
)))
1182 (if (assoc tem texinfo-node-names
)
1183 (error "Duplicate node name: %s" name
)
1184 (setq texinfo-node-names
(cons (list tem
) texinfo-node-names
))))
1185 (setq texinfo-footnote-number
0)
1186 ;; insert "\n\^_" unconditionally since this is what info is looking for
1187 (insert "\n\^_\nFile: " texinfo-format-filename
1190 (insert ", Next: " next
))
1192 (insert ", Prev: " prev
))
1194 (insert ", Up: " up
))
1196 (setq texinfo-last-node-pos
(point))))
1198 (put 'anchor
'texinfo-format
'texinfo-anchor
)
1199 (defun texinfo-anchor ()
1201 (here (- (point) 7)) ; save location of beginning of `@anchor'
1202 (arg (texinfo-parse-arg-discard)))
1203 (if (looking-at " ") ; since a space may be left after -discard
1206 (let ((end (point)))
1209 (search-forward "@refill" end t
))
1210 (setq anchor-string
"@anchor-yes-refill")
1211 (setq anchor-string
"@anchor-no-refill")))
1213 (insert anchor-string
"{" arg
"}")))
1215 (put 'menu
'texinfo-format
'texinfo-format-menu
)
1216 (defun texinfo-format-menu ()
1217 (texinfo-discard-line)
1218 (insert "* Menu:\n\n"))
1220 (put 'menu
'texinfo-end
'texinfo-discard-command
)
1222 ;; The @detailmenu should be removed eventually.
1224 ;; According to Karl Berry, 31 August 1996:
1226 ;; You don't like, I don't like it. I agree, it would be better just to
1227 ;; fix the bug [in `makeinfo']. .. At this point, since inserting those
1228 ;; two commands in the Elisp fn is trivial, I don't especially want to
1229 ;; expend more effort...
1231 ;; I added a couple sentences of documentation to the manual (putting the
1232 ;; blame on makeinfo where it belongs :-().
1234 (put 'detailmenu
'texinfo-format
'texinfo-discard-line
)
1235 (put 'detailmenu
'texinfo-end
'texinfo-discard-command
)
1237 ;; (Also see `texnfo-upd.el')
1240 ;;; Cross references
1242 ;; @xref {NODE, FNAME, NAME, FILE, DOCUMENT}
1243 ;; -> *Note FNAME: (FILE)NODE
1244 ;; If FILE is missing,
1245 ;; *Note FNAME: NODE
1246 ;; If FNAME is empty and NAME is present
1248 ;; If both NAME and FNAME are missing
1250 ;; texinfo ignores the DOCUMENT argument.
1251 ;; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1252 ;; If FILE is specified, (FILE)NODE is used for xrefs.
1253 ;; If fifth argument DOCUMENT is specified, produces
1254 ;; See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1257 ;; @ref a reference that does not put `See' or `see' in
1258 ;; the hardcopy and is the same as @xref in Info
1259 (put 'ref
'texinfo-format
'texinfo-format-xref
)
1261 (put 'xref
'texinfo-format
'texinfo-format-xref
)
1262 (defun texinfo-format-xref ()
1263 (let ((args (texinfo-format-parse-args)))
1264 (texinfo-discard-command)
1266 (let ((fname (or (nth 1 args
) (nth 2 args
))))
1267 (if (null (or fname
(nth 3 args
)))
1268 (insert (car args
) "::")
1269 (insert (or fname
(car args
)) ": ")
1271 (insert "(" (nth 3 args
) ")"))
1272 (and (car args
) (insert (car args
)))))))
1274 (put 'pxref
'texinfo-format
'texinfo-format-pxref
)
1275 (defun texinfo-format-pxref ()
1276 (texinfo-format-xref)
1282 ;; @inforef{NODE, FNAME, FILE}
1283 ;; Like @xref{NODE, FNAME,,FILE} in texinfo.
1284 ;; In Tex, generates "See Info file FILE, node NODE"
1285 (put 'inforef
'texinfo-format
'texinfo-format-inforef
)
1286 (defun texinfo-format-inforef ()
1287 (let ((args (texinfo-format-parse-args)))
1288 (texinfo-discard-command)
1290 (insert "*Note " (nth 1 args
) ": (" (nth 2 args
) ")" (car args
))
1291 (insert "*Note " "(" (nth 2 args
) ")" (car args
) "::"))))
1294 ;;; URL Reference: @uref
1296 ;; @uref produces a reference to a uniform resource locator (URL).
1297 ;; It takes one mandatory argument, the URL, and one optional argument,
1298 ;; the text to display (the default is the URL itself).
1300 (put 'uref
'texinfo-format
'texinfo-format-uref
)
1301 (defun texinfo-format-uref ()
1302 "Format URL and optional URL-TITLE.
1303 Insert ` ... ' around URL if no URL-TITLE argument;
1304 otherwise, insert URL-TITLE followed by URL in parentheses."
1305 (let ((args (texinfo-format-parse-args)))
1306 (texinfo-discard-command)
1309 (insert (nth 1 args
) " (" (nth 0 args
) ")")
1310 (insert "`" (nth 0 args
) "'"))
1311 (goto-char texinfo-command-start
)))
1314 ;;; Section headings
1316 (put 'majorheading
'texinfo-format
'texinfo-format-chapter
)
1317 (put 'chapheading
'texinfo-format
'texinfo-format-chapter
)
1318 (put 'ichapter
'texinfo-format
'texinfo-format-chapter
)
1319 (put 'chapter
'texinfo-format
'texinfo-format-chapter
)
1320 (put 'iappendix
'texinfo-format
'texinfo-format-chapter
)
1321 (put 'appendix
'texinfo-format
'texinfo-format-chapter
)
1322 (put 'iunnumbered
'texinfo-format
'texinfo-format-chapter
)
1323 (put 'top
'texinfo-format
'texinfo-format-chapter
)
1324 (put 'unnumbered
'texinfo-format
'texinfo-format-chapter
)
1325 (put 'centerchap
'texinfo-format
'texinfo-format-chapter
)
1326 (defun texinfo-format-chapter ()
1327 (texinfo-format-chapter-1 ?
*))
1329 (put 'heading
'texinfo-format
'texinfo-format-section
)
1330 (put 'isection
'texinfo-format
'texinfo-format-section
)
1331 (put 'section
'texinfo-format
'texinfo-format-section
)
1332 (put 'iappendixsection
'texinfo-format
'texinfo-format-section
)
1333 (put 'appendixsection
'texinfo-format
'texinfo-format-section
)
1334 (put 'iappendixsec
'texinfo-format
'texinfo-format-section
)
1335 (put 'appendixsec
'texinfo-format
'texinfo-format-section
)
1336 (put 'iunnumberedsec
'texinfo-format
'texinfo-format-section
)
1337 (put 'unnumberedsec
'texinfo-format
'texinfo-format-section
)
1338 (defun texinfo-format-section ()
1339 (texinfo-format-chapter-1 ?
=))
1341 (put 'subheading
'texinfo-format
'texinfo-format-subsection
)
1342 (put 'isubsection
'texinfo-format
'texinfo-format-subsection
)
1343 (put 'subsection
'texinfo-format
'texinfo-format-subsection
)
1344 (put 'iappendixsubsec
'texinfo-format
'texinfo-format-subsection
)
1345 (put 'appendixsubsec
'texinfo-format
'texinfo-format-subsection
)
1346 (put 'iunnumberedsubsec
'texinfo-format
'texinfo-format-subsection
)
1347 (put 'unnumberedsubsec
'texinfo-format
'texinfo-format-subsection
)
1348 (defun texinfo-format-subsection ()
1349 (texinfo-format-chapter-1 ?-
))
1351 (put 'subsubheading
'texinfo-format
'texinfo-format-subsubsection
)
1352 (put 'isubsubsection
'texinfo-format
'texinfo-format-subsubsection
)
1353 (put 'subsubsection
'texinfo-format
'texinfo-format-subsubsection
)
1354 (put 'iappendixsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1355 (put 'appendixsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1356 (put 'iunnumberedsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1357 (put 'unnumberedsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1358 (defun texinfo-format-subsubsection ()
1359 (texinfo-format-chapter-1 ?.
))
1361 (defun texinfo-format-chapter-1 (belowchar)
1362 (let ((arg (texinfo-parse-arg-discard)))
1363 (message "Formatting: %s ... " arg
) ; So we can see where we are.
1364 (insert ?
\n arg ?
\n "@SectionPAD " belowchar ?
\n)
1367 (put 'SectionPAD
'texinfo-format
'texinfo-format-sectionpad
)
1368 (defun texinfo-format-sectionpad ()
1369 (let ((str (texinfo-parse-arg-discard)))
1371 (let ((column (current-column)))
1375 (setq column
(1- column
))))
1379 ;;; Space controlling commands: @. and @:, and the soft hyphen.
1381 (put '\.
'texinfo-format
'texinfo-format-\.
)
1382 (defun texinfo-format-\.
()
1383 (texinfo-discard-command)
1386 (put '\
: 'texinfo-format
'texinfo-format-\
:)
1387 (defun texinfo-format-\
: ()
1388 (texinfo-discard-command))
1390 (put '\-
'texinfo-format
'texinfo-format-soft-hyphen
)
1391 (defun texinfo-format-soft-hyphen ()
1392 (texinfo-discard-command))
1395 ;;; @kbdinputstyle, @vskip, headings & footings
1396 ;; These commands for not for Info and should never
1397 ;; appear in an Info environment; but if they do,
1398 ;; this causes them to be discarded.
1401 (put 'kbdinputstyle
'texinfo-format
'texinfo-discard-line-with-args
)
1404 (put 'vskip
'texinfo-format
'texinfo-discard-line-with-args
)
1406 ;; headings & footings
1407 (put 'evenfooting
'texinfo-format
'texinfo-discard-line-with-args
)
1408 (put 'evenheading
'texinfo-format
'texinfo-discard-line-with-args
)
1409 (put 'oddfooting
'texinfo-format
'texinfo-discard-line-with-args
)
1410 (put 'oddheading
'texinfo-format
'texinfo-discard-line-with-args
)
1411 (put 'everyfooting
'texinfo-format
'texinfo-discard-line-with-args
)
1412 (put 'everyheading
'texinfo-format
'texinfo-discard-line-with-args
)
1415 ;;; @documentdescription ... @end documentdescription
1416 ;; This command is for HTML output and should never
1417 ;; appear in an Info environment; but if it does,
1418 ;; this causes it to be discarded.
1420 (put 'documentdescription
'texinfo-format
'texinfo-format-documentdescription
)
1421 (defun texinfo-format-documentdescription ()
1422 (delete-region texinfo-command-start
1423 (progn (re-search-forward "^@end documentdescription[ \t]*\n")
1428 ;;; @center, @sp, and @br
1430 (put 'center
'texinfo-format
'texinfo-format-center
)
1431 (defun texinfo-format-center ()
1432 (let ((arg (texinfo-parse-expanded-arg)))
1433 (texinfo-discard-command)
1437 (goto-char (1- (point)))
1438 (let ((indent-tabs-mode nil
))
1441 (put 'sp
'texinfo-format
'texinfo-format-sp
)
1442 (defun texinfo-format-sp ()
1443 (let* ((arg (texinfo-parse-arg-discard))
1445 (insert-char ?
\n num
)))
1447 (put 'br
'texinfo-format
'texinfo-format-paragraph-break
)
1448 (defun texinfo-format-paragraph-break ()
1449 "Force a paragraph break.
1450 If used within a line, follow `@br' with braces."
1451 (texinfo-optional-braces-discard)
1452 ;; insert one return if at end of line;
1453 ;; else insert two returns, to generate a blank line.
1454 (if (= (following-char) ?
\n)
1456 (insert-char ?
\n 2)))
1459 ;;; @footnote and @footnotestyle
1461 ;; In Texinfo, footnotes are created with the `@footnote' command.
1462 ;; This command is followed immediately by a left brace, then by the text of
1463 ;; the footnote, and then by a terminating right brace. The
1464 ;; template for a footnote is:
1468 ;; Info has two footnote styles:
1470 ;; * In the End of node style, all the footnotes for a single node
1471 ;; are placed at the end of that node. The footnotes are
1472 ;; separated from the rest of the node by a line of dashes with
1473 ;; the word `Footnotes' within it.
1475 ;; * In the Separate node style, all the footnotes for a single node
1476 ;; are placed in an automatically constructed node of their own.
1478 ;; Footnote style is specified by the @footnotestyle command, either
1479 ;; @footnotestyle separate
1481 ;; @footnotestyle end
1483 ;; The default is separate
1485 (defvar texinfo-footnote-style
"separate"
1486 "Footnote style, either separate or end.")
1488 (put 'footnotestyle
'texinfo-format
'texinfo-footnotestyle
)
1489 (defun texinfo-footnotestyle ()
1490 "Specify whether footnotes are at end of node or in separate nodes.
1491 Argument is either end or separate."
1492 (setq texinfo-footnote-style
(texinfo-parse-arg-discard)))
1494 (defvar texinfo-footnote-number
)
1496 (put 'footnote
'texinfo-format
'texinfo-format-footnote
)
1497 (defun texinfo-format-footnote ()
1498 "Format a footnote in either end of node or separate node style.
1499 The texinfo-footnote-style variable controls which style is used."
1500 (setq texinfo-footnote-number
(1+ texinfo-footnote-number
))
1501 (cond ((string= texinfo-footnote-style
"end")
1502 (texinfo-format-end-node))
1503 ((string= texinfo-footnote-style
"separate")
1504 (texinfo-format-separate-node))))
1506 (defun texinfo-format-separate-node ()
1507 "Format footnote in Separate node style, with notes in own node.
1508 The node is constructed automatically."
1510 (arg (texinfo-parse-line-arg))
1511 (node-name-beginning
1514 "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:")
1518 (buffer-substring-no-properties
1519 (progn (goto-char node-name-beginning
) ; skip over node command
1520 (skip-chars-forward " \t") ; and over spaces
1524 (save-excursion (end-of-line) (point)) t
) ; bound search
1526 (end-of-line) (point))))))
1527 (texinfo-discard-command) ; remove or insert whitespace, as needed
1528 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1530 (insert (format " (%d) (*Note %s-Footnotes::)"
1531 texinfo-footnote-number node-name
))
1532 (fill-paragraph nil
)
1534 (if (re-search-forward "^@node" nil
'move
)
1537 ;; two cases: for the first footnote, we must insert a node header;
1538 ;; for the second and subsequent footnotes, we need only insert
1539 ;; the text of the footnote.
1543 (concat node-name
"-Footnotes, Up: ")
1546 (progn ; already at least one footnote
1547 (setq start
(point))
1548 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1549 (fill-region start
(point)))
1550 ;; else not yet a footnote
1551 (insert "\n\^_\nFile: " texinfo-format-filename
1552 " Node: " node-name
"-Footnotes, Up: " node-name
"\n")
1553 (setq start
(point))
1554 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1555 (fill-region start
(point))))))
1557 (defun texinfo-format-end-node ()
1558 "Format footnote in the End of node style, with notes at end of node."
1560 (arg (texinfo-parse-line-arg)))
1561 (texinfo-discard-command) ; remove or insert whitespace, as needed
1562 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1564 (insert (format " (%d) " texinfo-footnote-number
))
1565 (fill-paragraph nil
)
1567 (if (search-forward "\n--------- Footnotes ---------\n" nil t
)
1568 (progn ; already have footnote, put new one before end of node
1569 (if (re-search-forward "^@node" nil
'move
)
1571 (setq start
(point))
1572 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1573 (fill-region start
(point)))
1574 ;; else no prior footnote
1575 (if (re-search-forward "^@node" nil
'move
)
1577 (insert "\n--------- Footnotes ---------\n")
1578 (setq start
(point))
1579 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))))))
1582 ;;; @itemize, @enumerate, and similar commands
1584 ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.
1585 ;; @enumerate pushes (enumerate 0 STARTPOS).
1586 ;; @item dispatches to the texinfo-item prop of the first elt of the list.
1587 ;; For itemize, this puts in and rescans the COMMANDS.
1588 ;; For enumerate, this increments the number and puts it in.
1589 ;; In either case, it puts a Backspace at the front of the line
1590 ;; which marks it not to be indented later.
1591 ;; All other lines get indented by 5 when the @end is reached.
1593 (defvar texinfo-stack-depth
0
1594 "Count of number of unpopped texinfo-push-stack calls.
1595 Used by @refill indenting command to avoid indenting within lists, etc.")
1597 (defun texinfo-push-stack (check arg
)
1598 (setq texinfo-stack-depth
(1+ texinfo-stack-depth
))
1600 (cons (list check arg texinfo-command-start
)
1603 (defun texinfo-pop-stack (check)
1604 (setq texinfo-stack-depth
(1- texinfo-stack-depth
))
1605 (if (null texinfo-stack
)
1606 (error "Unmatched @end %s" check
))
1607 (if (not (eq (car (car texinfo-stack
)) check
))
1608 (error "@end %s matches @%s"
1609 check
(car (car texinfo-stack
))))
1610 (prog1 (cdr (car texinfo-stack
))
1611 (setq texinfo-stack
(cdr texinfo-stack
))))
1613 (put 'itemize
'texinfo-format
'texinfo-itemize
)
1614 (defun texinfo-itemize ()
1617 (progn (skip-chars-forward " \t")
1620 (texinfo-parse-line-arg))))
1621 (texinfo-discard-line-with-args)
1622 (setq fill-column
(- fill-column
5)))
1624 (put 'itemize
'texinfo-end
'texinfo-end-itemize
)
1625 (defun texinfo-end-itemize ()
1626 (setq fill-column
(+ fill-column
5))
1627 (texinfo-discard-command)
1629 (texinfo-pop-stack 'itemize
)))
1630 (texinfo-do-itemize (nth 1 stacktop
))))
1632 (put 'enumerate
'texinfo-format
'texinfo-enumerate
)
1633 (defun texinfo-enumerate ()
1636 (progn (skip-chars-forward " \t")
1639 (read (current-buffer)))))
1640 (if (and (symbolp (car (cdr (car texinfo-stack
))))
1641 (> 1 (length (symbol-name (car (cdr (car texinfo-stack
)))))))
1643 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." ))
1644 (texinfo-discard-line-with-args)
1645 (setq fill-column
(- fill-column
5)))
1647 (put 'enumerate
'texinfo-end
'texinfo-end-enumerate
)
1648 (defun texinfo-end-enumerate ()
1649 (setq fill-column
(+ fill-column
5))
1650 (texinfo-discard-command)
1652 (texinfo-pop-stack 'enumerate
)))
1653 (texinfo-do-itemize (nth 1 stacktop
))))
1655 ;; @alphaenumerate never became a standard part of Texinfo
1656 (put 'alphaenumerate
'texinfo-format
'texinfo-alphaenumerate
)
1657 (defun texinfo-alphaenumerate ()
1658 (texinfo-push-stack 'alphaenumerate
(1- ?a
))
1659 (setq fill-column
(- fill-column
5))
1660 (texinfo-discard-line))
1662 (put 'alphaenumerate
'texinfo-end
'texinfo-end-alphaenumerate
)
1663 (defun texinfo-end-alphaenumerate ()
1664 (setq fill-column
(+ fill-column
5))
1665 (texinfo-discard-command)
1667 (texinfo-pop-stack 'alphaenumerate
)))
1668 (texinfo-do-itemize (nth 1 stacktop
))))
1670 ;; @capsenumerate never became a standard part of Texinfo
1671 (put 'capsenumerate
'texinfo-format
'texinfo-capsenumerate
)
1672 (defun texinfo-capsenumerate ()
1673 (texinfo-push-stack 'capsenumerate
(1- ?A
))
1674 (setq fill-column
(- fill-column
5))
1675 (texinfo-discard-line))
1677 (put 'capsenumerate
'texinfo-end
'texinfo-end-capsenumerate
)
1678 (defun texinfo-end-capsenumerate ()
1679 (setq fill-column
(+ fill-column
5))
1680 (texinfo-discard-command)
1682 (texinfo-pop-stack 'capsenumerate
)))
1683 (texinfo-do-itemize (nth 1 stacktop
))))
1685 ;; At the @end, indent all the lines within the construct
1686 ;; except those marked with backspace. FROM says where
1687 ;; construct started.
1688 (defun texinfo-do-itemize (from)
1690 (while (progn (forward-line -
1)
1692 (if (= (following-char) ?
\b)
1697 (if (not (looking-at "[ \t]*$"))
1698 (save-excursion (insert " ")))))))
1700 (put 'item
'texinfo-format
'texinfo-item
)
1701 (put 'itemx
'texinfo-format
'texinfo-item
)
1702 (defun texinfo-item ()
1703 (funcall (get (car (car texinfo-stack
)) 'texinfo-item
)))
1705 (put 'itemize
'texinfo-item
'texinfo-itemize-item
)
1706 (defun texinfo-itemize-item ()
1707 ;; (texinfo-discard-line) ; Did not handle text on same line as @item.
1708 (delete-region (1+ (point)) (save-excursion (beginning-of-line) (point)))
1709 (if (looking-at "[ \t]*[^ \t\n]+")
1710 ;; Text on same line as @item command.
1711 (insert "\b " (nth 1 (car texinfo-stack
)) " \n")
1712 ;; Else text on next line.
1713 (insert "\b " (nth 1 (car texinfo-stack
)) " "))
1716 (put 'enumerate
'texinfo-item
'texinfo-enumerate-item
)
1717 (defun texinfo-enumerate-item ()
1718 (texinfo-discard-line)
1719 (let (enumerating-symbol)
1720 (cond ((integerp (car (cdr (car texinfo-stack
))))
1721 (setq enumerating-symbol
(car (cdr (car texinfo-stack
))))
1722 (insert ?
\b (format "%3d. " enumerating-symbol
) ?
\n)
1723 (setcar (cdr (car texinfo-stack
)) (1+ enumerating-symbol
)))
1724 ((symbolp (car (cdr (car texinfo-stack
))))
1725 (setq enumerating-symbol
1726 (symbol-name (car (cdr (car texinfo-stack
)))))
1727 (if (or (equal ?\
[ (string-to-char enumerating-symbol
))
1728 (equal ?\
{ (string-to-char enumerating-symbol
)))
1730 "Too many items in enumerated list; alphabet ends at Z."))
1731 (insert ?
\b (format "%3s. " enumerating-symbol
) ?
\n)
1732 (setcar (cdr (car texinfo-stack
))
1736 (string-to-char enumerating-symbol
))))))
1739 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." )))
1742 (put 'alphaenumerate
'texinfo-item
'texinfo-alphaenumerate-item
)
1743 (defun texinfo-alphaenumerate-item ()
1744 (texinfo-discard-line)
1745 (let ((next (1+ (car (cdr (car texinfo-stack
))))))
1747 (error "More than 26 items in @alphaenumerate; get a bigger alphabet"))
1748 (setcar (cdr (car texinfo-stack
)) next
)
1749 (insert "\b " next
". \n"))
1752 (put 'capsenumerate
'texinfo-item
'texinfo-capsenumerate-item
)
1753 (defun texinfo-capsenumerate-item ()
1754 (texinfo-discard-line)
1755 (let ((next (1+ (car (cdr (car texinfo-stack
))))))
1757 (error "More than 26 items in @capsenumerate; get a bigger alphabet"))
1758 (setcar (cdr (car texinfo-stack
)) next
)
1759 (insert "\b " next
". \n"))
1765 ;; The `@table' command produces two-column tables.
1767 (put 'table
'texinfo-format
'texinfo-table
)
1768 (defun texinfo-table ()
1771 (progn (skip-chars-forward " \t")
1774 (texinfo-parse-line-arg))))
1775 (texinfo-discard-line-with-args)
1776 (setq fill-column
(- fill-column
5)))
1778 (put 'table
'texinfo-item
'texinfo-table-item
)
1779 (defun texinfo-table-item ()
1780 (let ((arg (texinfo-parse-arg-discard))
1781 (itemfont (car (cdr (car texinfo-stack
)))))
1782 (insert ?
\b itemfont ?\
{ arg
"}\n \n"))
1785 (put 'table
'texinfo-end
'texinfo-end-table
)
1786 (defun texinfo-end-table ()
1787 (setq fill-column
(+ fill-column
5))
1788 (texinfo-discard-command)
1790 (texinfo-pop-stack 'table
)))
1791 (texinfo-do-itemize (nth 1 stacktop
))))
1793 ;; @description appears to be an undocumented variant on @table that
1794 ;; does not require an arg. It fails in texinfo.tex 2.58 and is not
1795 ;; part of makeinfo.c The command appears to be a relic of the past.
1796 (put 'description
'texinfo-end
'texinfo-end-table
)
1797 (put 'description
'texinfo-format
'texinfo-description
)
1798 (defun texinfo-description ()
1799 (texinfo-push-stack 'table
"@asis")
1800 (setq fill-column
(- fill-column
5))
1801 (texinfo-discard-line))
1804 ;;; @ftable, @vtable
1806 ;; The `@ftable' and `@vtable' commands are like the `@table' command
1807 ;; but they also insert each entry in the first column of the table
1808 ;; into the function or variable index.
1810 ;; Handle the @ftable and @vtable commands:
1812 (put 'ftable
'texinfo-format
'texinfo-ftable
)
1813 (put 'vtable
'texinfo-format
'texinfo-vtable
)
1815 (defun texinfo-ftable () (texinfo-indextable 'ftable
))
1816 (defun texinfo-vtable () (texinfo-indextable 'vtable
))
1818 (defun texinfo-indextable (table-type)
1819 (texinfo-push-stack table-type
(texinfo-parse-arg-discard))
1820 (setq fill-column
(- fill-column
5)))
1822 ;; Handle the @item commands within ftable and vtable:
1824 (put 'ftable
'texinfo-item
'texinfo-ftable-item
)
1825 (put 'vtable
'texinfo-item
'texinfo-vtable-item
)
1827 (defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex
))
1828 (defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex
))
1830 (defun texinfo-indextable-item (index-type)
1831 (let ((item (texinfo-parse-arg-discard))
1832 (itemfont (car (cdr (car texinfo-stack
))))
1833 (indexvar index-type
))
1834 (insert ?
\b itemfont ?\
{ item
"}\n \n")
1837 (list item texinfo-last-node
)
1838 (symbol-value indexvar
)))
1841 ;; Handle @end ftable, @end vtable
1843 (put 'ftable
'texinfo-end
'texinfo-end-ftable
)
1844 (put 'vtable
'texinfo-end
'texinfo-end-vtable
)
1846 (defun texinfo-end-ftable () (texinfo-end-indextable 'ftable
))
1847 (defun texinfo-end-vtable () (texinfo-end-indextable 'vtable
))
1849 (defun texinfo-end-indextable (table-type)
1850 (setq fill-column
(+ fill-column
5))
1851 (texinfo-discard-command)
1853 (texinfo-pop-stack table-type
)))
1854 (texinfo-do-itemize (nth 1 stacktop
))))
1857 ;;; @multitable ... @end multitable
1859 ;; Produce a multi-column table, with as many columns as desired.
1861 ;; A multi-column table has this template:
1863 ;; @multitable {A1} {A2} {A3}
1864 ;; @item A1 @tab A2 @tab A3
1865 ;; @item B1 @tab B2 @tab B3
1866 ;; @item C1 @tab C2 @tab C3
1869 ;; where the width of the text in brackets specifies the width of the
1870 ;; respective column.
1874 ;; @multitable @columnfractions .25 .3 .45
1875 ;; @item A1 @tab A2 @tab A3
1876 ;; @item B1 @tab B2 @tab B3
1879 ;; where the fractions specify the width of each column as a percent
1880 ;; of the current width of the text (i.e., of the fill-column).
1882 ;; Long lines of text are filled within columns.
1884 ;; Using the Emacs Lisp formatter, texinfmt.el,
1885 ;; the whitespace between columns can be increased by setting
1886 ;; `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1887 ;; there is at least one blank space between columns.
1889 ;; The Emacs Lisp formatter, texinfmt.el, ignores the following four
1890 ;; commands that are defined in texinfo.tex for printed output.
1892 ;; @multitableparskip,
1893 ;; @multitableparindent,
1894 ;; @multitablecolmargin,
1895 ;; @multitablelinespace.
1897 ;; How @multitable works.
1898 ;; =====================
1900 ;; `texinfo-multitable' reads the @multitable line and determines from it
1901 ;; how wide each column should be.
1903 ;; Also, it pushes this information, along with an identifying symbol,
1904 ;; onto the `texinfo-stack'. At the @end multitable command, the stack
1905 ;; is checked for its matching @multitable command, and then popped, or
1906 ;; else an error is signaled. Also, this command pushes the location of
1907 ;; the start of the table onto the stack.
1909 ;; `texinfo-end-multitable' checks the `texinfo-stack' that the @end
1910 ;; multitable truly is ending a corresponding beginning, and if it is,
1913 ;; `texinfo-multitable-widths' is called by `texinfo-multitable'.
1914 ;; The function returns a list of the widths of each column in a
1915 ;; multi-column table, based on the information supplied by the arguments
1916 ;; to the @multitable command (by arguments, I mean the text on the rest
1917 ;; of the @multitable line, not the remainder of the multi-column table
1920 ;; `texinfo-multitable-item' formats a row within a multicolumn table.
1921 ;; This command is executed when texinfmt sees @item inside @multitable.
1922 ;; Cells in row are separated by `@tab's. Widths of cells are specified
1923 ;; by the arguments in the @multitable line. Cells are filled. All cells
1924 ;; are made to be the same height by padding their bottoms, as needed,
1927 ;; `texinfo-multitable-extract-row' is called by `texinfo-multitable-item'.
1928 ;; This function returns the text in a multitable row, as a string.
1929 ;; The start of a row is marked by an @item and the end of row is the
1930 ;; beginning of next @item or beginning of the @end multitable line.
1931 ;; Cells within a row are separated by @tab.
1933 ;; Note that @tab, the cell separators, are not treated as independent
1934 ;; Texinfo commands.
1936 (defvar texinfo-extra-inter-column-width
0
1937 "*Number of extra spaces between entries (columns) in @multitable.")
1939 (defvar texinfo-multitable-buffer-name
"*multitable-temporary-buffer*")
1940 (defvar texinfo-multitable-rectangle-name
"texinfo-multitable-temp-")
1942 ;; These commands are defined in texinfo.tex for printed output.
1943 (put 'multitableparskip
'texinfo-format
'texinfo-discard-line-with-args
)
1944 (put 'multitableparindent
'texinfo-format
'texinfo-discard-line-with-args
)
1945 (put 'multitablecolmargin
'texinfo-format
'texinfo-discard-line-with-args
)
1946 (put 'multitablelinespace
'texinfo-format
'texinfo-discard-line-with-args
)
1948 (put 'multitable
'texinfo-format
'texinfo-multitable
)
1950 (defun texinfo-multitable ()
1951 "Produce multi-column tables.
1953 A multi-column table has this template:
1955 @multitable {A1} {A2} {A3}
1956 @item A1 @tab A2 @tab A3
1957 @item B1 @tab B2 @tab B3
1958 @item C1 @tab C2 @tab C3
1961 where the width of the text in brackets specifies the width of the
1966 @multitable @columnfractions .25 .3 .45
1967 @item A1 @tab A2 @tab A3
1968 @item B1 @tab B2 @tab B3
1971 where the fractions specify the width of each column as a percent
1972 of the current width of the text (i.e., of the fill-column).
1974 Long lines of text are filled within columns.
1976 Using the Emacs Lisp formatter, texinfmt.el,
1977 the whitespace between columns can be increased by setting
1978 `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1979 there is at least one blank space between columns.
1981 The Emacs Lisp formatter, texinfmt.el, ignores the following four
1982 commands that are defined in texinfo.tex for printed output.
1985 @multitableparindent,
1986 @multitablecolmargin,
1987 @multitablelinespace."
1989 ;; This function pushes information onto the `texinfo-stack'.
1990 ;; A stack element consists of:
1991 ;; - type-of-command, i.e., multitable
1992 ;; - the information about column widths, and
1993 ;; - the position of texinfo-command-start.
1994 ;; e.g., ('multitable (1 2 3 4) 123)
1995 ;; The command line is then deleted.
1998 ;; push width information on stack
1999 (texinfo-multitable-widths))
2000 (texinfo-discard-line-with-args))
2002 (put 'multitable
'texinfo-end
'texinfo-end-multitable
)
2003 (defun texinfo-end-multitable ()
2004 "Discard the @end multitable line and pop the stack of multitable."
2005 (texinfo-discard-command)
2006 (texinfo-pop-stack 'multitable
))
2008 (defun texinfo-multitable-widths ()
2009 "Return list of widths of each column in a multi-column table."
2010 (let (texinfo-multitable-width-list)
2011 ;; Fractions format:
2012 ;; @multitable @columnfractions .25 .3 .45
2015 ;; @multitable {Column 1 template} {Column 2} {Column 3 example}
2016 ;; Place point before first argument
2017 (skip-chars-forward " \t")
2019 ;; Check for common misspelling
2020 ((looking-at "@columnfraction ")
2021 (error "In @multitable, @columnfractions misspelled"))
2022 ;; Case 1: @columnfractions .25 .3 .45
2023 ((looking-at "@columnfractions")
2026 (setq texinfo-multitable-width-list
2030 (* fill-column
(read (get-buffer (current-buffer))))))
2031 texinfo-multitable-width-list
))))
2033 ;; Case 2: {Column 1 template} {Column 2} {Column 3 example}
2035 (let ((start-of-templates (point)))
2037 (skip-chars-forward " \t")
2038 (let* ((start-of-template (1+ (point)))
2040 ;; forward-sexp works with braces in Texinfo mode
2041 (progn (forward-sexp 1) (1- (point)))))
2042 (setq texinfo-multitable-width-list
2043 (cons (- end-of-template start-of-template
)
2044 texinfo-multitable-width-list
))
2045 ;; Remove carriage return from within a template, if any.
2046 ;; This helps those those who want to use more than
2047 ;; one line's worth of words in @multitable line.
2048 (narrow-to-region start-of-template end-of-template
)
2049 (goto-char (point-min))
2050 (while (search-forward "
2053 (goto-char (point-max))
2055 (forward-char 1)))))
2060 "You probably need to specify column widths for @multitable correctly.")))
2061 ;; Check whether columns fit on page.
2062 (let ((desired-columns
2064 ;; between column spaces
2065 (length texinfo-multitable-width-list
)
2066 ;; additional between column spaces, if any
2067 texinfo-extra-inter-column-width
2068 ;; sum of spaces for each entry
2069 (apply '+ texinfo-multitable-width-list
))))
2070 (if (> desired-columns fill-column
)
2073 "Multi-column table width, %d chars, is greater than page width, %d chars."
2074 desired-columns fill-column
))))
2075 texinfo-multitable-width-list
))
2077 ;; @item A1 @tab A2 @tab A3
2078 (defun texinfo-multitable-extract-row ()
2079 "Return multitable row, as a string.
2080 End of row is beginning of next @item or beginning of @end.
2081 Cells within rows are separated by @tab."
2082 (skip-chars-forward " \t")
2083 (let* ((start (point))
2085 (re-search-forward "@item\\|@end")
2086 (match-beginning 0)))
2087 (row (progn (goto-char end
)
2088 (skip-chars-backward " ")
2089 ;; remove whitespace at end of argument
2090 (delete-region (point) end
)
2091 (buffer-substring-no-properties start
(point)))))
2092 (delete-region texinfo-command-start end
)
2095 (put 'multitable
'texinfo-item
'texinfo-multitable-item
)
2096 (defun texinfo-multitable-item ()
2097 "Format a row within a multicolumn table.
2098 Cells in row are separated by @tab.
2099 Widths of cells are specified by the arguments in the @multitable line.
2100 All cells are made to be the same height.
2101 This command is executed when texinfmt sees @item inside @multitable."
2102 (let ((original-buffer (current-buffer))
2103 (table-widths (reverse (car (cdr (car texinfo-stack
)))))
2104 (existing-fill-column fill-column
)
2108 (table-entry-height 0)
2109 ;; unformatted row looks like: A1 @tab A2 @tab A3
2110 ;; extract-row command deletes the source line in the table.
2111 (unformated-row (texinfo-multitable-extract-row)))
2112 ;; Use a temporary buffer
2113 (set-buffer (get-buffer-create texinfo-multitable-buffer-name
))
2114 (delete-region (point-min) (point-max))
2115 (insert unformated-row
)
2116 (goto-char (point-min))
2117 ;; 1. Check for correct number of @tab in line.
2118 (let ((tab-number 1)) ; one @tab between two columns
2119 (while (search-forward "@tab" nil t
)
2120 (setq tab-number
(1+ tab-number
)))
2121 (if (/= tab-number
(length table-widths
))
2122 (error "Wrong number of @tab's in a @multitable row")))
2123 (goto-char (point-min))
2124 ;; 2. Format each cell, and copy to a rectangle
2125 ;; buffer looks like this: A1 @tab A2 @tab A3
2126 ;; Cell #1: format up to @tab
2127 ;; Cell #2: format up to @tab
2128 ;; Cell #3: format up to eob
2130 (setq start
(point))
2131 (setq end
(save-excursion
2132 (if (search-forward "@tab" nil
'move
)
2133 ;; Delete the @tab command, including the @-sign
2136 (progn (forward-word -
1) (1- (point)))))
2138 ;; Set fill-column *wider* than needed to produce inter-column space
2139 (setq fill-column
(+ 1
2140 texinfo-extra-inter-column-width
2141 (nth table-column table-widths
)))
2142 (narrow-to-region start end
)
2143 ;; Remove whitespace before and after entry.
2144 (skip-chars-forward " ")
2145 (delete-region (point) (save-excursion (beginning-of-line) (point)))
2146 (goto-char (point-max))
2147 (skip-chars-backward " ")
2148 (delete-region (point) (save-excursion (end-of-line) (point)))
2149 ;; Temporarily set texinfo-stack to nil so texinfo-format-scan
2150 ;; does not see an unterminated @multitable.
2151 (let (texinfo-stack) ; nil
2152 (texinfo-format-scan))
2153 (let (fill-prefix) ; no fill prefix
2154 (fill-region (point-min) (point-max)))
2155 (setq table-entry-height
2156 (max table-entry-height
(count-lines (point-min) (point-max))))
2157 ;; 3. Move point to end of bottom line, and pad that line to fill column.
2158 (goto-char (point-min))
2159 (forward-line (1- table-entry-height
))
2160 (let* ((beg (point)) ; beginning of line
2161 ;; add one more space for inter-column spacing
2166 (progn (end-of-line) (point)) ; end of existing line
2168 (insert (make-string
2169 (if (> needed-whitespace
0) needed-whitespace
1)
2171 ;; now, put formatted cell into a rectangle
2172 (set (intern (concat texinfo-multitable-rectangle-name
2173 (int-to-string table-column
)))
2174 (extract-rectangle (point-min) (point)))
2175 (delete-region (point-min) (point))
2176 (goto-char (point-max))
2177 (setq table-column
(1+ table-column
))
2179 ;; 4. Add extra lines to rectangles so all are of same height
2180 (let ((total-number-of-columns table-column
)
2183 (while (> table-column
0)
2184 (let ((this-rectangle (int-to-string table-column
)))
2185 (while (< (length this-rectangle
) table-entry-height
)
2186 (setq this-rectangle
(append this-rectangle
'("")))))
2187 (setq table-column
(1- table-column
)))
2188 ;; 5. Insert formatted rectangles in original buffer
2189 (switch-to-buffer original-buffer
)
2190 (open-line table-entry-height
)
2191 (while (< column-number total-number-of-columns
)
2195 (concat texinfo-multitable-rectangle-name
2196 (int-to-string column-number
)))))
2199 (setq column-number
(1+ column-number
))))
2200 (kill-buffer texinfo-multitable-buffer-name
)
2201 (setq fill-column existing-fill-column
)))
2205 ;; Use only the FILENAME argument to the command.
2206 ;; In Info, ignore the other arguments.
2208 (put 'image
'texinfo-format
'texinfo-format-image
)
2209 (defun texinfo-format-image ()
2210 "Insert an image from an an file ending in .txt.
2211 Use only the FILENAME arg; for Info, ignore the other arguments to @image."
2212 (let ((args (texinfo-format-parse-args))
2214 (when (null (nth 0 args
))
2215 (error "Invalid image command"))
2216 (texinfo-discard-command)
2217 ;; makeinfo uses FILENAME.txt
2218 (setq filename
(format "%s.txt" (nth 0 args
)))
2219 (message "Reading included file: %s" filename
)
2220 ;; verbatim for Info output
2221 (goto-char (+ (point) (cadr (insert-file-contents filename
))))
2222 (message "Reading included file: %s...done" filename
)))
2225 ;;; @ifinfo, @iftex, @tex, @ifhtml, @html, @ifplaintext, @ifxml, @xml
2226 ;; @ifnottex, @ifnotinfo, @ifnothtml, @ifnotplaintext, @ifnotxml
2228 (put 'ifinfo
'texinfo-format
'texinfo-discard-line
)
2229 (put 'ifinfo
'texinfo-end
'texinfo-discard-command
)
2231 (put 'iftex
'texinfo-format
'texinfo-format-iftex
)
2232 (defun texinfo-format-iftex ()
2233 (delete-region texinfo-command-start
2234 (re-search-forward "@end iftex[ \t]*\n")))
2236 (put 'ifhtml
'texinfo-format
'texinfo-format-ifhtml
)
2237 (defun texinfo-format-ifhtml ()
2238 (delete-region texinfo-command-start
2239 (re-search-forward "@end ifhtml[ \t]*\n")))
2241 (put 'ifplaintext
'texinfo-format
'texinfo-format-ifplaintext
)
2242 (defun texinfo-format-ifplaintext ()
2243 (delete-region texinfo-command-start
2244 (re-search-forward "@end ifplaintext[ \t]*\n")))
2246 (put 'ifxml
'texinfo-format
'texinfo-format-ifxml
)
2247 (defun texinfo-format-ifxml ()
2248 (delete-region texinfo-command-start
2249 (progn (re-search-forward "^@end ifxml[ \t]*\n")
2252 (put 'tex
'texinfo-format
'texinfo-format-tex
)
2253 (defun texinfo-format-tex ()
2254 (delete-region texinfo-command-start
2255 (re-search-forward "@end tex[ \t]*\n")))
2257 (put 'html
'texinfo-format
'texinfo-format-html
)
2258 (defun texinfo-format-html ()
2259 (delete-region texinfo-command-start
2260 (re-search-forward "@end html[ \t]*\n")))
2262 (put 'xml
'texinfo-format
'texinfo-format-xml
)
2263 (defun texinfo-format-xml ()
2264 (delete-region texinfo-command-start
2265 (progn (re-search-forward "^@end xml[ \t]*\n")
2268 (put 'ifnotinfo
'texinfo-format
'texinfo-format-ifnotinfo
)
2269 (defun texinfo-format-ifnotinfo ()
2270 (delete-region texinfo-command-start
2271 (re-search-forward "@end ifnotinfo[ \t]*\n")))
2273 (put 'ifnotplaintext
'texinfo-format
'texinfo-discard-line
)
2274 (put 'ifnotplaintext
'texinfo-end
'texinfo-discard-command
)
2276 (put 'ifnottex
'texinfo-format
'texinfo-discard-line
)
2277 (put 'ifnottex
'texinfo-end
'texinfo-discard-command
)
2279 (put 'ifnothtml
'texinfo-format
'texinfo-discard-line
)
2280 (put 'ifnothtml
'texinfo-end
'texinfo-discard-command
)
2282 (put 'ifnotxml
'texinfo-format
'texinfo-discard-line
)
2283 (put 'ifnotxml
'texinfo-end
'texinfo-discard-command
)
2288 (put 'titlepage
'texinfo-format
'texinfo-format-titlepage
)
2289 (defun texinfo-format-titlepage ()
2290 (delete-region texinfo-command-start
2291 (re-search-forward "@end titlepage[ \t]*\n")))
2293 (put 'endtitlepage
'texinfo-format
'texinfo-discard-line
)
2295 ;; @titlespec an alternative titling command; ignored by Info
2297 (put 'titlespec
'texinfo-format
'texinfo-format-titlespec
)
2298 (defun texinfo-format-titlespec ()
2299 (delete-region texinfo-command-start
2300 (re-search-forward "@end titlespec[ \t]*\n")))
2302 (put 'endtitlespec
'texinfo-format
'texinfo-discard-line
)
2307 (put 'today
'texinfo-format
'texinfo-format-today
)
2309 ;; Produces Day Month Year style of output. eg `1 Jan 1900'
2310 ;; The `@today{}' command requires a pair of braces, like `@dots{}'.
2311 (defun texinfo-format-today ()
2312 (texinfo-parse-arg-discard)
2313 (insert (format-time-string "%e %b %Y")))
2317 ;; Produce `Day Month Year Hour:Min' style of output.
2318 ;; eg `1 Jan 1900 13:52'
2320 (put 'timestamp
'texinfo-format
'texinfo-format-timestamp
)
2322 ;; The `@timestamp{}' command requires a pair of braces, like `@dots{}'.
2323 (defun texinfo-format-timestamp ()
2324 "Insert the current local time and date."
2325 (texinfo-parse-arg-discard)
2326 ;; For seconds and time zone, replace format string with "%e %b %Y %T %Z"
2327 (insert (format-time-string "%e %b %Y %R")))
2332 (put 'ignore
'texinfo-format
'texinfo-format-ignore
)
2333 (defun texinfo-format-ignore ()
2334 (delete-region texinfo-command-start
2335 (re-search-forward "@end ignore[ \t]*\n")))
2337 (put 'endignore
'texinfo-format
'texinfo-discard-line
)
2340 ;;; Define the Info enclosure command: @definfoenclose
2342 ;; A `@definfoenclose' command may be used to define a highlighting
2343 ;; command for Info, but not for TeX. A command defined using
2344 ;; `@definfoenclose' marks text by enclosing it in strings that precede
2345 ;; and follow the text.
2347 ;; Presumably, if you define a command with `@definfoenclose` for Info,
2348 ;; you will also define the same command in the TeX definitions file,
2349 ;; `texinfo.tex' in a manner appropriate for typesetting.
2351 ;; Write a `@definfoenclose' command on a line and follow it with three
2352 ;; arguments separated by commas (commas are used as separators in an
2353 ;; `@node' line in the same way). The first argument to
2354 ;; `@definfoenclose' is the @-command name \(without the `@'\); the
2355 ;; second argument is the Info start delimiter string; and the third
2356 ;; argument is the Info end delimiter string. The latter two arguments
2357 ;; enclose the highlighted text in the Info file. A delimiter string
2358 ;; may contain spaces. Neither the start nor end delimiter is
2359 ;; required. However, if you do not provide a start delimiter, you
2360 ;; must follow the command name with two commas in a row; otherwise,
2361 ;; the Info formatting commands will misinterpret the end delimiter
2362 ;; string as a start delimiter string.
2364 ;; If you do a @definfoenclose{} on the name of a pre-defined macro (such
2365 ;; as @emph{}, @strong{}, @tt{}, or @i{}) the enclosure definition will
2366 ;; override the built-in definition.
2368 ;; An enclosure command defined this way takes one argument in braces.
2370 ;; For example, you can write:
2373 ;; @definfoenclose phoo, //, \\
2376 ;; near the beginning of a Texinfo file at the beginning of the lines
2377 ;; to define `@phoo' as an Info formatting command that inserts `//'
2378 ;; before and `\\' after the argument to `@phoo'. You can then write
2379 ;; `@phoo{bar}' wherever you want `//bar\\' highlighted in Info.
2381 ;; Also, for TeX formatting, you could write
2384 ;; @global@let@phoo=@i
2387 ;; to define `@phoo' as a command that causes TeX to typeset
2388 ;; the argument to `@phoo' in italics.
2390 ;; Note that each definition applies to its own formatter: one for TeX,
2391 ;; the other for texinfo-format-buffer or texinfo-format-region.
2393 ;; Here is another example: write
2395 ;; @definfoenclose headword, , :
2397 ;; near the beginning of the file, to define `@headword' as an Info
2398 ;; formatting command that inserts nothing before and a colon after the
2399 ;; argument to `@headword'.
2401 (put 'definfoenclose
'texinfo-format
'texinfo-define-info-enclosure
)
2402 (defun texinfo-define-info-enclosure ()
2403 (let* ((args (texinfo-format-parse-line-args))
2404 (command-name (nth 0 args
))
2405 (beginning-delimiter (or (nth 1 args
) ""))
2406 (end-delimiter (or (nth 2 args
) "")))
2407 (texinfo-discard-command)
2408 (setq texinfo-enclosure-list
2414 texinfo-enclosure-list
))))
2419 (put 'alias
'texinfo-format
'texinfo-alias
)
2420 (defun texinfo-alias ()
2421 (let ((start (1- (point)))
2423 (skip-chars-forward " ")
2424 (save-excursion (end-of-line) (setq texinfo-command-end
(point)))
2425 (if (not (looking-at "\\([^=]+\\)=\\(.*\\)"))
2426 (error "Invalid alias command")
2427 (setq texinfo-alias-list
2430 (match-string-no-properties 1)
2431 (match-string-no-properties 2))
2432 texinfo-alias-list
))
2433 (texinfo-discard-command))
2438 ;;; @var, @code and the like
2440 (put 'var
'texinfo-format
'texinfo-format-var
)
2441 ;; @sc a small caps font for TeX; formatted as `var' in Info
2442 (put 'sc
'texinfo-format
'texinfo-format-var
)
2443 ;; @acronym for abbreviations in all caps, such as `NASA'.
2444 ;; Convert all letters to uppercase if they are not already.
2445 (put 'acronym
'texinfo-format
'texinfo-format-var
)
2446 (defun texinfo-format-var ()
2447 (let ((arg (texinfo-parse-expanded-arg)))
2448 (texinfo-discard-command)
2449 (insert (upcase arg
))))
2451 (put 'cite
'texinfo-format
'texinfo-format-code
)
2452 (put 'code
'texinfo-format
'texinfo-format-code
)
2453 ;; @command (for command names)
2454 (put 'command
'texinfo-format
'texinfo-format-code
)
2455 ;; @env (for environment variables)
2456 (put 'env
'texinfo-format
'texinfo-format-code
)
2457 (put 'file
'texinfo-format
'texinfo-format-code
)
2458 (put 'samp
'texinfo-format
'texinfo-format-code
)
2459 (put 'url
'texinfo-format
'texinfo-format-code
)
2460 (defun texinfo-format-code ()
2461 (insert "`" (texinfo-parse-arg-discard) "'")
2462 (goto-char texinfo-command-start
))
2464 ;; @option (for command-line options) must be different from @code
2465 ;; because of its special formatting in @table; namely that it does
2466 ;; not lead to inserted ` ... ' in a table, but does elsewhere.
2467 (put 'option
'texinfo-format
'texinfo-format-option
)
2468 (defun texinfo-format-option ()
2469 "Insert ` ... ' around arg unless inside a table; in that case, no quotes."
2470 ;; `looking-at-backward' not available in v. 18.57, 20.2
2471 (if (not (search-backward "\b" ; searched-for character is a control-H
2472 (save-excursion (beginning-of-line) (point))
2474 (insert "`" (texinfo-parse-arg-discard) "'")
2475 (insert (texinfo-parse-arg-discard)))
2476 (goto-char texinfo-command-start
))
2478 (put 'emph
'texinfo-format
'texinfo-format-emph
)
2479 (put 'strong
'texinfo-format
'texinfo-format-emph
)
2480 (defun texinfo-format-emph ()
2481 (insert "*" (texinfo-parse-arg-discard) "*")
2482 (goto-char texinfo-command-start
))
2484 (put 'dfn
'texinfo-format
'texinfo-format-defn
)
2485 (put 'defn
'texinfo-format
'texinfo-format-defn
)
2486 (defun texinfo-format-defn ()
2487 (insert "\"" (texinfo-parse-arg-discard) "\"")
2488 (goto-char texinfo-command-start
))
2490 (put 'email
'texinfo-format
'texinfo-format-email
)
2491 (defun texinfo-format-email ()
2492 "Format email address and optional following full name.
2493 Insert full name, if present, followed by email address
2494 surrounded by in angle brackets."
2495 (let ((args (texinfo-format-parse-args)))
2496 (texinfo-discard-command)
2499 (insert (nth 1 args
) " "))
2500 (insert "<" (nth 0 args
) ">")))
2502 (put 'key
'texinfo-format
'texinfo-format-key
)
2503 ;; I've decided not want to have angle brackets around these -- rms.
2504 (defun texinfo-format-key ()
2505 (insert (texinfo-parse-arg-discard))
2506 (goto-char texinfo-command-start
))
2508 ;; @verb{<char>TEXT<char>} (in `makeinfo' 4.1 and later)
2509 (put 'verb
'texinfo-format
'texinfo-format-verb
)
2510 (defun texinfo-format-verb ()
2511 "Format text between non-quoted unique delimiter characters verbatim.
2512 Enclose the verbatim text, including the delimiters, in braces. Print
2513 text exactly as written (but not the delimiters) in a fixed-width.
2515 For example, @verb\{|@|\} results in @ and
2516 @verb\{+@'e?`!`+} results in @'e?`!`."
2518 (let ((delimiter (buffer-substring-no-properties
2519 (1+ texinfo-command-end
) (+ 2 texinfo-command-end
))))
2520 (unless (looking-at "{")
2521 (error "Not found: @verb start brace"))
2522 (delete-region texinfo-command-start
(+ 2 texinfo-command-end
))
2523 (search-forward delimiter
))
2524 (delete-backward-char 1)
2525 (unless (looking-at "}")
2526 (error "Not found: @verb end brace"))
2529 ;; as of 2002 Dec 10
2530 ;; see (texinfo)Block Enclosing Commands
2533 ;; as of 2002 Dec 10
2534 ;; see (texinfo)verbatiminclude
2535 ;; need: @verbatiminclude FILENAME
2537 (put 'bullet
'texinfo-format
'texinfo-format-bullet
)
2538 (defun texinfo-format-bullet ()
2539 "Insert an asterisk.
2540 If used within a line, follow `@bullet' with braces."
2541 (texinfo-optional-braces-discard)
2547 ;; Inside of @example ... @end example and similar environments,
2548 ;; @kbd does nothing; but outside of such environments, it places
2549 ;; single quotation marks around its argument.
2551 (defvar texinfo-format-kbd-regexp
2561 "Regexp specifying environments in which @kbd does not put `...'
2564 (defvar texinfo-format-kbd-end-regexp
2574 "Regexp specifying end of environments in which @kbd does not put `...'
2575 around argument. (See `texinfo-format-kbd-regexp')")
2577 (put 'kbd
'texinfo-format
'texinfo-format-kbd
)
2578 (defun texinfo-format-kbd ()
2579 "Place single quote marks around arg, except in @example and similar."
2580 ;; Search forward for @end example closer than an @example.
2581 ;; Can stop search at nearest @node or texinfo-section-types-regexp
2585 (concat "^@node\\|\\(" texinfo-section-types-regexp
"\\)")
2587 'move-to-end
) ; if necessary, return point at end of buffer
2591 (re-search-forward texinfo-format-kbd-regexp stop
'move-to-end
)
2593 (end-example-location
2595 (re-search-forward texinfo-format-kbd-end-regexp stop
'move-to-end
)
2597 ;; If inside @example, @end example will be closer than @example
2598 ;; or end of search i.e., end-example-location less than example-location
2599 (if (>= end-example-location example-location
)
2600 ;; outside an @example or equivalent
2601 (insert "`" (texinfo-parse-arg-discard) "'")
2602 ;; else, in @example; do not surround with `...'
2603 (insert (texinfo-parse-arg-discard)))
2604 (goto-char texinfo-command-start
)))
2607 ;;; @example, @lisp, @quotation, @display, @smalllisp, @smallexample,
2610 (put 'display
'texinfo-format
'texinfo-format-example
)
2611 (put 'smalldisplay
'texinfo-format
'texinfo-format-example
)
2612 (put 'example
'texinfo-format
'texinfo-format-example
)
2613 (put 'lisp
'texinfo-format
'texinfo-format-example
)
2614 (put 'quotation
'texinfo-format
'texinfo-format-example
)
2615 (put 'smallexample
'texinfo-format
'texinfo-format-example
)
2616 (put 'smalllisp
'texinfo-format
'texinfo-format-example
)
2617 (defun texinfo-format-example ()
2618 (texinfo-push-stack 'example nil
)
2619 (setq fill-column
(- fill-column
5))
2620 (texinfo-discard-line))
2622 (put 'example
'texinfo-end
'texinfo-end-example
)
2623 (put 'display
'texinfo-end
'texinfo-end-example
)
2624 (put 'smalldisplay
'texinfo-end
'texinfo-end-example
)
2625 (put 'lisp
'texinfo-end
'texinfo-end-example
)
2626 (put 'quotation
'texinfo-end
'texinfo-end-example
)
2627 (put 'smallexample
'texinfo-end
'texinfo-end-example
)
2628 (put 'smalllisp
'texinfo-end
'texinfo-end-example
)
2629 (defun texinfo-end-example ()
2630 (setq fill-column
(+ fill-column
5))
2631 (texinfo-discard-command)
2633 (texinfo-pop-stack 'example
)))
2634 (texinfo-do-itemize (nth 1 stacktop
))))
2636 (put 'exdent
'texinfo-format
'texinfo-format-exdent
)
2637 (defun texinfo-format-exdent ()
2638 (texinfo-discard-command)
2639 (delete-region (point)
2641 (skip-chars-forward " ")
2644 ;; Cancel out the deletion that texinfo-do-itemize
2645 ;; is going to do at the end of this line.
2651 ;; @direntry and @dircategory
2653 (put 'direntry
'texinfo-format
'texinfo-format-direntry
)
2654 (defun texinfo-format-direntry ()
2655 (texinfo-push-stack 'direntry nil
)
2656 (texinfo-discard-line)
2657 (insert "START-INFO-DIR-ENTRY\n"))
2659 (put 'direntry
'texinfo-end
'texinfo-end-direntry
)
2660 (defun texinfo-end-direntry ()
2661 (texinfo-discard-command)
2662 (insert "END-INFO-DIR-ENTRY\n\n")
2663 (texinfo-pop-stack 'direntry
))
2665 (put 'dircategory
'texinfo-format
'texinfo-format-dircategory
)
2666 (defun texinfo-format-dircategory ()
2667 (let ((str (texinfo-parse-arg-discard)))
2668 (delete-region (point)
2670 (skip-chars-forward " ")
2672 (insert "INFO-DIR-SECTION " str
"\n")))
2676 ;; The @cartouche command is a noop in Info; in a printed manual,
2677 ;; it makes a box with rounded corners.
2679 (put 'cartouche
'texinfo-format
'texinfo-discard-line
)
2680 (put 'cartouche
'texinfo-end
'texinfo-discard-command
)
2683 ;;; @flushleft and @format
2685 ;; The @flushleft command left justifies every line but leaves the
2686 ;; right end ragged. As far as Info is concerned, @flushleft is a
2687 ;; `do-nothing' command
2689 ;; The @format command is similar to @example except that it does not
2690 ;; indent; this means that in Info, @format is similar to @flushleft.
2692 (put 'format
'texinfo-format
'texinfo-format-flushleft
)
2693 (put 'smallformat
'texinfo-format
'texinfo-format-flushleft
)
2694 (put 'flushleft
'texinfo-format
'texinfo-format-flushleft
)
2695 (defun texinfo-format-flushleft ()
2696 (texinfo-discard-line))
2698 (put 'format
'texinfo-end
'texinfo-end-flushleft
)
2699 (put 'smallformat
'texinfo-end
'texinfo-end-flushleft
)
2700 (put 'flushleft
'texinfo-end
'texinfo-end-flushleft
)
2701 (defun texinfo-end-flushleft ()
2702 (texinfo-discard-command))
2707 ;; The @flushright command right justifies every line but leaves the
2708 ;; left end ragged. Spaces and tabs at the right ends of lines are
2709 ;; removed so that visible text lines up on the right side.
2711 (put 'flushright
'texinfo-format
'texinfo-format-flushright
)
2712 (defun texinfo-format-flushright ()
2713 (texinfo-push-stack 'flushright nil
)
2714 (texinfo-discard-line))
2716 (put 'flushright
'texinfo-end
'texinfo-end-flushright
)
2717 (defun texinfo-end-flushright ()
2718 (texinfo-discard-command)
2721 (texinfo-pop-stack 'flushright
)))
2723 (texinfo-do-flushright (nth 1 stacktop
))))
2725 (defun texinfo-do-flushright (from)
2727 (while (progn (forward-line -
1)
2736 (skip-chars-backward " \t")
2737 (delete-region (point) (progn (end-of-line) (point)))
2742 ;;; @ctrl, @TeX, @copyright, @minus, @dots, @enddots, @pounds
2744 (put 'ctrl
'texinfo-format
'texinfo-format-ctrl
)
2745 (defun texinfo-format-ctrl ()
2746 (let ((str (texinfo-parse-arg-discard)))
2747 (insert (logand 31 (aref str
0)))))
2749 (put 'TeX
'texinfo-format
'texinfo-format-TeX
)
2750 (defun texinfo-format-TeX ()
2751 (texinfo-parse-arg-discard)
2754 (put 'copyright
'texinfo-format
'texinfo-format-copyright
)
2755 (defun texinfo-format-copyright ()
2756 (texinfo-parse-arg-discard)
2759 (put 'minus
'texinfo-format
'texinfo-format-minus
)
2760 (defun texinfo-format-minus ()
2761 "Insert a minus sign.
2762 If used within a line, follow `@minus' with braces."
2763 (texinfo-optional-braces-discard)
2766 (put 'dots
'texinfo-format
'texinfo-format-dots
)
2767 (defun texinfo-format-dots ()
2768 (texinfo-parse-arg-discard)
2771 (put 'enddots
'texinfo-format
'texinfo-format-enddots
)
2772 (defun texinfo-format-enddots ()
2773 (texinfo-parse-arg-discard)
2776 (put 'pounds
'texinfo-format
'texinfo-format-pounds
)
2777 (defun texinfo-format-pounds ()
2778 (texinfo-parse-arg-discard)
2782 ;;; Refilling and indenting: @refill, @paragraphindent, @noindent
2784 ;;; Indent only those paragraphs that are refilled as a result of an
2785 ;;; @refill command.
2787 ;; * If the value is `asis', do not change the existing indentation at
2788 ;; the starts of paragraphs.
2790 ;; * If the value zero, delete any existing indentation.
2792 ;; * If the value is greater than zero, indent each paragraph by that
2793 ;; number of spaces.
2795 ;;; But do not refill paragraphs with an @refill command that are
2796 ;;; preceded by @noindent or are part of a table, list, or deffn.
2798 (defvar texinfo-paragraph-indent
"asis"
2799 "Number of spaces for @refill to indent a paragraph; else to leave as is.")
2801 (put 'paragraphindent
'texinfo-format
'texinfo-paragraphindent
)
2803 (defun texinfo-paragraphindent ()
2804 "Specify the number of spaces for @refill to indent a paragraph.
2805 Default is to leave the number of spaces as is."
2806 (let ((arg (texinfo-parse-arg-discard)))
2807 (if (string= "asis" arg
)
2808 (setq texinfo-paragraph-indent
"asis")
2809 (setq texinfo-paragraph-indent
(string-to-int arg
)))))
2811 (put 'refill
'texinfo-format
'texinfo-format-refill
)
2812 (defun texinfo-format-refill ()
2813 "Refill paragraph. Also, indent first line as set by @paragraphindent.
2814 Default is to leave paragraph indentation as is."
2815 (texinfo-discard-command)
2816 (let ((position (point-marker)))
2817 (forward-paragraph -
1)
2818 (if (looking-at "[ \t\n]*$") (forward-line 1))
2819 ;; Do not indent if an entry in a list, table, or deffn,
2820 ;; or if paragraph is preceded by @noindent.
2821 ;; Otherwise, indent
2823 ;; delete a @noindent line and do not indent paragraph
2824 ((save-excursion (forward-line -
1)
2825 (looking-at "^@noindent"))
2827 (delete-region (point) (progn (forward-line 1) (point))))
2828 ;; do nothing if "asis"
2829 ((equal texinfo-paragraph-indent
"asis"))
2830 ;; do no indenting in list, etc.
2831 ((> texinfo-stack-depth
0))
2832 ;; otherwise delete existing whitespace and indent
2834 (delete-region (point) (progn (skip-chars-forward " \t") (point)))
2835 (insert (make-string texinfo-paragraph-indent ?
))))
2836 (forward-paragraph 1)
2839 ;; Do not fill a section title line with asterisks, hyphens, etc. that
2840 ;; are used to underline it. This could occur if the line following
2841 ;; the underlining is not an index entry and has text within it.
2842 (let* ((previous-paragraph-separate paragraph-separate
)
2844 (concat paragraph-separate
"\\|[-=.]+\\|\\*\\*+"))
2845 (previous-paragraph-start paragraph-start
)
2847 (concat paragraph-start
"\\|[-=.]+\\|\\*\\*+")))
2849 (fill-paragraph nil
)
2850 (setq paragraph-separate previous-paragraph-separate
)
2851 (setq paragraph-start previous-paragraph-start
)))
2852 (goto-char position
)))
2854 (put 'noindent
'texinfo-format
'texinfo-noindent
)
2855 (defun texinfo-noindent ()
2857 (forward-paragraph 1)
2858 (if (search-backward "@refill"
2859 (save-excursion (forward-line -
1) (point)) t
)
2860 () ; leave @noindent command so @refill command knows not to indent
2862 (texinfo-discard-line))))
2865 ;;; Index generation
2867 (put 'vindex
'texinfo-format
'texinfo-format-vindex
)
2868 (defun texinfo-format-vindex ()
2869 (texinfo-index 'texinfo-vindex
))
2871 (put 'cindex
'texinfo-format
'texinfo-format-cindex
)
2872 (defun texinfo-format-cindex ()
2873 (texinfo-index 'texinfo-cindex
))
2875 (put 'findex
'texinfo-format
'texinfo-format-findex
)
2876 (defun texinfo-format-findex ()
2877 (texinfo-index 'texinfo-findex
))
2879 (put 'pindex
'texinfo-format
'texinfo-format-pindex
)
2880 (defun texinfo-format-pindex ()
2881 (texinfo-index 'texinfo-pindex
))
2883 (put 'tindex
'texinfo-format
'texinfo-format-tindex
)
2884 (defun texinfo-format-tindex ()
2885 (texinfo-index 'texinfo-tindex
))
2887 (put 'kindex
'texinfo-format
'texinfo-format-kindex
)
2888 (defun texinfo-format-kindex ()
2889 (texinfo-index 'texinfo-kindex
))
2891 (defun texinfo-index (indexvar)
2892 (let ((arg (texinfo-parse-expanded-arg)))
2893 (texinfo-discard-command)
2897 ;; Region formatting may not provide last node position.
2898 (if texinfo-last-node-pos
2899 (1+ (count-lines texinfo-last-node-pos
(point)))
2901 (symbol-value indexvar
)))))
2903 (defvar texinfo-indexvar-alist
2904 '(("cp" . texinfo-cindex
)
2905 ("fn" . texinfo-findex
)
2906 ("vr" . texinfo-vindex
)
2907 ("tp" . texinfo-tindex
)
2908 ("pg" . texinfo-pindex
)
2909 ("ky" . texinfo-kindex
)))
2912 ;;; @defindex @defcodeindex
2913 (put 'defindex
'texinfo-format
'texinfo-format-defindex
)
2914 (put 'defcodeindex
'texinfo-format
'texinfo-format-defindex
)
2916 (defun texinfo-format-defindex ()
2917 (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa'
2918 (indexing-command (intern (concat index-name
"index")))
2919 (index-formatting-command ; eg: `texinfo-format-aaindex'
2920 (intern (concat "texinfo-format-" index-name
"index")))
2921 (index-alist-name ; eg: `texinfo-aaindex'
2922 (intern (concat "texinfo-" index-name
"index"))))
2924 (set index-alist-name nil
)
2926 (put indexing-command
; eg, aaindex
2928 index-formatting-command
) ; eg, texinfo-format-aaindex
2930 ;; eg: "aa" . texinfo-aaindex
2931 (or (assoc index-name texinfo-indexvar-alist
)
2932 (setq texinfo-indexvar-alist
2936 texinfo-indexvar-alist
)))
2938 (fset index-formatting-command
2940 (list 'texinfo-index
2941 (list 'quote index-alist-name
))))))
2944 ;;; @synindex @syncodeindex
2946 (put 'synindex
'texinfo-format
'texinfo-format-synindex
)
2947 (put 'syncodeindex
'texinfo-format
'texinfo-format-synindex
)
2949 (defun texinfo-format-synindex ()
2950 (let* ((args (texinfo-parse-arg-discard))
2951 (second (cdr (read-from-string args
)))
2952 (joiner (symbol-name (car (read-from-string args
))))
2953 (joined (symbol-name (car (read-from-string args second
)))))
2955 (if (assoc joiner texinfo-short-index-cmds-alist
)
2957 (cdr (assoc joiner texinfo-short-index-cmds-alist
))
2959 (or (cdr (assoc joined texinfo-short-index-format-cmds-alist
))
2960 (intern (concat "texinfo-format-" joined
"index"))))
2962 (intern (concat joiner
"index"))
2964 (or (cdr(assoc joined texinfo-short-index-format-cmds-alist
))
2965 (intern (concat "texinfo-format-" joined
"index")))))))
2967 (defconst texinfo-short-index-cmds-alist
2975 (defconst texinfo-short-index-format-cmds-alist
2976 '(("cp" . texinfo-format-cindex
)
2977 ("fn" . texinfo-format-findex
)
2978 ("vr" . texinfo-format-vindex
)
2979 ("tp" . texinfo-format-tindex
)
2980 ("pg" . texinfo-format-pindex
)
2981 ("ky" . texinfo-format-kindex
)))
2984 ;;; Sort and index (for VMS)
2986 ;; Sort an index which is in the current buffer between START and END.
2987 ;; Used on VMS, where the `sort' utility is not available.
2988 (defun texinfo-sort-region (start end
)
2991 (narrow-to-region start end
)
2992 (goto-char (point-min))
2993 (sort-subr nil
'forward-line
'end-of-line
'texinfo-sort-startkeyfun
)))
2995 ;; Subroutine for sorting an index.
2996 ;; At start of a line, return a string to sort the line under.
2997 (defun texinfo-sort-startkeyfun ()
2998 (let ((line (buffer-substring-no-properties (point) (line-end-position))))
2999 ;; Canonicalize whitespace and eliminate funny chars.
3000 (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line
)
3001 (setq line
(concat (substring line
0 (match-beginning 0))
3003 (substring line
(match-end 0)))))
3009 (put 'printindex
'texinfo-format
'texinfo-format-printindex
)
3011 (defun texinfo-format-printindex ()
3012 (let ((indexelts (symbol-value
3013 (cdr (assoc (texinfo-parse-arg-discard)
3014 texinfo-indexvar-alist
))))
3016 (insert "\n* Menu:\n\n")
3017 (setq opoint
(point))
3018 (texinfo-print-index nil indexelts
)
3020 (if (memq system-type
'(vax-vms windows-nt ms-dos
))
3021 (texinfo-sort-region opoint
(point))
3022 (shell-command-on-region opoint
(point) "sort -fd" 1))))
3024 (defun texinfo-print-index (file indexelts
)
3026 (if (stringp (car (car indexelts
)))
3028 (insert "* " (car (car indexelts
)) ": " )
3031 (if file
(concat "(" file
")") "")
3032 (nth 1 (car indexelts
)) ".")
3035 (if (nth 2 (car indexelts
))
3036 (format " (line %3d)" (1+ (nth 2 (car indexelts
))))
3039 ;; index entries from @include'd file
3040 (texinfo-print-index (nth 1 (car indexelts
))
3041 (nth 2 (car indexelts
))))
3042 (setq indexelts
(cdr indexelts
))))
3045 ;;; Glyphs: @equiv, @error, etc
3047 ;; @equiv to show that two expressions are equivalent
3048 ;; @error to show an error message
3049 ;; @expansion to show what a macro expands to
3050 ;; @point to show the location of point in an example
3051 ;; @print to show what an evaluated expression prints
3052 ;; @result to indicate the value returned by an expression
3054 (put 'equiv
'texinfo-format
'texinfo-format-equiv
)
3055 (defun texinfo-format-equiv ()
3056 (texinfo-parse-arg-discard)
3059 (put 'error
'texinfo-format
'texinfo-format-error
)
3060 (defun texinfo-format-error ()
3061 (texinfo-parse-arg-discard)
3062 (insert "error-->"))
3064 (put 'expansion
'texinfo-format
'texinfo-format-expansion
)
3065 (defun texinfo-format-expansion ()
3066 (texinfo-parse-arg-discard)
3069 (put 'point
'texinfo-format
'texinfo-format-point
)
3070 (defun texinfo-format-point ()
3071 (texinfo-parse-arg-discard)
3074 (put 'print
'texinfo-format
'texinfo-format-print
)
3075 (defun texinfo-format-print ()
3076 (texinfo-parse-arg-discard)
3079 (put 'result
'texinfo-format
'texinfo-format-result
)
3080 (defun texinfo-format-result ()
3081 (texinfo-parse-arg-discard)
3087 ;; Info presumes a plain ASCII output, so the accented characters do
3088 ;; not look as they would if typeset, or output with a different
3091 ;; See the `texinfo-accent-commands' variable
3092 ;; in the section for `texinfo-append-refill'.
3093 ;; Also, see the defun for `texinfo-format-scan'
3094 ;; for single-character accent commands.
3096 ;; Command Info output Name
3098 ;; These do not have braces:
3099 ;; @^ ==> ^ circumflex accent
3100 ;; @` ==> ` grave accent
3101 ;; @' ==> ' acute accent
3102 ;; @" ==> " umlaut accent
3103 ;; @= ==> = overbar accent
3104 ;; @~ ==> ~ tilde accent
3106 ;; These have braces, but take no argument:
3107 ;; @OE{} ==> OE French-OE-ligature
3109 ;; @AA{} ==> AA Scandinavian-A-with-circle
3111 ;; @AE{} ==> AE Latin-Scandinavian-AE
3113 ;; @ss{} ==> ss German-sharp-S
3115 ;; @questiondown{} ==> ? upside-down-question-mark
3116 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
3117 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
3118 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
3119 ;; @O{} ==> O/ Scandinavian O-with-slash
3120 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
3122 ;; These have braces, and take an argument:
3123 ;; @,{c} ==> c, cedilla accent
3124 ;; @dotaccent{o} ==> .o overdot-accent
3125 ;; @ubaraccent{o} ==> _o underbar-accent
3126 ;; @udotaccent{o} ==> o-. underdot-accent
3127 ;; @H{o} ==> ""o long Hungarian umlaut
3128 ;; @ringaccent{o} ==> *o ring accent
3129 ;; @tieaccent{oo} ==> [oo tie after accent
3130 ;; @u{o} ==> (o breve accent
3131 ;; @v{o} ==> <o hacek accent
3132 ;; @dotless{i} ==> i dotless i and dotless j
3136 ;; Note: The defun texinfo-format-scan
3137 ;; looks at "[@{}^'`\",=~ *?!-]"
3138 ;; In the case of @*, a line break is inserted;
3139 ;; in the other cases, the characters are simply quoted and the @ is deleted.
3140 ;; Thus, `texinfo-format-scan' handles the following
3141 ;; single-character accent commands: @^ @` @' @" @, @- @= @~
3143 ;; @^ ==> ^ circumflex accent
3144 ;; (put '^ 'texinfo-format 'texinfo-format-circumflex-accent)
3145 ;; (defun texinfo-format-circumflex-accent ()
3146 ;; (texinfo-discard-command)
3149 ;; @` ==> ` grave accent
3150 ;; (put '\` 'texinfo-format 'texinfo-format-grave-accent)
3151 ;; (defun texinfo-format-grave-accent ()
3152 ;; (texinfo-discard-command)
3155 ;; @' ==> ' acute accent
3156 ;; (put '\' 'texinfo-format 'texinfo-format-acute-accent)
3157 ;; (defun texinfo-format-acute-accent ()
3158 ;; (texinfo-discard-command)
3161 ;; @" ==> " umlaut accent
3162 ;; (put '\" 'texinfo-format 'texinfo-format-umlaut-accent)
3163 ;; (defun texinfo-format-umlaut-accent ()
3164 ;; (texinfo-discard-command)
3167 ;; @= ==> = overbar accent
3168 ;; (put '= 'texinfo-format 'texinfo-format-overbar-accent)
3169 ;; (defun texinfo-format-overbar-accent ()
3170 ;; (texinfo-discard-command)
3173 ;; @~ ==> ~ tilde accent
3174 ;; (put '~ 'texinfo-format 'texinfo-format-tilde-accent)
3175 ;; (defun texinfo-format-tilde-accent ()
3176 ;; (texinfo-discard-command)
3179 ;; @OE{} ==> OE French-OE-ligature
3180 (put 'OE
'texinfo-format
'texinfo-format-French-OE-ligature
)
3181 (defun texinfo-format-French-OE-ligature ()
3182 (insert "OE" (texinfo-parse-arg-discard))
3183 (goto-char texinfo-command-start
))
3186 (put 'oe
'texinfo-format
'texinfo-format-French-oe-ligature
)
3187 (defun texinfo-format-French-oe-ligature () ; lower case
3188 (insert "oe" (texinfo-parse-arg-discard))
3189 (goto-char texinfo-command-start
))
3191 ;; @AA{} ==> AA Scandinavian-A-with-circle
3192 (put 'AA
'texinfo-format
'texinfo-format-Scandinavian-A-with-circle
)
3193 (defun texinfo-format-Scandinavian-A-with-circle ()
3194 (insert "AA" (texinfo-parse-arg-discard))
3195 (goto-char texinfo-command-start
))
3198 (put 'aa
'texinfo-format
'texinfo-format-Scandinavian-a-with-circle
)
3199 (defun texinfo-format-Scandinavian-a-with-circle () ; lower case
3200 (insert "aa" (texinfo-parse-arg-discard))
3201 (goto-char texinfo-command-start
))
3203 ;; @AE{} ==> AE Latin-Scandinavian-AE
3204 (put 'AE
'texinfo-format
'texinfo-format-Latin-Scandinavian-AE
)
3205 (defun texinfo-format-Latin-Scandinavian-AE ()
3206 (insert "AE" (texinfo-parse-arg-discard))
3207 (goto-char texinfo-command-start
))
3210 (put 'ae
'texinfo-format
'texinfo-format-Latin-Scandinavian-ae
)
3211 (defun texinfo-format-Latin-Scandinavian-ae () ; lower case
3212 (insert "ae" (texinfo-parse-arg-discard))
3213 (goto-char texinfo-command-start
))
3215 ;; @ss{} ==> ss German-sharp-S
3216 (put 'ss
'texinfo-format
'texinfo-format-German-sharp-S
)
3217 (defun texinfo-format-German-sharp-S ()
3218 (insert "ss" (texinfo-parse-arg-discard))
3219 (goto-char texinfo-command-start
))
3221 ;; @questiondown{} ==> ? upside-down-question-mark
3222 (put 'questiondown
'texinfo-format
'texinfo-format-upside-down-question-mark
)
3223 (defun texinfo-format-upside-down-question-mark ()
3224 (insert "?" (texinfo-parse-arg-discard))
3225 (goto-char texinfo-command-start
))
3227 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
3228 (put 'exclamdown
'texinfo-format
'texinfo-format-upside-down-exclamation-mark
)
3229 (defun texinfo-format-upside-down-exclamation-mark ()
3230 (insert "!" (texinfo-parse-arg-discard))
3231 (goto-char texinfo-command-start
))
3233 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
3234 (put 'L
'texinfo-format
'texinfo-format-Polish-suppressed-L
)
3235 (defun texinfo-format-Polish-suppressed-L ()
3236 (insert (texinfo-parse-arg-discard) "/L")
3237 (goto-char texinfo-command-start
))
3239 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
3240 (put 'l
'texinfo-format
'texinfo-format-Polish-suppressed-l-lower-case
)
3241 (defun texinfo-format-Polish-suppressed-l-lower-case ()
3242 (insert (texinfo-parse-arg-discard) "/l")
3243 (goto-char texinfo-command-start
))
3246 ;; @O{} ==> O/ Scandinavian O-with-slash
3247 (put 'O
'texinfo-format
'texinfo-format-Scandinavian-O-with-slash
)
3248 (defun texinfo-format-Scandinavian-O-with-slash ()
3249 (insert (texinfo-parse-arg-discard) "O/")
3250 (goto-char texinfo-command-start
))
3252 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
3253 (put 'o
'texinfo-format
'texinfo-format-Scandinavian-o-with-slash-lower-case
)
3254 (defun texinfo-format-Scandinavian-o-with-slash-lower-case ()
3255 (insert (texinfo-parse-arg-discard) "o/")
3256 (goto-char texinfo-command-start
))
3260 ;; @,{c} ==> c, cedilla accent
3261 (put ', 'texinfo-format
'texinfo-format-cedilla-accent
)
3262 (defun texinfo-format-cedilla-accent ()
3263 (insert (texinfo-parse-arg-discard) ",")
3264 (goto-char texinfo-command-start
))
3267 ;; @dotaccent{o} ==> .o overdot-accent
3268 (put 'dotaccent
'texinfo-format
'texinfo-format-overdot-accent
)
3269 (defun texinfo-format-overdot-accent ()
3270 (insert "." (texinfo-parse-arg-discard))
3271 (goto-char texinfo-command-start
))
3273 ;; @ubaraccent{o} ==> _o underbar-accent
3274 (put 'ubaraccent
'texinfo-format
'texinfo-format-underbar-accent
)
3275 (defun texinfo-format-underbar-accent ()
3276 (insert "_" (texinfo-parse-arg-discard))
3277 (goto-char texinfo-command-start
))
3279 ;; @udotaccent{o} ==> o-. underdot-accent
3280 (put 'udotaccent
'texinfo-format
'texinfo-format-underdot-accent
)
3281 (defun texinfo-format-underdot-accent ()
3282 (insert (texinfo-parse-arg-discard) "-.")
3283 (goto-char texinfo-command-start
))
3285 ;; @H{o} ==> ""o long Hungarian umlaut
3286 (put 'H
'texinfo-format
'texinfo-format-long-Hungarian-umlaut
)
3287 (defun texinfo-format-long-Hungarian-umlaut ()
3288 (insert "\"\"" (texinfo-parse-arg-discard))
3289 (goto-char texinfo-command-start
))
3291 ;; @ringaccent{o} ==> *o ring accent
3292 (put 'ringaccent
'texinfo-format
'texinfo-format-ring-accent
)
3293 (defun texinfo-format-ring-accent ()
3294 (insert "*" (texinfo-parse-arg-discard))
3295 (goto-char texinfo-command-start
))
3297 ;; @tieaccent{oo} ==> [oo tie after accent
3298 (put 'tieaccent
'texinfo-format
'texinfo-format-tie-after-accent
)
3299 (defun texinfo-format-tie-after-accent ()
3300 (insert "[" (texinfo-parse-arg-discard))
3301 (goto-char texinfo-command-start
))
3304 ;; @u{o} ==> (o breve accent
3305 (put 'u
'texinfo-format
'texinfo-format-breve-accent
)
3306 (defun texinfo-format-breve-accent ()
3307 (insert "(" (texinfo-parse-arg-discard))
3308 (goto-char texinfo-command-start
))
3310 ;; @v{o} ==> <o hacek accent
3311 (put 'v
'texinfo-format
'texinfo-format-hacek-accent
)
3312 (defun texinfo-format-hacek-accent ()
3313 (insert "<" (texinfo-parse-arg-discard))
3314 (goto-char texinfo-command-start
))
3317 ;; @dotless{i} ==> i dotless i and dotless j
3318 (put 'dotless
'texinfo-format
'texinfo-format-dotless
)
3319 (defun texinfo-format-dotless ()
3320 (insert (texinfo-parse-arg-discard))
3321 (goto-char texinfo-command-start
))
3324 ;;; Definition formatting: @deffn, @defun, etc
3326 ;; What definition formatting produces:
3328 ;; @deffn category name args...
3329 ;; In Info, `Category: name ARGS'
3330 ;; In index: name: node. line#.
3332 ;; @defvr category name
3333 ;; In Info, `Category: name'
3334 ;; In index: name: node. line#.
3336 ;; @deftp category name attributes...
3337 ;; `category name attributes...' Note: @deftp args in lower case.
3338 ;; In index: name: node. line#.
3340 ;; Specialized function-like or variable-like entity:
3342 ;; @defun, @defmac, @defspec, @defvar, @defopt
3344 ;; @defun name args In Info, `Function: name ARGS'
3345 ;; @defmac name args In Info, `Macro: name ARGS'
3346 ;; @defvar name In Info, `Variable: name'
3348 ;; In index: name: node. line#.
3350 ;; Generalized typed-function-like or typed-variable-like entity:
3351 ;; @deftypefn category data-type name args...
3352 ;; In Info, `Category: data-type name args...'
3353 ;; @deftypevr category data-type name
3354 ;; In Info, `Category: data-type name'
3355 ;; In index: name: node. line#.
3357 ;; Specialized typed-function-like or typed-variable-like entity:
3358 ;; @deftypefun data-type name args...
3359 ;; In Info, `Function: data-type name ARGS'
3360 ;; In index: name: node. line#.
3362 ;; @deftypevar data-type name
3363 ;; In Info, `Variable: data-type name'
3364 ;; In index: name: node. line#. but include args after name!?
3366 ;; Generalized object oriented entity:
3367 ;; @defop category class name args...
3368 ;; In Info, `Category on class: name ARG'
3369 ;; In index: name on class: node. line#.
3371 ;; @defcv category class name
3372 ;; In Info, `Category of class: name'
3373 ;; In index: name of class: node. line#.
3375 ;; Specialized object oriented entity:
3376 ;; @defmethod class name args...
3377 ;; In Info, `Method on class: name ARGS'
3378 ;; In index: name on class: node. line#.
3380 ;; @defivar class name
3381 ;; In Info, `Instance variable of class: name'
3382 ;; In index: name of class: node. line#.
3385 ;;; The definition formatting functions
3387 (defun texinfo-format-defun ()
3388 (texinfo-push-stack 'defun
nil)
3389 (setq fill-column
(- fill-column
5))
3390 (texinfo-format-defun-1 t
))
3392 (defun texinfo-end-defun ()
3393 (setq fill-column
(+ fill-column
5))
3394 (texinfo-discard-command)
3395 (let ((start (nth 1 (texinfo-pop-stack 'defun
))))
3396 (texinfo-do-itemize start
)
3397 ;; Delete extra newline inserted after header.
3402 (defun texinfo-format-defunx ()
3403 (texinfo-format-defun-1 nil
))
3405 (defun texinfo-format-defun-1 (first-p)
3406 (let ((parse-args (texinfo-format-parse-defun-args))
3407 (texinfo-defun-type (get texinfo-command-name
'texinfo-defun-type
)))
3408 (texinfo-discard-command)
3409 ;; Delete extra newline inserted after previous header line.
3413 (get texinfo-command-name
'texinfo-deffn-formatting-property
) parse-args
)
3414 ;; Insert extra newline so that paragraph filling does not mess
3415 ;; with header line.
3417 (rplaca (cdr (cdr (car texinfo-stack
))) (point))
3419 (get texinfo-command-name
'texinfo-defun-indexing-property
) parse-args
)))
3421 ;;; Formatting the first line of a definition
3423 ;; @deffn, @defvr, @deftp
3424 (put 'deffn
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3425 (put 'deffnx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3426 (put 'defvr
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3427 (put 'defvrx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3428 (put 'deftp
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3429 (put 'deftpx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3430 (defun texinfo-format-deffn (parsed-args)
3431 ;; Generalized function-like, variable-like, or generic data-type entity:
3432 ;; @deffn category name args...
3433 ;; In Info, `Category: name ARGS'
3434 ;; @deftp category name attributes...
3435 ;; `category name attributes...' Note: @deftp args in lower case.
3436 (let ((category (car parsed-args
))
3437 (name (car (cdr parsed-args
)))
3438 (args (cdr (cdr parsed-args
))))
3439 (insert " -- " category
": " name
)
3442 (if (or (= ?
& (aref (car args
) 0))
3443 (eq (eval (car texinfo-defun-type
)) 'deftp-type
))
3445 (upcase (car args
))))
3446 (setq args
(cdr args
)))))
3448 ;; @defun, @defmac, @defspec, @defvar, @defopt: Specialized, simple
3449 (put 'defun
'texinfo-deffn-formatting-property
3450 'texinfo-format-specialized-defun
)
3451 (put 'defunx
'texinfo-deffn-formatting-property
3452 'texinfo-format-specialized-defun
)
3453 (put 'defmac
'texinfo-deffn-formatting-property
3454 'texinfo-format-specialized-defun
)
3455 (put 'defmacx
'texinfo-deffn-formatting-property
3456 'texinfo-format-specialized-defun
)
3457 (put 'defspec
'texinfo-deffn-formatting-property
3458 'texinfo-format-specialized-defun
)
3459 (put 'defspecx
'texinfo-deffn-formatting-property
3460 'texinfo-format-specialized-defun
)
3461 (put 'defvar
'texinfo-deffn-formatting-property
3462 'texinfo-format-specialized-defun
)
3463 (put 'defvarx
'texinfo-deffn-formatting-property
3464 'texinfo-format-specialized-defun
)
3465 (put 'defopt
'texinfo-deffn-formatting-property
3466 'texinfo-format-specialized-defun
)
3467 (put 'defoptx
'texinfo-deffn-formatting-property
3468 'texinfo-format-specialized-defun
)
3469 (defun texinfo-format-specialized-defun (parsed-args)
3470 ;; Specialized function-like or variable-like entity:
3471 ;; @defun name args In Info, `Function: Name ARGS'
3472 ;; @defmac name args In Info, `Macro: Name ARGS'
3473 ;; @defvar name In Info, `Variable: Name'
3474 ;; Use cdr of texinfo-defun-type to determine category:
3475 (let ((category (car (cdr texinfo-defun-type
)))
3476 (name (car parsed-args
))
3477 (args (cdr parsed-args
)))
3478 (insert " -- " category
": " name
)
3481 (if (= ?
& (aref (car args
) 0))
3483 (upcase (car args
))))
3484 (setq args
(cdr args
)))))
3486 ;; @deftypefn, @deftypevr: Generalized typed
3487 (put 'deftypefn
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3488 (put 'deftypefnx
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3489 (put 'deftypevr
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3490 (put 'deftypevrx
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3491 (defun texinfo-format-deftypefn (parsed-args)
3492 ;; Generalized typed-function-like or typed-variable-like entity:
3493 ;; @deftypefn category data-type name args...
3494 ;; In Info, `Category: data-type name args...'
3495 ;; @deftypevr category data-type name
3496 ;; In Info, `Category: data-type name'
3497 ;; Note: args in lower case, unless modified in command line.
3498 (let ((category (car parsed-args
))
3499 (data-type (car (cdr parsed-args
)))
3500 (name (car (cdr (cdr parsed-args
))))
3501 (args (cdr (cdr (cdr parsed-args
)))))
3502 (insert " -- " category
": " data-type
" " name
)
3504 (insert " " (car args
))
3505 (setq args
(cdr args
)))))
3507 ;; @deftypefun, @deftypevar: Specialized typed
3508 (put 'deftypefun
'texinfo-deffn-formatting-property
'texinfo-format-deftypefun
)
3509 (put 'deftypefunx
'texinfo-deffn-formatting-property
3510 'texinfo-format-deftypefun
)
3511 (put 'deftypevar
'texinfo-deffn-formatting-property
'texinfo-format-deftypefun
)
3512 (put 'deftypevarx
'texinfo-deffn-formatting-property
3513 'texinfo-format-deftypefun
)
3514 (defun texinfo-format-deftypefun (parsed-args)
3515 ;; Specialized typed-function-like or typed-variable-like entity:
3516 ;; @deftypefun data-type name args...
3517 ;; In Info, `Function: data-type name ARGS'
3518 ;; @deftypevar data-type name
3519 ;; In Info, `Variable: data-type name'
3520 ;; Note: args in lower case, unless modified in command line.
3521 ;; Use cdr of texinfo-defun-type to determine category:
3522 (let ((category (car (cdr texinfo-defun-type
)))
3523 (data-type (car parsed-args
))
3524 (name (car (cdr parsed-args
)))
3525 (args (cdr (cdr parsed-args
))))
3526 (insert " -- " category
": " data-type
" " name
)
3528 (insert " " (car args
))
3529 (setq args
(cdr args
)))))
3531 ;; @defop: Generalized object-oriented
3532 (put 'defop
'texinfo-deffn-formatting-property
'texinfo-format-defop
)
3533 (put 'defopx
'texinfo-deffn-formatting-property
'texinfo-format-defop
)
3534 (defun texinfo-format-defop (parsed-args)
3535 ;; Generalized object oriented entity:
3536 ;; @defop category class name args...
3537 ;; In Info, `Category on class: name ARG'
3538 ;; Note: args in upper case; use of `on'
3539 (let ((category (car parsed-args
))
3540 (class (car (cdr parsed-args
)))
3541 (name (car (cdr (cdr parsed-args
))))
3542 (args (cdr (cdr (cdr parsed-args
)))))
3543 (insert " -- " category
" on " class
": " name
)
3545 (insert " " (upcase (car args
)))
3546 (setq args
(cdr args
)))))
3548 ;; @defcv: Generalized object-oriented
3549 (put 'defcv
'texinfo-deffn-formatting-property
'texinfo-format-defcv
)
3550 (put 'defcvx
'texinfo-deffn-formatting-property
'texinfo-format-defcv
)
3551 (defun texinfo-format-defcv (parsed-args)
3552 ;; Generalized object oriented entity:
3553 ;; @defcv category class name
3554 ;; In Info, `Category of class: name'
3555 ;; Note: args in upper case; use of `of'
3556 (let ((category (car parsed-args
))
3557 (class (car (cdr parsed-args
)))
3558 (name (car (cdr (cdr parsed-args
))))
3559 (args (cdr (cdr (cdr parsed-args
)))))
3560 (insert " -- " category
" of " class
": " name
)
3562 (insert " " (upcase (car args
)))
3563 (setq args
(cdr args
)))))
3565 ;; @defmethod: Specialized object-oriented
3566 (put 'defmethod
'texinfo-deffn-formatting-property
'texinfo-format-defmethod
)
3567 (put 'defmethodx
'texinfo-deffn-formatting-property
'texinfo-format-defmethod
)
3568 (defun texinfo-format-defmethod (parsed-args)
3569 ;; Specialized object oriented entity:
3570 ;; @defmethod class name args...
3571 ;; In Info, `Method on class: name ARGS'
3572 ;; Note: args in upper case; use of `on'
3573 ;; Use cdr of texinfo-defun-type to determine category:
3574 (let ((category (car (cdr texinfo-defun-type
)))
3575 (class (car parsed-args
))
3576 (name (car (cdr parsed-args
)))
3577 (args (cdr (cdr parsed-args
))))
3578 (insert " -- " category
" on " class
": " name
)
3580 (insert " " (upcase (car args
)))
3581 (setq args
(cdr args
)))))
3583 ;; @defivar: Specialized object-oriented
3584 (put 'defivar
'texinfo-deffn-formatting-property
'texinfo-format-defivar
)
3585 (put 'defivarx
'texinfo-deffn-formatting-property
'texinfo-format-defivar
)
3586 (defun texinfo-format-defivar (parsed-args)
3587 ;; Specialized object oriented entity:
3588 ;; @defivar class name
3589 ;; In Info, `Instance variable of class: name'
3590 ;; Note: args in upper case; use of `of'
3591 ;; Use cdr of texinfo-defun-type to determine category:
3592 (let ((category (car (cdr texinfo-defun-type
)))
3593 (class (car parsed-args
))
3594 (name (car (cdr parsed-args
)))
3595 (args (cdr (cdr parsed-args
))))
3596 (insert " -- " category
" of " class
": " name
)
3598 (insert " " (upcase (car args
)))
3599 (setq args
(cdr args
)))))
3602 ;;; Indexing for definitions
3604 ;; An index entry has three parts: the `entry proper', the node name, and the
3605 ;; line number. Depending on the which command is used, the entry is
3606 ;; formatted differently:
3612 ;; @defopt all use their 1st argument as the entry-proper
3618 ;; @deftypevar all use their 2nd argument as the entry-proper
3621 ;; @deftypevr both use their 3rd argument as the entry-proper
3623 ;; @defmethod uses its 2nd and 1st arguments as an entry-proper
3624 ;; formatted: NAME on CLASS
3626 ;; @defop uses its 3rd and 2nd arguments as an entry-proper
3627 ;; formatted: NAME on CLASS
3629 ;; @defivar uses its 2nd and 1st arguments as an entry-proper
3630 ;; formatted: NAME of CLASS
3632 ;; @defcv uses its 3rd and 2nd argument as an entry-proper
3633 ;; formatted: NAME of CLASS
3635 (put 'defun
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3636 (put 'defunx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3637 (put 'defmac
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3638 (put 'defmacx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3639 (put 'defspec
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3640 (put 'defspecx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3641 (put 'defvar
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3642 (put 'defvarx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3643 (put 'defopt
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3644 (put 'defoptx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3645 (defun texinfo-index-defun (parsed-args)
3646 ;; use 1st parsed-arg as entry-proper
3647 ;; `index-list' will be texinfo-findex or the like
3648 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3651 ;; Three elements: entry-proper, node-name, line-number
3655 ;; Region formatting may not provide last node position.
3656 (if texinfo-last-node-pos
3657 (1+ (count-lines texinfo-last-node-pos
(point)))
3659 (symbol-value index-list
)))))
3661 (put 'deffn
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3662 (put 'deffnx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3663 (put 'defvr
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3664 (put 'defvrx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3665 (put 'deftp
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3666 (put 'deftpx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3667 (put 'deftypefun
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3668 (put 'deftypefunx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3669 (put 'deftypevar
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3670 (put 'deftypevarx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3671 (defun texinfo-index-deffn (parsed-args)
3672 ;; use 2nd parsed-arg as entry-proper
3673 ;; `index-list' will be texinfo-findex or the like
3674 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3677 ;; Three elements: entry-proper, node-name, line-number
3679 (car (cdr parsed-args
))
3681 ;; Region formatting may not provide last node position.
3682 (if texinfo-last-node-pos
3683 (1+ (count-lines texinfo-last-node-pos
(point)))
3685 (symbol-value index-list
)))))
3687 (put 'deftypefn
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3688 (put 'deftypefnx
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3689 (put 'deftypevr
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3690 (put 'deftypevrx
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3691 (defun texinfo-index-deftypefn (parsed-args)
3692 ;; use 3rd parsed-arg as entry-proper
3693 ;; `index-list' will be texinfo-findex or the like
3694 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3697 ;; Three elements: entry-proper, node-name, line-number
3699 (car (cdr (cdr parsed-args
)))
3701 ;; Region formatting may not provide last node position.
3702 (if texinfo-last-node-pos
3703 (1+ (count-lines texinfo-last-node-pos
(point)))
3705 (symbol-value index-list
)))))
3707 (put 'defmethod
'texinfo-defun-indexing-property
'texinfo-index-defmethod
)
3708 (put 'defmethodx
'texinfo-defun-indexing-property
'texinfo-index-defmethod
)
3709 (defun texinfo-index-defmethod (parsed-args)
3710 ;; use 2nd on 1st parsed-arg as entry-proper
3711 ;; `index-list' will be texinfo-findex or the like
3712 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3715 ;; Three elements: entry-proper, node-name, line-number
3718 (car (cdr parsed-args
))
3721 ;; Region formatting may not provide last node position.
3722 (if texinfo-last-node-pos
3723 (1+ (count-lines texinfo-last-node-pos
(point)))
3725 (symbol-value index-list
)))))
3727 (put 'defop
'texinfo-defun-indexing-property
'texinfo-index-defop
)
3728 (put 'defopx
'texinfo-defun-indexing-property
'texinfo-index-defop
)
3729 (defun texinfo-index-defop (parsed-args)
3730 ;; use 3rd on 2nd parsed-arg as entry-proper
3731 ;; `index-list' will be texinfo-findex or the like
3732 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3735 ;; Three elements: entry-proper, node-name, line-number
3738 (car (cdr (cdr parsed-args
)))
3739 (car (cdr parsed-args
)))
3741 ;; Region formatting may not provide last node position.
3742 (if texinfo-last-node-pos
3743 (1+ (count-lines texinfo-last-node-pos
(point)))
3745 (symbol-value index-list
)))))
3747 (put 'defivar
'texinfo-defun-indexing-property
'texinfo-index-defivar
)
3748 (put 'defivarx
'texinfo-defun-indexing-property
'texinfo-index-defivar
)
3749 (defun texinfo-index-defivar (parsed-args)
3750 ;; use 2nd of 1st parsed-arg as entry-proper
3751 ;; `index-list' will be texinfo-findex or the like
3752 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3755 ;; Three elements: entry-proper, node-name, line-number
3758 (car (cdr parsed-args
))
3761 ;; Region formatting may not provide last node position.
3762 (if texinfo-last-node-pos
3763 (1+ (count-lines texinfo-last-node-pos
(point)))
3765 (symbol-value index-list
)))))
3767 (put 'defcv
'texinfo-defun-indexing-property
'texinfo-index-defcv
)
3768 (put 'defcvx
'texinfo-defun-indexing-property
'texinfo-index-defcv
)
3769 (defun texinfo-index-defcv (parsed-args)
3770 ;; use 3rd of 2nd parsed-arg as entry-proper
3771 ;; `index-list' will be texinfo-findex or the like
3772 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3775 ;; Three elements: entry-proper, node-name, line-number
3778 (car (cdr (cdr parsed-args
)))
3779 (car (cdr parsed-args
)))
3781 ;; Region formatting may not provide last node position.
3782 (if texinfo-last-node-pos
3783 (1+ (count-lines texinfo-last-node-pos
(point)))
3785 (symbol-value index-list
)))))
3788 ;;; Properties for definitions
3790 ;; Each definition command has six properties:
3792 ;; 1. texinfo-deffn-formatting-property to format definition line
3793 ;; 2. texinfo-defun-indexing-property to create index entry
3794 ;; 3. texinfo-format formatting command
3795 ;; 4. texinfo-end end formatting command
3796 ;; 5. texinfo-defun-type type of deffn to format
3797 ;; 6. texinfo-defun-index type of index to use
3799 ;; The `x' forms of each definition command are used for the second
3800 ;; and subsequent header lines.
3802 ;; The texinfo-deffn-formatting-property and texinfo-defun-indexing-property
3803 ;; are listed just before the appropriate formatting and indexing commands.
3805 (put 'deffn
'texinfo-format
'texinfo-format-defun
)
3806 (put 'deffnx
'texinfo-format
'texinfo-format-defunx
)
3807 (put 'deffn
'texinfo-end
'texinfo-end-defun
)
3808 (put 'deffn
'texinfo-defun-type
'('deffn-type nil
))
3809 (put 'deffnx
'texinfo-defun-type
'('deffn-type nil
))
3810 (put 'deffn
'texinfo-defun-index
'texinfo-findex
)
3811 (put 'deffnx
'texinfo-defun-index
'texinfo-findex
)
3813 (put 'defun
'texinfo-format
'texinfo-format-defun
)
3814 (put 'defunx
'texinfo-format
'texinfo-format-defunx
)
3815 (put 'defun
'texinfo-end
'texinfo-end-defun
)
3816 (put 'defun
'texinfo-defun-type
'('defun-type
"Function"))
3817 (put 'defunx
'texinfo-defun-type
'('defun-type
"Function"))
3818 (put 'defun
'texinfo-defun-index
'texinfo-findex
)
3819 (put 'defunx
'texinfo-defun-index
'texinfo-findex
)
3821 (put 'defmac
'texinfo-format
'texinfo-format-defun
)
3822 (put 'defmacx
'texinfo-format
'texinfo-format-defunx
)
3823 (put 'defmac
'texinfo-end
'texinfo-end-defun
)
3824 (put 'defmac
'texinfo-defun-type
'('defun-type
"Macro"))
3825 (put 'defmacx
'texinfo-defun-type
'('defun-type
"Macro"))
3826 (put 'defmac
'texinfo-defun-index
'texinfo-findex
)
3827 (put 'defmacx
'texinfo-defun-index
'texinfo-findex
)
3829 (put 'defspec
'texinfo-format
'texinfo-format-defun
)
3830 (put 'defspecx
'texinfo-format
'texinfo-format-defunx
)
3831 (put 'defspec
'texinfo-end
'texinfo-end-defun
)
3832 (put 'defspec
'texinfo-defun-type
'('defun-type
"Special form"))
3833 (put 'defspecx
'texinfo-defun-type
'('defun-type
"Special form"))
3834 (put 'defspec
'texinfo-defun-index
'texinfo-findex
)
3835 (put 'defspecx
'texinfo-defun-index
'texinfo-findex
)
3837 (put 'defvr
'texinfo-format
'texinfo-format-defun
)
3838 (put 'defvrx
'texinfo-format
'texinfo-format-defunx
)
3839 (put 'defvr
'texinfo-end
'texinfo-end-defun
)
3840 (put 'defvr
'texinfo-defun-type
'('deffn-type nil
))
3841 (put 'defvrx
'texinfo-defun-type
'('deffn-type nil
))
3842 (put 'defvr
'texinfo-defun-index
'texinfo-vindex
)
3843 (put 'defvrx
'texinfo-defun-index
'texinfo-vindex
)
3845 (put 'defvar
'texinfo-format
'texinfo-format-defun
)
3846 (put 'defvarx
'texinfo-format
'texinfo-format-defunx
)
3847 (put 'defvar
'texinfo-end
'texinfo-end-defun
)
3848 (put 'defvar
'texinfo-defun-type
'('defun-type
"Variable"))
3849 (put 'defvarx
'texinfo-defun-type
'('defun-type
"Variable"))
3850 (put 'defvar
'texinfo-defun-index
'texinfo-vindex
)
3851 (put 'defvarx
'texinfo-defun-index
'texinfo-vindex
)
3853 (put 'defconst
'texinfo-format
'texinfo-format-defun
)
3854 (put 'defconstx
'texinfo-format
'texinfo-format-defunx
)
3855 (put 'defconst
'texinfo-end
'texinfo-end-defun
)
3856 (put 'defconst
'texinfo-defun-type
'('defun-type
"Constant"))
3857 (put 'defconstx
'texinfo-defun-type
'('defun-type
"Constant"))
3858 (put 'defconst
'texinfo-defun-index
'texinfo-vindex
)
3859 (put 'defconstx
'texinfo-defun-index
'texinfo-vindex
)
3861 (put 'defcmd
'texinfo-format
'texinfo-format-defun
)
3862 (put 'defcmdx
'texinfo-format
'texinfo-format-defunx
)
3863 (put 'defcmd
'texinfo-end
'texinfo-end-defun
)
3864 (put 'defcmd
'texinfo-defun-type
'('defun-type
"Command"))
3865 (put 'defcmdx
'texinfo-defun-type
'('defun-type
"Command"))
3866 (put 'defcmd
'texinfo-defun-index
'texinfo-findex
)
3867 (put 'defcmdx
'texinfo-defun-index
'texinfo-findex
)
3869 (put 'defopt
'texinfo-format
'texinfo-format-defun
)
3870 (put 'defoptx
'texinfo-format
'texinfo-format-defunx
)
3871 (put 'defopt
'texinfo-end
'texinfo-end-defun
)
3872 (put 'defopt
'texinfo-defun-type
'('defun-type
"User Option"))
3873 (put 'defoptx
'texinfo-defun-type
'('defun-type
"User Option"))
3874 (put 'defopt
'texinfo-defun-index
'texinfo-vindex
)
3875 (put 'defoptx
'texinfo-defun-index
'texinfo-vindex
)
3877 (put 'deftp
'texinfo-format
'texinfo-format-defun
)
3878 (put 'deftpx
'texinfo-format
'texinfo-format-defunx
)
3879 (put 'deftp
'texinfo-end
'texinfo-end-defun
)
3880 (put 'deftp
'texinfo-defun-type
'('deftp-type nil
))
3881 (put 'deftpx
'texinfo-defun-type
'('deftp-type nil
))
3882 (put 'deftp
'texinfo-defun-index
'texinfo-tindex
)
3883 (put 'deftpx
'texinfo-defun-index
'texinfo-tindex
)
3885 ;;; Object-oriented stuff is a little hairier.
3887 (put 'defop
'texinfo-format
'texinfo-format-defun
)
3888 (put 'defopx
'texinfo-format
'texinfo-format-defunx
)
3889 (put 'defop
'texinfo-end
'texinfo-end-defun
)
3890 (put 'defop
'texinfo-defun-type
'('defop-type nil
))
3891 (put 'defopx
'texinfo-defun-type
'('defop-type nil
))
3892 (put 'defop
'texinfo-defun-index
'texinfo-findex
)
3893 (put 'defopx
'texinfo-defun-index
'texinfo-findex
)
3895 (put 'defmethod
'texinfo-format
'texinfo-format-defun
)
3896 (put 'defmethodx
'texinfo-format
'texinfo-format-defunx
)
3897 (put 'defmethod
'texinfo-end
'texinfo-end-defun
)
3898 (put 'defmethod
'texinfo-defun-type
'('defmethod-type
"Method"))
3899 (put 'defmethodx
'texinfo-defun-type
'('defmethod-type
"Method"))
3900 (put 'defmethod
'texinfo-defun-index
'texinfo-findex
)
3901 (put 'defmethodx
'texinfo-defun-index
'texinfo-findex
)
3903 (put 'defcv
'texinfo-format
'texinfo-format-defun
)
3904 (put 'defcvx
'texinfo-format
'texinfo-format-defunx
)
3905 (put 'defcv
'texinfo-end
'texinfo-end-defun
)
3906 (put 'defcv
'texinfo-defun-type
'('defop-type nil
))
3907 (put 'defcvx
'texinfo-defun-type
'('defop-type nil
))
3908 (put 'defcv
'texinfo-defun-index
'texinfo-vindex
)
3909 (put 'defcvx
'texinfo-defun-index
'texinfo-vindex
)
3911 (put 'defivar
'texinfo-format
'texinfo-format-defun
)
3912 (put 'defivarx
'texinfo-format
'texinfo-format-defunx
)
3913 (put 'defivar
'texinfo-end
'texinfo-end-defun
)
3914 (put 'defivar
'texinfo-defun-type
'('defmethod-type
"Instance variable"))
3915 (put 'defivarx
'texinfo-defun-type
'('defmethod-type
"Instance variable"))
3916 (put 'defivar
'texinfo-defun-index
'texinfo-vindex
)
3917 (put 'defivarx
'texinfo-defun-index
'texinfo-vindex
)
3919 ;;; Typed functions and variables
3921 (put 'deftypefn
'texinfo-format
'texinfo-format-defun
)
3922 (put 'deftypefnx
'texinfo-format
'texinfo-format-defunx
)
3923 (put 'deftypefn
'texinfo-end
'texinfo-end-defun
)
3924 (put 'deftypefn
'texinfo-defun-type
'('deftypefn-type nil
))
3925 (put 'deftypefnx
'texinfo-defun-type
'('deftypefn-type nil
))
3926 (put 'deftypefn
'texinfo-defun-index
'texinfo-findex
)
3927 (put 'deftypefnx
'texinfo-defun-index
'texinfo-findex
)
3929 (put 'deftypefun
'texinfo-format
'texinfo-format-defun
)
3930 (put 'deftypefunx
'texinfo-format
'texinfo-format-defunx
)
3931 (put 'deftypefun
'texinfo-end
'texinfo-end-defun
)
3932 (put 'deftypefun
'texinfo-defun-type
'('deftypefun-type
"Function"))
3933 (put 'deftypefunx
'texinfo-defun-type
'('deftypefun-type
"Function"))
3934 (put 'deftypefun
'texinfo-defun-index
'texinfo-findex
)
3935 (put 'deftypefunx
'texinfo-defun-index
'texinfo-findex
)
3937 (put 'deftypevr
'texinfo-format
'texinfo-format-defun
)
3938 (put 'deftypevrx
'texinfo-format
'texinfo-format-defunx
)
3939 (put 'deftypevr
'texinfo-end
'texinfo-end-defun
)
3940 (put 'deftypevr
'texinfo-defun-type
'('deftypefn-type nil
))
3941 (put 'deftypevrx
'texinfo-defun-type
'('deftypefn-type nil
))
3942 (put 'deftypevr
'texinfo-defun-index
'texinfo-vindex
)
3943 (put 'deftypevrx
'texinfo-defun-index
'texinfo-vindex
)
3945 (put 'deftypevar
'texinfo-format
'texinfo-format-defun
)
3946 (put 'deftypevarx
'texinfo-format
'texinfo-format-defunx
)
3947 (put 'deftypevar
'texinfo-end
'texinfo-end-defun
)
3948 (put 'deftypevar
'texinfo-defun-type
'('deftypevar-type
"Variable"))
3949 (put 'deftypevarx
'texinfo-defun-type
'('deftypevar-type
"Variable"))
3950 (put 'deftypevar
'texinfo-defun-index
'texinfo-vindex
)
3951 (put 'deftypevarx
'texinfo-defun-index
'texinfo-vindex
)
3954 ;;; @set, @clear, @ifset, @ifclear
3956 ;; If a flag is set with @set FLAG, then text between @ifset and @end
3957 ;; ifset is formatted normally, but if the flag is is cleared with
3958 ;; @clear FLAG, then the text is not formatted; it is ignored.
3960 ;; If a flag is cleared with @clear FLAG, then text between @ifclear
3961 ;; and @end ifclear is formatted normally, but if the flag is is set with
3962 ;; @set FLAG, then the text is not formatted; it is ignored. @ifclear
3963 ;; is the opposite of @ifset.
3965 ;; If a flag is set to a string with @set FLAG,
3966 ;; replace @value{FLAG} with the string.
3967 ;; If a flag with a value is cleared,
3968 ;; @value{FLAG} is invalid,
3969 ;; as if there had never been any @set FLAG previously.
3971 (put 'clear
'texinfo-format
'texinfo-clear
)
3972 (defun texinfo-clear ()
3973 "Clear the value of the flag."
3974 (let* ((arg (texinfo-parse-arg-discard))
3975 (flag (car (read-from-string arg
)))
3976 (value (substring arg
(cdr (read-from-string arg
)))))
3977 (put flag
'texinfo-whether-setp
'flag-cleared
)
3978 (put flag
'texinfo-set-value
"")))
3980 (put 'set
'texinfo-format
'texinfo-set
)
3981 (defun texinfo-set ()
3982 "Set the value of the flag, optionally to a string.
3983 The command `@set foo This is a string.'
3984 sets flag foo to the value: `This is a string.'
3985 The command `@value{foo}' expands to the value."
3986 (let* ((arg (texinfo-parse-arg-discard))
3987 (flag (car (read-from-string arg
)))
3988 (value (substring arg
(cdr (read-from-string arg
)))))
3989 (if (string-match "^[ \t]+" value
)
3990 (setq value
(substring value
(match-end 0))))
3991 (put flag
'texinfo-whether-setp
'flag-set
)
3992 (put flag
'texinfo-set-value value
)))
3994 (put 'value
'texinfo-format
'texinfo-value
)
3995 (defun texinfo-value ()
3996 "Insert the string to which the flag is set.
3997 The command `@set foo This is a string.'
3998 sets flag foo to the value: `This is a string.'
3999 The command `@value{foo}' expands to the value."
4000 (let ((arg (texinfo-parse-arg-discard)))
4002 (eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4004 (get (car (read-from-string arg
)) 'texinfo-set-value
))
4005 (insert (get (car (read-from-string arg
)) 'texinfo-set-value
)))
4006 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4008 (insert (format "{No value for \"%s\"}" arg
)))
4009 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
) nil
)
4010 (insert (format "{No value for \"%s\"}" arg
))))))
4012 (put 'ifset
'texinfo-end
'texinfo-discard-command
)
4013 (put 'ifset
'texinfo-format
'texinfo-if-set
)
4014 (defun texinfo-if-set ()
4015 "If set, continue formatting; else do not format region up to @end ifset"
4016 (let ((arg (texinfo-parse-arg-discard)))
4018 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4020 ;; Format the text (i.e., do not remove it); do nothing here.
4022 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4024 ;; Clear region (i.e., cause the text to be ignored).
4025 (delete-region texinfo-command-start
4026 (re-search-forward "@end ifset[ \t]*\n")))
4027 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4029 ;; In this case flag is neither set nor cleared.
4030 ;; Act as if set, i.e. do nothing.
4033 (put 'ifclear
'texinfo-end
'texinfo-discard-command
)
4034 (put 'ifclear
'texinfo-format
'texinfo-if-clear
)
4035 (defun texinfo-if-clear ()
4036 "If clear, continue formatting; if set, do not format up to @end ifset"
4037 (let ((arg (texinfo-parse-arg-discard)))
4039 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4041 ;; Clear region (i.e., cause the text to be ignored).
4042 (delete-region texinfo-command-start
4043 (re-search-forward "@end ifclear[ \t]*\n")))
4044 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4046 ;; Format the text (i.e., do not remove it); do nothing here.
4048 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4050 ;; In this case flag is neither set nor cleared.
4051 ;; Act as if clear, i.e. do nothing.
4056 (put 'ifeq
'texinfo-format
'texinfo-format-ifeq
)
4057 (defun texinfo-format-ifeq ()
4058 "If ARG1 and ARG2 caselessly string compare to same string, perform COMMAND.
4059 Otherwise produces no output.
4062 @ifeq{ arg1 , arg1 , @code{foo}} bar
4066 @ifeq{ arg1 , arg2 , @code{foo}} bar
4070 Note that the Texinfo command and its arguments must be arguments to
4072 ;; compare-buffer-substrings does not exist in version 18; don't use
4073 (goto-char texinfo-command-end
)
4074 (let* ((case-fold-search t
)
4075 (stop (save-excursion (forward-sexp 1) (point)))
4077 ;; @ifeq{arg1, arg2, @command{optional-args}}
4081 (skip-chars-forward " ")
4082 (setq start
(point))
4083 (search-forward "," stop t
)
4084 (skip-chars-backward ", ")
4085 (buffer-substring-no-properties start
(point))))
4088 (search-forward "," stop t
)
4089 (skip-chars-forward " ")
4090 (setq start
(point))
4091 (search-forward "," stop t
)
4092 (skip-chars-backward ", ")
4093 (buffer-substring-no-properties start
(point))))
4096 (search-forward "," stop t
)
4097 (skip-chars-forward " ")
4098 (setq start
(point))
4099 (goto-char (1- stop
))
4100 (skip-chars-backward " ")
4101 (buffer-substring-no-properties start
(point)))))
4102 (delete-region texinfo-command-start stop
)
4103 (if (equal arg1 arg2
)
4104 (insert texinfo-command
))
4105 (goto-char texinfo-command-start
)))
4108 ;;; Process included files: `@include' command
4110 ;; Updated 19 October 1990
4111 ;; In the original version, include files were ignored by Info but
4112 ;; incorporated in to the printed manual. To make references to the
4113 ;; included file, the Texinfo source file has to refer to the included
4114 ;; files using the `(filename)nodename' format for referring to other
4115 ;; Info files. Also, the included files had to be formatted on their
4116 ;; own. It was just like they were another file.
4118 ;; Currently, include files are inserted into the buffer that is
4119 ;; formatted for Info. If large, the resulting info file is split and
4120 ;; tagified. For current include files to work, the master menu must
4121 ;; refer to all the nodes, and the highest level nodes in the include
4122 ;; files must have the correct next, prev, and up pointers.
4124 ;; The included file may have an @setfilename and even an @settitle,
4125 ;; but not an `\input texinfo' line.
4127 ;; Updated 24 March 1993
4128 ;; In order for @raisesections and @lowersections to work, included
4129 ;; files must be inserted into the buffer holding the outer file
4130 ;; before other Info formatting takes place. So @include is no longer
4131 ;; is treated like other @-commands.
4132 (put 'include
'texinfo-format
'texinfo-format-noop
)
4134 ;; Original definition:
4135 ;; (defun texinfo-format-include ()
4136 ;; (let ((filename (texinfo-parse-arg-discard))
4137 ;; (default-directory input-directory)
4141 ;; (progn (find-file
4142 ;; (cond ((file-readable-p (concat filename ".texinfo"))
4143 ;; (concat filename ".texinfo"))
4144 ;; ((file-readable-p (concat filename ".texi"))
4145 ;; (concat filename ".texi"))
4146 ;; ((file-readable-p (concat filename ".tex"))
4147 ;; (concat filename ".tex"))
4148 ;; ((file-readable-p filename)
4150 ;; (t (error "@include'd file %s not found"
4152 ;; (texinfo-format-buffer-1))))
4153 ;; (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex))
4154 ;; (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex))
4155 ;; (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex))
4156 ;; (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex))
4157 ;; (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex))
4158 ;; (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex))))
4160 ;;(defun texinfo-subindex (indexvar file content)
4161 ;; (set indexvar (cons (list 'recurse file content)
4162 ;; (symbol-value indexvar))))
4164 ;; Second definition:
4165 ;; (put 'include 'texinfo-format 'texinfo-format-include)
4166 ;; (defun texinfo-format-include ()
4167 ;; (let ((filename (concat input-directory
4168 ;; (texinfo-parse-arg-discard)))
4169 ;; (default-directory input-directory))
4170 ;; (message "Reading: %s" filename)
4172 ;; (save-restriction
4173 ;; (narrow-to-region
4175 ;; (+ (point) (car (cdr (insert-file-contents filename)))))
4176 ;; (goto-char (point-min))
4177 ;; (texinfo-append-refill)
4178 ;; (texinfo-format-convert (point-min) (point-max))))
4179 ;; (setq last-input-buffer input-buffer) ; to bypass setfilename
4183 ;;; Numerous commands do nothing in Info
4184 ;; These commands are defined in texinfo.tex for printed output.
4187 ;;; various noops, such as @b{foo}, that take arguments in braces
4189 (put 'b
'texinfo-format
'texinfo-format-noop
)
4190 (put 'i
'texinfo-format
'texinfo-format-noop
)
4191 (put 'r
'texinfo-format
'texinfo-format-noop
)
4192 (put 't
'texinfo-format
'texinfo-format-noop
)
4193 (put 'w
'texinfo-format
'texinfo-format-noop
)
4194 (put 'asis
'texinfo-format
'texinfo-format-noop
)
4195 (put 'dmn
'texinfo-format
'texinfo-format-noop
)
4196 (put 'math
'texinfo-format
'texinfo-format-noop
)
4197 (put 'titlefont
'texinfo-format
'texinfo-format-noop
)
4198 (defun texinfo-format-noop ()
4199 (insert (texinfo-parse-arg-discard))
4200 (goto-char texinfo-command-start
))
4202 ;; @hyphenation command discards an argument within braces
4203 (put 'hyphenation
'texinfo-format
'texinfo-discard-command-and-arg
)
4204 (defun texinfo-discard-command-and-arg ()
4205 "Discard both @-command and its argument in braces."
4206 (goto-char texinfo-command-end
)
4208 (setq texinfo-command-end
(point))
4209 (delete-region texinfo-command-start texinfo-command-end
))
4212 ;;; Do nothing commands, such as @smallbook, that have no args and no braces
4213 ;; These must appear on a line of their own
4215 (put 'bye
'texinfo-format
'texinfo-discard-line
)
4216 (put 'smallbook
'texinfo-format
'texinfo-discard-line
)
4217 (put 'finalout
'texinfo-format
'texinfo-discard-line
)
4218 (put 'overfullrule
'texinfo-format
'texinfo-discard-line
)
4219 (put 'smallbreak
'texinfo-format
'texinfo-discard-line
)
4220 (put 'medbreak
'texinfo-format
'texinfo-discard-line
)
4221 (put 'bigbreak
'texinfo-format
'texinfo-discard-line
)
4222 (put 'afourpaper
'texinfo-format
'texinfo-discard-line
)
4223 (put 'afivepaper
'texinfo-format
'texinfo-discard-line
)
4224 (put 'afourlatex
'texinfo-format
'texinfo-discard-line
)
4225 (put 'afourwide
'texinfo-format
'texinfo-discard-line
)
4228 ;;; These noop commands discard the rest of the line.
4230 (put 'c
'texinfo-format
'texinfo-discard-line-with-args
)
4231 (put 'comment
'texinfo-format
'texinfo-discard-line-with-args
)
4232 (put 'contents
'texinfo-format
'texinfo-discard-line-with-args
)
4233 (put 'group
'texinfo-end
'texinfo-discard-line-with-args
)
4234 (put 'group
'texinfo-format
'texinfo-discard-line-with-args
)
4235 (put 'headings
'texinfo-format
'texinfo-discard-line-with-args
)
4236 (put 'setchapterstyle
'texinfo-format
'texinfo-discard-line-with-args
)
4237 (put 'hsize
'texinfo-format
'texinfo-discard-line-with-args
)
4238 (put 'itemindent
'texinfo-format
'texinfo-discard-line-with-args
)
4239 (put 'lispnarrowing
'texinfo-format
'texinfo-discard-line-with-args
)
4240 (put 'need
'texinfo-format
'texinfo-discard-line-with-args
)
4241 (put 'nopara
'texinfo-format
'texinfo-discard-line-with-args
)
4243 ;; @novalidate suppresses cross-reference checking and auxiliary file
4244 ;; creation with TeX. The Info-validate command checks that every
4245 ;; node pointer points to an existing node. Since this Info command
4246 ;; is not invoked automatically, the @novalidate command is irrelevant
4247 ;; and not supported by texinfmt.el
4248 (put 'novalidate
'texinfo-format
'texinfo-discard-line-with-args
)
4250 (put 'page
'texinfo-format
'texinfo-discard-line-with-args
)
4251 (put 'pagesizes
'texinfo-format
'texinfo-discard-line-with-args
)
4252 (put 'parindent
'texinfo-format
'texinfo-discard-line-with-args
)
4253 (put 'setchapternewpage
'texinfo-format
'texinfo-discard-line-with-args
)
4254 (put 'setq
'texinfo-format
'texinfo-discard-line-with-args
)
4256 (put 'setcontentsaftertitlepage
4257 'texinfo-format
'texinfo-discard-line-with-args
)
4258 (put 'setshortcontentsaftertitlepage
4259 'texinfo-format
'texinfo-discard-line-with-args
)
4261 (put 'settitle
'texinfo-format
'texinfo-discard-line-with-args
)
4262 (put 'setx
'texinfo-format
'texinfo-discard-line-with-args
)
4263 (put 'shortcontents
'texinfo-format
'texinfo-discard-line-with-args
)
4264 (put 'shorttitlepage
'texinfo-format
'texinfo-discard-line-with-args
)
4265 (put 'summarycontents
'texinfo-format
'texinfo-discard-line-with-args
)
4266 (put 'input
'texinfo-format
'texinfo-discard-line-with-args
)
4268 (put 'documentlanguage
'texinfo-format
'texinfo-discard-line-with-args
)
4269 (put 'documentencoding
'texinfo-format
'texinfo-discard-line-with-args
)
4273 ;;; Some commands cannot be handled
4275 (defun texinfo-unsupported ()
4276 (error "%s is not handled by texinfo"
4277 (buffer-substring-no-properties texinfo-command-start texinfo-command-end
)))
4279 ;;; Batch formatting
4281 (defun batch-texinfo-format ()
4282 "Runs texinfo-format-buffer on the files remaining on the command line.
4283 Must be used only with -batch, and kills emacs on completion.
4284 Each file will be processed even if an error occurred previously.
4286 \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"."
4287 (if (not noninteractive
)
4288 (error "batch-texinfo-format may only be used -batch"))
4289 (let ((version-control t
)
4290 (auto-save-default nil
)
4291 (find-file-run-dired nil
)
4292 (kept-old-versions 259259)
4293 (kept-new-versions 259259))
4297 (while command-line-args-left
4298 (setq file
(expand-file-name (car command-line-args-left
)))
4299 (cond ((not (file-exists-p file
))
4300 (message ">> %s does not exist!" file
)
4302 command-line-args-left
(cdr command-line-args-left
)))
4303 ((file-directory-p file
)
4304 (setq command-line-args-left
4305 (nconc (directory-files file
)
4306 (cdr command-line-args-left
))))
4308 (setq files
(cons file files
)
4309 command-line-args-left
(cdr command-line-args-left
)))))
4311 (setq file
(car files
)
4315 (if buffer-file-name
(kill-buffer (current-buffer)))
4317 (buffer-disable-undo (current-buffer))
4318 (set-buffer-modified-p nil
)
4320 (message "texinfo formatting %s..." file
)
4321 (texinfo-format-buffer nil
)
4322 (if (buffer-modified-p)
4323 (progn (message "Saving modified %s" (buffer-file-name))
4326 (message ">> Error: %s" (prin1-to-string err
))
4327 (message ">> point at")
4328 (let ((s (buffer-substring-no-properties (point)
4329 (min (+ (point) 100)
4332 (while (setq tem
(string-match "\n+" s tem
))
4333 (setq s
(concat (substring s
0 (match-beginning 0))
4335 (substring s
(match-end 0)))
4337 (message ">> %s" s
))
4339 (kill-emacs error
))))
4342 ;;; Place `provide' at end of file.
4345 ;;; arch-tag: 1e8d9a2d-bca0-40a0-ac6c-dab01bc6f725
4346 ;;; texinfmt.el ends here