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].")
138 (defun texinfo-format-region (region-beginning region-end
)
139 "Convert the current region of the Texinfo file to Info format.
140 This lets you see what that part of the file will look like in Info.
141 The command is bound to \\[texinfo-format-region]. The text that is
142 converted to Info is stored in a temporary buffer."
144 (message "Converting region to Info format...")
145 (let (texinfo-command-start
155 (texinfo-format-filename "")
156 texinfo-example-start
157 texinfo-last-node-pos
160 (texinfo-footnote-number 0)
162 (fill-column-for-info fill-column
)
163 (input-buffer (current-buffer))
164 (input-directory default-directory
)
169 ;;; Copy lines between beginning and end of header lines,
170 ;;; if any, or else copy the `@setfilename' line, if any.
174 (goto-char (point-min))
175 (let ((search-end (save-excursion (forward-line 100) (point))))
177 ;; Either copy header text.
180 (search-forward tex-start-of-header search-end t
)
182 ;; Mark beginning of header.
183 (setq header-beginning
(point)))
185 (search-forward tex-end-of-header nil t
)
187 ;; Mark end of header
188 (setq header-end
(point))))
189 ;; Or copy @filename line.
191 (goto-char (point-min))
192 (search-forward "@setfilename" search-end t
)
194 (setq header-beginning
(point))
196 (setq header-end
(point))))
200 (buffer-substring-no-properties
201 (min header-beginning region-beginning
)
204 ;;; Find a buffer to use.
205 (switch-to-buffer (get-buffer-create texinfo-region-buffer-name
))
207 ;; Insert the header into the buffer.
209 ;; Insert the region into the buffer.
210 (insert-buffer-substring
212 (max region-beginning header-end
)
214 ;; Make sure region ends in a newline.
215 (or (= (preceding-char) ?
\n)
218 (goto-char (point-min))
220 (message "Converting region to Info format...")
221 (setq fill-column fill-column-for-info
)
222 ;; Install a syntax table useful for scanning command operands.
223 (set-syntax-table texinfo-format-syntax-table
)
225 ;; Insert @include files so `texinfo-raise-lower-sections' can
226 ;; work on them without losing track of multiple
227 ;; @raise/@lowersections commands.
228 (while (re-search-forward "^@include" nil t
)
229 (setq texinfo-command-end
(point))
230 (let ((filename (concat input-directory
231 (texinfo-parse-line-arg))))
232 (re-search-backward "^@include")
233 (delete-region (point) (save-excursion (forward-line 1) (point)))
234 (message "Reading included file: %s" filename
)
239 (+ (point) (car (cdr (insert-file-contents filename
)))))
240 (goto-char (point-min))
241 ;; Remove `@setfilename' line from included file, if any,
242 ;; so @setfilename command not duplicated.
243 (if (re-search-forward
244 "^@setfilename" (save-excursion (forward-line 100) (point)) t
)
248 (point) (save-excursion (forward-line 1) (point)))))))))
250 ;; Raise or lower level of each section, if necessary.
251 (goto-char (point-min))
252 (texinfo-raise-lower-sections)
253 ;; Append @refill to appropriate paragraphs for filling.
254 (goto-char (point-min))
255 (texinfo-append-refill)
256 ;; If the region includes the effective end of the data,
257 ;; discard everything after that.
258 (goto-char (point-max))
259 (if (re-search-backward "^@bye" nil t
)
260 (delete-region (point) (point-max)))
261 ;; Make sure buffer ends in a newline.
262 (or (= (preceding-char) ?
\n)
264 ;; Don't use a previous value of texinfo-enclosure-list.
265 (setq texinfo-enclosure-list nil
)
266 (setq texinfo-alias-list nil
)
268 (goto-char (point-min))
269 (if (looking-at "\\\\input[ \t]+texinfo")
270 (delete-region (point) (save-excursion (forward-line 1) (point))))
272 ;; Insert Info region title text.
273 (goto-char (point-min))
275 "@setfilename" (save-excursion (forward-line 100) (point)) t
)
277 (setq texinfo-command-end
(point))
279 (setq texinfo-command-start
(point))
280 (let ((arg (texinfo-parse-arg-discard)))
282 texinfo-region-buffer-name
284 (insert (file-name-nondirectory (expand-file-name arg
)))
285 (insert "', -*-Text-*-\n")))
286 ;; Else no `@setfilename' line
288 texinfo-region-buffer-name
289 " buffer -*-Text-*-\n"))
290 (insert "produced by `texinfo-format-region'\n"
292 (if (buffer-file-name input-buffer
)
294 (file-name-sans-versions
295 (file-name-nondirectory
296 (buffer-file-name input-buffer
)))
298 (concat "buffer `" (buffer-name input-buffer
) "'"))
299 "\nusing `texinfmt.el' version "
303 ;; Now convert for real.
304 (goto-char (point-min))
305 (texinfo-format-scan)
306 (goto-char (point-min))
307 (Info-tagify input-buffer
)
308 (goto-char (point-min))
312 (defun texi2info (&optional nosplit
)
313 "Convert the current buffer (written in Texinfo code) into an Info file.
314 The Info file output is generated in a buffer visiting the Info file
315 names specified in the @setfilename command.
317 This function automatically updates all node pointers and menus, and
318 creates a master menu. This work is done on a temporary buffer that
319 is automatically removed when the Info file is created. The original
320 Texinfo source buffer is not changed.
322 Non-nil argument (prefix, if interactive) means don't split the file
323 if large. You can use Info-split to do this manually."
325 (let ((temp-buffer (concat "*--" (buffer-name) "--temporary-buffer*" )))
326 (message "First updating nodes and menus, then creating Info file.")
328 (copy-to-buffer temp-buffer
(point-min) (point-max))
329 (switch-to-buffer temp-buffer
)
330 (texinfo-master-menu t
)
331 (message "Now creating Info file.")
333 (texinfo-format-buffer nosplit
)
335 (kill-buffer temp-buffer
)))
338 ;;; Primary internal formatting function for the whole buffer.
340 (defun texinfo-format-buffer-1 ()
341 (let (texinfo-format-filename
342 texinfo-example-start
343 texinfo-command-start
347 texinfo-last-node-pos
356 (texinfo-footnote-number 0)
359 (fill-column-for-info fill-column
)
360 (input-buffer (current-buffer))
361 (input-directory default-directory
))
362 (setq texinfo-enclosure-list nil
)
363 (setq texinfo-alias-list nil
)
365 (goto-char (point-min))
366 (or (search-forward "@setfilename" nil t
)
367 (error "Texinfo file needs an `@setfilename FILENAME' line"))
368 (setq texinfo-command-end
(point))
369 (setq outfile
(texinfo-parse-line-arg)))
375 (message "Formatting Info file: %s" outfile
)
376 (setq texinfo-format-filename
377 (file-name-nondirectory (expand-file-name outfile
)))
379 (setq fill-column fill-column-for-info
)
380 (set-syntax-table texinfo-format-syntax-table
)
382 (insert-buffer-substring input-buffer
)
383 (message "Converting %s to Info format..." (buffer-name input-buffer
))
385 ;; Insert @include files so `texinfo-raise-lower-sections' can
386 ;; work on them without losing track of multiple
387 ;; @raise/@lowersections commands.
388 (goto-char (point-min))
389 (while (re-search-forward "^@include" nil t
)
390 (setq texinfo-command-end
(point))
391 (let ((filename (concat input-directory
392 (texinfo-parse-line-arg))))
393 (re-search-backward "^@include")
394 (delete-region (point) (save-excursion (forward-line 1) (point)))
395 (message "Reading included file: %s" filename
)
400 (+ (point) (car (cdr (insert-file-contents filename
)))))
401 (goto-char (point-min))
402 ;; Remove `@setfilename' line from included file, if any,
403 ;; so @setfilename command not duplicated.
404 (if (re-search-forward
406 (save-excursion (forward-line 100) (point)) t
)
410 (point) (save-excursion (forward-line 1) (point)))))))))
411 ;; Raise or lower level of each section, if necessary.
412 (goto-char (point-min))
413 (texinfo-raise-lower-sections)
414 ;; Append @refill to appropriate paragraphs
415 (goto-char (point-min))
416 (texinfo-append-refill)
417 (goto-char (point-min))
418 (search-forward "@setfilename")
420 (delete-region (point-min) (point))
421 ;; Remove @bye at end of file, if it is there.
422 (goto-char (point-max))
423 (if (search-backward "@bye" nil t
)
424 (delete-region (point) (point-max)))
425 ;; Make sure buffer ends in a newline.
426 (or (= (preceding-char) ?
\n)
428 ;; Scan the whole buffer, converting to Info format.
429 (texinfo-format-scan)
430 (goto-char (point-min))
431 ;; Insert info about how this file was made.
432 (insert "Info file: "
433 texinfo-format-filename
", -*-Text-*-\n"
434 "produced by `texinfo-format-buffer'\n"
435 ;; Date string removed so that regression testing is easier.
437 ;; (insert (format-time-string "%e %b %Y")) " "
439 (if (buffer-file-name input-buffer
)
441 (file-name-sans-versions
442 (file-name-nondirectory
443 (buffer-file-name input-buffer
)))
445 (concat "buffer `" (buffer-name input-buffer
) "'"))
446 "\nusing `texinfmt.el' version "
449 ;; Return data for indices.
451 texinfo-vindex texinfo-findex texinfo-cindex
452 texinfo-pindex texinfo-tindex texinfo-kindex
)))
455 ;;; Perform non-@-command file conversions: quotes and hyphens
457 (defun texinfo-format-convert (min max
)
458 ;; Convert left and right quotes to typewriter font quotes.
460 (while (search-forward "``" max t
)
461 (replace-match "\""))
463 (while (search-forward "''" max t
)
464 (replace-match "\""))
465 ;; Convert three hyphens in a row to two.
467 (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t
)
468 (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning
472 ;;; Handle paragraph filling
474 ;; Keep as concatinated lists for ease of maintenance
476 (defvar texinfo-no-refill-regexp
480 ;; add "itemize\\|" (from experiment of 2001 Nov 28)
481 ;; because of a problem with @end itemize@refill
482 ;; I don't know if this causes other problems.
483 ;; I suspect itemized lists don't get filled properly and a
484 ;; more precise fix is required. Bob
505 "Regexp specifying environments in which paragraphs are not filled.")
507 (defvar texinfo-accent-commands
540 (defvar texinfo-part-of-para-regexp
575 "@-\\|" ; @- is a descretionary hyphen (not an accent) (a noop).
576 texinfo-accent-commands
579 "Regexp specifying @-commands found within paragraphs.")
581 (defun texinfo-append-refill ()
582 "Append @refill at end of each paragraph that should be filled.
583 Do not append @refill to paragraphs within @example and similar environments.
584 Do not append @refill to paragraphs containing @w{TEXT} or @*."
586 ;; It is necessary to append @refill before other processing because
587 ;; the other processing removes information that tells Texinfo
588 ;; whether the text should or should not be filled.
590 (while (< (point) (point-max))
591 (let ((refill-blank-lines "^[ \t\n]*$")
592 (case-fold-search nil
)) ; Don't confuse @TeX and @tex....
594 ;; 1. Skip over blank lines;
595 ;; skip over lines beginning with @-commands,
596 ;; but do not skip over lines
597 ;; that are no-refill environments such as @example or
598 ;; that begin with within-paragraph @-commands such as @code.
599 (while (and (looking-at (concat "^@\\|^\\\\\\|" refill-blank-lines
))
603 texinfo-no-refill-regexp
605 texinfo-part-of-para-regexp
607 (< (point) (point-max)))
609 ;; 2. Skip over @example and similar no-refill environments.
610 (if (looking-at texinfo-no-refill-regexp
)
612 (buffer-substring-no-properties (match-beginning 1) (match-end 1))))
613 (progn (re-search-forward (concat "^@end " environment
) nil t
)
616 ;; 3. Do not refill a paragraph containing @w or @*, or ending
617 ;; with @<newline> followed by a newline.
619 (>= (point) (point-max))
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 (whitespace-cleanup))
948 (defvar texinfo-copying-text
""
949 "Text of the copyright notice and copying permissions.")
951 (defun texinfo-copying ()
952 "Copy the copyright notice and copying permissions from the Texinfo file,
953 as indicated by the @copying ... @end copying command;
954 insert the text with the @insertcopying command."
955 (let ((beg (progn (beginning-of-line) (point)))
956 (end (progn (re-search-forward "^@end copying[ \t]*\n") (point))))
957 (setq texinfo-copying-text
958 (buffer-substring-no-properties
959 (save-excursion (goto-char beg
) (forward-line 1) (point))
960 (save-excursion (goto-char end
) (forward-line -
1) (point))))
961 (delete-region beg end
)))
963 (defun texinfo-insertcopying ()
964 "Insert the copyright notice and copying permissions from the Texinfo file,
965 which are indicated by the @copying ... @end copying command."
966 (insert (concat "\n" texinfo-copying-text
)))
968 (put 'begin
'texinfo-format
'texinfo-format-begin
)
969 (defun texinfo-format-begin ()
970 (texinfo-format-begin-end 'texinfo-format
))
972 (put 'end
'texinfo-format
'texinfo-format-end
)
973 (defun texinfo-format-end ()
974 (texinfo-format-begin-end 'texinfo-end
))
976 (defun texinfo-format-begin-end (prop)
977 (setq texinfo-command-name
(intern (texinfo-parse-line-arg)))
978 (let ((cmd (get texinfo-command-name prop
)))
979 (if cmd
(funcall cmd
)
980 (texinfo-unsupported))))
982 ;;; Parsing functions
984 (defun texinfo-parse-line-arg ()
985 "Return argument of @-command as string.
986 Argument is separated from command either by a space or by a brace.
987 If a space, return rest of line, with beginning and ending white
988 space removed. If a brace, return string between braces.
989 Leave point after argument."
990 (goto-char texinfo-command-end
)
991 (let ((start (point)))
992 (cond ((looking-at " ")
993 (skip-chars-forward " ")
996 (skip-chars-backward " ")
997 (delete-region (point) (progn (end-of-line) (point)))
998 (setq texinfo-command-end
(1+ (point))))
1000 (setq start
(1+ (point)))
1002 (setq texinfo-command-end
(point))
1005 (error "Invalid texinfo command arg format")))
1006 (prog1 (buffer-substring-no-properties start
(point))
1007 (if (eolp) (forward-char 1)))))
1009 (defun texinfo-parse-expanded-arg ()
1010 (goto-char texinfo-command-end
)
1011 (let ((start (point))
1013 (cond ((looking-at " ")
1014 (skip-chars-forward " ")
1015 (setq start
(point))
1017 (setq texinfo-command-end
(1+ (point))))
1019 (setq start
(1+ (point)))
1021 (setq texinfo-command-end
(point))
1024 (error "Invalid texinfo command arg format")))
1025 (setq marker
(move-marker (make-marker) texinfo-command-end
))
1026 (texinfo-format-expand-region start
(point))
1027 (setq texinfo-command-end
(marker-position marker
))
1028 (move-marker marker nil
)
1029 (prog1 (buffer-substring-no-properties start
(point))
1030 (if (eolp) (forward-char 1)))))
1032 (defun texinfo-format-expand-region (start end
)
1034 (narrow-to-region start end
)
1035 (let (texinfo-command-start
1037 texinfo-command-name
1039 (texinfo-format-scan))
1040 (goto-char (point-max))))
1042 (defun texinfo-parse-arg-discard ()
1043 "Delete command and argument; return argument of command."
1044 (prog1 (texinfo-parse-line-arg)
1045 (texinfo-discard-command)))
1047 (defun texinfo-discard-command ()
1048 (delete-region texinfo-command-start texinfo-command-end
))
1050 (defun texinfo-optional-braces-discard ()
1051 "Discard braces following command, if any."
1052 (goto-char texinfo-command-end
)
1053 (let ((start (point)))
1054 (cond ((looking-at "[ \t]*\n")) ; do nothing
1055 ((looking-at "{") ; remove braces, if any
1057 (setq texinfo-command-end
(point)))
1060 "Invalid `texinfo-optional-braces-discard' format \(need braces?\)")))
1061 (delete-region texinfo-command-start texinfo-command-end
)))
1063 (defun texinfo-format-parse-line-args ()
1064 (let ((start (1- (point)))
1067 (skip-chars-forward " ")
1070 (re-search-forward "[\n,]")
1072 (if (bolp) (setq next
(1- next
)))
1074 (skip-chars-backward " ")
1076 (setq args
(cons (if (> end beg
) (buffer-substring-no-properties beg end
))
1079 (skip-chars-forward " "))
1080 (if (eolp) (forward-char 1))
1081 (setq texinfo-command-end
(point))
1084 (defun texinfo-format-parse-args ()
1085 (let ((start (1- (point)))
1088 (search-forward "{")
1090 (texinfo-format-expand-region
1092 (save-excursion (up-list 1) (1- (point)))))
1093 ;; The following does not handle cross references of the form:
1094 ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the
1095 ;; re-search-forward finds the first right brace after the second
1097 (while (/= (preceding-char) ?\
})
1098 (skip-chars-forward " \t\n")
1100 (re-search-forward "[},]")
1103 (skip-chars-backward " \t\n")
1107 (while (search-forward "\n" end t
)
1108 (replace-match " "))))
1109 (setq args
(cons (if (> end beg
) (buffer-substring-no-properties beg end
))
1112 ;;(if (eolp) (forward-char 1))
1113 (setq texinfo-command-end
(point))
1116 (defun texinfo-format-parse-defun-args ()
1117 (goto-char texinfo-command-end
)
1118 (let ((start (point)))
1120 (setq texinfo-command-end
(1+ (point)))
1121 (let ((marker (move-marker (make-marker) texinfo-command-end
)))
1122 (texinfo-format-expand-region start
(point))
1123 (setq texinfo-command-end
(marker-position marker
))
1124 (move-marker marker nil
))
1128 (skip-chars-forward " ")
1130 (cond ((looking-at "{")
1131 (setq beg
(1+ (point)))
1133 (setq end
(1- (point))))
1136 (re-search-forward "[\n ]")
1138 (setq end
(point))))
1139 (setq args
(cons (buffer-substring-no-properties beg end
) args
))
1140 (skip-chars-forward " "))
1144 (defun texinfo-discard-line ()
1145 (goto-char texinfo-command-end
)
1146 (skip-chars-forward " \t")
1148 (error "Extraneous text at end of command line"))
1149 (goto-char texinfo-command-start
)
1151 (error "Extraneous text at beginning of command line"))
1152 (delete-region (point) (progn (forward-line 1) (point))))
1154 (defun texinfo-discard-line-with-args ()
1155 (goto-char texinfo-command-start
)
1156 (delete-region (point) (progn (forward-line 1) (point))))
1161 ;; Only `texinfo-format-buffer' handles @setfilename with this
1162 ;; definition; `texinfo-format-region' handles @setfilename, if any,
1164 (put 'setfilename
'texinfo-format
'texinfo-format-setfilename
)
1165 (defun texinfo-format-setfilename ()
1166 (texinfo-parse-arg-discard))
1168 ;;; @node, @menu, @detailmenu
1170 (put 'node
'texinfo-format
'texinfo-format-node
)
1171 (put 'nwnode
'texinfo-format
'texinfo-format-node
)
1172 (defun texinfo-format-node ()
1173 (let* ((args (texinfo-format-parse-line-args))
1178 (texinfo-discard-command)
1179 (setq texinfo-last-node name
)
1180 (let ((tem (if texinfo-fold-nodename-case
(downcase name
) name
)))
1181 (if (assoc tem texinfo-node-names
)
1182 (error "Duplicate node name: %s" name
)
1183 (setq texinfo-node-names
(cons (list tem
) texinfo-node-names
))))
1184 (setq texinfo-footnote-number
0)
1185 ;; insert "\n\^_" unconditionally since this is what info is looking for
1186 (insert "\n\^_\nFile: " texinfo-format-filename
1189 (insert ", Next: " next
))
1191 (insert ", Prev: " prev
))
1193 (insert ", Up: " up
))
1195 (setq texinfo-last-node-pos
(point))))
1197 (put 'anchor
'texinfo-format
'texinfo-anchor
)
1198 (defun texinfo-anchor ()
1200 (here (- (point) 7)) ; save location of beginning of `@anchor'
1201 (arg (texinfo-parse-arg-discard)))
1202 (if (looking-at " ") ; since a space may be left after -discard
1205 (let ((end (point)))
1208 (search-forward "@refill" end t
))
1209 (setq anchor-string
"@anchor-yes-refill")
1210 (setq anchor-string
"@anchor-no-refill")))
1212 (insert anchor-string
"{" arg
"}")))
1214 (put 'menu
'texinfo-format
'texinfo-format-menu
)
1215 (defun texinfo-format-menu ()
1216 (texinfo-discard-line)
1217 (insert "* Menu:\n\n"))
1219 (put 'menu
'texinfo-end
'texinfo-discard-command
)
1221 ;; The @detailmenu should be removed eventually.
1223 ;; According to Karl Berry, 31 August 1996:
1225 ;; You don't like, I don't like it. I agree, it would be better just to
1226 ;; fix the bug [in `makeinfo']. .. At this point, since inserting those
1227 ;; two commands in the Elisp fn is trivial, I don't especially want to
1228 ;; expend more effort...
1230 ;; I added a couple sentences of documentation to the manual (putting the
1231 ;; blame on makeinfo where it belongs :-().
1233 (put 'detailmenu
'texinfo-format
'texinfo-discard-line
)
1234 (put 'detailmenu
'texinfo-end
'texinfo-discard-command
)
1236 ;; (Also see `texnfo-upd.el')
1239 ;;; Cross references
1241 ;; @xref {NODE, FNAME, NAME, FILE, DOCUMENT}
1242 ;; -> *Note FNAME: (FILE)NODE
1243 ;; If FILE is missing,
1244 ;; *Note FNAME: NODE
1245 ;; If FNAME is empty and NAME is present
1247 ;; If both NAME and FNAME are missing
1249 ;; texinfo ignores the DOCUMENT argument.
1250 ;; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1251 ;; If FILE is specified, (FILE)NODE is used for xrefs.
1252 ;; If fifth argument DOCUMENT is specified, produces
1253 ;; See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1256 ;; @ref a reference that does not put `See' or `see' in
1257 ;; the hardcopy and is the same as @xref in Info
1258 (put 'ref
'texinfo-format
'texinfo-format-xref
)
1260 (put 'xref
'texinfo-format
'texinfo-format-xref
)
1261 (defun texinfo-format-xref ()
1262 (let ((args (texinfo-format-parse-args)))
1263 (texinfo-discard-command)
1265 (let ((fname (or (nth 1 args
) (nth 2 args
))))
1266 (if (null (or fname
(nth 3 args
)))
1267 (insert (car args
) "::")
1268 (insert (or fname
(car args
)) ": ")
1270 (insert "(" (nth 3 args
) ")"))
1271 (and (car args
) (insert (car args
)))))))
1273 (put 'pxref
'texinfo-format
'texinfo-format-pxref
)
1274 (defun texinfo-format-pxref ()
1275 (texinfo-format-xref)
1281 ;; @inforef{NODE, FNAME, FILE}
1282 ;; Like @xref{NODE, FNAME,,FILE} in texinfo.
1283 ;; In Tex, generates "See Info file FILE, node NODE"
1284 (put 'inforef
'texinfo-format
'texinfo-format-inforef
)
1285 (defun texinfo-format-inforef ()
1286 (let ((args (texinfo-format-parse-args)))
1287 (texinfo-discard-command)
1289 (insert "*Note " (nth 1 args
) ": (" (nth 2 args
) ")" (car args
))
1290 (insert "*Note " "(" (nth 2 args
) ")" (car args
) "::"))))
1293 ;;; URL Reference: @uref
1295 ;; @uref produces a reference to a uniform resource locator (URL).
1296 ;; It takes one mandatory argument, the URL, and one optional argument,
1297 ;; the text to display (the default is the URL itself).
1299 (put 'uref
'texinfo-format
'texinfo-format-uref
)
1300 (defun texinfo-format-uref ()
1301 "Format URL and optional URL-TITLE.
1302 Insert ` ... ' around URL if no URL-TITLE argument;
1303 otherwise, insert URL-TITLE followed by URL in parentheses."
1304 (let ((args (texinfo-format-parse-args)))
1305 (texinfo-discard-command)
1308 (insert (nth 1 args
) " (" (nth 0 args
) ")")
1309 (insert "`" (nth 0 args
) "'"))
1310 (goto-char texinfo-command-start
)))
1313 ;;; Section headings
1315 (put 'majorheading
'texinfo-format
'texinfo-format-chapter
)
1316 (put 'chapheading
'texinfo-format
'texinfo-format-chapter
)
1317 (put 'ichapter
'texinfo-format
'texinfo-format-chapter
)
1318 (put 'chapter
'texinfo-format
'texinfo-format-chapter
)
1319 (put 'iappendix
'texinfo-format
'texinfo-format-chapter
)
1320 (put 'appendix
'texinfo-format
'texinfo-format-chapter
)
1321 (put 'iunnumbered
'texinfo-format
'texinfo-format-chapter
)
1322 (put 'top
'texinfo-format
'texinfo-format-chapter
)
1323 (put 'unnumbered
'texinfo-format
'texinfo-format-chapter
)
1324 (put 'centerchap
'texinfo-format
'texinfo-format-chapter
)
1325 (defun texinfo-format-chapter ()
1326 (texinfo-format-chapter-1 ?
*))
1328 (put 'heading
'texinfo-format
'texinfo-format-section
)
1329 (put 'isection
'texinfo-format
'texinfo-format-section
)
1330 (put 'section
'texinfo-format
'texinfo-format-section
)
1331 (put 'iappendixsection
'texinfo-format
'texinfo-format-section
)
1332 (put 'appendixsection
'texinfo-format
'texinfo-format-section
)
1333 (put 'iappendixsec
'texinfo-format
'texinfo-format-section
)
1334 (put 'appendixsec
'texinfo-format
'texinfo-format-section
)
1335 (put 'iunnumberedsec
'texinfo-format
'texinfo-format-section
)
1336 (put 'unnumberedsec
'texinfo-format
'texinfo-format-section
)
1337 (defun texinfo-format-section ()
1338 (texinfo-format-chapter-1 ?
=))
1340 (put 'subheading
'texinfo-format
'texinfo-format-subsection
)
1341 (put 'isubsection
'texinfo-format
'texinfo-format-subsection
)
1342 (put 'subsection
'texinfo-format
'texinfo-format-subsection
)
1343 (put 'iappendixsubsec
'texinfo-format
'texinfo-format-subsection
)
1344 (put 'appendixsubsec
'texinfo-format
'texinfo-format-subsection
)
1345 (put 'iunnumberedsubsec
'texinfo-format
'texinfo-format-subsection
)
1346 (put 'unnumberedsubsec
'texinfo-format
'texinfo-format-subsection
)
1347 (defun texinfo-format-subsection ()
1348 (texinfo-format-chapter-1 ?-
))
1350 (put 'subsubheading
'texinfo-format
'texinfo-format-subsubsection
)
1351 (put 'isubsubsection
'texinfo-format
'texinfo-format-subsubsection
)
1352 (put 'subsubsection
'texinfo-format
'texinfo-format-subsubsection
)
1353 (put 'iappendixsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1354 (put 'appendixsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1355 (put 'iunnumberedsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1356 (put 'unnumberedsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1357 (defun texinfo-format-subsubsection ()
1358 (texinfo-format-chapter-1 ?.
))
1360 (defun texinfo-format-chapter-1 (belowchar)
1361 (let ((arg (texinfo-parse-arg-discard)))
1362 (message "Formatting: %s ... " arg
) ; So we can see where we are.
1363 (insert ?
\n arg ?
\n "@SectionPAD " belowchar ?
\n)
1366 (put 'SectionPAD
'texinfo-format
'texinfo-format-sectionpad
)
1367 (defun texinfo-format-sectionpad ()
1368 (let ((str (texinfo-parse-arg-discard)))
1370 (let ((column (current-column)))
1374 (setq column
(1- column
))))
1378 ;;; Space controlling commands: @. and @:, and the soft hyphen.
1380 (put '\.
'texinfo-format
'texinfo-format-\.
)
1381 (defun texinfo-format-\.
()
1382 (texinfo-discard-command)
1385 (put '\
: 'texinfo-format
'texinfo-format-\
:)
1386 (defun texinfo-format-\
: ()
1387 (texinfo-discard-command))
1389 (put '\-
'texinfo-format
'texinfo-format-soft-hyphen
)
1390 (defun texinfo-format-soft-hyphen ()
1391 (texinfo-discard-command))
1394 ;;; @center, @sp, and @br
1396 (put 'center
'texinfo-format
'texinfo-format-center
)
1397 (defun texinfo-format-center ()
1398 (let ((arg (texinfo-parse-expanded-arg)))
1399 (texinfo-discard-command)
1403 (goto-char (1- (point)))
1404 (let ((indent-tabs-mode nil
))
1407 (put 'sp
'texinfo-format
'texinfo-format-sp
)
1408 (defun texinfo-format-sp ()
1409 (let* ((arg (texinfo-parse-arg-discard))
1411 (insert-char ?
\n num
)))
1413 (put 'br
'texinfo-format
'texinfo-format-paragraph-break
)
1414 (defun texinfo-format-paragraph-break ()
1415 "Force a paragraph break.
1416 If used within a line, follow `@br' with braces."
1417 (texinfo-optional-braces-discard)
1418 ;; insert one return if at end of line;
1419 ;; else insert two returns, to generate a blank line.
1420 (if (= (following-char) ?
\n)
1422 (insert-char ?
\n 2)))
1425 ;;; @footnote and @footnotestyle
1427 ;; In Texinfo, footnotes are created with the `@footnote' command.
1428 ;; This command is followed immediately by a left brace, then by the text of
1429 ;; the footnote, and then by a terminating right brace. The
1430 ;; template for a footnote is:
1434 ;; Info has two footnote styles:
1436 ;; * In the End of node style, all the footnotes for a single node
1437 ;; are placed at the end of that node. The footnotes are
1438 ;; separated from the rest of the node by a line of dashes with
1439 ;; the word `Footnotes' within it.
1441 ;; * In the Separate node style, all the footnotes for a single node
1442 ;; are placed in an automatically constructed node of their own.
1444 ;; Footnote style is specified by the @footnotestyle command, either
1445 ;; @footnotestyle separate
1447 ;; @footnotestyle end
1449 ;; The default is separate
1451 (defvar texinfo-footnote-style
"separate"
1452 "Footnote style, either separate or end.")
1454 (put 'footnotestyle
'texinfo-format
'texinfo-footnotestyle
)
1455 (defun texinfo-footnotestyle ()
1456 "Specify whether footnotes are at end of node or in separate nodes.
1457 Argument is either end or separate."
1458 (setq texinfo-footnote-style
(texinfo-parse-arg-discard)))
1460 (defvar texinfo-footnote-number
)
1462 (put 'footnote
'texinfo-format
'texinfo-format-footnote
)
1463 (defun texinfo-format-footnote ()
1464 "Format a footnote in either end of node or separate node style.
1465 The texinfo-footnote-style variable controls which style is used."
1466 (setq texinfo-footnote-number
(1+ texinfo-footnote-number
))
1467 (cond ((string= texinfo-footnote-style
"end")
1468 (texinfo-format-end-node))
1469 ((string= texinfo-footnote-style
"separate")
1470 (texinfo-format-separate-node))))
1472 (defun texinfo-format-separate-node ()
1473 "Format footnote in Separate node style, with notes in own node.
1474 The node is constructed automatically."
1476 (arg (texinfo-parse-line-arg))
1477 (node-name-beginning
1480 "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:")
1484 (buffer-substring-no-properties
1485 (progn (goto-char node-name-beginning
) ; skip over node command
1486 (skip-chars-forward " \t") ; and over spaces
1490 (save-excursion (end-of-line) (point)) t
) ; bound search
1492 (end-of-line) (point))))))
1493 (texinfo-discard-command) ; remove or insert whitespace, as needed
1494 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1496 (insert (format " (%d) (*Note %s-Footnotes::)"
1497 texinfo-footnote-number node-name
))
1498 (fill-paragraph nil
)
1500 (if (re-search-forward "^@node" nil
'move
)
1503 ;; two cases: for the first footnote, we must insert a node header;
1504 ;; for the second and subsequent footnotes, we need only insert
1505 ;; the text of the footnote.
1509 (concat node-name
"-Footnotes, Up: ")
1512 (progn ; already at least one footnote
1513 (setq start
(point))
1514 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1515 (fill-region start
(point)))
1516 ;; else not yet a footnote
1517 (insert "\n\^_\nFile: " texinfo-format-filename
1518 " Node: " node-name
"-Footnotes, Up: " node-name
"\n")
1519 (setq start
(point))
1520 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1521 (fill-region start
(point))))))
1523 (defun texinfo-format-end-node ()
1524 "Format footnote in the End of node style, with notes at end of node."
1526 (arg (texinfo-parse-line-arg)))
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) " texinfo-footnote-number
))
1531 (fill-paragraph nil
)
1533 (if (search-forward "\n--------- Footnotes ---------\n" nil t
)
1534 (progn ; already have footnote, put new one before end of node
1535 (if (re-search-forward "^@node" nil
'move
)
1537 (setq start
(point))
1538 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1539 (fill-region start
(point)))
1540 ;; else no prior footnote
1541 (if (re-search-forward "^@node" nil
'move
)
1543 (insert "\n--------- Footnotes ---------\n")
1544 (setq start
(point))
1545 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))))))
1548 ;;; @itemize, @enumerate, and similar commands
1550 ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.
1551 ;; @enumerate pushes (enumerate 0 STARTPOS).
1552 ;; @item dispatches to the texinfo-item prop of the first elt of the list.
1553 ;; For itemize, this puts in and rescans the COMMANDS.
1554 ;; For enumerate, this increments the number and puts it in.
1555 ;; In either case, it puts a Backspace at the front of the line
1556 ;; which marks it not to be indented later.
1557 ;; All other lines get indented by 5 when the @end is reached.
1559 (defvar texinfo-stack-depth
0
1560 "Count of number of unpopped texinfo-push-stack calls.
1561 Used by @refill indenting command to avoid indenting within lists, etc.")
1563 (defun texinfo-push-stack (check arg
)
1564 (setq texinfo-stack-depth
(1+ texinfo-stack-depth
))
1566 (cons (list check arg texinfo-command-start
)
1569 (defun texinfo-pop-stack (check)
1570 (setq texinfo-stack-depth
(1- texinfo-stack-depth
))
1571 (if (null texinfo-stack
)
1572 (error "Unmatched @end %s" check
))
1573 (if (not (eq (car (car texinfo-stack
)) check
))
1574 (error "@end %s matches @%s"
1575 check
(car (car texinfo-stack
))))
1576 (prog1 (cdr (car texinfo-stack
))
1577 (setq texinfo-stack
(cdr texinfo-stack
))))
1579 (put 'itemize
'texinfo-format
'texinfo-itemize
)
1580 (defun texinfo-itemize ()
1583 (progn (skip-chars-forward " \t")
1586 (texinfo-parse-line-arg))))
1587 (texinfo-discard-line-with-args)
1588 (setq fill-column
(- fill-column
5)))
1590 (put 'itemize
'texinfo-end
'texinfo-end-itemize
)
1591 (defun texinfo-end-itemize ()
1592 (setq fill-column
(+ fill-column
5))
1593 (texinfo-discard-command)
1595 (texinfo-pop-stack 'itemize
)))
1596 (texinfo-do-itemize (nth 1 stacktop
))))
1598 (put 'enumerate
'texinfo-format
'texinfo-enumerate
)
1599 (defun texinfo-enumerate ()
1602 (progn (skip-chars-forward " \t")
1605 (read (current-buffer)))))
1606 (if (and (symbolp (car (cdr (car texinfo-stack
))))
1607 (> 1 (length (symbol-name (car (cdr (car texinfo-stack
)))))))
1609 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." ))
1610 (texinfo-discard-line-with-args)
1611 (setq fill-column
(- fill-column
5)))
1613 (put 'enumerate
'texinfo-end
'texinfo-end-enumerate
)
1614 (defun texinfo-end-enumerate ()
1615 (setq fill-column
(+ fill-column
5))
1616 (texinfo-discard-command)
1618 (texinfo-pop-stack 'enumerate
)))
1619 (texinfo-do-itemize (nth 1 stacktop
))))
1621 ;; @alphaenumerate never became a standard part of Texinfo
1622 (put 'alphaenumerate
'texinfo-format
'texinfo-alphaenumerate
)
1623 (defun texinfo-alphaenumerate ()
1624 (texinfo-push-stack 'alphaenumerate
(1- ?a
))
1625 (setq fill-column
(- fill-column
5))
1626 (texinfo-discard-line))
1628 (put 'alphaenumerate
'texinfo-end
'texinfo-end-alphaenumerate
)
1629 (defun texinfo-end-alphaenumerate ()
1630 (setq fill-column
(+ fill-column
5))
1631 (texinfo-discard-command)
1633 (texinfo-pop-stack 'alphaenumerate
)))
1634 (texinfo-do-itemize (nth 1 stacktop
))))
1636 ;; @capsenumerate never became a standard part of Texinfo
1637 (put 'capsenumerate
'texinfo-format
'texinfo-capsenumerate
)
1638 (defun texinfo-capsenumerate ()
1639 (texinfo-push-stack 'capsenumerate
(1- ?A
))
1640 (setq fill-column
(- fill-column
5))
1641 (texinfo-discard-line))
1643 (put 'capsenumerate
'texinfo-end
'texinfo-end-capsenumerate
)
1644 (defun texinfo-end-capsenumerate ()
1645 (setq fill-column
(+ fill-column
5))
1646 (texinfo-discard-command)
1648 (texinfo-pop-stack 'capsenumerate
)))
1649 (texinfo-do-itemize (nth 1 stacktop
))))
1651 ;; At the @end, indent all the lines within the construct
1652 ;; except those marked with backspace. FROM says where
1653 ;; construct started.
1654 (defun texinfo-do-itemize (from)
1656 (while (progn (forward-line -
1)
1658 (if (= (following-char) ?
\b)
1663 (if (not (looking-at "[ \t]*$"))
1664 (save-excursion (insert " ")))))))
1666 (put 'item
'texinfo-format
'texinfo-item
)
1667 (put 'itemx
'texinfo-format
'texinfo-item
)
1668 (defun texinfo-item ()
1669 (funcall (get (car (car texinfo-stack
)) 'texinfo-item
)))
1671 (put 'itemize
'texinfo-item
'texinfo-itemize-item
)
1672 (defun texinfo-itemize-item ()
1673 ;; (texinfo-discard-line) ; Did not handle text on same line as @item.
1674 (delete-region (1+ (point)) (save-excursion (beginning-of-line) (point)))
1675 (if (looking-at "[ \t]*[^ \t\n]+")
1676 ;; Text on same line as @item command.
1677 (insert "\b " (nth 1 (car texinfo-stack
)) " \n")
1678 ;; Else text on next line.
1679 (insert "\b " (nth 1 (car texinfo-stack
)) " "))
1682 (put 'enumerate
'texinfo-item
'texinfo-enumerate-item
)
1683 (defun texinfo-enumerate-item ()
1684 (texinfo-discard-line)
1685 (let (enumerating-symbol)
1686 (cond ((integerp (car (cdr (car texinfo-stack
))))
1687 (setq enumerating-symbol
(car (cdr (car texinfo-stack
))))
1688 (insert ?
\b (format "%3d. " enumerating-symbol
) ?
\n)
1689 (setcar (cdr (car texinfo-stack
)) (1+ enumerating-symbol
)))
1690 ((symbolp (car (cdr (car texinfo-stack
))))
1691 (setq enumerating-symbol
1692 (symbol-name (car (cdr (car texinfo-stack
)))))
1693 (if (or (equal ?\
[ (string-to-char enumerating-symbol
))
1694 (equal ?\
{ (string-to-char enumerating-symbol
)))
1696 "Too many items in enumerated list; alphabet ends at Z."))
1697 (insert ?
\b (format "%3s. " enumerating-symbol
) ?
\n)
1698 (setcar (cdr (car texinfo-stack
))
1702 (string-to-char enumerating-symbol
))))))
1705 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." )))
1708 (put 'alphaenumerate
'texinfo-item
'texinfo-alphaenumerate-item
)
1709 (defun texinfo-alphaenumerate-item ()
1710 (texinfo-discard-line)
1711 (let ((next (1+ (car (cdr (car texinfo-stack
))))))
1713 (error "More than 26 items in @alphaenumerate; get a bigger alphabet"))
1714 (setcar (cdr (car texinfo-stack
)) next
)
1715 (insert "\b " next
". \n"))
1718 (put 'capsenumerate
'texinfo-item
'texinfo-capsenumerate-item
)
1719 (defun texinfo-capsenumerate-item ()
1720 (texinfo-discard-line)
1721 (let ((next (1+ (car (cdr (car texinfo-stack
))))))
1723 (error "More than 26 items in @capsenumerate; get a bigger alphabet"))
1724 (setcar (cdr (car texinfo-stack
)) next
)
1725 (insert "\b " next
". \n"))
1731 ;; The `@table' command produces two-column tables.
1733 (put 'table
'texinfo-format
'texinfo-table
)
1734 (defun texinfo-table ()
1737 (progn (skip-chars-forward " \t")
1740 (texinfo-parse-line-arg))))
1741 (texinfo-discard-line-with-args)
1742 (setq fill-column
(- fill-column
5)))
1744 (put 'table
'texinfo-item
'texinfo-table-item
)
1745 (defun texinfo-table-item ()
1746 (let ((arg (texinfo-parse-arg-discard))
1747 (itemfont (car (cdr (car texinfo-stack
)))))
1748 (insert ?
\b itemfont ?\
{ arg
"}\n \n"))
1751 (put 'table
'texinfo-end
'texinfo-end-table
)
1752 (defun texinfo-end-table ()
1753 (setq fill-column
(+ fill-column
5))
1754 (texinfo-discard-command)
1756 (texinfo-pop-stack 'table
)))
1757 (texinfo-do-itemize (nth 1 stacktop
))))
1759 ;; @description appears to be an undocumented variant on @table that
1760 ;; does not require an arg. It fails in texinfo.tex 2.58 and is not
1761 ;; part of makeinfo.c The command appears to be a relic of the past.
1762 (put 'description
'texinfo-end
'texinfo-end-table
)
1763 (put 'description
'texinfo-format
'texinfo-description
)
1764 (defun texinfo-description ()
1765 (texinfo-push-stack 'table
"@asis")
1766 (setq fill-column
(- fill-column
5))
1767 (texinfo-discard-line))
1770 ;;; @ftable, @vtable
1772 ;; The `@ftable' and `@vtable' commands are like the `@table' command
1773 ;; but they also insert each entry in the first column of the table
1774 ;; into the function or variable index.
1776 ;; Handle the @ftable and @vtable commands:
1778 (put 'ftable
'texinfo-format
'texinfo-ftable
)
1779 (put 'vtable
'texinfo-format
'texinfo-vtable
)
1781 (defun texinfo-ftable () (texinfo-indextable 'ftable
))
1782 (defun texinfo-vtable () (texinfo-indextable 'vtable
))
1784 (defun texinfo-indextable (table-type)
1785 (texinfo-push-stack table-type
(texinfo-parse-arg-discard))
1786 (setq fill-column
(- fill-column
5)))
1788 ;; Handle the @item commands within ftable and vtable:
1790 (put 'ftable
'texinfo-item
'texinfo-ftable-item
)
1791 (put 'vtable
'texinfo-item
'texinfo-vtable-item
)
1793 (defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex
))
1794 (defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex
))
1796 (defun texinfo-indextable-item (index-type)
1797 (let ((item (texinfo-parse-arg-discard))
1798 (itemfont (car (cdr (car texinfo-stack
))))
1799 (indexvar index-type
))
1800 (insert ?
\b itemfont ?\
{ item
"}\n \n")
1803 (list item texinfo-last-node
)
1804 (symbol-value indexvar
)))
1807 ;; Handle @end ftable, @end vtable
1809 (put 'ftable
'texinfo-end
'texinfo-end-ftable
)
1810 (put 'vtable
'texinfo-end
'texinfo-end-vtable
)
1812 (defun texinfo-end-ftable () (texinfo-end-indextable 'ftable
))
1813 (defun texinfo-end-vtable () (texinfo-end-indextable 'vtable
))
1815 (defun texinfo-end-indextable (table-type)
1816 (setq fill-column
(+ fill-column
5))
1817 (texinfo-discard-command)
1819 (texinfo-pop-stack table-type
)))
1820 (texinfo-do-itemize (nth 1 stacktop
))))
1823 ;;; @multitable ... @end multitable
1825 ;; Produce a multi-column table, with as many columns as desired.
1827 ;; A multi-column table has this template:
1829 ;; @multitable {A1} {A2} {A3}
1830 ;; @item A1 @tab A2 @tab A3
1831 ;; @item B1 @tab B2 @tab B3
1832 ;; @item C1 @tab C2 @tab C3
1835 ;; where the width of the text in brackets specifies the width of the
1836 ;; respective column.
1840 ;; @multitable @columnfractions .25 .3 .45
1841 ;; @item A1 @tab A2 @tab A3
1842 ;; @item B1 @tab B2 @tab B3
1845 ;; where the fractions specify the width of each column as a percent
1846 ;; of the current width of the text (i.e., of the fill-column).
1848 ;; Long lines of text are filled within columns.
1850 ;; Using the Emacs Lisp formatter, texinfmt.el,
1851 ;; the whitespace between columns can be increased by setting
1852 ;; `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1853 ;; there is at least one blank space between columns.
1855 ;; The Emacs Lisp formatter, texinfmt.el, ignores the following four
1856 ;; commands that are defined in texinfo.tex for printed output.
1858 ;; @multitableparskip,
1859 ;; @multitableparindent,
1860 ;; @multitablecolmargin,
1861 ;; @multitablelinespace.
1863 ;; How @multitable works.
1864 ;; =====================
1866 ;; `texinfo-multitable' reads the @multitable line and determines from it
1867 ;; how wide each column should be.
1869 ;; Also, it pushes this information, along with an identifying symbol,
1870 ;; onto the `texinfo-stack'. At the @end multitable command, the stack
1871 ;; is checked for its matching @multitable command, and then popped, or
1872 ;; else an error is signaled. Also, this command pushes the location of
1873 ;; the start of the table onto the stack.
1875 ;; `texinfo-end-multitable' checks the `texinfo-stack' that the @end
1876 ;; multitable truly is ending a corresponding beginning, and if it is,
1879 ;; `texinfo-multitable-widths' is called by `texinfo-multitable'.
1880 ;; The function returns a list of the widths of each column in a
1881 ;; multi-column table, based on the information supplied by the arguments
1882 ;; to the @multitable command (by arguments, I mean the text on the rest
1883 ;; of the @multitable line, not the remainder of the multi-column table
1886 ;; `texinfo-multitable-item' formats a row within a multicolumn table.
1887 ;; This command is executed when texinfmt sees @item inside @multitable.
1888 ;; Cells in row are separated by `@tab's. Widths of cells are specified
1889 ;; by the arguments in the @multitable line. Cells are filled. All cells
1890 ;; are made to be the same height by padding their bottoms, as needed,
1893 ;; `texinfo-multitable-extract-row' is called by `texinfo-multitable-item'.
1894 ;; This function returns the text in a multitable row, as a string.
1895 ;; The start of a row is marked by an @item and the end of row is the
1896 ;; beginning of next @item or beginning of the @end multitable line.
1897 ;; Cells within a row are separated by @tab.
1899 ;; Note that @tab, the cell separators, are not treated as independent
1900 ;; Texinfo commands.
1902 (defvar texinfo-extra-inter-column-width
0
1903 "*Number of extra spaces between entries (columns) in @multitable.")
1905 (defvar texinfo-multitable-buffer-name
"*multitable-temporary-buffer*")
1906 (defvar texinfo-multitable-rectangle-name
"texinfo-multitable-temp-")
1908 ;; These commands are defined in texinfo.tex for printed output.
1909 (put 'multitableparskip
'texinfo-format
'texinfo-discard-line-with-args
)
1910 (put 'multitableparindent
'texinfo-format
'texinfo-discard-line-with-args
)
1911 (put 'multitablecolmargin
'texinfo-format
'texinfo-discard-line-with-args
)
1912 (put 'multitablelinespace
'texinfo-format
'texinfo-discard-line-with-args
)
1914 (put 'multitable
'texinfo-format
'texinfo-multitable
)
1916 (defun texinfo-multitable ()
1917 "Produce multi-column tables.
1919 A multi-column table has this template:
1921 @multitable {A1} {A2} {A3}
1922 @item A1 @tab A2 @tab A3
1923 @item B1 @tab B2 @tab B3
1924 @item C1 @tab C2 @tab C3
1927 where the width of the text in brackets specifies the width of the
1932 @multitable @columnfractions .25 .3 .45
1933 @item A1 @tab A2 @tab A3
1934 @item B1 @tab B2 @tab B3
1937 where the fractions specify the width of each column as a percent
1938 of the current width of the text (i.e., of the fill-column).
1940 Long lines of text are filled within columns.
1942 Using the Emacs Lisp formatter, texinfmt.el,
1943 the whitespace between columns can be increased by setting
1944 `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1945 there is at least one blank space between columns.
1947 The Emacs Lisp formatter, texinfmt.el, ignores the following four
1948 commands that are defined in texinfo.tex for printed output.
1951 @multitableparindent,
1952 @multitablecolmargin,
1953 @multitablelinespace."
1955 ;; This function pushes information onto the `texinfo-stack'.
1956 ;; A stack element consists of:
1957 ;; - type-of-command, i.e., multitable
1958 ;; - the information about column widths, and
1959 ;; - the position of texinfo-command-start.
1960 ;; e.g., ('multitable (1 2 3 4) 123)
1961 ;; The command line is then deleted.
1964 ;; push width information on stack
1965 (texinfo-multitable-widths))
1966 (texinfo-discard-line-with-args))
1968 (put 'multitable
'texinfo-end
'texinfo-end-multitable
)
1969 (defun texinfo-end-multitable ()
1970 "Discard the @end multitable line and pop the stack of multitable."
1971 (texinfo-discard-command)
1972 (texinfo-pop-stack 'multitable
))
1974 (defun texinfo-multitable-widths ()
1975 "Return list of widths of each column in a multi-column table."
1976 (let (texinfo-multitable-width-list)
1977 ;; Fractions format:
1978 ;; @multitable @columnfractions .25 .3 .45
1981 ;; @multitable {Column 1 template} {Column 2} {Column 3 example}
1982 ;; Place point before first argument
1983 (skip-chars-forward " \t")
1985 ;; Check for common misspelling
1986 ((looking-at "@columnfraction ")
1987 (error "In @multitable, @columnfractions misspelled"))
1988 ;; Case 1: @columnfractions .25 .3 .45
1989 ((looking-at "@columnfractions")
1992 (setq texinfo-multitable-width-list
1996 (* fill-column
(read (get-buffer (current-buffer))))))
1997 texinfo-multitable-width-list
))))
1999 ;; Case 2: {Column 1 template} {Column 2} {Column 3 example}
2001 (let ((start-of-templates (point)))
2003 (skip-chars-forward " \t")
2004 (let* ((start-of-template (1+ (point)))
2006 ;; forward-sexp works with braces in Texinfo mode
2007 (progn (forward-sexp 1) (1- (point)))))
2008 (setq texinfo-multitable-width-list
2009 (cons (- end-of-template start-of-template
)
2010 texinfo-multitable-width-list
))
2011 ;; Remove carriage return from within a template, if any.
2012 ;; This helps those those who want to use more than
2013 ;; one line's worth of words in @multitable line.
2014 (narrow-to-region start-of-template end-of-template
)
2015 (goto-char (point-min))
2016 (while (search-forward "
2019 (goto-char (point-max))
2021 (forward-char 1)))))
2026 "You probably need to specify column widths for @multitable correctly.")))
2027 ;; Check whether columns fit on page.
2028 (let ((desired-columns
2030 ;; between column spaces
2031 (length texinfo-multitable-width-list
)
2032 ;; additional between column spaces, if any
2033 texinfo-extra-inter-column-width
2034 ;; sum of spaces for each entry
2035 (apply '+ texinfo-multitable-width-list
))))
2036 (if (> desired-columns fill-column
)
2039 "Multi-column table width, %d chars, is greater than page width, %d chars."
2040 desired-columns fill-column
))))
2041 texinfo-multitable-width-list
))
2043 ;; @item A1 @tab A2 @tab A3
2044 (defun texinfo-multitable-extract-row ()
2045 "Return multitable row, as a string.
2046 End of row is beginning of next @item or beginning of @end.
2047 Cells within rows are separated by @tab."
2048 (skip-chars-forward " \t")
2049 (let* ((start (point))
2051 (re-search-forward "@item\\|@end")
2052 (match-beginning 0)))
2053 (row (progn (goto-char end
)
2054 (skip-chars-backward " ")
2055 ;; remove whitespace at end of argument
2056 (delete-region (point) end
)
2057 (buffer-substring-no-properties start
(point)))))
2058 (delete-region texinfo-command-start end
)
2061 (put 'multitable
'texinfo-item
'texinfo-multitable-item
)
2062 (defun texinfo-multitable-item ()
2063 "Format a row within a multicolumn table.
2064 Cells in row are separated by @tab.
2065 Widths of cells are specified by the arguments in the @multitable line.
2066 All cells are made to be the same height.
2067 This command is executed when texinfmt sees @item inside @multitable."
2068 (let ((original-buffer (current-buffer))
2069 (table-widths (reverse (car (cdr (car texinfo-stack
)))))
2070 (existing-fill-column fill-column
)
2074 (table-entry-height 0)
2075 ;; unformatted row looks like: A1 @tab A2 @tab A3
2076 ;; extract-row command deletes the source line in the table.
2077 (unformated-row (texinfo-multitable-extract-row)))
2078 ;; Use a temporary buffer
2079 (set-buffer (get-buffer-create texinfo-multitable-buffer-name
))
2080 (delete-region (point-min) (point-max))
2081 (insert unformated-row
)
2082 (goto-char (point-min))
2083 ;; 1. Check for correct number of @tab in line.
2084 (let ((tab-number 1)) ; one @tab between two columns
2085 (while (search-forward "@tab" nil t
)
2086 (setq tab-number
(1+ tab-number
)))
2087 (if (/= tab-number
(length table-widths
))
2088 (error "Wrong number of @tab's in a @multitable row")))
2089 (goto-char (point-min))
2090 ;; 2. Format each cell, and copy to a rectangle
2091 ;; buffer looks like this: A1 @tab A2 @tab A3
2092 ;; Cell #1: format up to @tab
2093 ;; Cell #2: format up to @tab
2094 ;; Cell #3: format up to eob
2096 (setq start
(point))
2097 (setq end
(save-excursion
2098 (if (search-forward "@tab" nil
'move
)
2099 ;; Delete the @tab command, including the @-sign
2102 (progn (forward-word -
1) (1- (point)))))
2104 ;; Set fill-column *wider* than needed to produce inter-column space
2105 (setq fill-column
(+ 1
2106 texinfo-extra-inter-column-width
2107 (nth table-column table-widths
)))
2108 (narrow-to-region start end
)
2109 ;; Remove whitespace before and after entry.
2110 (skip-chars-forward " ")
2111 (delete-region (point) (save-excursion (beginning-of-line) (point)))
2112 (goto-char (point-max))
2113 (skip-chars-backward " ")
2114 (delete-region (point) (save-excursion (end-of-line) (point)))
2115 ;; Temporarily set texinfo-stack to nil so texinfo-format-scan
2116 ;; does not see an unterminated @multitable.
2117 (let (texinfo-stack) ; nil
2118 (texinfo-format-scan))
2119 (let (fill-prefix) ; no fill prefix
2120 (fill-region (point-min) (point-max)))
2121 (setq table-entry-height
2122 (max table-entry-height
(count-lines (point-min) (point-max))))
2123 ;; 3. Move point to end of bottom line, and pad that line to fill column.
2124 (goto-char (point-min))
2125 (forward-line (1- table-entry-height
))
2126 (let* ((beg (point)) ; beginning of line
2127 ;; add one more space for inter-column spacing
2132 (progn (end-of-line) (point)) ; end of existing line
2134 (insert (make-string
2135 (if (> needed-whitespace
0) needed-whitespace
1)
2137 ;; now, put formatted cell into a rectangle
2138 (set (intern (concat texinfo-multitable-rectangle-name
2139 (int-to-string table-column
)))
2140 (extract-rectangle (point-min) (point)))
2141 (delete-region (point-min) (point))
2142 (goto-char (point-max))
2143 (setq table-column
(1+ table-column
))
2145 ;; 4. Add extra lines to rectangles so all are of same height
2146 (let ((total-number-of-columns table-column
)
2149 (while (> table-column
0)
2150 (let ((this-rectangle (int-to-string table-column
)))
2151 (while (< (length this-rectangle
) table-entry-height
)
2152 (setq this-rectangle
(append this-rectangle
'("")))))
2153 (setq table-column
(1- table-column
)))
2154 ;; 5. Insert formatted rectangles in original buffer
2155 (switch-to-buffer original-buffer
)
2156 (open-line table-entry-height
)
2157 (while (< column-number total-number-of-columns
)
2161 (concat texinfo-multitable-rectangle-name
2162 (int-to-string column-number
)))))
2165 (setq column-number
(1+ column-number
))))
2166 (kill-buffer texinfo-multitable-buffer-name
)
2167 (setq fill-column existing-fill-column
)))
2170 ;;; @ifinfo, @iftex, @tex, @ifhtml, @html, @ifplaintext, @ifxml, @xml
2171 ;; @ifnottex, @ifnotinfo, @ifnothtml, @ifnotplaintext, @ifnotxml
2173 (put 'ifinfo
'texinfo-format
'texinfo-discard-line
)
2174 (put 'ifinfo
'texinfo-end
'texinfo-discard-command
)
2176 (put 'iftex
'texinfo-format
'texinfo-format-iftex
)
2177 (defun texinfo-format-iftex ()
2178 (delete-region texinfo-command-start
2179 (progn (re-search-forward "@end iftex[ \t]*\n")
2182 (put 'ifhtml
'texinfo-format
'texinfo-format-ifhtml
)
2183 (defun texinfo-format-ifhtml ()
2184 (delete-region texinfo-command-start
2185 (progn (re-search-forward "@end ifhtml[ \t]*\n")
2188 (put 'ifplaintext
'texinfo-format
'texinfo-format-ifplaintext
)
2189 (defun texinfo-format-ifplaintext ()
2190 (delete-region texinfo-command-start
2191 (progn (re-search-forward "@end ifplaintext[ \t]*\n")
2194 (put 'ifxml
'texinfo-format
'texinfo-format-ifxml
)
2195 (defun texinfo-format-ifxml ()
2196 (delete-region texinfo-command-start
2197 (progn (re-search-forward "^@end ifxml[ \t]*\n")
2200 (put 'tex
'texinfo-format
'texinfo-format-tex
)
2201 (defun texinfo-format-tex ()
2202 (delete-region texinfo-command-start
2203 (progn (re-search-forward "@end tex[ \t]*\n")
2206 (put 'html
'texinfo-format
'texinfo-format-html
)
2207 (defun texinfo-format-html ()
2208 (delete-region texinfo-command-start
2209 (progn (re-search-forward "@end html[ \t]*\n")
2212 (put 'xml
'texinfo-format
'texinfo-format-xml
)
2213 (defun texinfo-format-xml ()
2214 (delete-region texinfo-command-start
2215 (progn (re-search-forward "^@end xml[ \t]*\n")
2218 (put 'ifnotinfo
'texinfo-format
'texinfo-format-ifnotinfo
)
2219 (defun texinfo-format-ifnotinfo ()
2220 (delete-region texinfo-command-start
2221 (progn (re-search-forward "@end ifnotinfo[ \t]*\n")
2224 (put 'ifnotplaintext
'texinfo-format
'texinfo-discard-line
)
2225 (put 'ifnotplaintext
'texinfo-end
'texinfo-discard-command
)
2227 (put 'ifnottex
'texinfo-format
'texinfo-discard-line
)
2228 (put 'ifnottex
'texinfo-end
'texinfo-discard-command
)
2230 (put 'ifnothtml
'texinfo-format
'texinfo-discard-line
)
2231 (put 'ifnothtml
'texinfo-end
'texinfo-discard-command
)
2233 (put 'ifnotxml
'texinfo-format
'texinfo-discard-line
)
2234 (put 'ifnotxml
'texinfo-end
'texinfo-discard-command
)
2239 (put 'titlepage
'texinfo-format
'texinfo-format-titlepage
)
2240 (defun texinfo-format-titlepage ()
2241 (delete-region texinfo-command-start
2242 (progn (re-search-forward "@end titlepage[ \t]*\n")
2245 (put 'endtitlepage
'texinfo-format
'texinfo-discard-line
)
2247 ;; @titlespec an alternative titling command; ignored by Info
2249 (put 'titlespec
'texinfo-format
'texinfo-format-titlespec
)
2250 (defun texinfo-format-titlespec ()
2251 (delete-region texinfo-command-start
2252 (progn (re-search-forward "@end titlespec[ \t]*\n")
2255 (put 'endtitlespec
'texinfo-format
'texinfo-discard-line
)
2260 (put 'today
'texinfo-format
'texinfo-format-today
)
2262 ;; Produces Day Month Year style of output. eg `1 Jan 1900'
2263 ;; The `@today{}' command requires a pair of braces, like `@dots{}'.
2264 (defun texinfo-format-today ()
2265 (texinfo-parse-arg-discard)
2266 (insert (format-time-string "%e %b %Y")))
2270 ;; Produce `Day Month Year Hour:Min' style of output.
2271 ;; eg `1 Jan 1900 13:52'
2273 (put 'timestamp
'texinfo-format
'texinfo-format-timestamp
)
2275 ;; The `@timestamp{}' command requires a pair of braces, like `@dots{}'.
2276 (defun texinfo-format-timestamp ()
2277 "Insert the current local time and date."
2278 (texinfo-parse-arg-discard)
2279 ;; For seconds and time zone, replace format string with "%e %b %Y %T %Z"
2280 (insert (format-time-string "%e %b %Y %R")))
2285 (put 'ignore
'texinfo-format
'texinfo-format-ignore
)
2286 (defun texinfo-format-ignore ()
2287 (delete-region texinfo-command-start
2288 (progn (re-search-forward "@end ignore[ \t]*\n")
2291 (put 'endignore
'texinfo-format
'texinfo-discard-line
)
2294 ;;; Define the Info enclosure command: @definfoenclose
2296 ;; A `@definfoenclose' command may be used to define a highlighting
2297 ;; command for Info, but not for TeX. A command defined using
2298 ;; `@definfoenclose' marks text by enclosing it in strings that precede
2299 ;; and follow the text.
2301 ;; Presumably, if you define a command with `@definfoenclose` for Info,
2302 ;; you will also define the same command in the TeX definitions file,
2303 ;; `texinfo.tex' in a manner appropriate for typesetting.
2305 ;; Write a `@definfoenclose' command on a line and follow it with three
2306 ;; arguments separated by commas (commas are used as separators in an
2307 ;; `@node' line in the same way). The first argument to
2308 ;; `@definfoenclose' is the @-command name \(without the `@'\); the
2309 ;; second argument is the Info start delimiter string; and the third
2310 ;; argument is the Info end delimiter string. The latter two arguments
2311 ;; enclose the highlighted text in the Info file. A delimiter string
2312 ;; may contain spaces. Neither the start nor end delimiter is
2313 ;; required. However, if you do not provide a start delimiter, you
2314 ;; must follow the command name with two commas in a row; otherwise,
2315 ;; the Info formatting commands will misinterpret the end delimiter
2316 ;; string as a start delimiter string.
2318 ;; If you do a @definfoenclose{} on the name of a pre-defined macro (such
2319 ;; as @emph{}, @strong{}, @tt{}, or @i{}) the enclosure definition will
2320 ;; override the built-in definition.
2322 ;; An enclosure command defined this way takes one argument in braces.
2324 ;; For example, you can write:
2327 ;; @definfoenclose phoo, //, \\
2330 ;; near the beginning of a Texinfo file at the beginning of the lines
2331 ;; to define `@phoo' as an Info formatting command that inserts `//'
2332 ;; before and `\\' after the argument to `@phoo'. You can then write
2333 ;; `@phoo{bar}' wherever you want `//bar\\' highlighted in Info.
2335 ;; Also, for TeX formatting, you could write
2338 ;; @global@let@phoo=@i
2341 ;; to define `@phoo' as a command that causes TeX to typeset
2342 ;; the argument to `@phoo' in italics.
2344 ;; Note that each definition applies to its own formatter: one for TeX,
2345 ;; the other for texinfo-format-buffer or texinfo-format-region.
2347 ;; Here is another example: write
2349 ;; @definfoenclose headword, , :
2351 ;; near the beginning of the file, to define `@headword' as an Info
2352 ;; formatting command that inserts nothing before and a colon after the
2353 ;; argument to `@headword'.
2355 (put 'definfoenclose
'texinfo-format
'texinfo-define-info-enclosure
)
2356 (defun texinfo-define-info-enclosure ()
2357 (let* ((args (texinfo-format-parse-line-args))
2358 (command-name (nth 0 args
))
2359 (beginning-delimiter (or (nth 1 args
) ""))
2360 (end-delimiter (or (nth 2 args
) "")))
2361 (texinfo-discard-command)
2362 (setq texinfo-enclosure-list
2368 texinfo-enclosure-list
))))
2373 (put 'alias
'texinfo-format
'texinfo-alias
)
2374 (defun texinfo-alias ()
2375 (let ((start (1- (point)))
2377 (skip-chars-forward " ")
2378 (save-excursion (end-of-line) (setq texinfo-command-end
(point)))
2379 (if (not (looking-at "\\([^=]+\\)=\\(.*\\)"))
2380 (error "Invalid alias command")
2381 (setq texinfo-alias-list
2384 (buffer-substring-no-properties (match-beginning 1) (match-end 1))
2385 (buffer-substring-no-properties (match-beginning 2) (match-end 2)))
2386 texinfo-alias-list
))
2387 (texinfo-discard-command))
2392 ;;; @var, @code and the like
2394 (put 'var
'texinfo-format
'texinfo-format-var
)
2395 ;; @sc a small caps font for TeX; formatted as `var' in Info
2396 (put 'sc
'texinfo-format
'texinfo-format-var
)
2397 ;; @acronym for abbreviations in all caps, such as `NASA'.
2398 ;; Convert all letters to uppercase if they are not already.
2399 (put 'acronym
'texinfo-format
'texinfo-format-var
)
2400 (defun texinfo-format-var ()
2401 (let ((arg (texinfo-parse-expanded-arg)))
2402 (texinfo-discard-command)
2403 (insert (upcase arg
))))
2405 (put 'cite
'texinfo-format
'texinfo-format-code
)
2406 (put 'code
'texinfo-format
'texinfo-format-code
)
2407 ;; @command (for command names)
2408 (put 'command
'texinfo-format
'texinfo-format-code
)
2409 ;; @env (for environment variables)
2410 (put 'env
'texinfo-format
'texinfo-format-code
)
2411 (put 'file
'texinfo-format
'texinfo-format-code
)
2412 (put 'samp
'texinfo-format
'texinfo-format-code
)
2413 (put 'url
'texinfo-format
'texinfo-format-code
)
2414 (defun texinfo-format-code ()
2415 (insert "`" (texinfo-parse-arg-discard) "'")
2416 (goto-char texinfo-command-start
))
2418 ;; @option (for command-line options) must be different from @code
2419 ;; because of its special formatting in @table; namely that it does
2420 ;; not lead to inserted ` ... ' in a table, but does elsewhere.
2421 (put 'option
'texinfo-format
'texinfo-format-option
)
2422 (defun texinfo-format-option ()
2423 "Insert ` ... ' around arg unless inside a table; in that case, no quotes."
2424 ;; `looking-at-backward' not available in v. 18.57, 20.2
2425 (if (not (search-backward "\b" ; searched-for character is a control-H
2426 (save-excursion (beginning-of-line) (point))
2428 (insert "`" (texinfo-parse-arg-discard) "'")
2429 (insert (texinfo-parse-arg-discard)))
2430 (goto-char texinfo-command-start
))
2432 (put 'emph
'texinfo-format
'texinfo-format-emph
)
2433 (put 'strong
'texinfo-format
'texinfo-format-emph
)
2434 (defun texinfo-format-emph ()
2435 (insert "*" (texinfo-parse-arg-discard) "*")
2436 (goto-char texinfo-command-start
))
2438 (put 'dfn
'texinfo-format
'texinfo-format-defn
)
2439 (put 'defn
'texinfo-format
'texinfo-format-defn
)
2440 (defun texinfo-format-defn ()
2441 (insert "\"" (texinfo-parse-arg-discard) "\"")
2442 (goto-char texinfo-command-start
))
2444 (put 'email
'texinfo-format
'texinfo-format-email
)
2445 (defun texinfo-format-email ()
2446 "Format email address and optional following full name.
2447 Insert full name, if present, followed by email address
2448 surrounded by in angle brackets."
2449 (let ((args (texinfo-format-parse-args)))
2450 (texinfo-discard-command)
2453 (insert (nth 1 args
) " "))
2454 (insert "<" (nth 0 args
) ">")))
2456 (put 'key
'texinfo-format
'texinfo-format-key
)
2457 ;; I've decided not want to have angle brackets around these -- rms.
2458 (defun texinfo-format-key ()
2459 (insert (texinfo-parse-arg-discard))
2460 (goto-char texinfo-command-start
))
2462 (put 'bullet
'texinfo-format
'texinfo-format-bullet
)
2463 (defun texinfo-format-bullet ()
2464 "Insert an asterisk.
2465 If used within a line, follow `@bullet' with braces."
2466 (texinfo-optional-braces-discard)
2472 ;; Inside of @example ... @end example and similar environments,
2473 ;; @kbd does nothing; but outside of such environments, it places
2474 ;; single quotation marks around its argument.
2476 (defvar texinfo-format-kbd-regexp
2486 "Regexp specifying environments in which @kbd does not put `...'
2489 (defvar texinfo-format-kbd-end-regexp
2499 "Regexp specifying end of environments in which @kbd does not put `...'
2500 around argument. (See `texinfo-format-kbd-regexp')")
2502 (put 'kbd
'texinfo-format
'texinfo-format-kbd
)
2503 (defun texinfo-format-kbd ()
2504 "Place single quote marks around arg, except in @example and similar."
2505 ;; Search forward for @end example closer than an @example.
2506 ;; Can stop search at nearest @node or texinfo-section-types-regexp
2510 (concat "^@node\\|\\(" texinfo-section-types-regexp
"\\)")
2512 'move-to-end
) ; if necessary, return point at end of buffer
2516 (re-search-forward texinfo-format-kbd-regexp stop
'move-to-end
)
2518 (end-example-location
2520 (re-search-forward texinfo-format-kbd-end-regexp stop
'move-to-end
)
2522 ;; If inside @example, @end example will be closer than @example
2523 ;; or end of search i.e., end-example-location less than example-location
2524 (if (>= end-example-location example-location
)
2525 ;; outside an @example or equivalent
2526 (insert "`" (texinfo-parse-arg-discard) "'")
2527 ;; else, in @example; do not surround with `...'
2528 (insert (texinfo-parse-arg-discard)))
2529 (goto-char texinfo-command-start
)))
2532 ;;; @example, @lisp, @quotation, @display, @smalllisp, @smallexample,
2535 (put 'display
'texinfo-format
'texinfo-format-example
)
2536 (put 'smalldisplay
'texinfo-format
'texinfo-format-example
)
2537 (put 'example
'texinfo-format
'texinfo-format-example
)
2538 (put 'lisp
'texinfo-format
'texinfo-format-example
)
2539 (put 'quotation
'texinfo-format
'texinfo-format-example
)
2540 (put 'smallexample
'texinfo-format
'texinfo-format-example
)
2541 (put 'smalllisp
'texinfo-format
'texinfo-format-example
)
2542 (defun texinfo-format-example ()
2543 (texinfo-push-stack 'example nil
)
2544 (setq fill-column
(- fill-column
5))
2545 (texinfo-discard-line))
2547 (put 'example
'texinfo-end
'texinfo-end-example
)
2548 (put 'display
'texinfo-end
'texinfo-end-example
)
2549 (put 'smalldisplay
'texinfo-end
'texinfo-end-example
)
2550 (put 'lisp
'texinfo-end
'texinfo-end-example
)
2551 (put 'quotation
'texinfo-end
'texinfo-end-example
)
2552 (put 'smallexample
'texinfo-end
'texinfo-end-example
)
2553 (put 'smalllisp
'texinfo-end
'texinfo-end-example
)
2554 (defun texinfo-end-example ()
2555 (setq fill-column
(+ fill-column
5))
2556 (texinfo-discard-command)
2558 (texinfo-pop-stack 'example
)))
2559 (texinfo-do-itemize (nth 1 stacktop
))))
2561 (put 'exdent
'texinfo-format
'texinfo-format-exdent
)
2562 (defun texinfo-format-exdent ()
2563 (texinfo-discard-command)
2564 (delete-region (point)
2566 (skip-chars-forward " ")
2569 ;; Cancel out the deletion that texinfo-do-itemize
2570 ;; is going to do at the end of this line.
2576 ;; @direntry and @dircategory
2578 (put 'direntry
'texinfo-format
'texinfo-format-direntry
)
2579 (defun texinfo-format-direntry ()
2580 (texinfo-push-stack 'direntry nil
)
2581 (texinfo-discard-line)
2582 (insert "START-INFO-DIR-ENTRY\n"))
2584 (put 'direntry
'texinfo-end
'texinfo-end-direntry
)
2585 (defun texinfo-end-direntry ()
2586 (texinfo-discard-command)
2587 (insert "END-INFO-DIR-ENTRY\n\n")
2588 (texinfo-pop-stack 'direntry
))
2590 (put 'dircategory
'texinfo-format
'texinfo-format-dircategory
)
2591 (defun texinfo-format-dircategory ()
2592 (let ((str (texinfo-parse-arg-discard)))
2593 (delete-region (point)
2595 (skip-chars-forward " ")
2597 (insert "INFO-DIR-SECTION " str
"\n")))
2601 ;; The @cartouche command is a noop in Info; in a printed manual,
2602 ;; it makes a box with rounded corners.
2604 (put 'cartouche
'texinfo-format
'texinfo-discard-line
)
2605 (put 'cartouche
'texinfo-end
'texinfo-discard-command
)
2608 ;;; @flushleft and @format
2610 ;; The @flushleft command left justifies every line but leaves the
2611 ;; right end ragged. As far as Info is concerned, @flushleft is a
2612 ;; `do-nothing' command
2614 ;; The @format command is similar to @example except that it does not
2615 ;; indent; this means that in Info, @format is similar to @flushleft.
2617 (put 'format
'texinfo-format
'texinfo-format-flushleft
)
2618 (put 'smallformat
'texinfo-format
'texinfo-format-flushleft
)
2619 (put 'flushleft
'texinfo-format
'texinfo-format-flushleft
)
2620 (defun texinfo-format-flushleft ()
2621 (texinfo-discard-line))
2623 (put 'format
'texinfo-end
'texinfo-end-flushleft
)
2624 (put 'smallformat
'texinfo-end
'texinfo-end-flushleft
)
2625 (put 'flushleft
'texinfo-end
'texinfo-end-flushleft
)
2626 (defun texinfo-end-flushleft ()
2627 (texinfo-discard-command))
2632 ;; The @flushright command right justifies every line but leaves the
2633 ;; left end ragged. Spaces and tabs at the right ends of lines are
2634 ;; removed so that visible text lines up on the right side.
2636 (put 'flushright
'texinfo-format
'texinfo-format-flushright
)
2637 (defun texinfo-format-flushright ()
2638 (texinfo-push-stack 'flushright nil
)
2639 (texinfo-discard-line))
2641 (put 'flushright
'texinfo-end
'texinfo-end-flushright
)
2642 (defun texinfo-end-flushright ()
2643 (texinfo-discard-command)
2646 (texinfo-pop-stack 'flushright
)))
2648 (texinfo-do-flushright (nth 1 stacktop
))))
2650 (defun texinfo-do-flushright (from)
2652 (while (progn (forward-line -
1)
2661 (skip-chars-backward " \t")
2662 (delete-region (point) (progn (end-of-line) (point)))
2667 ;;; @ctrl, @TeX, @copyright, @minus, @dots, @enddots, @pounds
2669 (put 'ctrl
'texinfo-format
'texinfo-format-ctrl
)
2670 (defun texinfo-format-ctrl ()
2671 (let ((str (texinfo-parse-arg-discard)))
2672 (insert (logand 31 (aref str
0)))))
2674 (put 'TeX
'texinfo-format
'texinfo-format-TeX
)
2675 (defun texinfo-format-TeX ()
2676 (texinfo-parse-arg-discard)
2679 (put 'copyright
'texinfo-format
'texinfo-format-copyright
)
2680 (defun texinfo-format-copyright ()
2681 (texinfo-parse-arg-discard)
2684 (put 'minus
'texinfo-format
'texinfo-format-minus
)
2685 (defun texinfo-format-minus ()
2686 "Insert a minus sign.
2687 If used within a line, follow `@minus' with braces."
2688 (texinfo-optional-braces-discard)
2691 (put 'dots
'texinfo-format
'texinfo-format-dots
)
2692 (defun texinfo-format-dots ()
2693 (texinfo-parse-arg-discard)
2696 (put 'enddots
'texinfo-format
'texinfo-format-enddots
)
2697 (defun texinfo-format-enddots ()
2698 (texinfo-parse-arg-discard)
2701 (put 'pounds
'texinfo-format
'texinfo-format-pounds
)
2702 (defun texinfo-format-pounds ()
2703 (texinfo-parse-arg-discard)
2707 ;;; Refilling and indenting: @refill, @paragraphindent, @noindent
2709 ;;; Indent only those paragraphs that are refilled as a result of an
2710 ;;; @refill command.
2712 ;; * If the value is `asis', do not change the existing indentation at
2713 ;; the starts of paragraphs.
2715 ;; * If the value zero, delete any existing indentation.
2717 ;; * If the value is greater than zero, indent each paragraph by that
2718 ;; number of spaces.
2720 ;;; But do not refill paragraphs with an @refill command that are
2721 ;;; preceded by @noindent or are part of a table, list, or deffn.
2723 (defvar texinfo-paragraph-indent
"asis"
2724 "Number of spaces for @refill to indent a paragraph; else to leave as is.")
2726 (put 'paragraphindent
'texinfo-format
'texinfo-paragraphindent
)
2728 (defun texinfo-paragraphindent ()
2729 "Specify the number of spaces for @refill to indent a paragraph.
2730 Default is to leave the number of spaces as is."
2731 (let ((arg (texinfo-parse-arg-discard)))
2732 (if (string= "asis" arg
)
2733 (setq texinfo-paragraph-indent
"asis")
2734 (setq texinfo-paragraph-indent
(string-to-int arg
)))))
2736 (put 'refill
'texinfo-format
'texinfo-format-refill
)
2737 (defun texinfo-format-refill ()
2738 "Refill paragraph. Also, indent first line as set by @paragraphindent.
2739 Default is to leave paragraph indentation as is."
2740 (texinfo-discard-command)
2741 (let ((position (point-marker)))
2742 (forward-paragraph -
1)
2743 (if (looking-at "[ \t\n]*$") (forward-line 1))
2744 ;; Do not indent if an entry in a list, table, or deffn,
2745 ;; or if paragraph is preceded by @noindent.
2746 ;; Otherwise, indent
2748 ;; delete a @noindent line and do not indent paragraph
2749 ((save-excursion (forward-line -
1)
2750 (looking-at "^@noindent"))
2752 (delete-region (point) (progn (forward-line 1) (point))))
2753 ;; do nothing if "asis"
2754 ((equal texinfo-paragraph-indent
"asis"))
2755 ;; do no indenting in list, etc.
2756 ((> texinfo-stack-depth
0))
2757 ;; otherwise delete existing whitespace and indent
2759 (delete-region (point) (progn (skip-chars-forward " \t") (point)))
2760 (insert (make-string texinfo-paragraph-indent ?
))))
2761 (forward-paragraph 1)
2764 ;; Do not fill a section title line with asterisks, hyphens, etc. that
2765 ;; are used to underline it. This could occur if the line following
2766 ;; the underlining is not an index entry and has text within it.
2767 (let* ((previous-paragraph-separate paragraph-separate
)
2769 (concat paragraph-separate
"\\|[-=.]+\\|\\*\\*+"))
2770 (previous-paragraph-start paragraph-start
)
2772 (concat paragraph-start
"\\|[-=.]+\\|\\*\\*+")))
2774 (fill-paragraph nil
)
2775 (setq paragraph-separate previous-paragraph-separate
)
2776 (setq paragraph-start previous-paragraph-start
)))
2777 (goto-char position
)))
2779 (put 'noindent
'texinfo-format
'texinfo-noindent
)
2780 (defun texinfo-noindent ()
2782 (forward-paragraph 1)
2783 (if (search-backward "@refill"
2784 (save-excursion (forward-line -
1) (point)) t
)
2785 () ; leave @noindent command so @refill command knows not to indent
2787 (texinfo-discard-line))))
2790 ;;; Index generation
2792 (put 'vindex
'texinfo-format
'texinfo-format-vindex
)
2793 (defun texinfo-format-vindex ()
2794 (texinfo-index 'texinfo-vindex
))
2796 (put 'cindex
'texinfo-format
'texinfo-format-cindex
)
2797 (defun texinfo-format-cindex ()
2798 (texinfo-index 'texinfo-cindex
))
2800 (put 'findex
'texinfo-format
'texinfo-format-findex
)
2801 (defun texinfo-format-findex ()
2802 (texinfo-index 'texinfo-findex
))
2804 (put 'pindex
'texinfo-format
'texinfo-format-pindex
)
2805 (defun texinfo-format-pindex ()
2806 (texinfo-index 'texinfo-pindex
))
2808 (put 'tindex
'texinfo-format
'texinfo-format-tindex
)
2809 (defun texinfo-format-tindex ()
2810 (texinfo-index 'texinfo-tindex
))
2812 (put 'kindex
'texinfo-format
'texinfo-format-kindex
)
2813 (defun texinfo-format-kindex ()
2814 (texinfo-index 'texinfo-kindex
))
2816 (defun texinfo-index (indexvar)
2817 (let ((arg (texinfo-parse-expanded-arg)))
2818 (texinfo-discard-command)
2822 ;; Region formatting may not provide last node position.
2823 (if texinfo-last-node-pos
2824 (1+ (count-lines texinfo-last-node-pos
(point)))
2826 (symbol-value indexvar
)))))
2828 (defconst texinfo-indexvar-alist
2829 '(("cp" . texinfo-cindex
)
2830 ("fn" . texinfo-findex
)
2831 ("vr" . texinfo-vindex
)
2832 ("tp" . texinfo-tindex
)
2833 ("pg" . texinfo-pindex
)
2834 ("ky" . texinfo-kindex
)))
2837 ;;; @defindex @defcodeindex
2838 (put 'defindex
'texinfo-format
'texinfo-format-defindex
)
2839 (put 'defcodeindex
'texinfo-format
'texinfo-format-defindex
)
2841 (defun texinfo-format-defindex ()
2842 (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa'
2843 (indexing-command (intern (concat index-name
"index")))
2844 (index-formatting-command ; eg: `texinfo-format-aaindex'
2845 (intern (concat "texinfo-format-" index-name
"index")))
2846 (index-alist-name ; eg: `texinfo-aaindex'
2847 (intern (concat "texinfo-" index-name
"index"))))
2849 (set index-alist-name nil
)
2851 (put indexing-command
; eg, aaindex
2853 index-formatting-command
) ; eg, texinfo-format-aaindex
2855 ;; eg: "aa" . texinfo-aaindex
2856 (or (assoc index-name texinfo-indexvar-alist
)
2857 (setq texinfo-indexvar-alist
2861 texinfo-indexvar-alist
)))
2863 (fset index-formatting-command
2865 (list 'texinfo-index
2866 (list 'quote index-alist-name
))))))
2869 ;;; @synindex @syncodeindex
2871 (put 'synindex
'texinfo-format
'texinfo-format-synindex
)
2872 (put 'syncodeindex
'texinfo-format
'texinfo-format-synindex
)
2874 (defun texinfo-format-synindex ()
2875 (let* ((args (texinfo-parse-arg-discard))
2876 (second (cdr (read-from-string args
)))
2877 (joiner (symbol-name (car (read-from-string args
))))
2878 (joined (symbol-name (car (read-from-string args second
)))))
2880 (if (assoc joiner texinfo-short-index-cmds-alist
)
2882 (cdr (assoc joiner texinfo-short-index-cmds-alist
))
2884 (or (cdr (assoc joined texinfo-short-index-format-cmds-alist
))
2885 (intern (concat "texinfo-format-" joined
"index"))))
2887 (intern (concat joiner
"index"))
2889 (or (cdr(assoc joined texinfo-short-index-format-cmds-alist
))
2890 (intern (concat "texinfo-format-" joined
"index")))))))
2892 (defconst texinfo-short-index-cmds-alist
2900 (defconst texinfo-short-index-format-cmds-alist
2901 '(("cp" . texinfo-format-cindex
)
2902 ("fn" . texinfo-format-findex
)
2903 ("vr" . texinfo-format-vindex
)
2904 ("tp" . texinfo-format-tindex
)
2905 ("pg" . texinfo-format-pindex
)
2906 ("ky" . texinfo-format-kindex
)))
2909 ;;; Sort and index (for VMS)
2911 ;; Sort an index which is in the current buffer between START and END.
2912 ;; Used on VMS, where the `sort' utility is not available.
2913 (defun texinfo-sort-region (start end
)
2916 (narrow-to-region start end
)
2917 (goto-char (point-min))
2918 (sort-subr nil
'forward-line
'end-of-line
'texinfo-sort-startkeyfun
)))
2920 ;; Subroutine for sorting an index.
2921 ;; At start of a line, return a string to sort the line under.
2922 (defun texinfo-sort-startkeyfun ()
2924 (buffer-substring-no-properties (point) (save-excursion (end-of-line) (point)))))
2925 ;; Canonicalize whitespace and eliminate funny chars.
2926 (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line
)
2927 (setq line
(concat (substring line
0 (match-beginning 0))
2929 (substring line
(match-end 0) (length line
)))))
2935 (put 'printindex
'texinfo-format
'texinfo-format-printindex
)
2937 (defun texinfo-format-printindex ()
2938 (let ((indexelts (symbol-value
2939 (cdr (assoc (texinfo-parse-arg-discard)
2940 texinfo-indexvar-alist
))))
2942 (insert "\n* Menu:\n\n")
2943 (setq opoint
(point))
2944 (texinfo-print-index nil indexelts
)
2946 (if (memq system-type
'(vax-vms windows-nt ms-dos
))
2947 (texinfo-sort-region opoint
(point))
2948 (shell-command-on-region opoint
(point) "sort -fd" 1))))
2950 (defun texinfo-print-index (file indexelts
)
2952 (if (stringp (car (car indexelts
)))
2954 (insert "* " (car (car indexelts
)) ": " )
2957 (if file
(concat "(" file
")") "")
2958 (nth 1 (car indexelts
)) ".")
2961 (if (nth 2 (car indexelts
))
2962 (format " %d." (nth 2 (car indexelts
)))
2965 ;; index entries from @include'd file
2966 (texinfo-print-index (nth 1 (car indexelts
))
2967 (nth 2 (car indexelts
))))
2968 (setq indexelts
(cdr indexelts
))))
2971 ;;; Glyphs: @equiv, @error, etc
2973 ;; @equiv to show that two expressions are equivalent
2974 ;; @error to show an error message
2975 ;; @expansion to show what a macro expands to
2976 ;; @point to show the location of point in an example
2977 ;; @print to show what an evaluated expression prints
2978 ;; @result to indicate the value returned by an expression
2980 (put 'equiv
'texinfo-format
'texinfo-format-equiv
)
2981 (defun texinfo-format-equiv ()
2982 (texinfo-parse-arg-discard)
2985 (put 'error
'texinfo-format
'texinfo-format-error
)
2986 (defun texinfo-format-error ()
2987 (texinfo-parse-arg-discard)
2988 (insert "error-->"))
2990 (put 'expansion
'texinfo-format
'texinfo-format-expansion
)
2991 (defun texinfo-format-expansion ()
2992 (texinfo-parse-arg-discard)
2995 (put 'point
'texinfo-format
'texinfo-format-point
)
2996 (defun texinfo-format-point ()
2997 (texinfo-parse-arg-discard)
3000 (put 'print
'texinfo-format
'texinfo-format-print
)
3001 (defun texinfo-format-print ()
3002 (texinfo-parse-arg-discard)
3005 (put 'result
'texinfo-format
'texinfo-format-result
)
3006 (defun texinfo-format-result ()
3007 (texinfo-parse-arg-discard)
3013 ;; Info presumes a plain ASCII output, so the accented characters do
3014 ;; not look as they would if typeset, or output with a different
3017 ;; See the `texinfo-accent-commands' variable
3018 ;; in the section for `texinfo-append-refill'.
3019 ;; Also, see the defun for `texinfo-format-scan'
3020 ;; for single-character accent commands.
3022 ;; Command Info output Name
3024 ;; These do not have braces:
3025 ;; @^ ==> ^ circumflex accent
3026 ;; @` ==> ` grave accent
3027 ;; @' ==> ' acute accent
3028 ;; @" ==> " umlaut accent
3029 ;; @= ==> = overbar accent
3030 ;; @~ ==> ~ tilde accent
3032 ;; These have braces, but take no argument:
3033 ;; @OE{} ==> OE French-OE-ligature
3035 ;; @AA{} ==> AA Scandinavian-A-with-circle
3037 ;; @AE{} ==> AE Latin-Scandinavian-AE
3039 ;; @ss{} ==> ss German-sharp-S
3041 ;; @questiondown{} ==> ? upside-down-question-mark
3042 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
3043 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
3044 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
3045 ;; @O{} ==> O/ Scandinavian O-with-slash
3046 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
3048 ;; These have braces, and take an argument:
3049 ;; @,{c} ==> c, cedilla accent
3050 ;; @dotaccent{o} ==> .o overdot-accent
3051 ;; @ubaraccent{o} ==> _o underbar-accent
3052 ;; @udotaccent{o} ==> o-. underdot-accent
3053 ;; @H{o} ==> ""o long Hungarian umlaut
3054 ;; @ringaccent{o} ==> *o ring accent
3055 ;; @tieaccent{oo} ==> [oo tie after accent
3056 ;; @u{o} ==> (o breve accent
3057 ;; @v{o} ==> <o hacek accent
3058 ;; @dotless{i} ==> i dotless i and dotless j
3062 ;; Note: The defun texinfo-format-scan
3063 ;; looks at "[@{}^'`\",=~ *?!-]"
3064 ;; In the case of @*, a line break is inserted;
3065 ;; in the other cases, the characters are simply quoted and the @ is deleted.
3066 ;; Thus, `texinfo-format-scan' handles the following
3067 ;; single-character accent commands: @^ @` @' @" @, @- @= @~
3069 ;; @^ ==> ^ circumflex accent
3070 ;; (put '^ 'texinfo-format 'texinfo-format-circumflex-accent)
3071 ;; (defun texinfo-format-circumflex-accent ()
3072 ;; (texinfo-discard-command)
3075 ;; @` ==> ` grave accent
3076 ;; (put '\` 'texinfo-format 'texinfo-format-grave-accent)
3077 ;; (defun texinfo-format-grave-accent ()
3078 ;; (texinfo-discard-command)
3081 ;; @' ==> ' acute accent
3082 ;; (put '\' 'texinfo-format 'texinfo-format-acute-accent)
3083 ;; (defun texinfo-format-acute-accent ()
3084 ;; (texinfo-discard-command)
3087 ;; @" ==> " umlaut accent
3088 ;; (put '\" 'texinfo-format 'texinfo-format-umlaut-accent)
3089 ;; (defun texinfo-format-umlaut-accent ()
3090 ;; (texinfo-discard-command)
3093 ;; @= ==> = overbar accent
3094 ;; (put '= 'texinfo-format 'texinfo-format-overbar-accent)
3095 ;; (defun texinfo-format-overbar-accent ()
3096 ;; (texinfo-discard-command)
3099 ;; @~ ==> ~ tilde accent
3100 ;; (put '~ 'texinfo-format 'texinfo-format-tilde-accent)
3101 ;; (defun texinfo-format-tilde-accent ()
3102 ;; (texinfo-discard-command)
3105 ;; @OE{} ==> OE French-OE-ligature
3106 (put 'OE
'texinfo-format
'texinfo-format-French-OE-ligature
)
3107 (defun texinfo-format-French-OE-ligature ()
3108 (insert "OE" (texinfo-parse-arg-discard))
3109 (goto-char texinfo-command-start
))
3112 (put 'oe
'texinfo-format
'texinfo-format-French-oe-ligature
)
3113 (defun texinfo-format-French-oe-ligature () ; lower case
3114 (insert "oe" (texinfo-parse-arg-discard))
3115 (goto-char texinfo-command-start
))
3117 ;; @AA{} ==> AA Scandinavian-A-with-circle
3118 (put 'AA
'texinfo-format
'texinfo-format-Scandinavian-A-with-circle
)
3119 (defun texinfo-format-Scandinavian-A-with-circle ()
3120 (insert "AA" (texinfo-parse-arg-discard))
3121 (goto-char texinfo-command-start
))
3124 (put 'aa
'texinfo-format
'texinfo-format-Scandinavian-a-with-circle
)
3125 (defun texinfo-format-Scandinavian-a-with-circle () ; lower case
3126 (insert "aa" (texinfo-parse-arg-discard))
3127 (goto-char texinfo-command-start
))
3129 ;; @AE{} ==> AE Latin-Scandinavian-AE
3130 (put 'AE
'texinfo-format
'texinfo-format-Latin-Scandinavian-AE
)
3131 (defun texinfo-format-Latin-Scandinavian-AE ()
3132 (insert "AE" (texinfo-parse-arg-discard))
3133 (goto-char texinfo-command-start
))
3136 (put 'ae
'texinfo-format
'texinfo-format-Latin-Scandinavian-ae
)
3137 (defun texinfo-format-Latin-Scandinavian-ae () ; lower case
3138 (insert "ae" (texinfo-parse-arg-discard))
3139 (goto-char texinfo-command-start
))
3141 ;; @ss{} ==> ss German-sharp-S
3142 (put 'ss
'texinfo-format
'texinfo-format-German-sharp-S
)
3143 (defun texinfo-format-German-sharp-S ()
3144 (insert "ss" (texinfo-parse-arg-discard))
3145 (goto-char texinfo-command-start
))
3147 ;; @questiondown{} ==> ? upside-down-question-mark
3148 (put 'questiondown
'texinfo-format
'texinfo-format-upside-down-question-mark
)
3149 (defun texinfo-format-upside-down-question-mark ()
3150 (insert "?" (texinfo-parse-arg-discard))
3151 (goto-char texinfo-command-start
))
3153 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
3154 (put 'exclamdown
'texinfo-format
'texinfo-format-upside-down-exclamation-mark
)
3155 (defun texinfo-format-upside-down-exclamation-mark ()
3156 (insert "!" (texinfo-parse-arg-discard))
3157 (goto-char texinfo-command-start
))
3159 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
3160 (put 'L
'texinfo-format
'texinfo-format-Polish-suppressed-L
)
3161 (defun texinfo-format-Polish-suppressed-L ()
3162 (insert (texinfo-parse-arg-discard) "/L")
3163 (goto-char texinfo-command-start
))
3165 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
3166 (put 'l
'texinfo-format
'texinfo-format-Polish-suppressed-l-lower-case
)
3167 (defun texinfo-format-Polish-suppressed-l-lower-case ()
3168 (insert (texinfo-parse-arg-discard) "/l")
3169 (goto-char texinfo-command-start
))
3172 ;; @O{} ==> O/ Scandinavian O-with-slash
3173 (put 'O
'texinfo-format
'texinfo-format-Scandinavian-O-with-slash
)
3174 (defun texinfo-format-Scandinavian-O-with-slash ()
3175 (insert (texinfo-parse-arg-discard) "O/")
3176 (goto-char texinfo-command-start
))
3178 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
3179 (put 'o
'texinfo-format
'texinfo-format-Scandinavian-o-with-slash-lower-case
)
3180 (defun texinfo-format-Scandinavian-o-with-slash-lower-case ()
3181 (insert (texinfo-parse-arg-discard) "o/")
3182 (goto-char texinfo-command-start
))
3186 ;; @,{c} ==> c, cedilla accent
3187 (put ', 'texinfo-format
'texinfo-format-cedilla-accent
)
3188 (defun texinfo-format-cedilla-accent ()
3189 (insert (texinfo-parse-arg-discard) ",")
3190 (goto-char texinfo-command-start
))
3193 ;; @dotaccent{o} ==> .o overdot-accent
3194 (put 'dotaccent
'texinfo-format
'texinfo-format-overdot-accent
)
3195 (defun texinfo-format-overdot-accent ()
3196 (insert "." (texinfo-parse-arg-discard))
3197 (goto-char texinfo-command-start
))
3199 ;; @ubaraccent{o} ==> _o underbar-accent
3200 (put 'ubaraccent
'texinfo-format
'texinfo-format-underbar-accent
)
3201 (defun texinfo-format-underbar-accent ()
3202 (insert "_" (texinfo-parse-arg-discard))
3203 (goto-char texinfo-command-start
))
3205 ;; @udotaccent{o} ==> o-. underdot-accent
3206 (put 'udotaccent
'texinfo-format
'texinfo-format-underdot-accent
)
3207 (defun texinfo-format-underdot-accent ()
3208 (insert (texinfo-parse-arg-discard) "-.")
3209 (goto-char texinfo-command-start
))
3211 ;; @H{o} ==> ""o long Hungarian umlaut
3212 (put 'H
'texinfo-format
'texinfo-format-long-Hungarian-umlaut
)
3213 (defun texinfo-format-long-Hungarian-umlaut ()
3214 (insert "\"\"" (texinfo-parse-arg-discard))
3215 (goto-char texinfo-command-start
))
3217 ;; @ringaccent{o} ==> *o ring accent
3218 (put 'ringaccent
'texinfo-format
'texinfo-format-ring-accent
)
3219 (defun texinfo-format-ring-accent ()
3220 (insert "*" (texinfo-parse-arg-discard))
3221 (goto-char texinfo-command-start
))
3223 ;; @tieaccent{oo} ==> [oo tie after accent
3224 (put 'tieaccent
'texinfo-format
'texinfo-format-tie-after-accent
)
3225 (defun texinfo-format-tie-after-accent ()
3226 (insert "[" (texinfo-parse-arg-discard))
3227 (goto-char texinfo-command-start
))
3230 ;; @u{o} ==> (o breve accent
3231 (put 'u
'texinfo-format
'texinfo-format-breve-accent
)
3232 (defun texinfo-format-breve-accent ()
3233 (insert "(" (texinfo-parse-arg-discard))
3234 (goto-char texinfo-command-start
))
3236 ;; @v{o} ==> <o hacek accent
3237 (put 'v
'texinfo-format
'texinfo-format-hacek-accent
)
3238 (defun texinfo-format-hacek-accent ()
3239 (insert "<" (texinfo-parse-arg-discard))
3240 (goto-char texinfo-command-start
))
3243 ;; @dotless{i} ==> i dotless i and dotless j
3244 (put 'dotless
'texinfo-format
'texinfo-format-dotless
)
3245 (defun texinfo-format-dotless ()
3246 (insert (texinfo-parse-arg-discard))
3247 (goto-char texinfo-command-start
))
3250 ;;; Definition formatting: @deffn, @defun, etc
3252 ;; What definition formatting produces:
3254 ;; @deffn category name args...
3255 ;; In Info, `Category: name ARGS'
3256 ;; In index: name: node. line#.
3258 ;; @defvr category name
3259 ;; In Info, `Category: name'
3260 ;; In index: name: node. line#.
3262 ;; @deftp category name attributes...
3263 ;; `category name attributes...' Note: @deftp args in lower case.
3264 ;; In index: name: node. line#.
3266 ;; Specialized function-like or variable-like entity:
3268 ;; @defun, @defmac, @defspec, @defvar, @defopt
3270 ;; @defun name args In Info, `Function: name ARGS'
3271 ;; @defmac name args In Info, `Macro: name ARGS'
3272 ;; @defvar name In Info, `Variable: name'
3274 ;; In index: name: node. line#.
3276 ;; Generalized typed-function-like or typed-variable-like entity:
3277 ;; @deftypefn category data-type name args...
3278 ;; In Info, `Category: data-type name args...'
3279 ;; @deftypevr category data-type name
3280 ;; In Info, `Category: data-type name'
3281 ;; In index: name: node. line#.
3283 ;; Specialized typed-function-like or typed-variable-like entity:
3284 ;; @deftypefun data-type name args...
3285 ;; In Info, `Function: data-type name ARGS'
3286 ;; In index: name: node. line#.
3288 ;; @deftypevar data-type name
3289 ;; In Info, `Variable: data-type name'
3290 ;; In index: name: node. line#. but include args after name!?
3292 ;; Generalized object oriented entity:
3293 ;; @defop category class name args...
3294 ;; In Info, `Category on class: name ARG'
3295 ;; In index: name on class: node. line#.
3297 ;; @defcv category class name
3298 ;; In Info, `Category of class: name'
3299 ;; In index: name of class: node. line#.
3301 ;; Specialized object oriented entity:
3302 ;; @defmethod class name args...
3303 ;; In Info, `Method on class: name ARGS'
3304 ;; In index: name on class: node. line#.
3306 ;; @defivar class name
3307 ;; In Info, `Instance variable of class: name'
3308 ;; In index: name of class: node. line#.
3311 ;;; The definition formatting functions
3313 (defun texinfo-format-defun ()
3314 (texinfo-push-stack 'defun
nil)
3315 (setq fill-column
(- fill-column
5))
3316 (texinfo-format-defun-1 t
))
3318 (defun texinfo-end-defun ()
3319 (setq fill-column
(+ fill-column
5))
3320 (texinfo-discard-command)
3321 (let ((start (nth 1 (texinfo-pop-stack 'defun
))))
3322 (texinfo-do-itemize start
)
3323 ;; Delete extra newline inserted after header.
3328 (defun texinfo-format-defunx ()
3329 (texinfo-format-defun-1 nil
))
3331 (defun texinfo-format-defun-1 (first-p)
3332 (let ((parse-args (texinfo-format-parse-defun-args))
3333 (texinfo-defun-type (get texinfo-command-name
'texinfo-defun-type
)))
3334 (texinfo-discard-command)
3335 ;; Delete extra newline inserted after previous header line.
3339 (get texinfo-command-name
'texinfo-deffn-formatting-property
) parse-args
)
3340 ;; Insert extra newline so that paragraph filling does not mess
3341 ;; with header line.
3343 (rplaca (cdr (cdr (car texinfo-stack
))) (point))
3345 (get texinfo-command-name
'texinfo-defun-indexing-property
) parse-args
)))
3347 ;;; Formatting the first line of a definition
3349 ;; @deffn, @defvr, @deftp
3350 (put 'deffn
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3351 (put 'deffnx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3352 (put 'defvr
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3353 (put 'defvrx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3354 (put 'deftp
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3355 (put 'deftpx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3356 (defun texinfo-format-deffn (parsed-args)
3357 ;; Generalized function-like, variable-like, or generic data-type entity:
3358 ;; @deffn category name args...
3359 ;; In Info, `Category: name ARGS'
3360 ;; @deftp category name attributes...
3361 ;; `category name attributes...' Note: @deftp args in lower case.
3362 (let ((category (car parsed-args
))
3363 (name (car (cdr parsed-args
)))
3364 (args (cdr (cdr parsed-args
))))
3365 (insert " -- " category
": " name
)
3368 (if (or (= ?
& (aref (car args
) 0))
3369 (eq (eval (car texinfo-defun-type
)) 'deftp-type
))
3371 (upcase (car args
))))
3372 (setq args
(cdr args
)))))
3374 ;; @defun, @defmac, @defspec, @defvar, @defopt: Specialized, simple
3375 (put 'defun
'texinfo-deffn-formatting-property
3376 'texinfo-format-specialized-defun
)
3377 (put 'defunx
'texinfo-deffn-formatting-property
3378 'texinfo-format-specialized-defun
)
3379 (put 'defmac
'texinfo-deffn-formatting-property
3380 'texinfo-format-specialized-defun
)
3381 (put 'defmacx
'texinfo-deffn-formatting-property
3382 'texinfo-format-specialized-defun
)
3383 (put 'defspec
'texinfo-deffn-formatting-property
3384 'texinfo-format-specialized-defun
)
3385 (put 'defspecx
'texinfo-deffn-formatting-property
3386 'texinfo-format-specialized-defun
)
3387 (put 'defvar
'texinfo-deffn-formatting-property
3388 'texinfo-format-specialized-defun
)
3389 (put 'defvarx
'texinfo-deffn-formatting-property
3390 'texinfo-format-specialized-defun
)
3391 (put 'defopt
'texinfo-deffn-formatting-property
3392 'texinfo-format-specialized-defun
)
3393 (put 'defoptx
'texinfo-deffn-formatting-property
3394 'texinfo-format-specialized-defun
)
3395 (defun texinfo-format-specialized-defun (parsed-args)
3396 ;; Specialized function-like or variable-like entity:
3397 ;; @defun name args In Info, `Function: Name ARGS'
3398 ;; @defmac name args In Info, `Macro: Name ARGS'
3399 ;; @defvar name In Info, `Variable: Name'
3400 ;; Use cdr of texinfo-defun-type to determine category:
3401 (let ((category (car (cdr texinfo-defun-type
)))
3402 (name (car parsed-args
))
3403 (args (cdr parsed-args
)))
3404 (insert " -- " category
": " name
)
3407 (if (= ?
& (aref (car args
) 0))
3409 (upcase (car args
))))
3410 (setq args
(cdr args
)))))
3412 ;; @deftypefn, @deftypevr: Generalized typed
3413 (put 'deftypefn
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3414 (put 'deftypefnx
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3415 (put 'deftypevr
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3416 (put 'deftypevrx
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3417 (defun texinfo-format-deftypefn (parsed-args)
3418 ;; Generalized typed-function-like or typed-variable-like entity:
3419 ;; @deftypefn category data-type name args...
3420 ;; In Info, `Category: data-type name args...'
3421 ;; @deftypevr category data-type name
3422 ;; In Info, `Category: data-type name'
3423 ;; Note: args in lower case, unless modified in command line.
3424 (let ((category (car parsed-args
))
3425 (data-type (car (cdr parsed-args
)))
3426 (name (car (cdr (cdr parsed-args
))))
3427 (args (cdr (cdr (cdr parsed-args
)))))
3428 (insert " -- " category
": " data-type
" " name
)
3430 (insert " " (car args
))
3431 (setq args
(cdr args
)))))
3433 ;; @deftypefun, @deftypevar: Specialized typed
3434 (put 'deftypefun
'texinfo-deffn-formatting-property
'texinfo-format-deftypefun
)
3435 (put 'deftypefunx
'texinfo-deffn-formatting-property
3436 'texinfo-format-deftypefun
)
3437 (put 'deftypevar
'texinfo-deffn-formatting-property
'texinfo-format-deftypefun
)
3438 (put 'deftypevarx
'texinfo-deffn-formatting-property
3439 'texinfo-format-deftypefun
)
3440 (defun texinfo-format-deftypefun (parsed-args)
3441 ;; Specialized typed-function-like or typed-variable-like entity:
3442 ;; @deftypefun data-type name args...
3443 ;; In Info, `Function: data-type name ARGS'
3444 ;; @deftypevar data-type name
3445 ;; In Info, `Variable: data-type name'
3446 ;; Note: args in lower case, unless modified in command line.
3447 ;; Use cdr of texinfo-defun-type to determine category:
3448 (let ((category (car (cdr texinfo-defun-type
)))
3449 (data-type (car parsed-args
))
3450 (name (car (cdr parsed-args
)))
3451 (args (cdr (cdr parsed-args
))))
3452 (insert " -- " category
": " data-type
" " name
)
3454 (insert " " (car args
))
3455 (setq args
(cdr args
)))))
3457 ;; @defop: Generalized object-oriented
3458 (put 'defop
'texinfo-deffn-formatting-property
'texinfo-format-defop
)
3459 (put 'defopx
'texinfo-deffn-formatting-property
'texinfo-format-defop
)
3460 (defun texinfo-format-defop (parsed-args)
3461 ;; Generalized object oriented entity:
3462 ;; @defop category class name args...
3463 ;; In Info, `Category on class: name ARG'
3464 ;; Note: args in upper case; use of `on'
3465 (let ((category (car parsed-args
))
3466 (class (car (cdr parsed-args
)))
3467 (name (car (cdr (cdr parsed-args
))))
3468 (args (cdr (cdr (cdr parsed-args
)))))
3469 (insert " -- " category
" on " class
": " name
)
3471 (insert " " (upcase (car args
)))
3472 (setq args
(cdr args
)))))
3474 ;; @defcv: Generalized object-oriented
3475 (put 'defcv
'texinfo-deffn-formatting-property
'texinfo-format-defcv
)
3476 (put 'defcvx
'texinfo-deffn-formatting-property
'texinfo-format-defcv
)
3477 (defun texinfo-format-defcv (parsed-args)
3478 ;; Generalized object oriented entity:
3479 ;; @defcv category class name
3480 ;; In Info, `Category of class: name'
3481 ;; Note: args in upper case; use of `of'
3482 (let ((category (car parsed-args
))
3483 (class (car (cdr parsed-args
)))
3484 (name (car (cdr (cdr parsed-args
))))
3485 (args (cdr (cdr (cdr parsed-args
)))))
3486 (insert " -- " category
" of " class
": " name
)
3488 (insert " " (upcase (car args
)))
3489 (setq args
(cdr args
)))))
3491 ;; @defmethod: Specialized object-oriented
3492 (put 'defmethod
'texinfo-deffn-formatting-property
'texinfo-format-defmethod
)
3493 (put 'defmethodx
'texinfo-deffn-formatting-property
'texinfo-format-defmethod
)
3494 (defun texinfo-format-defmethod (parsed-args)
3495 ;; Specialized object oriented entity:
3496 ;; @defmethod class name args...
3497 ;; In Info, `Method on class: name ARGS'
3498 ;; Note: args in upper case; use of `on'
3499 ;; Use cdr of texinfo-defun-type to determine category:
3500 (let ((category (car (cdr texinfo-defun-type
)))
3501 (class (car parsed-args
))
3502 (name (car (cdr parsed-args
)))
3503 (args (cdr (cdr parsed-args
))))
3504 (insert " -- " category
" on " class
": " name
)
3506 (insert " " (upcase (car args
)))
3507 (setq args
(cdr args
)))))
3509 ;; @defivar: Specialized object-oriented
3510 (put 'defivar
'texinfo-deffn-formatting-property
'texinfo-format-defivar
)
3511 (put 'defivarx
'texinfo-deffn-formatting-property
'texinfo-format-defivar
)
3512 (defun texinfo-format-defivar (parsed-args)
3513 ;; Specialized object oriented entity:
3514 ;; @defivar class name
3515 ;; In Info, `Instance variable of class: name'
3516 ;; Note: args in upper case; use of `of'
3517 ;; Use cdr of texinfo-defun-type to determine category:
3518 (let ((category (car (cdr texinfo-defun-type
)))
3519 (class (car parsed-args
))
3520 (name (car (cdr parsed-args
)))
3521 (args (cdr (cdr parsed-args
))))
3522 (insert " -- " category
" of " class
": " name
)
3524 (insert " " (upcase (car args
)))
3525 (setq args
(cdr args
)))))
3528 ;;; Indexing for definitions
3530 ;; An index entry has three parts: the `entry proper', the node name, and the
3531 ;; line number. Depending on the which command is used, the entry is
3532 ;; formatted differently:
3538 ;; @defopt all use their 1st argument as the entry-proper
3544 ;; @deftypevar all use their 2nd argument as the entry-proper
3547 ;; @deftypevr both use their 3rd argument as the entry-proper
3549 ;; @defmethod uses its 2nd and 1st arguments as an entry-proper
3550 ;; formatted: NAME on CLASS
3552 ;; @defop uses its 3rd and 2nd arguments as an entry-proper
3553 ;; formatted: NAME on CLASS
3555 ;; @defivar uses its 2nd and 1st arguments as an entry-proper
3556 ;; formatted: NAME of CLASS
3558 ;; @defcv uses its 3rd and 2nd argument as an entry-proper
3559 ;; formatted: NAME of CLASS
3561 (put 'defun
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3562 (put 'defunx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3563 (put 'defmac
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3564 (put 'defmacx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3565 (put 'defspec
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3566 (put 'defspecx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3567 (put 'defvar
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3568 (put 'defvarx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3569 (put 'defopt
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3570 (put 'defoptx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3571 (defun texinfo-index-defun (parsed-args)
3572 ;; use 1st parsed-arg as entry-proper
3573 ;; `index-list' will be texinfo-findex or the like
3574 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3577 ;; Three elements: entry-proper, node-name, line-number
3581 ;; Region formatting may not provide last node position.
3582 (if texinfo-last-node-pos
3583 (1+ (count-lines texinfo-last-node-pos
(point)))
3585 (symbol-value index-list
)))))
3587 (put 'deffn
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3588 (put 'deffnx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3589 (put 'defvr
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3590 (put 'defvrx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3591 (put 'deftp
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3592 (put 'deftpx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3593 (put 'deftypefun
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3594 (put 'deftypefunx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3595 (put 'deftypevar
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3596 (put 'deftypevarx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3597 (defun texinfo-index-deffn (parsed-args)
3598 ;; use 2nd parsed-arg as entry-proper
3599 ;; `index-list' will be texinfo-findex or the like
3600 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3603 ;; Three elements: entry-proper, node-name, line-number
3605 (car (cdr parsed-args
))
3607 ;; Region formatting may not provide last node position.
3608 (if texinfo-last-node-pos
3609 (1+ (count-lines texinfo-last-node-pos
(point)))
3611 (symbol-value index-list
)))))
3613 (put 'deftypefn
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3614 (put 'deftypefnx
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3615 (put 'deftypevr
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3616 (put 'deftypevrx
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3617 (defun texinfo-index-deftypefn (parsed-args)
3618 ;; use 3rd parsed-arg as entry-proper
3619 ;; `index-list' will be texinfo-findex or the like
3620 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3623 ;; Three elements: entry-proper, node-name, line-number
3625 (car (cdr (cdr parsed-args
)))
3627 ;; Region formatting may not provide last node position.
3628 (if texinfo-last-node-pos
3629 (1+ (count-lines texinfo-last-node-pos
(point)))
3631 (symbol-value index-list
)))))
3633 (put 'defmethod
'texinfo-defun-indexing-property
'texinfo-index-defmethod
)
3634 (put 'defmethodx
'texinfo-defun-indexing-property
'texinfo-index-defmethod
)
3635 (defun texinfo-index-defmethod (parsed-args)
3636 ;; use 2nd on 1st parsed-arg as entry-proper
3637 ;; `index-list' will be texinfo-findex or the like
3638 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3641 ;; Three elements: entry-proper, node-name, line-number
3644 (car (cdr parsed-args
))
3647 ;; Region formatting may not provide last node position.
3648 (if texinfo-last-node-pos
3649 (1+ (count-lines texinfo-last-node-pos
(point)))
3651 (symbol-value index-list
)))))
3653 (put 'defop
'texinfo-defun-indexing-property
'texinfo-index-defop
)
3654 (put 'defopx
'texinfo-defun-indexing-property
'texinfo-index-defop
)
3655 (defun texinfo-index-defop (parsed-args)
3656 ;; use 3rd on 2nd parsed-arg as entry-proper
3657 ;; `index-list' will be texinfo-findex or the like
3658 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3661 ;; Three elements: entry-proper, node-name, line-number
3664 (car (cdr (cdr parsed-args
)))
3665 (car (cdr parsed-args
)))
3667 ;; Region formatting may not provide last node position.
3668 (if texinfo-last-node-pos
3669 (1+ (count-lines texinfo-last-node-pos
(point)))
3671 (symbol-value index-list
)))))
3673 (put 'defivar
'texinfo-defun-indexing-property
'texinfo-index-defivar
)
3674 (put 'defivarx
'texinfo-defun-indexing-property
'texinfo-index-defivar
)
3675 (defun texinfo-index-defivar (parsed-args)
3676 ;; use 2nd of 1st parsed-arg as entry-proper
3677 ;; `index-list' will be texinfo-findex or the like
3678 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3681 ;; Three elements: entry-proper, node-name, line-number
3684 (car (cdr parsed-args
))
3687 ;; Region formatting may not provide last node position.
3688 (if texinfo-last-node-pos
3689 (1+ (count-lines texinfo-last-node-pos
(point)))
3691 (symbol-value index-list
)))))
3693 (put 'defcv
'texinfo-defun-indexing-property
'texinfo-index-defcv
)
3694 (put 'defcvx
'texinfo-defun-indexing-property
'texinfo-index-defcv
)
3695 (defun texinfo-index-defcv (parsed-args)
3696 ;; use 3rd of 2nd parsed-arg as entry-proper
3697 ;; `index-list' will be texinfo-findex or the like
3698 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3701 ;; Three elements: entry-proper, node-name, line-number
3704 (car (cdr (cdr parsed-args
)))
3705 (car (cdr parsed-args
)))
3707 ;; Region formatting may not provide last node position.
3708 (if texinfo-last-node-pos
3709 (1+ (count-lines texinfo-last-node-pos
(point)))
3711 (symbol-value index-list
)))))
3714 ;;; Properties for definitions
3716 ;; Each definition command has six properties:
3718 ;; 1. texinfo-deffn-formatting-property to format definition line
3719 ;; 2. texinfo-defun-indexing-property to create index entry
3720 ;; 3. texinfo-format formatting command
3721 ;; 4. texinfo-end end formatting command
3722 ;; 5. texinfo-defun-type type of deffn to format
3723 ;; 6. texinfo-defun-index type of index to use
3725 ;; The `x' forms of each definition command are used for the second
3726 ;; and subsequent header lines.
3728 ;; The texinfo-deffn-formatting-property and texinfo-defun-indexing-property
3729 ;; are listed just before the appropriate formatting and indexing commands.
3731 (put 'deffn
'texinfo-format
'texinfo-format-defun
)
3732 (put 'deffnx
'texinfo-format
'texinfo-format-defunx
)
3733 (put 'deffn
'texinfo-end
'texinfo-end-defun
)
3734 (put 'deffn
'texinfo-defun-type
'('deffn-type nil
))
3735 (put 'deffnx
'texinfo-defun-type
'('deffn-type nil
))
3736 (put 'deffn
'texinfo-defun-index
'texinfo-findex
)
3737 (put 'deffnx
'texinfo-defun-index
'texinfo-findex
)
3739 (put 'defun
'texinfo-format
'texinfo-format-defun
)
3740 (put 'defunx
'texinfo-format
'texinfo-format-defunx
)
3741 (put 'defun
'texinfo-end
'texinfo-end-defun
)
3742 (put 'defun
'texinfo-defun-type
'('defun-type
"Function"))
3743 (put 'defunx
'texinfo-defun-type
'('defun-type
"Function"))
3744 (put 'defun
'texinfo-defun-index
'texinfo-findex
)
3745 (put 'defunx
'texinfo-defun-index
'texinfo-findex
)
3747 (put 'defmac
'texinfo-format
'texinfo-format-defun
)
3748 (put 'defmacx
'texinfo-format
'texinfo-format-defunx
)
3749 (put 'defmac
'texinfo-end
'texinfo-end-defun
)
3750 (put 'defmac
'texinfo-defun-type
'('defun-type
"Macro"))
3751 (put 'defmacx
'texinfo-defun-type
'('defun-type
"Macro"))
3752 (put 'defmac
'texinfo-defun-index
'texinfo-findex
)
3753 (put 'defmacx
'texinfo-defun-index
'texinfo-findex
)
3755 (put 'defspec
'texinfo-format
'texinfo-format-defun
)
3756 (put 'defspecx
'texinfo-format
'texinfo-format-defunx
)
3757 (put 'defspec
'texinfo-end
'texinfo-end-defun
)
3758 (put 'defspec
'texinfo-defun-type
'('defun-type
"Special form"))
3759 (put 'defspecx
'texinfo-defun-type
'('defun-type
"Special form"))
3760 (put 'defspec
'texinfo-defun-index
'texinfo-findex
)
3761 (put 'defspecx
'texinfo-defun-index
'texinfo-findex
)
3763 (put 'defvr
'texinfo-format
'texinfo-format-defun
)
3764 (put 'defvrx
'texinfo-format
'texinfo-format-defunx
)
3765 (put 'defvr
'texinfo-end
'texinfo-end-defun
)
3766 (put 'defvr
'texinfo-defun-type
'('deffn-type nil
))
3767 (put 'defvrx
'texinfo-defun-type
'('deffn-type nil
))
3768 (put 'defvr
'texinfo-defun-index
'texinfo-vindex
)
3769 (put 'defvrx
'texinfo-defun-index
'texinfo-vindex
)
3771 (put 'defvar
'texinfo-format
'texinfo-format-defun
)
3772 (put 'defvarx
'texinfo-format
'texinfo-format-defunx
)
3773 (put 'defvar
'texinfo-end
'texinfo-end-defun
)
3774 (put 'defvar
'texinfo-defun-type
'('defun-type
"Variable"))
3775 (put 'defvarx
'texinfo-defun-type
'('defun-type
"Variable"))
3776 (put 'defvar
'texinfo-defun-index
'texinfo-vindex
)
3777 (put 'defvarx
'texinfo-defun-index
'texinfo-vindex
)
3779 (put 'defconst
'texinfo-format
'texinfo-format-defun
)
3780 (put 'defconstx
'texinfo-format
'texinfo-format-defunx
)
3781 (put 'defconst
'texinfo-end
'texinfo-end-defun
)
3782 (put 'defconst
'texinfo-defun-type
'('defun-type
"Constant"))
3783 (put 'defconstx
'texinfo-defun-type
'('defun-type
"Constant"))
3784 (put 'defconst
'texinfo-defun-index
'texinfo-vindex
)
3785 (put 'defconstx
'texinfo-defun-index
'texinfo-vindex
)
3787 (put 'defcmd
'texinfo-format
'texinfo-format-defun
)
3788 (put 'defcmdx
'texinfo-format
'texinfo-format-defunx
)
3789 (put 'defcmd
'texinfo-end
'texinfo-end-defun
)
3790 (put 'defcmd
'texinfo-defun-type
'('defun-type
"Command"))
3791 (put 'defcmdx
'texinfo-defun-type
'('defun-type
"Command"))
3792 (put 'defcmd
'texinfo-defun-index
'texinfo-findex
)
3793 (put 'defcmdx
'texinfo-defun-index
'texinfo-findex
)
3795 (put 'defopt
'texinfo-format
'texinfo-format-defun
)
3796 (put 'defoptx
'texinfo-format
'texinfo-format-defunx
)
3797 (put 'defopt
'texinfo-end
'texinfo-end-defun
)
3798 (put 'defopt
'texinfo-defun-type
'('defun-type
"User Option"))
3799 (put 'defoptx
'texinfo-defun-type
'('defun-type
"User Option"))
3800 (put 'defopt
'texinfo-defun-index
'texinfo-vindex
)
3801 (put 'defoptx
'texinfo-defun-index
'texinfo-vindex
)
3803 (put 'deftp
'texinfo-format
'texinfo-format-defun
)
3804 (put 'deftpx
'texinfo-format
'texinfo-format-defunx
)
3805 (put 'deftp
'texinfo-end
'texinfo-end-defun
)
3806 (put 'deftp
'texinfo-defun-type
'('deftp-type nil
))
3807 (put 'deftpx
'texinfo-defun-type
'('deftp-type nil
))
3808 (put 'deftp
'texinfo-defun-index
'texinfo-tindex
)
3809 (put 'deftpx
'texinfo-defun-index
'texinfo-tindex
)
3811 ;;; Object-oriented stuff is a little hairier.
3813 (put 'defop
'texinfo-format
'texinfo-format-defun
)
3814 (put 'defopx
'texinfo-format
'texinfo-format-defunx
)
3815 (put 'defop
'texinfo-end
'texinfo-end-defun
)
3816 (put 'defop
'texinfo-defun-type
'('defop-type nil
))
3817 (put 'defopx
'texinfo-defun-type
'('defop-type nil
))
3818 (put 'defop
'texinfo-defun-index
'texinfo-findex
)
3819 (put 'defopx
'texinfo-defun-index
'texinfo-findex
)
3821 (put 'defmethod
'texinfo-format
'texinfo-format-defun
)
3822 (put 'defmethodx
'texinfo-format
'texinfo-format-defunx
)
3823 (put 'defmethod
'texinfo-end
'texinfo-end-defun
)
3824 (put 'defmethod
'texinfo-defun-type
'('defmethod-type
"Method"))
3825 (put 'defmethodx
'texinfo-defun-type
'('defmethod-type
"Method"))
3826 (put 'defmethod
'texinfo-defun-index
'texinfo-findex
)
3827 (put 'defmethodx
'texinfo-defun-index
'texinfo-findex
)
3829 (put 'defcv
'texinfo-format
'texinfo-format-defun
)
3830 (put 'defcvx
'texinfo-format
'texinfo-format-defunx
)
3831 (put 'defcv
'texinfo-end
'texinfo-end-defun
)
3832 (put 'defcv
'texinfo-defun-type
'('defop-type nil
))
3833 (put 'defcvx
'texinfo-defun-type
'('defop-type nil
))
3834 (put 'defcv
'texinfo-defun-index
'texinfo-vindex
)
3835 (put 'defcvx
'texinfo-defun-index
'texinfo-vindex
)
3837 (put 'defivar
'texinfo-format
'texinfo-format-defun
)
3838 (put 'defivarx
'texinfo-format
'texinfo-format-defunx
)
3839 (put 'defivar
'texinfo-end
'texinfo-end-defun
)
3840 (put 'defivar
'texinfo-defun-type
'('defmethod-type
"Instance variable"))
3841 (put 'defivarx
'texinfo-defun-type
'('defmethod-type
"Instance variable"))
3842 (put 'defivar
'texinfo-defun-index
'texinfo-vindex
)
3843 (put 'defivarx
'texinfo-defun-index
'texinfo-vindex
)
3845 ;;; Typed functions and variables
3847 (put 'deftypefn
'texinfo-format
'texinfo-format-defun
)
3848 (put 'deftypefnx
'texinfo-format
'texinfo-format-defunx
)
3849 (put 'deftypefn
'texinfo-end
'texinfo-end-defun
)
3850 (put 'deftypefn
'texinfo-defun-type
'('deftypefn-type nil
))
3851 (put 'deftypefnx
'texinfo-defun-type
'('deftypefn-type nil
))
3852 (put 'deftypefn
'texinfo-defun-index
'texinfo-findex
)
3853 (put 'deftypefnx
'texinfo-defun-index
'texinfo-findex
)
3855 (put 'deftypefun
'texinfo-format
'texinfo-format-defun
)
3856 (put 'deftypefunx
'texinfo-format
'texinfo-format-defunx
)
3857 (put 'deftypefun
'texinfo-end
'texinfo-end-defun
)
3858 (put 'deftypefun
'texinfo-defun-type
'('deftypefun-type
"Function"))
3859 (put 'deftypefunx
'texinfo-defun-type
'('deftypefun-type
"Function"))
3860 (put 'deftypefun
'texinfo-defun-index
'texinfo-findex
)
3861 (put 'deftypefunx
'texinfo-defun-index
'texinfo-findex
)
3863 (put 'deftypevr
'texinfo-format
'texinfo-format-defun
)
3864 (put 'deftypevrx
'texinfo-format
'texinfo-format-defunx
)
3865 (put 'deftypevr
'texinfo-end
'texinfo-end-defun
)
3866 (put 'deftypevr
'texinfo-defun-type
'('deftypefn-type nil
))
3867 (put 'deftypevrx
'texinfo-defun-type
'('deftypefn-type nil
))
3868 (put 'deftypevr
'texinfo-defun-index
'texinfo-vindex
)
3869 (put 'deftypevrx
'texinfo-defun-index
'texinfo-vindex
)
3871 (put 'deftypevar
'texinfo-format
'texinfo-format-defun
)
3872 (put 'deftypevarx
'texinfo-format
'texinfo-format-defunx
)
3873 (put 'deftypevar
'texinfo-end
'texinfo-end-defun
)
3874 (put 'deftypevar
'texinfo-defun-type
'('deftypevar-type
"Variable"))
3875 (put 'deftypevarx
'texinfo-defun-type
'('deftypevar-type
"Variable"))
3876 (put 'deftypevar
'texinfo-defun-index
'texinfo-vindex
)
3877 (put 'deftypevarx
'texinfo-defun-index
'texinfo-vindex
)
3880 ;;; @set, @clear, @ifset, @ifclear
3882 ;; If a flag is set with @set FLAG, then text between @ifset and @end
3883 ;; ifset is formatted normally, but if the flag is is cleared with
3884 ;; @clear FLAG, then the text is not formatted; it is ignored.
3886 ;; If a flag is cleared with @clear FLAG, then text between @ifclear
3887 ;; and @end ifclear is formatted normally, but if the flag is is set with
3888 ;; @set FLAG, then the text is not formatted; it is ignored. @ifclear
3889 ;; is the opposite of @ifset.
3891 ;; If a flag is set to a string with @set FLAG,
3892 ;; replace @value{FLAG} with the string.
3893 ;; If a flag with a value is cleared,
3894 ;; @value{FLAG} is invalid,
3895 ;; as if there had never been any @set FLAG previously.
3897 (put 'clear
'texinfo-format
'texinfo-clear
)
3898 (defun texinfo-clear ()
3899 "Clear the value of the flag."
3900 (let* ((arg (texinfo-parse-arg-discard))
3901 (flag (car (read-from-string arg
)))
3902 (value (substring arg
(cdr (read-from-string arg
)))))
3903 (put flag
'texinfo-whether-setp
'flag-cleared
)
3904 (put flag
'texinfo-set-value
"")))
3906 (put 'set
'texinfo-format
'texinfo-set
)
3907 (defun texinfo-set ()
3908 "Set the value of the flag, optionally to a string.
3909 The command `@set foo This is a string.'
3910 sets flag foo to the value: `This is a string.'
3911 The command `@value{foo}' expands to the value."
3912 (let* ((arg (texinfo-parse-arg-discard))
3913 (flag (car (read-from-string arg
)))
3914 (value (substring arg
(cdr (read-from-string arg
)))))
3915 (if (string-match "^[ \t]+" value
)
3916 (setq value
(substring value
(match-end 0))))
3917 (put flag
'texinfo-whether-setp
'flag-set
)
3918 (put flag
'texinfo-set-value value
)))
3920 (put 'value
'texinfo-format
'texinfo-value
)
3921 (defun texinfo-value ()
3922 "Insert the string to which the flag is set.
3923 The command `@set foo This is a string.'
3924 sets flag foo to the value: `This is a string.'
3925 The command `@value{foo}' expands to the value."
3926 (let ((arg (texinfo-parse-arg-discard)))
3928 (eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3930 (get (car (read-from-string arg
)) 'texinfo-set-value
))
3931 (insert (get (car (read-from-string arg
)) 'texinfo-set-value
)))
3932 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3934 (insert (format "{No value for \"%s\"}" arg
)))
3935 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
) nil
)
3936 (insert (format "{No value for \"%s\"}" arg
))))))
3938 (put 'ifset
'texinfo-end
'texinfo-discard-command
)
3939 (put 'ifset
'texinfo-format
'texinfo-if-set
)
3940 (defun texinfo-if-set ()
3941 "If set, continue formatting; else do not format region up to @end ifset"
3942 (let ((arg (texinfo-parse-arg-discard)))
3944 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3946 ;; Format the text (i.e., do not remove it); do nothing here.
3948 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3950 ;; Clear region (i.e., cause the text to be ignored).
3951 (delete-region texinfo-command-start
3952 (progn (re-search-forward "@end ifset[ \t]*\n")
3954 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3956 ;; In this case flag is neither set nor cleared.
3957 ;; Act as if set, i.e. do nothing.
3960 (put 'ifclear
'texinfo-end
'texinfo-discard-command
)
3961 (put 'ifclear
'texinfo-format
'texinfo-if-clear
)
3962 (defun texinfo-if-clear ()
3963 "If clear, continue formatting; if set, do not format up to @end ifset"
3964 (let ((arg (texinfo-parse-arg-discard)))
3966 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3968 ;; Clear region (i.e., cause the text to be ignored).
3969 (delete-region texinfo-command-start
3970 (progn (re-search-forward "@end ifclear[ \t]*\n")
3972 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3974 ;; Format the text (i.e., do not remove it); do nothing here.
3976 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3978 ;; In this case flag is neither set nor cleared.
3979 ;; Act as if clear, i.e. do nothing.
3984 (put 'ifeq
'texinfo-format
'texinfo-format-ifeq
)
3985 (defun texinfo-format-ifeq ()
3986 "If ARG1 and ARG2 caselessly string compare to same string, perform COMMAND.
3987 Otherwise produces no output.
3990 @ifeq{ arg1 , arg1 , @code{foo}} bar
3994 @ifeq{ arg1 , arg2 , @code{foo}} bar
3998 Note that the Texinfo command and its arguments must be arguments to
4000 ;; compare-buffer-substrings does not exist in version 18; don't use
4001 (goto-char texinfo-command-end
)
4002 (let* ((case-fold-search t
)
4003 (stop (save-excursion (forward-sexp 1) (point)))
4005 ;; @ifeq{arg1, arg2, @command{optional-args}}
4009 (skip-chars-forward " ")
4010 (setq start
(point))
4011 (search-forward "," stop t
)
4012 (skip-chars-backward ", ")
4013 (buffer-substring-no-properties start
(point))))
4016 (search-forward "," stop t
)
4017 (skip-chars-forward " ")
4018 (setq start
(point))
4019 (search-forward "," stop t
)
4020 (skip-chars-backward ", ")
4021 (buffer-substring-no-properties start
(point))))
4024 (search-forward "," stop t
)
4025 (skip-chars-forward " ")
4026 (setq start
(point))
4027 (goto-char (1- stop
))
4028 (skip-chars-backward " ")
4029 (buffer-substring-no-properties start
(point)))))
4030 (delete-region texinfo-command-start stop
)
4031 (if (equal arg1 arg2
)
4032 (insert texinfo-command
))
4033 (goto-char texinfo-command-start
)))
4036 ;;; Process included files: `@include' command
4038 ;; Updated 19 October 1990
4039 ;; In the original version, include files were ignored by Info but
4040 ;; incorporated in to the printed manual. To make references to the
4041 ;; included file, the Texinfo source file has to refer to the included
4042 ;; files using the `(filename)nodename' format for referring to other
4043 ;; Info files. Also, the included files had to be formatted on their
4044 ;; own. It was just like they were another file.
4046 ;; Currently, include files are inserted into the buffer that is
4047 ;; formatted for Info. If large, the resulting info file is split and
4048 ;; tagified. For current include files to work, the master menu must
4049 ;; refer to all the nodes, and the highest level nodes in the include
4050 ;; files must have the correct next, prev, and up pointers.
4052 ;; The included file may have an @setfilename and even an @settitle,
4053 ;; but not an `\input texinfo' line.
4055 ;; Updated 24 March 1993
4056 ;; In order for @raisesections and @lowersections to work, included
4057 ;; files must be inserted into the buffer holding the outer file
4058 ;; before other Info formatting takes place. So @include is no longer
4059 ;; is treated like other @-commands.
4060 (put 'include
'texinfo-format
'texinfo-format-noop
)
4062 ;; Original definition:
4063 ;; (defun texinfo-format-include ()
4064 ;; (let ((filename (texinfo-parse-arg-discard))
4065 ;; (default-directory input-directory)
4069 ;; (progn (find-file
4070 ;; (cond ((file-readable-p (concat filename ".texinfo"))
4071 ;; (concat filename ".texinfo"))
4072 ;; ((file-readable-p (concat filename ".texi"))
4073 ;; (concat filename ".texi"))
4074 ;; ((file-readable-p (concat filename ".tex"))
4075 ;; (concat filename ".tex"))
4076 ;; ((file-readable-p filename)
4078 ;; (t (error "@include'd file %s not found"
4080 ;; (texinfo-format-buffer-1))))
4081 ;; (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex))
4082 ;; (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex))
4083 ;; (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex))
4084 ;; (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex))
4085 ;; (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex))
4086 ;; (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex))))
4088 ;;(defun texinfo-subindex (indexvar file content)
4089 ;; (set indexvar (cons (list 'recurse file content)
4090 ;; (symbol-value indexvar))))
4092 ;; Second definition:
4093 ;; (put 'include 'texinfo-format 'texinfo-format-include)
4094 ;; (defun texinfo-format-include ()
4095 ;; (let ((filename (concat input-directory
4096 ;; (texinfo-parse-arg-discard)))
4097 ;; (default-directory input-directory))
4098 ;; (message "Reading: %s" filename)
4100 ;; (save-restriction
4101 ;; (narrow-to-region
4103 ;; (+ (point) (car (cdr (insert-file-contents filename)))))
4104 ;; (goto-char (point-min))
4105 ;; (texinfo-append-refill)
4106 ;; (texinfo-format-convert (point-min) (point-max))))
4107 ;; (setq last-input-buffer input-buffer) ; to bypass setfilename
4111 ;;; Numerous commands do nothing in Info
4112 ;; These commands are defined in texinfo.tex for printed output.
4115 ;;; various noops, such as @b{foo}, that take arguments in braces
4117 (put 'b
'texinfo-format
'texinfo-format-noop
)
4118 (put 'i
'texinfo-format
'texinfo-format-noop
)
4119 (put 'r
'texinfo-format
'texinfo-format-noop
)
4120 (put 't
'texinfo-format
'texinfo-format-noop
)
4121 (put 'w
'texinfo-format
'texinfo-format-noop
)
4122 (put 'asis
'texinfo-format
'texinfo-format-noop
)
4123 (put 'dmn
'texinfo-format
'texinfo-format-noop
)
4124 (put 'math
'texinfo-format
'texinfo-format-noop
)
4125 (put 'titlefont
'texinfo-format
'texinfo-format-noop
)
4126 (defun texinfo-format-noop ()
4127 (insert (texinfo-parse-arg-discard))
4128 (goto-char texinfo-command-start
))
4130 ;; @hyphenation command discards an argument within braces
4131 (put 'hyphenation
'texinfo-format
'texinfo-discard-command-and-arg
)
4132 (defun texinfo-discard-command-and-arg ()
4133 "Discard both @-command and its argument in braces."
4134 (goto-char texinfo-command-end
)
4136 (setq texinfo-command-end
(point))
4137 (delete-region texinfo-command-start texinfo-command-end
))
4140 ;;; Do nothing commands, such as @smallbook, that have no args and no braces
4141 ;; These must appear on a line of their own
4143 (put 'bye
'texinfo-format
'texinfo-discard-line
)
4144 (put 'smallbook
'texinfo-format
'texinfo-discard-line
)
4145 (put 'finalout
'texinfo-format
'texinfo-discard-line
)
4146 (put 'overfullrule
'texinfo-format
'texinfo-discard-line
)
4147 (put 'smallbreak
'texinfo-format
'texinfo-discard-line
)
4148 (put 'medbreak
'texinfo-format
'texinfo-discard-line
)
4149 (put 'bigbreak
'texinfo-format
'texinfo-discard-line
)
4150 (put 'afourpaper
'texinfo-format
'texinfo-discard-line
)
4151 (put 'afivepaper
'texinfo-format
'texinfo-discard-line
)
4152 (put 'afourlatex
'texinfo-format
'texinfo-discard-line
)
4153 (put 'afourwide
'texinfo-format
'texinfo-discard-line
)
4156 ;;; These noop commands discard the rest of the line.
4158 (put 'c
'texinfo-format
'texinfo-discard-line-with-args
)
4159 (put 'comment
'texinfo-format
'texinfo-discard-line-with-args
)
4160 (put 'contents
'texinfo-format
'texinfo-discard-line-with-args
)
4161 (put 'group
'texinfo-end
'texinfo-discard-line-with-args
)
4162 (put 'group
'texinfo-format
'texinfo-discard-line-with-args
)
4163 (put 'headings
'texinfo-format
'texinfo-discard-line-with-args
)
4164 (put 'setchapterstyle
'texinfo-format
'texinfo-discard-line-with-args
)
4165 (put 'hsize
'texinfo-format
'texinfo-discard-line-with-args
)
4166 (put 'itemindent
'texinfo-format
'texinfo-discard-line-with-args
)
4167 (put 'lispnarrowing
'texinfo-format
'texinfo-discard-line-with-args
)
4168 (put 'need
'texinfo-format
'texinfo-discard-line-with-args
)
4169 (put 'nopara
'texinfo-format
'texinfo-discard-line-with-args
)
4171 ;; @novalidate suppresses cross-reference checking and auxiliary file
4172 ;; creation with TeX. The Info-validate command checks that every
4173 ;; node pointer points to an existing node. Since this Info command
4174 ;; is not invoked automatically, the @novalidate command is irrelevant
4175 ;; and not supported by texinfmt.el
4176 (put 'novalidate
'texinfo-format
'texinfo-discard-line-with-args
)
4178 (put 'page
'texinfo-format
'texinfo-discard-line-with-args
)
4179 (put 'pagesizes
'texinfo-format
'texinfo-discard-line-with-args
)
4180 (put 'parindent
'texinfo-format
'texinfo-discard-line-with-args
)
4181 (put 'setchapternewpage
'texinfo-format
'texinfo-discard-line-with-args
)
4182 (put 'setq
'texinfo-format
'texinfo-discard-line-with-args
)
4184 (put 'setcontentsaftertitlepage
4185 'texinfo-format
'texinfo-discard-line-with-args
)
4186 (put 'setshortcontentsaftertitlepage
4187 'texinfo-format
'texinfo-discard-line-with-args
)
4189 (put 'settitle
'texinfo-format
'texinfo-discard-line-with-args
)
4190 (put 'setx
'texinfo-format
'texinfo-discard-line-with-args
)
4191 (put 'shortcontents
'texinfo-format
'texinfo-discard-line-with-args
)
4192 (put 'shorttitlepage
'texinfo-format
'texinfo-discard-line-with-args
)
4193 (put 'summarycontents
'texinfo-format
'texinfo-discard-line-with-args
)
4194 (put 'input
'texinfo-format
'texinfo-discard-line-with-args
)
4196 (put 'documentlanguage
'texinfo-format
'texinfo-discard-line-with-args
)
4197 (put 'documentencoding
'texinfo-format
'texinfo-discard-line-with-args
)
4201 ;;; Some commands cannot be handled
4203 (defun texinfo-unsupported ()
4204 (error "%s is not handled by texinfo"
4205 (buffer-substring-no-properties texinfo-command-start texinfo-command-end
)))
4207 ;;; Batch formatting
4209 (defun batch-texinfo-format ()
4210 "Runs texinfo-format-buffer on the files remaining on the command line.
4211 Must be used only with -batch, and kills emacs on completion.
4212 Each file will be processed even if an error occurred previously.
4214 \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"."
4215 (if (not noninteractive
)
4216 (error "batch-texinfo-format may only be used -batch"))
4217 (let ((version-control t
)
4218 (auto-save-default nil
)
4219 (find-file-run-dired nil
)
4220 (kept-old-versions 259259)
4221 (kept-new-versions 259259))
4225 (while command-line-args-left
4226 (setq file
(expand-file-name (car command-line-args-left
)))
4227 (cond ((not (file-exists-p file
))
4228 (message ">> %s does not exist!" file
)
4230 command-line-args-left
(cdr command-line-args-left
)))
4231 ((file-directory-p file
)
4232 (setq command-line-args-left
4233 (nconc (directory-files file
)
4234 (cdr command-line-args-left
))))
4236 (setq files
(cons file files
)
4237 command-line-args-left
(cdr command-line-args-left
)))))
4239 (setq file
(car files
)
4243 (if buffer-file-name
(kill-buffer (current-buffer)))
4245 (buffer-disable-undo (current-buffer))
4246 (set-buffer-modified-p nil
)
4248 (message "texinfo formatting %s..." file
)
4249 (texinfo-format-buffer nil
)
4250 (if (buffer-modified-p)
4251 (progn (message "Saving modified %s" (buffer-file-name))
4254 (message ">> Error: %s" (prin1-to-string err
))
4255 (message ">> point at")
4256 (let ((s (buffer-substring-no-properties (point)
4257 (min (+ (point) 100)
4260 (while (setq tem
(string-match "\n+" s tem
))
4261 (setq s
(concat (substring s
0 (match-beginning 0))
4263 (substring s
(match-end 0)))
4265 (message ">> %s" s
))
4267 (kill-emacs error
))))
4270 ;;; Place `provide' at end of file.
4273 ;;; texinfmt.el ends here