1 ;;; texinfmt.el --- format Texinfo files into Info files.
3 ;; Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993,
4 ;; 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
6 ;; Maintainer: Robert J. Chassell <bug-texinfo@prep.ai.mit.edu>
7 ;; Keywords: maint, tex, docs
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;;; Emacs lisp functions to convert Texinfo files to Info files.
30 (defvar texinfmt-version "2.37 of 24 May 1997")
32 (defun texinfmt-version (&optional here)
33 "Show the version of texinfmt.el in the minibuffer.
34 If optional argument HERE is non-nil, insert info at point."
37 (format "Version of \`texinfmt.el\': %s" texinfmt-version)))
39 (insert version-string)
41 (message "%s" version-string)
45 ;;; Variable definitions
47 (require 'texinfo) ; So `texinfo-footnote-style' is defined.
48 (require 'texnfo-upd) ; So `texinfo-section-types-regexp' is defined.
50 (defvar texinfo-format-syntax-table nil)
52 (defvar texinfo-vindex)
53 (defvar texinfo-findex)
54 (defvar texinfo-cindex)
55 (defvar texinfo-pindex)
56 (defvar texinfo-tindex)
57 (defvar texinfo-kindex)
58 (defvar texinfo-last-node)
59 (defvar texinfo-node-names)
60 (defvar texinfo-enclosure-list)
61 (defvar texinfo-alias-list)
63 (defvar texinfo-command-start)
64 (defvar texinfo-command-end)
65 (defvar texinfo-command-name)
66 (defvar texinfo-defun-type)
67 (defvar texinfo-last-node-pos)
68 (defvar texinfo-stack)
69 (defvar texinfo-short-index-cmds-alist)
70 (defvar texinfo-short-index-format-cmds-alist)
71 (defvar texinfo-format-filename)
72 (defvar texinfo-footnote-number)
73 (defvar texinfo-start-of-header)
74 (defvar texinfo-end-of-header)
75 (defvar texinfo-raisesections-alist)
76 (defvar texinfo-lowersections-alist)
80 (if texinfo-format-syntax-table
82 (setq texinfo-format-syntax-table (make-syntax-table))
83 (modify-syntax-entry ?\" " " texinfo-format-syntax-table)
84 (modify-syntax-entry ?\\ " " texinfo-format-syntax-table)
85 (modify-syntax-entry ?@ "\\" texinfo-format-syntax-table)
86 (modify-syntax-entry ?\^q "\\" texinfo-format-syntax-table)
87 (modify-syntax-entry ?\[ "." texinfo-format-syntax-table)
88 (modify-syntax-entry ?\] "." texinfo-format-syntax-table)
89 (modify-syntax-entry ?\( "." texinfo-format-syntax-table)
90 (modify-syntax-entry ?\) "." texinfo-format-syntax-table)
91 (modify-syntax-entry ?{ "(}" texinfo-format-syntax-table)
92 (modify-syntax-entry ?} "){" texinfo-format-syntax-table)
93 (modify-syntax-entry ?\' "." texinfo-format-syntax-table))
96 ;;; Top level buffer and region formatting functions
99 (defun texinfo-format-buffer (&optional notagify)
100 "Process the current buffer as texinfo code, into an Info file.
101 The Info file output is generated in a buffer visiting the Info file
102 name specified in the @setfilename command.
104 Non-nil argument (prefix, if interactive) means don't make tag table
105 and don't split the file if large. You can use Info-tagify and
106 Info-split to do these manually."
108 (let ((lastmessage "Formatting Info file..."))
109 (message lastmessage)
110 (texinfo-format-buffer-1)
113 (if (> (buffer-size) 30000)
115 (message (setq lastmessage "Making tags table for Info file..."))
117 (if (> (buffer-size) 100000)
119 (message (setq lastmessage "Splitting Info file..."))
121 (message (concat lastmessage
122 (if (interactive-p) "done. Now save it." "done.")))))
124 (defvar texinfo-region-buffer-name "*Info Region*"
125 "*Name of the temporary buffer used by \\[texinfo-format-region].")
128 (defun texinfo-format-region (region-beginning region-end)
129 "Convert the current region of the Texinfo file to Info format.
130 This lets you see what that part of the file will look like in Info.
131 The command is bound to \\[texinfo-format-region]. The text that is
132 converted to Info is stored in a temporary buffer."
134 (message "Converting region to Info format...")
135 (let (texinfo-command-start
145 (texinfo-format-filename "")
146 texinfo-example-start
147 texinfo-last-node-pos
150 (texinfo-footnote-number 0)
152 (fill-column-for-info fill-column)
153 (input-buffer (current-buffer))
154 (input-directory default-directory)
159 ;;; Copy lines between beginning and end of header lines,
160 ;;; if any, or else copy the `@setfilename' line, if any.
164 (goto-char (point-min))
165 (let ((search-end (save-excursion (forward-line 100) (point))))
167 ;; Either copy header text.
170 (search-forward tex-start-of-header search-end t)
172 ;; Mark beginning of header.
173 (setq header-beginning (point)))
175 (search-forward tex-end-of-header nil t)
177 ;; Mark end of header
178 (setq header-end (point))))
179 ;; Or copy @filename line.
181 (goto-char (point-min))
182 (search-forward "@setfilename" search-end t)
184 (setq header-beginning (point))
186 (setq header-end (point))))
191 (min header-beginning region-beginning)
194 ;;; Find a buffer to use.
195 (switch-to-buffer (get-buffer-create texinfo-region-buffer-name))
197 ;; Insert the header into the buffer.
199 ;; Insert the region into the buffer.
200 (insert-buffer-substring
202 (max region-beginning header-end)
204 ;; Make sure region ends in a newline.
205 (or (= (preceding-char) ?\n)
208 (goto-char (point-min))
210 (message "Converting region to Info format...")
211 (setq fill-column fill-column-for-info)
212 ;; Install a syntax table useful for scanning command operands.
213 (set-syntax-table texinfo-format-syntax-table)
215 ;; Insert @include files so `texinfo-raise-lower-sections' can
216 ;; work on them without losing track of multiple
217 ;; @raise/@lowersections commands.
218 (while (re-search-forward "^@include" nil t)
219 (setq texinfo-command-end (point))
220 (let ((filename (concat input-directory
221 (texinfo-parse-line-arg))))
222 (re-search-backward "^@include")
223 (delete-region (point) (save-excursion (forward-line 1) (point)))
224 (message "Reading included file: %s" filename)
229 (+ (point) (car (cdr (insert-file-contents filename)))))
230 (goto-char (point-min))
231 ;; Remove `@setfilename' line from included file, if any,
232 ;; so @setfilename command not duplicated.
233 (if (re-search-forward
234 "^@setfilename" (save-excursion (forward-line 100) (point)) t)
238 (point) (save-excursion (forward-line 1) (point)))))))))
240 ;; Raise or lower level of each section, if necessary.
241 (goto-char (point-min))
242 (texinfo-raise-lower-sections)
243 ;; Append @refill to appropriate paragraphs for filling.
244 (goto-char (point-min))
245 (texinfo-append-refill)
246 ;; If the region includes the effective end of the data,
247 ;; discard everything after that.
248 (goto-char (point-max))
249 (if (re-search-backward "^@bye" nil t)
250 (delete-region (point) (point-max)))
251 ;; Make sure buffer ends in a newline.
252 (or (= (preceding-char) ?\n)
254 ;; Don't use a previous value of texinfo-enclosure-list.
255 (setq texinfo-enclosure-list nil)
256 (setq texinfo-alias-list nil)
258 (goto-char (point-min))
259 (if (looking-at "\\\\input[ \t]+texinfo")
260 (delete-region (point) (save-excursion (forward-line 1) (point))))
262 ;; Insert Info region title text.
263 (goto-char (point-min))
265 "@setfilename" (save-excursion (forward-line 100) (point)) t)
267 (setq texinfo-command-end (point))
269 (setq texinfo-command-start (point))
270 (let ((arg (texinfo-parse-arg-discard)))
272 texinfo-region-buffer-name
274 (insert (file-name-nondirectory (expand-file-name arg)))
275 (insert "', -*-Text-*-\n")))
276 ;; Else no `@setfilename' line
278 texinfo-region-buffer-name
279 " buffer -*-Text-*-\n"))
280 (insert "produced by `texinfo-format-region'\n"
282 (if (buffer-file-name input-buffer)
284 (file-name-sans-versions
285 (file-name-nondirectory
286 (buffer-file-name input-buffer)))
288 (concat "buffer `" (buffer-name input-buffer) "'"))
289 "\nusing `texinfmt.el' version "
293 ;; Now convert for real.
294 (goto-char (point-min))
295 (texinfo-format-scan)
296 (goto-char (point-min))
301 (defun texi2info (&optional notagify)
302 "Convert the current buffer (written in Texinfo code) into an Info file.
303 The Info file output is generated in a buffer visiting the Info file
304 names specified in the @setfilename command.
306 This function automatically updates all node pointers and menus, and
307 creates a master menu. This work is done on a temporary buffer that
308 is automatically removed when the Info file is created. The original
309 Texinfo source buffer is not changed.
311 Non-nil argument (prefix, if interactive) means don't make tag table
312 and don't split the file if large. You can use Info-tagify and
313 Info-split to do these manually."
315 (let ((temp-buffer (concat "*--" (buffer-name) "--temporary-buffer*" )))
316 (message "First updating nodes and menus, then creating Info file.")
318 (copy-to-buffer temp-buffer (point-min) (point-max))
319 (switch-to-buffer temp-buffer)
320 (texinfo-master-menu t)
321 (message "Now creating Info file.")
323 (texinfo-format-buffer notagify)
325 (kill-buffer temp-buffer)))
328 ;;; Primary internal formatting function for the whole buffer.
330 (defun texinfo-format-buffer-1 ()
331 (let (texinfo-format-filename
332 texinfo-example-start
333 texinfo-command-start
337 texinfo-last-node-pos
346 (texinfo-footnote-number 0)
349 (fill-column-for-info fill-column)
350 (input-buffer (current-buffer))
351 (input-directory default-directory))
352 (setq texinfo-enclosure-list nil)
353 (setq texinfo-alias-list nil)
355 (goto-char (point-min))
356 (or (search-forward "@setfilename" nil t)
357 (error "Texinfo file needs an `@setfilename FILENAME' line."))
358 (setq texinfo-command-end (point))
359 (setq outfile (texinfo-parse-line-arg)))
365 (message "Formatting Info file: %s" outfile)
366 (setq texinfo-format-filename
367 (file-name-nondirectory (expand-file-name outfile)))
369 (setq fill-column fill-column-for-info)
370 (set-syntax-table texinfo-format-syntax-table)
372 (insert-buffer-substring input-buffer)
373 (message "Converting %s to Info format..." (buffer-name input-buffer))
375 ;; Insert @include files so `texinfo-raise-lower-sections' can
376 ;; work on them without losing track of multiple
377 ;; @raise/@lowersections commands.
378 (goto-char (point-min))
379 (while (re-search-forward "^@include" nil t)
380 (setq texinfo-command-end (point))
381 (let ((filename (concat input-directory
382 (texinfo-parse-line-arg))))
383 (re-search-backward "^@include")
384 (delete-region (point) (save-excursion (forward-line 1) (point)))
385 (message "Reading included file: %s" filename)
390 (+ (point) (car (cdr (insert-file-contents filename)))))
391 (goto-char (point-min))
392 ;; Remove `@setfilename' line from included file, if any,
393 ;; so @setfilename command not duplicated.
394 (if (re-search-forward
396 (save-excursion (forward-line 100) (point)) t)
400 (point) (save-excursion (forward-line 1) (point)))))))))
401 ;; Raise or lower level of each section, if necessary.
402 (goto-char (point-min))
403 (texinfo-raise-lower-sections)
404 ;; Append @refill to appropriate paragraphs
405 (goto-char (point-min))
406 (texinfo-append-refill)
407 (goto-char (point-min))
408 (search-forward "@setfilename")
410 (delete-region (point-min) (point))
411 ;; Remove @bye at end of file, if it is there.
412 (goto-char (point-max))
413 (if (search-backward "@bye" nil t)
414 (delete-region (point) (point-max)))
415 ;; Make sure buffer ends in a newline.
416 (or (= (preceding-char) ?\n)
418 ;; Scan the whole buffer, converting to Info format.
419 (texinfo-format-scan)
420 (goto-char (point-min))
421 ;; Insert info about how this file was made.
422 (insert "Info file: "
423 texinfo-format-filename ", -*-Text-*-\n"
424 "produced by `texinfo-format-buffer'\n"
425 ;; Date string removed so that regression testing is easier.
427 ;; (insert (format-time-string "%e %b %Y")) " "
429 (if (buffer-file-name input-buffer)
431 (file-name-sans-versions
432 (file-name-nondirectory
433 (buffer-file-name input-buffer)))
435 (concat "buffer `" (buffer-name input-buffer) "'"))
436 "\nusing `texinfmt.el' version "
439 ;; Return data for indices.
441 texinfo-vindex texinfo-findex texinfo-cindex
442 texinfo-pindex texinfo-tindex texinfo-kindex)))
445 ;;; Perform non-@-command file conversions: quotes and hyphens
447 (defun texinfo-format-convert (min max)
448 ;; Convert left and right quotes to typewriter font quotes.
450 (while (search-forward "``" max t)
451 (replace-match "\""))
453 (while (search-forward "''" max t)
454 (replace-match "\""))
455 ;; Convert three hyphens in a row to two.
457 (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t)
458 (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning
462 ;;; Handle paragraph filling
464 ;; Keep as concatinated lists for ease of maintenance
466 (defvar texinfo-no-refill-regexp
487 "Regexp specifying environments in which paragraphs are not filled.")
489 (defvar texinfo-accent-commands
522 (defvar texinfo-part-of-para-regexp
557 "@-\\|" ; @- is a descretionary hyphen (not an accent) (a noop).
558 texinfo-accent-commands
561 "Regexp specifying @-commands found within paragraphs.")
563 (defun texinfo-append-refill ()
564 "Append @refill at end of each paragraph that should be filled.
565 Do not append @refill to paragraphs within @example and similar environments.
566 Do not append @refill to paragraphs containing @w{TEXT} or @*."
568 ;; It is necessary to append @refill before other processing because
569 ;; the other processing removes information that tells Texinfo
570 ;; whether the text should or should not be filled.
572 (while (< (point) (point-max))
573 (let ((refill-blank-lines "^[ \t\n]*$")
574 (case-fold-search nil)) ; Don't confuse @TeX and @tex....
576 ;; 1. Skip over blank lines;
577 ;; skip over lines beginning with @-commands,
578 ;; but do not skip over lines
579 ;; that are no-refill environments such as @example or
580 ;; that begin with within-paragraph @-commands such as @code.
581 (while (and (looking-at (concat "^@\\|^\\\\\\|" refill-blank-lines))
585 texinfo-no-refill-regexp
587 texinfo-part-of-para-regexp
589 (< (point) (point-max)))
591 ;; 2. Skip over @example and similar no-refill environments.
592 (if (looking-at texinfo-no-refill-regexp)
594 (buffer-substring (match-beginning 1) (match-end 1))))
595 (progn (re-search-forward (concat "^@end " environment) nil t)
598 ;; 3. Do not refill a paragraph containing @w or @*, or ending
599 ;; with @<newline> followed by a newline.
601 (>= (point) (point-max))
608 ;; Go to end of paragraph and do nothing.
610 ;; 4. Else go to end of paragraph and insert @refill
616 (save-excursion (skip-chars-backward " \t") (point)))
617 ;; `looking-at-backward' not available in v. 18.57
618 ;; (if (not (looking-at-backward "@refill\\|@bye")) ;)
619 (if (not (re-search-backward
621 (save-excursion (beginning-of-line) (point))
624 (forward-line 1))))))
627 ;;; Handle `@raisesections' and `@lowersections' commands
629 ;; These commands change the hierarchical level of chapter structuring
632 ;; @raisesections changes @subsection to @section,
633 ;; @section to @chapter,
636 ;; @lowersections changes @chapter to @section
637 ;; @subsection to @subsubsection,
640 ;; An @raisesections/@lowersections command changes only those
641 ;; structuring commands that follow the @raisesections/@lowersections
644 ;; Repeated @raisesections/@lowersections continue to raise or lower
645 ;; the heading level.
647 ;; An @lowersections command cancels an @raisesections command, and
650 ;; You cannot raise or lower "beyond" chapters or subsubsections, but
651 ;; trying to do so does not elicit an error---you just get more
652 ;; headings that mean the same thing as you keep raising or lowering
653 ;; (for example, after a single @raisesections, both @chapter and
654 ;; @section produce chapter headings).
656 (defun texinfo-raise-lower-sections ()
657 "Raise or lower the hierarchical level of chapters, sections, etc.
659 This function acts according to `@raisesections' and `@lowersections'
660 commands in the Texinfo file.
662 For example, an `@lowersections' command is useful if you wish to
663 include what is written as an outer or standalone Texinfo file in
664 another Texinfo file as an inner, included file. The `@lowersections'
665 command changes chapters to sections, sections to subsections and so
668 @raisesections changes @subsection to @section,
669 @section to @chapter,
670 @heading to @chapheading,
673 @lowersections changes @chapter to @section,
674 @subsection to @subsubsection,
675 @heading to @subheading,
678 An `@raisesections' or `@lowersections' command changes only those
679 structuring commands that follow the `@raisesections' or
680 `@lowersections' command.
682 An `@lowersections' command cancels an `@raisesections' command, and
685 Repeated use of the commands continue to raise or lower the hierarchical
686 level a step at a time.
688 An attempt to raise above `chapters' reproduces chapter commands; an
689 attempt to lower below subsubsections reproduces subsubsection
692 ;; `texinfo-section-types-regexp' is defined in `texnfo-upd.el';
693 ;; it is a regexp matching chapter, section, other headings
694 ;; (but not the top node).
696 (let (type (level 0))
700 "\\(\\(^@\\(raise\\|lower\\)sections\\)\\|\\("
701 texinfo-section-types-regexp
705 (save-excursion (setq type (read (current-buffer))))
708 ;; 1. Increment level
709 ((eq type '@raisesections)
710 (setq level (1+ level))
712 (point) (save-excursion (forward-line 1) (point))))
714 ;; 2. Decrement level
715 ((eq type '@lowersections)
716 (setq level (1- level))
718 (point) (save-excursion (forward-line 1) (point))))
720 ;; Now handle structuring commands
723 ;; 3. Raise level when positive
729 (cdr (assq new-level texinfo-raisesections-alist)))
730 (setq count (1- count)))
732 (insert (symbol-name new-level))))
734 ;; 4. Do nothing except move point when level is zero
735 ((= level 0) (forward-line 1))
737 ;; 5. Lower level when positive
743 (cdr (assq new-level texinfo-lowersections-alist)))
744 (setq count (1+ count)))
746 (insert (symbol-name new-level))))))))))
748 (defvar texinfo-raisesections-alist
749 '((@chapter . @chapter) ; Cannot go higher
750 (@unnumbered . @unnumbered)
751 (@centerchap . @unnumbered)
753 (@majorheading . @majorheading)
754 (@chapheading . @chapheading)
755 (@appendix . @appendix)
757 (@section . @chapter)
758 (@unnumberedsec . @unnumbered)
759 (@heading . @chapheading)
760 (@appendixsec . @appendix)
762 (@subsection . @section)
763 (@unnumberedsubsec . @unnumberedsec)
764 (@subheading . @heading)
765 (@appendixsubsec . @appendixsec)
767 (@subsubsection . @subsection)
768 (@unnumberedsubsubsec . @unnumberedsubsec)
769 (@subsubheading . @subheading)
770 (@appendixsubsubsec . @appendixsubsec))
771 "*An alist of next higher levels for chapters, sections. etc.
772 For example, section to chapter, subsection to section.
773 Used by `texinfo-raise-lower-sections'.
774 The keys specify types of section; the values correspond to the next
777 (defvar texinfo-lowersections-alist
778 '((@chapter . @section)
779 (@unnumbered . @unnumberedsec)
780 (@centerchap . @unnumberedsec)
781 (@majorheading . @heading)
782 (@chapheading . @heading)
783 (@appendix . @appendixsec)
785 (@section . @subsection)
786 (@unnumberedsec . @unnumberedsubsec)
787 (@heading . @subheading)
788 (@appendixsec . @appendixsubsec)
790 (@subsection . @subsubsection)
791 (@unnumberedsubsec . @unnumberedsubsubsec)
792 (@subheading . @subsubheading)
793 (@appendixsubsec . @appendixsubsubsec)
795 (@subsubsection . @subsubsection) ; Cannot go lower.
796 (@unnumberedsubsubsec . @unnumberedsubsubsec)
797 (@subsubheading . @subsubheading)
798 (@appendixsubsubsec . @appendixsubsubsec))
799 "*An alist of next lower levels for chapters, sections. etc.
800 For example, chapter to section, section to subsection.
801 Used by `texinfo-raise-lower-sections'.
802 The keys specify types of section; the values correspond to the next
806 ;;; Perform those texinfo-to-info conversions that apply to the whole input
809 (defun texinfo-format-scan ()
810 (texinfo-format-convert (point-min) (point-max))
811 ;; Scan for @-commands.
812 (goto-char (point-min))
813 (while (search-forward "@" nil t)
815 ;; These are the single-character accent commands: @^ @` @' @" @= @~
816 ;; In Info, they are simply quoted and the @ deleted.
817 ;; Other single-character commands:
818 ;; @* forces a line break,
819 ;; @- is a discretionary hyphenation point; does nothing in Info.
820 ;; @<space>, @<tab>, @<newline> each produce a single space,
821 ;; unless followed by a newline.
823 ;; Old version 2.34 expression: (looking-at "[@{}^'` *\"?!]")
824 (if (looking-at "[@{}^'`\"=~ \t\n*?!-]")
825 ;; @*, causes a line break.
828 ((= (following-char) ?*)
830 (delete-region (1- (point)) (1+ (point)))
831 ;; insert return if not at end of line;
832 ;; else line is already broken.
833 (if (not (= (following-char) ?\n))
836 ((= (following-char) ?-)
837 (delete-region (1- (point)) (1+ (point))))
838 ;; @<space>, @<tab>, @<newline>: produce a single space,
839 ;; unless followed by a newline.
840 ((= (following-char) ? )
841 (delete-region (1- (point)) (1+ (point)))
842 ;; insert single space if not at end of line;
843 ;; else line is already broken.
844 (if (not (= (following-char) ?\n))
846 ((= (following-char) ?\t)
847 (delete-region (1- (point)) (1+ (point)))
848 ;; insert single space if not at end of line;
849 ;; else line is already broken.
850 (if (not (= (following-char) ?\n))
852 ;; following char is a carriage return
853 ((= (following-char) ?
856 (delete-region (1- (point)) (1+ (point)))
857 ;; insert single space if not at end of line;
858 ;; else line is already broken.
859 (if (not (= (following-char) ?\n))
861 ;; Otherwise: the other characters are simply quoted. Delete the @.
865 ;; @ is followed by a command-word; find the end of the word.
866 (setq texinfo-command-start (1- (point)))
867 (if (= (char-syntax (following-char)) ?w)
870 (setq texinfo-command-end (point))
871 ;; Handle let aliasing
872 (setq texinfo-command-name
876 (1+ texinfo-command-start) texinfo-command-end)))
877 (while (setq trial (assoc cmdname texinfo-alias-list))
878 (setq cmdname (cdr trial)))
880 ;; Call the handler for this command.
881 (let ((enclosure-type
883 (symbol-name texinfo-command-name)
884 texinfo-enclosure-list)))
888 (car (car (cdr enclosure-type)))
889 (texinfo-parse-arg-discard)
890 (car (cdr (car (cdr enclosure-type)))))
891 (goto-char texinfo-command-start))
892 (let ((cmd (get texinfo-command-name 'texinfo-format)))
893 (if cmd (funcall cmd) (texinfo-unsupported)))))))
896 (goto-char (nth 2 (car texinfo-stack)))
897 (error "Unterminated @%s" (car (car texinfo-stack))))))
899 (put 'begin 'texinfo-format 'texinfo-format-begin)
900 (defun texinfo-format-begin ()
901 (texinfo-format-begin-end 'texinfo-format))
903 (put 'end 'texinfo-format 'texinfo-format-end)
904 (defun texinfo-format-end ()
905 (texinfo-format-begin-end 'texinfo-end))
907 (defun texinfo-format-begin-end (prop)
908 (setq texinfo-command-name (intern (texinfo-parse-line-arg)))
909 (let ((cmd (get texinfo-command-name prop)))
910 (if cmd (funcall cmd)
911 (texinfo-unsupported))))
913 ;;; Parsing functions
915 (defun texinfo-parse-line-arg ()
916 "Return argument of @-command as string.
917 Argument is separated from command either by a space or by a brace.
918 If a space, return rest of line, with beginning and ending white
919 space removed. If a brace, return string between braces.
920 Leave point after argument."
921 (goto-char texinfo-command-end)
922 (let ((start (point)))
923 (cond ((looking-at " ")
924 (skip-chars-forward " ")
927 (skip-chars-backward " ")
928 (delete-region (point) (progn (end-of-line) (point)))
929 (setq texinfo-command-end (1+ (point))))
931 (setq start (1+ (point)))
933 (setq texinfo-command-end (point))
936 (error "Invalid texinfo command arg format")))
937 (prog1 (buffer-substring start (point))
938 (if (eolp) (forward-char 1)))))
940 (defun texinfo-parse-expanded-arg ()
941 (goto-char texinfo-command-end)
942 (let ((start (point))
944 (cond ((looking-at " ")
945 (skip-chars-forward " ")
948 (setq texinfo-command-end (1+ (point))))
950 (setq start (1+ (point)))
952 (setq texinfo-command-end (point))
955 (error "Invalid texinfo command arg format")))
956 (setq marker (move-marker (make-marker) texinfo-command-end))
957 (texinfo-format-expand-region start (point))
958 (setq texinfo-command-end (marker-position marker))
959 (move-marker marker nil)
960 (prog1 (buffer-substring start (point))
961 (if (eolp) (forward-char 1)))))
963 (defun texinfo-format-expand-region (start end)
965 (narrow-to-region start end)
966 (let (texinfo-command-start
970 (texinfo-format-scan))
971 (goto-char (point-max))))
973 (defun texinfo-parse-arg-discard ()
974 "Delete command and argument; return argument of command."
975 (prog1 (texinfo-parse-line-arg)
976 (texinfo-discard-command)))
978 (defun texinfo-discard-command ()
979 (delete-region texinfo-command-start texinfo-command-end))
981 (defun texinfo-optional-braces-discard ()
982 "Discard braces following command, if any."
983 (goto-char texinfo-command-end)
984 (let ((start (point)))
985 (cond ((looking-at "[ \t]*\n")) ; do nothing
986 ((looking-at "{") ; remove braces, if any
988 (setq texinfo-command-end (point)))
991 "Invalid `texinfo-optional-braces-discard' format \(need braces?\)")))
992 (delete-region texinfo-command-start texinfo-command-end)))
994 (defun texinfo-format-parse-line-args ()
995 (let ((start (1- (point)))
998 (skip-chars-forward " ")
1001 (re-search-forward "[\n,]")
1003 (if (bolp) (setq next (1- next)))
1005 (skip-chars-backward " ")
1007 (setq args (cons (if (> end beg) (buffer-substring beg end))
1010 (skip-chars-forward " "))
1011 (if (eolp) (forward-char 1))
1012 (setq texinfo-command-end (point))
1015 (defun texinfo-format-parse-args ()
1016 (let ((start (1- (point)))
1019 (search-forward "{")
1021 (texinfo-format-expand-region
1023 (save-excursion (up-list 1) (1- (point)))))
1024 ;; The following does not handle cross references of the form:
1025 ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the
1026 ;; re-search-forward finds the first right brace after the second
1028 (while (/= (preceding-char) ?\})
1029 (skip-chars-forward " \t\n")
1031 (re-search-forward "[},]")
1034 (skip-chars-backward " \t\n")
1038 (while (search-forward "\n" end t)
1039 (replace-match " "))))
1040 (setq args (cons (if (> end beg) (buffer-substring beg end))
1043 (if (eolp) (forward-char 1))
1044 (setq texinfo-command-end (point))
1047 (defun texinfo-format-parse-defun-args ()
1048 (goto-char texinfo-command-end)
1049 (let ((start (point)))
1051 (setq texinfo-command-end (1+ (point)))
1052 (let ((marker (move-marker (make-marker) texinfo-command-end)))
1053 (texinfo-format-expand-region start (point))
1054 (setq texinfo-command-end (marker-position marker))
1055 (move-marker marker nil))
1059 (skip-chars-forward " ")
1061 (cond ((looking-at "{")
1062 (setq beg (1+ (point)))
1064 (setq end (1- (point))))
1067 (re-search-forward "[\n ]")
1069 (setq end (point))))
1070 (setq args (cons (buffer-substring beg end) args))
1071 (skip-chars-forward " "))
1075 (defun texinfo-discard-line ()
1076 (goto-char texinfo-command-end)
1077 (skip-chars-forward " \t")
1079 (error "Extraneous text at end of command line."))
1080 (goto-char texinfo-command-start)
1082 (error "Extraneous text at beginning of command line."))
1083 (delete-region (point) (progn (forward-line 1) (point))))
1085 (defun texinfo-discard-line-with-args ()
1086 (goto-char texinfo-command-start)
1087 (delete-region (point) (progn (forward-line 1) (point))))
1092 ;; Only `texinfo-format-buffer' handles @setfilename with this
1093 ;; definition; `texinfo-format-region' handles @setfilename, if any,
1095 (put 'setfilename 'texinfo-format 'texinfo-format-setfilename)
1096 (defun texinfo-format-setfilename ()
1097 (texinfo-parse-arg-discard))
1099 ;;; @node, @menu, @detailmenu
1101 (put 'node 'texinfo-format 'texinfo-format-node)
1102 (put 'nwnode 'texinfo-format 'texinfo-format-node)
1103 (defun texinfo-format-node ()
1104 (let* ((args (texinfo-format-parse-line-args))
1109 (texinfo-discard-command)
1110 (setq texinfo-last-node name)
1111 (let ((tem (downcase name)))
1112 (if (assoc tem texinfo-node-names)
1113 (error "Duplicate node name: %s" name)
1114 (setq texinfo-node-names (cons (list tem) texinfo-node-names))))
1115 (setq texinfo-footnote-number 0)
1116 ;; insert "\n\^_" unconditionally since this is what info is looking for
1117 (insert "\n\^_\nFile: " texinfo-format-filename
1120 (insert ", Next: " next))
1122 (insert ", Prev: " prev))
1124 (insert ", Up: " up))
1126 (setq texinfo-last-node-pos (point))))
1128 (put 'menu 'texinfo-format 'texinfo-format-menu)
1129 (defun texinfo-format-menu ()
1130 (texinfo-discard-line)
1131 (insert "* Menu:\n\n"))
1133 (put 'menu 'texinfo-end 'texinfo-discard-command)
1135 ;; The @detailmenu should be removed eventually.
1137 ;; According to Karl Berry, 31 August 1996:
1139 ;; You don't like, I don't like it. I agree, it would be better just to
1140 ;; fix the bug [in `makeinfo']. .. At this point, since inserting those
1141 ;; two commands in the Elisp fn is trivial, I don't especially want to
1142 ;; expend more effort...
1144 ;; I added a couple sentences of documentation to the manual (putting the
1145 ;; blame on makeinfo where it belongs :-().
1147 (put 'detailmenu 'texinfo-format 'texinfo-discard-line)
1148 (put 'detailmenu 'texinfo-end 'texinfo-discard-command)
1150 ;; (Also see `texnfo-upd.el')
1153 ;;; Cross references
1155 ;; @xref {NODE, FNAME, NAME, FILE, DOCUMENT}
1156 ;; -> *Note FNAME: (FILE)NODE
1157 ;; If FILE is missing,
1158 ;; *Note FNAME: NODE
1159 ;; If FNAME is empty and NAME is present
1161 ;; If both NAME and FNAME are missing
1163 ;; texinfo ignores the DOCUMENT argument.
1164 ;; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1165 ;; If FILE is specified, (FILE)NODE is used for xrefs.
1166 ;; If fifth argument DOCUMENT is specified, produces
1167 ;; See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1170 ;; @ref a reference that does not put `See' or `see' in
1171 ;; the hardcopy and is the same as @xref in Info
1172 (put 'ref 'texinfo-format 'texinfo-format-xref)
1174 (put 'xref 'texinfo-format 'texinfo-format-xref)
1175 (defun texinfo-format-xref ()
1176 (let ((args (texinfo-format-parse-args)))
1177 (texinfo-discard-command)
1179 (let ((fname (or (nth 1 args) (nth 2 args))))
1180 (if (null (or fname (nth 3 args)))
1181 (insert (car args) "::")
1182 (insert (or fname (car args)) ": ")
1184 (insert "(" (nth 3 args) ")"))
1185 (insert (car args))))))
1187 (put 'pxref 'texinfo-format 'texinfo-format-pxref)
1188 (defun texinfo-format-pxref ()
1189 (texinfo-format-xref)
1195 ;; @inforef{NODE, FNAME, FILE}
1196 ;; Like @xref{NODE, FNAME,,FILE} in texinfo.
1197 ;; In Tex, generates "See Info file FILE, node NODE"
1198 (put 'inforef 'texinfo-format 'texinfo-format-inforef)
1199 (defun texinfo-format-inforef ()
1200 (let ((args (texinfo-format-parse-args)))
1201 (texinfo-discard-command)
1203 (insert "*Note " (nth 1 args) ": (" (nth 2 args) ")" (car args))
1204 (insert "*Note " "(" (nth 2 args) ")" (car args) "::"))))
1207 ;;; Section headings
1209 (put 'majorheading 'texinfo-format 'texinfo-format-chapter)
1210 (put 'chapheading 'texinfo-format 'texinfo-format-chapter)
1211 (put 'ichapter 'texinfo-format 'texinfo-format-chapter)
1212 (put 'chapter 'texinfo-format 'texinfo-format-chapter)
1213 (put 'iappendix 'texinfo-format 'texinfo-format-chapter)
1214 (put 'appendix 'texinfo-format 'texinfo-format-chapter)
1215 (put 'iunnumbered 'texinfo-format 'texinfo-format-chapter)
1216 (put 'top 'texinfo-format 'texinfo-format-chapter)
1217 (put 'unnumbered 'texinfo-format 'texinfo-format-chapter)
1218 (put 'centerchap 'texinfo-format 'texinfo-format-chapter)
1219 (defun texinfo-format-chapter ()
1220 (texinfo-format-chapter-1 ?*))
1222 (put 'heading 'texinfo-format 'texinfo-format-section)
1223 (put 'isection 'texinfo-format 'texinfo-format-section)
1224 (put 'section 'texinfo-format 'texinfo-format-section)
1225 (put 'iappendixsection 'texinfo-format 'texinfo-format-section)
1226 (put 'appendixsection 'texinfo-format 'texinfo-format-section)
1227 (put 'iappendixsec 'texinfo-format 'texinfo-format-section)
1228 (put 'appendixsec 'texinfo-format 'texinfo-format-section)
1229 (put 'iunnumberedsec 'texinfo-format 'texinfo-format-section)
1230 (put 'unnumberedsec 'texinfo-format 'texinfo-format-section)
1231 (defun texinfo-format-section ()
1232 (texinfo-format-chapter-1 ?=))
1234 (put 'subheading 'texinfo-format 'texinfo-format-subsection)
1235 (put 'isubsection 'texinfo-format 'texinfo-format-subsection)
1236 (put 'subsection 'texinfo-format 'texinfo-format-subsection)
1237 (put 'iappendixsubsec 'texinfo-format 'texinfo-format-subsection)
1238 (put 'appendixsubsec 'texinfo-format 'texinfo-format-subsection)
1239 (put 'iunnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
1240 (put 'unnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
1241 (defun texinfo-format-subsection ()
1242 (texinfo-format-chapter-1 ?-))
1244 (put 'subsubheading 'texinfo-format 'texinfo-format-subsubsection)
1245 (put 'isubsubsection 'texinfo-format 'texinfo-format-subsubsection)
1246 (put 'subsubsection 'texinfo-format 'texinfo-format-subsubsection)
1247 (put 'iappendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
1248 (put 'appendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
1249 (put 'iunnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
1250 (put 'unnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
1251 (defun texinfo-format-subsubsection ()
1252 (texinfo-format-chapter-1 ?.))
1254 (defun texinfo-format-chapter-1 (belowchar)
1255 (let ((arg (texinfo-parse-arg-discard)))
1256 (message "Formatting: %s ... " arg) ; So we can see where we are.
1257 (insert ?\n arg ?\n "@SectionPAD " belowchar ?\n)
1260 (put 'SectionPAD 'texinfo-format 'texinfo-format-sectionpad)
1261 (defun texinfo-format-sectionpad ()
1262 (let ((str (texinfo-parse-arg-discard)))
1264 (let ((column (current-column)))
1268 (setq column (1- column))))
1272 ;;; Space controlling commands: @. and @:, and the soft hyphen.
1274 (put '\. 'texinfo-format 'texinfo-format-\.)
1275 (defun texinfo-format-\. ()
1276 (texinfo-discard-command)
1279 (put '\: 'texinfo-format 'texinfo-format-\:)
1280 (defun texinfo-format-\: ()
1281 (texinfo-discard-command))
1283 (put '\- 'texinfo-format 'texinfo-format-soft-hyphen)
1284 (defun texinfo-format-soft-hyphen ()
1285 (texinfo-discard-command))
1288 ;;; @center, @sp, and @br
1290 (put 'center 'texinfo-format 'texinfo-format-center)
1291 (defun texinfo-format-center ()
1292 (let ((arg (texinfo-parse-expanded-arg)))
1293 (texinfo-discard-command)
1297 (goto-char (1- (point)))
1298 (let ((indent-tabs-mode nil))
1301 (put 'sp 'texinfo-format 'texinfo-format-sp)
1302 (defun texinfo-format-sp ()
1303 (let* ((arg (texinfo-parse-arg-discard))
1305 (insert-char ?\n num)))
1307 (put 'br 'texinfo-format 'texinfo-format-paragraph-break)
1308 (defun texinfo-format-paragraph-break ()
1309 "Force a paragraph break.
1310 If used within a line, follow `@br' with braces."
1311 (texinfo-optional-braces-discard)
1312 ;; insert one return if at end of line;
1313 ;; else insert two returns, to generate a blank line.
1314 (if (= (following-char) ?\n)
1316 (insert-char ?\n 2)))
1319 ;;; @footnote and @footnotestyle
1321 ;; In Texinfo, footnotes are created with the `@footnote' command.
1322 ;; This command is followed immediately by a left brace, then by the text of
1323 ;; the footnote, and then by a terminating right brace. The
1324 ;; template for a footnote is:
1328 ;; Info has two footnote styles:
1330 ;; * In the End of node style, all the footnotes for a single node
1331 ;; are placed at the end of that node. The footnotes are
1332 ;; separated from the rest of the node by a line of dashes with
1333 ;; the word `Footnotes' within it.
1335 ;; * In the Separate node style, all the footnotes for a single node
1336 ;; are placed in an automatically constructed node of their own.
1338 ;; Footnote style is specified by the @footnotestyle command, either
1339 ;; @footnotestyle separate
1341 ;; @footnotestyle end
1343 ;; The default is separate
1345 (defvar texinfo-footnote-style "separate"
1346 "Footnote style, either separate or end.")
1348 (put 'footnotestyle 'texinfo-format 'texinfo-footnotestyle)
1349 (defun texinfo-footnotestyle ()
1350 "Specify whether footnotes are at end of node or in separate nodes.
1351 Argument is either end or separate."
1352 (setq texinfo-footnote-style (texinfo-parse-arg-discard)))
1354 (defvar texinfo-footnote-number)
1356 (put 'footnote 'texinfo-format 'texinfo-format-footnote)
1357 (defun texinfo-format-footnote ()
1358 "Format a footnote in either end of node or separate node style.
1359 The texinfo-footnote-style variable controls which style is used."
1360 (setq texinfo-footnote-number (1+ texinfo-footnote-number))
1361 (cond ((string= texinfo-footnote-style "end")
1362 (texinfo-format-end-node))
1363 ((string= texinfo-footnote-style "separate")
1364 (texinfo-format-separate-node))))
1366 (defun texinfo-format-separate-node ()
1367 "Format footnote in Separate node style, with notes in own node.
1368 The node is constructed automatically."
1370 (arg (texinfo-parse-line-arg))
1371 (node-name-beginning
1374 "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:")
1379 (progn (goto-char node-name-beginning) ; skip over node command
1380 (skip-chars-forward " \t") ; and over spaces
1384 (save-excursion (end-of-line) (point)) t) ; bound search
1386 (end-of-line) (point))))))
1387 (texinfo-discard-command) ; remove or insert whitespace, as needed
1388 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1390 (insert (format " (%d) (*Note %s-Footnotes::)"
1391 texinfo-footnote-number node-name))
1392 (fill-paragraph nil)
1394 (if (re-search-forward "^@node" nil 'move)
1397 ;; two cases: for the first footnote, we must insert a node header;
1398 ;; for the second and subsequent footnotes, we need only insert
1399 ;; the text of the footnote.
1403 (concat node-name "-Footnotes, Up: ")
1406 (progn ; already at least one footnote
1407 (setq start (point))
1408 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
1409 (fill-region start (point)))
1410 ;; else not yet a footnote
1411 (insert "\n\^_\nFile: " texinfo-format-filename
1412 " Node: " node-name "-Footnotes, Up: " node-name "\n")
1413 (setq start (point))
1414 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
1415 (fill-region start (point))))))
1417 (defun texinfo-format-end-node ()
1418 "Format footnote in the End of node style, with notes at end of node."
1420 (arg (texinfo-parse-line-arg)))
1421 (texinfo-discard-command) ; remove or insert whitespace, as needed
1422 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1424 (insert (format " (%d) " texinfo-footnote-number))
1425 (fill-paragraph nil)
1427 (if (search-forward "\n--------- Footnotes ---------\n" nil t)
1428 (progn ; already have footnote, put new one before end of node
1429 (if (re-search-forward "^@node" nil 'move)
1431 (setq start (point))
1432 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
1433 (fill-region start (point)))
1434 ;; else no prior footnote
1435 (if (re-search-forward "^@node" nil 'move)
1437 (insert "\n--------- Footnotes ---------\n")
1438 (setq start (point))
1439 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))))))
1442 ;;; @itemize, @enumerate, and similar commands
1444 ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.
1445 ;; @enumerate pushes (enumerate 0 STARTPOS).
1446 ;; @item dispatches to the texinfo-item prop of the first elt of the list.
1447 ;; For itemize, this puts in and rescans the COMMANDS.
1448 ;; For enumerate, this increments the number and puts it in.
1449 ;; In either case, it puts a Backspace at the front of the line
1450 ;; which marks it not to be indented later.
1451 ;; All other lines get indented by 5 when the @end is reached.
1453 (defvar texinfo-stack-depth 0
1454 "Count of number of unpopped texinfo-push-stack calls.
1455 Used by @refill indenting command to avoid indenting within lists, etc.")
1457 (defun texinfo-push-stack (check arg)
1458 (setq texinfo-stack-depth (1+ texinfo-stack-depth))
1460 (cons (list check arg texinfo-command-start)
1463 (defun texinfo-pop-stack (check)
1464 (setq texinfo-stack-depth (1- texinfo-stack-depth))
1465 (if (null texinfo-stack)
1466 (error "Unmatched @end %s" check))
1467 (if (not (eq (car (car texinfo-stack)) check))
1468 (error "@end %s matches @%s"
1469 check (car (car texinfo-stack))))
1470 (prog1 (cdr (car texinfo-stack))
1471 (setq texinfo-stack (cdr texinfo-stack))))
1473 (put 'itemize 'texinfo-format 'texinfo-itemize)
1474 (defun texinfo-itemize ()
1477 (progn (skip-chars-forward " \t")
1480 (texinfo-parse-line-arg))))
1481 (texinfo-discard-line-with-args)
1482 (setq fill-column (- fill-column 5)))
1484 (put 'itemize 'texinfo-end 'texinfo-end-itemize)
1485 (defun texinfo-end-itemize ()
1486 (setq fill-column (+ fill-column 5))
1487 (texinfo-discard-command)
1489 (texinfo-pop-stack 'itemize)))
1490 (texinfo-do-itemize (nth 1 stacktop))))
1492 (put 'enumerate 'texinfo-format 'texinfo-enumerate)
1493 (defun texinfo-enumerate ()
1496 (progn (skip-chars-forward " \t")
1499 (read (current-buffer)))))
1500 (if (and (symbolp (car (cdr (car texinfo-stack))))
1501 (> 1 (length (symbol-name (car (cdr (car texinfo-stack)))))))
1503 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." ))
1504 (texinfo-discard-line-with-args)
1505 (setq fill-column (- fill-column 5)))
1507 (put 'enumerate 'texinfo-end 'texinfo-end-enumerate)
1508 (defun texinfo-end-enumerate ()
1509 (setq fill-column (+ fill-column 5))
1510 (texinfo-discard-command)
1512 (texinfo-pop-stack 'enumerate)))
1513 (texinfo-do-itemize (nth 1 stacktop))))
1515 ;; @alphaenumerate never became a standard part of Texinfo
1516 (put 'alphaenumerate 'texinfo-format 'texinfo-alphaenumerate)
1517 (defun texinfo-alphaenumerate ()
1518 (texinfo-push-stack 'alphaenumerate (1- ?a))
1519 (setq fill-column (- fill-column 5))
1520 (texinfo-discard-line))
1522 (put 'alphaenumerate 'texinfo-end 'texinfo-end-alphaenumerate)
1523 (defun texinfo-end-alphaenumerate ()
1524 (setq fill-column (+ fill-column 5))
1525 (texinfo-discard-command)
1527 (texinfo-pop-stack 'alphaenumerate)))
1528 (texinfo-do-itemize (nth 1 stacktop))))
1530 ;; @capsenumerate never became a standard part of Texinfo
1531 (put 'capsenumerate 'texinfo-format 'texinfo-capsenumerate)
1532 (defun texinfo-capsenumerate ()
1533 (texinfo-push-stack 'capsenumerate (1- ?A))
1534 (setq fill-column (- fill-column 5))
1535 (texinfo-discard-line))
1537 (put 'capsenumerate 'texinfo-end 'texinfo-end-capsenumerate)
1538 (defun texinfo-end-capsenumerate ()
1539 (setq fill-column (+ fill-column 5))
1540 (texinfo-discard-command)
1542 (texinfo-pop-stack 'capsenumerate)))
1543 (texinfo-do-itemize (nth 1 stacktop))))
1545 ;; At the @end, indent all the lines within the construct
1546 ;; except those marked with backspace. FROM says where
1547 ;; construct started.
1548 (defun texinfo-do-itemize (from)
1550 (while (progn (forward-line -1)
1552 (if (= (following-char) ?\b)
1557 (if (not (looking-at "[ \t]*$"))
1558 (save-excursion (insert " ")))))))
1560 (put 'item 'texinfo-format 'texinfo-item)
1561 (put 'itemx 'texinfo-format 'texinfo-item)
1562 (defun texinfo-item ()
1563 (funcall (get (car (car texinfo-stack)) 'texinfo-item)))
1565 (put 'itemize 'texinfo-item 'texinfo-itemize-item)
1566 (defun texinfo-itemize-item ()
1567 ;; (texinfo-discard-line) ; Did not handle text on same line as @item.
1568 (delete-region (1+ (point)) (save-excursion (beginning-of-line) (point)))
1569 (if (looking-at "[ \t]*[^ \t\n]+")
1570 ;; Text on same line as @item command.
1571 (insert "\b " (nth 1 (car texinfo-stack)) " \n")
1572 ;; Else text on next line.
1573 (insert "\b " (nth 1 (car texinfo-stack)) " "))
1576 (put 'enumerate 'texinfo-item 'texinfo-enumerate-item)
1577 (defun texinfo-enumerate-item ()
1578 (texinfo-discard-line)
1579 (let (enumerating-symbol)
1580 (cond ((integerp (car (cdr (car texinfo-stack))))
1581 (setq enumerating-symbol (car (cdr (car texinfo-stack))))
1582 (insert ?\b (format "%3d. " enumerating-symbol) ?\n)
1583 (setcar (cdr (car texinfo-stack)) (1+ enumerating-symbol)))
1584 ((symbolp (car (cdr (car texinfo-stack))))
1585 (setq enumerating-symbol
1586 (symbol-name (car (cdr (car texinfo-stack)))))
1587 (if (or (equal ?\[ (string-to-char enumerating-symbol))
1588 (equal ?\{ (string-to-char enumerating-symbol)))
1590 "Too many items in enumerated list; alphabet ends at Z."))
1591 (insert ?\b (format "%3s. " enumerating-symbol) ?\n)
1592 (setcar (cdr (car texinfo-stack))
1596 (string-to-char enumerating-symbol))))))
1599 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." )))
1602 (put 'alphaenumerate 'texinfo-item 'texinfo-alphaenumerate-item)
1603 (defun texinfo-alphaenumerate-item ()
1604 (texinfo-discard-line)
1605 (let ((next (1+ (car (cdr (car texinfo-stack))))))
1607 (error "More than 26 items in @alphaenumerate; get a bigger alphabet."))
1608 (setcar (cdr (car texinfo-stack)) next)
1609 (insert "\b " next ". \n"))
1612 (put 'capsenumerate 'texinfo-item 'texinfo-capsenumerate-item)
1613 (defun texinfo-capsenumerate-item ()
1614 (texinfo-discard-line)
1615 (let ((next (1+ (car (cdr (car texinfo-stack))))))
1617 (error "More than 26 items in @capsenumerate; get a bigger alphabet."))
1618 (setcar (cdr (car texinfo-stack)) next)
1619 (insert "\b " next ". \n"))
1625 ;; The `@table' command produces two-column tables.
1627 (put 'table 'texinfo-format 'texinfo-table)
1628 (defun texinfo-table ()
1631 (progn (skip-chars-forward " \t")
1634 (texinfo-parse-line-arg))))
1635 (texinfo-discard-line-with-args)
1636 (setq fill-column (- fill-column 5)))
1638 (put 'table 'texinfo-item 'texinfo-table-item)
1639 (defun texinfo-table-item ()
1640 (let ((arg (texinfo-parse-arg-discard))
1641 (itemfont (car (cdr (car texinfo-stack)))))
1642 (insert ?\b itemfont ?\{ arg "}\n \n"))
1645 (put 'table 'texinfo-end 'texinfo-end-table)
1646 (defun texinfo-end-table ()
1647 (setq fill-column (+ fill-column 5))
1648 (texinfo-discard-command)
1650 (texinfo-pop-stack 'table)))
1651 (texinfo-do-itemize (nth 1 stacktop))))
1653 ;; @description appears to be an undocumented variant on @table that
1654 ;; does not require an arg. It fails in texinfo.tex 2.58 and is not
1655 ;; part of makeinfo.c The command appears to be a relic of the past.
1656 (put 'description 'texinfo-end 'texinfo-end-table)
1657 (put 'description 'texinfo-format 'texinfo-description)
1658 (defun texinfo-description ()
1659 (texinfo-push-stack 'table "@asis")
1660 (setq fill-column (- fill-column 5))
1661 (texinfo-discard-line))
1664 ;;; @ftable, @vtable
1666 ;; The `@ftable' and `@vtable' commands are like the `@table' command
1667 ;; but they also insert each entry in the first column of the table
1668 ;; into the function or variable index.
1670 ;; Handle the @ftable and @vtable commands:
1672 (put 'ftable 'texinfo-format 'texinfo-ftable)
1673 (put 'vtable 'texinfo-format 'texinfo-vtable)
1675 (defun texinfo-ftable () (texinfo-indextable 'ftable))
1676 (defun texinfo-vtable () (texinfo-indextable 'vtable))
1678 (defun texinfo-indextable (table-type)
1679 (texinfo-push-stack table-type (texinfo-parse-arg-discard))
1680 (setq fill-column (- fill-column 5)))
1682 ;; Handle the @item commands within ftable and vtable:
1684 (put 'ftable 'texinfo-item 'texinfo-ftable-item)
1685 (put 'vtable 'texinfo-item 'texinfo-vtable-item)
1687 (defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex))
1688 (defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex))
1690 (defun texinfo-indextable-item (index-type)
1691 (let ((item (texinfo-parse-arg-discard))
1692 (itemfont (car (cdr (car texinfo-stack))))
1693 (indexvar index-type))
1694 (insert ?\b itemfont ?\{ item "}\n \n")
1697 (list item texinfo-last-node)
1698 (symbol-value indexvar)))
1701 ;; Handle @end ftable, @end vtable
1703 (put 'ftable 'texinfo-end 'texinfo-end-ftable)
1704 (put 'vtable 'texinfo-end 'texinfo-end-vtable)
1706 (defun texinfo-end-ftable () (texinfo-end-indextable 'ftable))
1707 (defun texinfo-end-vtable () (texinfo-end-indextable 'vtable))
1709 (defun texinfo-end-indextable (table-type)
1710 (setq fill-column (+ fill-column 5))
1711 (texinfo-discard-command)
1713 (texinfo-pop-stack table-type)))
1714 (texinfo-do-itemize (nth 1 stacktop))))
1717 ;;; @multitable ... @end multitable
1719 ;; Produce a multi-column table, with as many columns as desired.
1721 ;; A multi-column table has this template:
1723 ;; @multitable {A1} {A2} {A3}
1724 ;; @item A1 @tab A2 @tab A3
1725 ;; @item B1 @tab B2 @tab B3
1726 ;; @item C1 @tab C2 @tab C3
1729 ;; where the width of the text in brackets specifies the width of the
1730 ;; respective column.
1734 ;; @multitable @columnfractions .25 .3 .45
1735 ;; @item A1 @tab A2 @tab A3
1736 ;; @item B1 @tab B2 @tab B3
1739 ;; where the fractions specify the width of each column as a percent
1740 ;; of the current width of the text (i.e., of the fill-column).
1742 ;; Long lines of text are filled within columns.
1744 ;; Using the Emacs Lisp formatter, texinfmt.el,
1745 ;; the whitespace between columns can be increased by setting
1746 ;; `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1747 ;; there is at least one blank space between columns.
1749 ;; The Emacs Lisp formatter, texinfmt.el, ignores the following four
1750 ;; commands that are defined in texinfo.tex for printed output.
1752 ;; @multitableparskip,
1753 ;; @multitableparindent,
1754 ;; @multitablecolmargin,
1755 ;; @multitablelinespace.
1757 ;; How @multitable works.
1758 ;; =====================
1760 ;; `texinfo-multitable' reads the @multitable line and determines from it
1761 ;; how wide each column should be.
1763 ;; Also, it pushes this information, along with an identifying symbol,
1764 ;; onto the `texinfo-stack'. At the @end multitable command, the stack
1765 ;; is checked for its matching @multitable command, and then popped, or
1766 ;; else an error is signaled. Also, this command pushes the location of
1767 ;; the start of the table onto the stack.
1769 ;; `texinfo-end-multitable' checks the `texinfo-stack' that the @end
1770 ;; multitable truly is ending a corresponding beginning, and if it is,
1773 ;; `texinfo-multitable-widths' is called by `texinfo-multitable'.
1774 ;; The function returns a list of the widths of each column in a
1775 ;; multi-column table, based on the information supplied by the arguments
1776 ;; to the @multitable command (by arguments, I mean the text on the rest
1777 ;; of the @multitable line, not the remainder of the multi-column table
1780 ;; `texinfo-multitable-item' formats a row within a multicolumn table.
1781 ;; This command is executed when texinfmt sees @item inside @multitable.
1782 ;; Cells in row are separated by `@tab's. Widths of cells are specified
1783 ;; by the arguments in the @multitable line. Cells are filled. All cells
1784 ;; are made to be the same height by padding their bottoms, as needed,
1787 ;; `texinfo-multitable-extract-row' is called by `texinfo-multitable-item'.
1788 ;; This function returns the text in a multitable row, as a string.
1789 ;; The start of a row is marked by an @item and the end of row is the
1790 ;; beginning of next @item or beginning of the @end multitable line.
1791 ;; Cells within a row are separated by @tab.
1793 ;; Note that @tab, the cell separators, are not treated as independent
1794 ;; Texinfo commands.
1796 (defvar texinfo-extra-inter-column-width 0
1797 "*Number of extra spaces between entries (columns) in @multitable.")
1799 (defvar texinfo-multitable-buffer-name "*multitable-temporary-buffer*")
1800 (defvar texinfo-multitable-rectangle-name "texinfo-multitable-temp-")
1802 ;; These commands are defined in texinfo.tex for printed output.
1803 (put 'multitableparskip 'texinfo-format 'texinfo-discard-line-with-args)
1804 (put 'multitableparindent 'texinfo-format 'texinfo-discard-line-with-args)
1805 (put 'multitablecolmargin 'texinfo-format 'texinfo-discard-line-with-args)
1806 (put 'multitablelinespace 'texinfo-format 'texinfo-discard-line-with-args)
1808 (put 'multitable 'texinfo-format 'texinfo-multitable)
1810 (defun texinfo-multitable ()
1811 "Produce multi-column tables.
1813 A multi-column table has this template:
1815 @multitable {A1} {A2} {A3}
1816 @item A1 @tab A2 @tab A3
1817 @item B1 @tab B2 @tab B3
1818 @item C1 @tab C2 @tab C3
1821 where the width of the text in brackets specifies the width of the
1826 @multitable @columnfractions .25 .3 .45
1827 @item A1 @tab A2 @tab A3
1828 @item B1 @tab B2 @tab B3
1831 where the fractions specify the width of each column as a percent
1832 of the current width of the text (i.e., of the fill-column).
1834 Long lines of text are filled within columns.
1836 Using the Emacs Lisp formatter, texinfmt.el,
1837 the whitespace between columns can be increased by setting
1838 `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1839 there is at least one blank space between columns.
1841 The Emacs Lisp formatter, texinfmt.el, ignores the following four
1842 commands that are defined in texinfo.tex for printed output.
1845 @multitableparindent,
1846 @multitablecolmargin,
1847 @multitablelinespace."
1849 ;; This function pushes information onto the `texinfo-stack'.
1850 ;; A stack element consists of:
1851 ;; - type-of-command, i.e., multitable
1852 ;; - the information about column widths, and
1853 ;; - the position of texinfo-command-start.
1854 ;; e.g., ('multitable (1 2 3 4) 123)
1855 ;; The command line is then deleted.
1858 ;; push width information on stack
1859 (texinfo-multitable-widths))
1860 (texinfo-discard-line-with-args))
1862 (put 'multitable 'texinfo-end 'texinfo-end-multitable)
1863 (defun texinfo-end-multitable ()
1864 "Discard the @end multitable line and pop the stack of multitable."
1865 (texinfo-discard-command)
1866 (texinfo-pop-stack 'multitable))
1868 (defun texinfo-multitable-widths ()
1869 "Return list of widths of each column in a multi-column table."
1870 (let (texinfo-multitable-width-list)
1871 ;; Fractions format:
1872 ;; @multitable @columnfractions .25 .3 .45
1875 ;; @multitable {Column 1 template} {Column 2} {Column 3 example}
1876 ;; Place point before first argument
1877 (skip-chars-forward " \t")
1879 ;; Check for common misspelling
1880 ((looking-at "@columnfraction ")
1881 (error "In @multitable, @columnfractions misspelled"))
1882 ;; Case 1: @columnfractions .25 .3 .45
1883 ((looking-at "@columnfractions")
1886 (setq texinfo-multitable-width-list
1890 (* fill-column (read (get-buffer (current-buffer))))))
1891 texinfo-multitable-width-list))))
1893 ;; Case 2: {Column 1 template} {Column 2} {Column 3 example}
1895 (let ((start-of-templates (point)))
1897 (skip-chars-forward " \t")
1898 (let* ((start-of-template (1+ (point)))
1900 ;; forward-sexp works with braces in Texinfo mode
1901 (progn (forward-sexp 1) (1- (point)))))
1902 (setq texinfo-multitable-width-list
1903 (cons (- end-of-template start-of-template)
1904 texinfo-multitable-width-list))
1905 ;; Remove carriage return from within a template, if any.
1906 ;; This helps those those who want to use more than
1907 ;; one line's worth of words in @multitable line.
1908 (narrow-to-region start-of-template end-of-template)
1909 (goto-char (point-min))
1910 (while (search-forward "
1913 (goto-char (point-max))
1915 (forward-char 1)))))
1920 "You probably need to specify column widths for @multitable correctly.")))
1921 ;; Check whether columns fit on page.
1922 (let ((desired-columns
1924 ;; between column spaces
1925 (length texinfo-multitable-width-list)
1926 ;; additional between column spaces, if any
1927 texinfo-extra-inter-column-width
1928 ;; sum of spaces for each entry
1929 (apply '+ texinfo-multitable-width-list))))
1930 (if (> desired-columns fill-column)
1933 "Multi-column table width, %d chars, is greater than page width, %d chars."
1934 desired-columns fill-column))))
1935 texinfo-multitable-width-list))
1937 ;; @item A1 @tab A2 @tab A3
1938 (defun texinfo-multitable-extract-row ()
1939 "Return multitable row, as a string.
1940 End of row is beginning of next @item or beginning of @end.
1941 Cells within rows are separated by @tab."
1942 (skip-chars-forward " \t")
1943 (let* ((start (point))
1945 (re-search-forward "@item\\|@end")
1946 (match-beginning 0)))
1947 (row (progn (goto-char end)
1948 (skip-chars-backward " ")
1949 ;; remove whitespace at end of argument
1950 (delete-region (point) end)
1951 (buffer-substring start (point)))))
1952 (delete-region texinfo-command-start end)
1955 (put 'multitable 'texinfo-item 'texinfo-multitable-item)
1956 (defun texinfo-multitable-item ()
1957 "Format a row within a multicolumn table.
1958 Cells in row are separated by @tab.
1959 Widths of cells are specified by the arguments in the @multitable line.
1960 All cells are made to be the same height.
1961 This command is executed when texinfmt sees @item inside @multitable."
1962 (let ((original-buffer (current-buffer))
1963 (table-widths (reverse (car (cdr (car texinfo-stack)))))
1964 (existing-fill-column fill-column)
1968 (table-entry-height 0)
1969 ;; unformatted row looks like: A1 @tab A2 @tab A3
1970 ;; extract-row command deletes the source line in the table.
1971 (unformated-row (texinfo-multitable-extract-row)))
1972 ;; Use a temporary buffer
1973 (set-buffer (get-buffer-create texinfo-multitable-buffer-name))
1974 (delete-region (point-min) (point-max))
1975 (insert unformated-row)
1976 (goto-char (point-min))
1977 ;; 1. Check for correct number of @tab in line.
1978 (let ((tab-number 1)) ; one @tab between two columns
1979 (while (search-forward "@tab" nil t)
1980 (setq tab-number (1+ tab-number)))
1981 (if (/= tab-number (length table-widths))
1982 (error "Wrong number of @tab's in a @multitable row.")))
1983 (goto-char (point-min))
1984 ;; 2. Format each cell, and copy to a rectangle
1985 ;; buffer looks like this: A1 @tab A2 @tab A3
1986 ;; Cell #1: format up to @tab
1987 ;; Cell #2: format up to @tab
1988 ;; Cell #3: format up to eob
1990 (setq start (point))
1991 (setq end (save-excursion
1992 (if (search-forward "@tab" nil 'move)
1993 ;; Delete the @tab command, including the @-sign
1996 (progn (forward-word -1) (1- (point)))))
1998 ;; Set fill-column *wider* than needed to produce inter-column space
1999 (setq fill-column (+ 1
2000 texinfo-extra-inter-column-width
2001 (nth table-column table-widths)))
2002 (narrow-to-region start end)
2003 ;; Remove whitespace before and after entry.
2004 (skip-chars-forward " ")
2005 (delete-region (point) (save-excursion (beginning-of-line) (point)))
2006 (goto-char (point-max))
2007 (skip-chars-backward " ")
2008 (delete-region (point) (save-excursion (end-of-line) (point)))
2009 ;; Temorarily set texinfo-stack to nil so texinfo-format-scan
2010 ;; does not see an unterminated @multitable.
2011 (let (texinfo-stack) ; nil
2012 (texinfo-format-scan))
2013 (let (fill-prefix) ; no fill prefix
2014 (fill-region (point-min) (point-max)))
2015 (setq table-entry-height
2016 (max table-entry-height (count-lines (point-min) (point-max))))
2017 ;; 3. Move point to end of bottom line, and pad that line to fill column.
2018 (goto-char (point-min))
2019 (forward-line (1- table-entry-height))
2020 (let* ((beg (point)) ; beginning of line
2021 ;; add one more space for inter-column spacing
2026 (progn (end-of-line) (point)) ; end of existing line
2028 (insert (make-string
2029 (if (> needed-whitespace 0) needed-whitespace 1)
2031 ;; now, put formatted cell into a rectangle
2032 (set (intern (concat texinfo-multitable-rectangle-name
2033 (int-to-string table-column)))
2034 (extract-rectangle (point-min) (point)))
2035 (delete-region (point-min) (point))
2036 (goto-char (point-max))
2037 (setq table-column (1+ table-column))
2039 ;; 4. Add extra lines to rectangles so all are of same height
2040 (let ((total-number-of-columns table-column)
2043 (while (> table-column 0)
2044 (let ((this-rectangle (int-to-string table-column)))
2045 (while (< (length this-rectangle) table-entry-height)
2046 (setq this-rectangle (append this-rectangle '("")))))
2047 (setq table-column (1- table-column)))
2048 ;; 5. Insert formatted rectangles in original buffer
2049 (switch-to-buffer original-buffer)
2050 (open-line table-entry-height)
2051 (while (< column-number total-number-of-columns)
2055 (concat texinfo-multitable-rectangle-name
2056 (int-to-string column-number)))))
2059 (setq column-number (1+ column-number))))
2060 (kill-buffer texinfo-multitable-buffer-name)
2061 (setq fill-column existing-fill-column)))
2064 ;;; @ifinfo, @iftex, @tex, @ifhtml, @html
2066 (put 'ifinfo 'texinfo-format 'texinfo-discard-line)
2067 (put 'ifinfo 'texinfo-end 'texinfo-discard-command)
2069 (put 'iftex 'texinfo-format 'texinfo-format-iftex)
2070 (defun texinfo-format-iftex ()
2071 (delete-region texinfo-command-start
2072 (progn (re-search-forward "@end iftex[ \t]*\n")
2075 (put 'ifhtml 'texinfo-format 'texinfo-format-ifhtml)
2076 (defun texinfo-format-ifhtml ()
2077 (delete-region texinfo-command-start
2078 (progn (re-search-forward "@end ifhtml[ \t]*\n")
2081 (put 'tex 'texinfo-format 'texinfo-format-tex)
2082 (defun texinfo-format-tex ()
2083 (delete-region texinfo-command-start
2084 (progn (re-search-forward "@end tex[ \t]*\n")
2087 (put 'html 'texinfo-format 'texinfo-format-html)
2088 (defun texinfo-format-html ()
2089 (delete-region texinfo-command-start
2090 (progn (re-search-forward "@end html[ \t]*\n")
2096 (put 'titlepage 'texinfo-format 'texinfo-format-titlepage)
2097 (defun texinfo-format-titlepage ()
2098 (delete-region texinfo-command-start
2099 (progn (re-search-forward "@end titlepage[ \t]*\n")
2102 (put 'endtitlepage 'texinfo-format 'texinfo-discard-line)
2104 ;; @titlespec an alternative titling command; ignored by Info
2106 (put 'titlespec 'texinfo-format 'texinfo-format-titlespec)
2107 (defun texinfo-format-titlespec ()
2108 (delete-region texinfo-command-start
2109 (progn (re-search-forward "@end titlespec[ \t]*\n")
2112 (put 'endtitlespec 'texinfo-format 'texinfo-discard-line)
2117 (put 'today 'texinfo-format 'texinfo-format-today)
2119 ;; Produces Day Month Year style of output. eg `1 Jan 1900'
2120 ;; The `@today{}' command requires a pair of braces, like `@dots{}'.
2121 (defun texinfo-format-today ()
2122 (texinfo-parse-arg-discard)
2123 (insert (format-time-string "%e %b %Y")))
2127 ;; Produce `Day Month Year Hour:Min' style of output.
2128 ;; eg `1 Jan 1900 13:52'
2130 (put 'timestamp 'texinfo-format 'texinfo-format-timestamp)
2132 ;; The `@timestamp{}' command requires a pair of braces, like `@dots{}'.
2133 (defun texinfo-format-timestamp ()
2134 "Insert the current local time and date."
2135 (texinfo-parse-arg-discard)
2136 ;; For seconds and time zone, replace format string with "%e %b %Y %T %Z"
2137 (insert (format-time-string "%e %b %Y %R")))
2142 (put 'ignore 'texinfo-format 'texinfo-format-ignore)
2143 (defun texinfo-format-ignore ()
2144 (delete-region texinfo-command-start
2145 (progn (re-search-forward "@end ignore[ \t]*\n")
2148 (put 'endignore 'texinfo-format 'texinfo-discard-line)
2151 ;;; Define the Info enclosure command: @definfoenclose
2153 ;; A `@definfoenclose' command may be used to define a highlighting
2154 ;; command for Info, but not for TeX. A command defined using
2155 ;; `@definfoenclose' marks text by enclosing it in strings that precede
2156 ;; and follow the text.
2158 ;; Presumably, if you define a command with `@definfoenclose` for Info,
2159 ;; you will also define the same command in the TeX definitions file,
2160 ;; `texinfo.tex' in a manner appropriate for typesetting.
2162 ;; Write a `@definfoenclose' command on a line and follow it with three
2163 ;; arguments separated by commas (commas are used as separators in an
2164 ;; `@node' line in the same way). The first argument to
2165 ;; `@definfoenclose' is the @-command name \(without the `@'\); the
2166 ;; second argument is the Info start delimiter string; and the third
2167 ;; argument is the Info end delimiter string. The latter two arguments
2168 ;; enclose the highlighted text in the Info file. A delimiter string
2169 ;; may contain spaces. Neither the start nor end delimiter is
2170 ;; required. However, if you do not provide a start delimiter, you
2171 ;; must follow the command name with two commas in a row; otherwise,
2172 ;; the Info formatting commands will misinterpret the end delimiter
2173 ;; string as a start delimiter string.
2175 ;; If you do a @definfoenclose{} on the name of a pre-defined macro (such
2176 ;; as @emph{}, @strong{}, @tt{}, or @i{}) the enclosure definition will
2177 ;; override the built-in definition.
2179 ;; An enclosure command defined this way takes one argument in braces.
2181 ;; For example, you can write:
2184 ;; @definfoenclose phoo, //, \\
2187 ;; near the beginning of a Texinfo file at the beginning of the lines
2188 ;; to define `@phoo' as an Info formatting command that inserts `//'
2189 ;; before and `\\' after the argument to `@phoo'. You can then write
2190 ;; `@phoo{bar}' wherever you want `//bar\\' highlighted in Info.
2192 ;; Also, for TeX formatting, you could write
2195 ;; @global@let@phoo=@i
2198 ;; to define `@phoo' as a command that causes TeX to typeset
2199 ;; the argument to `@phoo' in italics.
2201 ;; Note that each definition applies to its own formatter: one for TeX,
2202 ;; the other for texinfo-format-buffer or texinfo-format-region.
2204 ;; Here is another example: write
2206 ;; @definfoenclose headword, , :
2208 ;; near the beginning of the file, to define `@headword' as an Info
2209 ;; formatting command that inserts nothing before and a colon after the
2210 ;; argument to `@headword'.
2212 (put 'definfoenclose 'texinfo-format 'texinfo-define-info-enclosure)
2213 (defun texinfo-define-info-enclosure ()
2214 (let* ((args (texinfo-format-parse-line-args))
2215 (command-name (nth 0 args))
2216 (beginning-delimiter (or (nth 1 args) ""))
2217 (end-delimiter (or (nth 2 args) "")))
2218 (texinfo-discard-command)
2219 (setq texinfo-enclosure-list
2225 texinfo-enclosure-list))))
2228 ;;; @var, @code and the like
2230 (put 'var 'texinfo-format 'texinfo-format-var)
2231 ;; @sc a small caps font for TeX; formatted as `var' in Info
2232 (put 'sc 'texinfo-format 'texinfo-format-var)
2233 (defun texinfo-format-var ()
2234 (insert (upcase (texinfo-parse-arg-discard)))
2235 (goto-char texinfo-command-start))
2237 (put 'url 'texinfo-format 'texinfo-format-code)
2238 (put 'cite 'texinfo-format 'texinfo-format-code)
2239 (put 'code 'texinfo-format 'texinfo-format-code)
2240 (put 'file 'texinfo-format 'texinfo-format-code)
2241 (put 'samp 'texinfo-format 'texinfo-format-code)
2242 (defun texinfo-format-code ()
2243 (insert "`" (texinfo-parse-arg-discard) "'")
2244 (goto-char texinfo-command-start))
2246 (put 'emph 'texinfo-format 'texinfo-format-emph)
2247 (put 'strong 'texinfo-format 'texinfo-format-emph)
2248 (defun texinfo-format-emph ()
2249 (insert "*" (texinfo-parse-arg-discard) "*")
2250 (goto-char texinfo-command-start))
2252 (put 'dfn 'texinfo-format 'texinfo-format-defn)
2253 (put 'defn 'texinfo-format 'texinfo-format-defn)
2254 (defun texinfo-format-defn ()
2255 (insert "\"" (texinfo-parse-arg-discard) "\"")
2256 (goto-char texinfo-command-start))
2258 (put 'email 'texinfo-format 'texinfo-format-key)
2259 (put 'key 'texinfo-format 'texinfo-format-key)
2260 ;; I've decided not want to have angle brackets around these -- rms.
2261 (defun texinfo-format-key ()
2262 (insert (texinfo-parse-arg-discard))
2263 (goto-char texinfo-command-start))
2265 (put 'bullet 'texinfo-format 'texinfo-format-bullet)
2266 (defun texinfo-format-bullet ()
2267 "Insert an asterisk.
2268 If used within a line, follow `@bullet' with braces."
2269 (texinfo-optional-braces-discard)
2275 ;; Inside of @example ... @end example and similar environments,
2276 ;; @kbd does nothing; but outside of such environments, it places
2277 ;; single quotation markes around its argument.
2279 (defvar texinfo-format-kbd-regexp
2288 "Regexp specifying environments in which @kbd does not put `...'
2291 (defvar texinfo-format-kbd-end-regexp
2300 "Regexp specifying end of environments in which @kbd does not put `...'
2301 around argument. (See `texinfo-format-kbd-regexp')")
2303 (put 'kbd 'texinfo-format 'texinfo-format-kbd)
2304 (defun texinfo-format-kbd ()
2305 "Place single quote marks around arg, except in @example and similar."
2306 ;; Search forward for @end example closer than an @example.
2307 ;; Can stop search at nearest @node or texinfo-section-types-regexp
2311 (concat "^@node\\|\\(" texinfo-section-types-regexp "\\)")
2313 'move-to-end) ; if necessary, return point at end of buffer
2317 (re-search-forward texinfo-format-kbd-regexp stop 'move-to-end)
2319 (end-example-location
2321 (re-search-forward texinfo-format-kbd-end-regexp stop 'move-to-end)
2323 ;; If inside @example, @end example will be closer than @example
2324 ;; or end of search i.e., end-example-location less than example-location
2325 (if (>= end-example-location example-location)
2326 ;; outside an @example or equivalent
2327 (insert "`" (texinfo-parse-arg-discard) "'")
2328 ;; else, in @example; do not surround with `...'
2329 (insert (texinfo-parse-arg-discard)))
2330 (goto-char texinfo-command-start)))
2333 ;;; @example, @lisp, @quotation, @display, @smalllisp, @smallexample
2335 (put 'display 'texinfo-format 'texinfo-format-example)
2336 (put 'example 'texinfo-format 'texinfo-format-example)
2337 (put 'lisp 'texinfo-format 'texinfo-format-example)
2338 (put 'quotation 'texinfo-format 'texinfo-format-example)
2339 (put 'smallexample 'texinfo-format 'texinfo-format-example)
2340 (put 'smalllisp 'texinfo-format 'texinfo-format-example)
2341 (defun texinfo-format-example ()
2342 (texinfo-push-stack 'example nil)
2343 (setq fill-column (- fill-column 5))
2344 (texinfo-discard-line))
2346 (put 'example 'texinfo-end 'texinfo-end-example)
2347 (put 'display 'texinfo-end 'texinfo-end-example)
2348 (put 'lisp 'texinfo-end 'texinfo-end-example)
2349 (put 'quotation 'texinfo-end 'texinfo-end-example)
2350 (put 'smallexample 'texinfo-end 'texinfo-end-example)
2351 (put 'smalllisp 'texinfo-end 'texinfo-end-example)
2352 (defun texinfo-end-example ()
2353 (setq fill-column (+ fill-column 5))
2354 (texinfo-discard-command)
2356 (texinfo-pop-stack 'example)))
2357 (texinfo-do-itemize (nth 1 stacktop))))
2359 (put 'exdent 'texinfo-format 'texinfo-format-exdent)
2360 (defun texinfo-format-exdent ()
2361 (texinfo-discard-command)
2362 (delete-region (point)
2364 (skip-chars-forward " ")
2367 ;; Cancel out the deletion that texinfo-do-itemize
2368 ;; is going to do at the end of this line.
2374 ;; @direntry and @dircategory
2376 (put 'direntry 'texinfo-format 'texinfo-format-direntry)
2377 (defun texinfo-format-direntry ()
2378 (texinfo-push-stack 'direntry nil)
2379 (texinfo-discard-line)
2380 (insert "START-INFO-DIR-ENTRY\n\n"))
2382 (put 'direntry 'texinfo-end 'texinfo-end-direntry)
2383 (defun texinfo-end-direntry ()
2384 (texinfo-discard-command)
2385 (insert "END-INFO-DIR-ENTRY\n\n")
2386 (texinfo-pop-stack 'direntry))
2388 (put 'dircategory 'texinfo-format 'texinfo-format-dircategory)
2389 (defun texinfo-format-dircategory ()
2390 (let ((str (texinfo-parse-arg-discard)))
2391 (delete-region (point)
2393 (skip-chars-forward " ")
2395 (insert "INFO-DIR-SECTION " str "\n")))
2399 ;; The @cartouche command is a noop in Info; in a printed manual,
2400 ;; it makes a box with rounded corners.
2402 (put 'cartouche 'texinfo-format 'texinfo-discard-line)
2403 (put 'cartouche 'texinfo-end 'texinfo-discard-command)
2406 ;;; @flushleft and @format
2408 ;; The @flushleft command left justifies every line but leaves the
2409 ;; right end ragged. As far as Info is concerned, @flushleft is a
2410 ;; `do-nothing' command
2412 ;; The @format command is similar to @example except that it does not
2413 ;; indent; this means that in Info, @format is similar to @flushleft.
2415 (put 'format 'texinfo-format 'texinfo-format-flushleft)
2416 (put 'flushleft 'texinfo-format 'texinfo-format-flushleft)
2417 (defun texinfo-format-flushleft ()
2418 (texinfo-discard-line))
2420 (put 'format 'texinfo-end 'texinfo-end-flushleft)
2421 (put 'flushleft 'texinfo-end 'texinfo-end-flushleft)
2422 (defun texinfo-end-flushleft ()
2423 (texinfo-discard-command))
2428 ;; The @flushright command right justifies every line but leaves the
2429 ;; left end ragged. Spaces and tabs at the right ends of lines are
2430 ;; removed so that visible text lines up on the right side.
2432 (put 'flushright 'texinfo-format 'texinfo-format-flushright)
2433 (defun texinfo-format-flushright ()
2434 (texinfo-push-stack 'flushright nil)
2435 (texinfo-discard-line))
2437 (put 'flushright 'texinfo-end 'texinfo-end-flushright)
2438 (defun texinfo-end-flushright ()
2439 (texinfo-discard-command)
2442 (texinfo-pop-stack 'flushright)))
2444 (texinfo-do-flushright (nth 1 stacktop))))
2446 (defun texinfo-do-flushright (from)
2448 (while (progn (forward-line -1)
2457 (skip-chars-backward " \t")
2458 (delete-region (point) (progn (end-of-line) (point)))
2463 ;;; @ctrl, @TeX, @copyright, @minus, @dots, @enddots, @pounds
2465 (put 'ctrl 'texinfo-format 'texinfo-format-ctrl)
2466 (defun texinfo-format-ctrl ()
2467 (let ((str (texinfo-parse-arg-discard)))
2468 (insert (logand 31 (aref str 0)))))
2470 (put 'TeX 'texinfo-format 'texinfo-format-TeX)
2471 (defun texinfo-format-TeX ()
2472 (texinfo-parse-arg-discard)
2475 (put 'copyright 'texinfo-format 'texinfo-format-copyright)
2476 (defun texinfo-format-copyright ()
2477 (texinfo-parse-arg-discard)
2480 (put 'minus 'texinfo-format 'texinfo-format-minus)
2481 (defun texinfo-format-minus ()
2482 "Insert a minus sign.
2483 If used within a line, follow `@minus' with braces."
2484 (texinfo-optional-braces-discard)
2487 (put 'dots 'texinfo-format 'texinfo-format-dots)
2488 (defun texinfo-format-dots ()
2489 (texinfo-parse-arg-discard)
2492 (put 'enddots 'texinfo-format 'texinfo-format-enddots)
2493 (defun texinfo-format-enddots ()
2494 (texinfo-parse-arg-discard)
2497 (put 'pounds 'texinfo-format 'texinfo-format-pounds)
2498 (defun texinfo-format-pounds ()
2499 (texinfo-parse-arg-discard)
2503 ;;; Refilling and indenting: @refill, @paragraphindent, @noindent
2505 ;;; Indent only those paragraphs that are refilled as a result of an
2506 ;;; @refill command.
2508 ;; * If the value is `asis', do not change the existing indentation at
2509 ;; the starts of paragraphs.
2511 ;; * If the value zero, delete any existing indentation.
2513 ;; * If the value is greater than zero, indent each paragraph by that
2514 ;; number of spaces.
2516 ;;; But do not refill paragraphs with an @refill command that are
2517 ;;; preceded by @noindent or are part of a table, list, or deffn.
2519 (defvar texinfo-paragraph-indent "asis"
2520 "Number of spaces for @refill to indent a paragraph; else to leave as is.")
2522 (put 'paragraphindent 'texinfo-format 'texinfo-paragraphindent)
2524 (defun texinfo-paragraphindent ()
2525 "Specify the number of spaces for @refill to indent a paragraph.
2526 Default is to leave the number of spaces as is."
2527 (let ((arg (texinfo-parse-arg-discard)))
2528 (if (string= "asis" arg)
2529 (setq texinfo-paragraph-indent "asis")
2530 (setq texinfo-paragraph-indent (string-to-int arg)))))
2532 (put 'refill 'texinfo-format 'texinfo-format-refill)
2533 (defun texinfo-format-refill ()
2534 "Refill paragraph. Also, indent first line as set by @paragraphindent.
2535 Default is to leave paragraph indentation as is."
2536 (texinfo-discard-command)
2537 (forward-paragraph -1)
2538 (if (looking-at "[ \t\n]*$") (forward-line 1))
2539 ;; Do not indent if an entry in a list, table, or deffn,
2540 ;; or if paragraph is preceded by @noindent.
2541 ;; Otherwise, indent
2543 ;; delete a @noindent line and do not indent paragraph
2544 ((save-excursion (forward-line -1)
2545 (looking-at "^@noindent"))
2547 (delete-region (point) (progn (forward-line 1) (point))))
2548 ;; do nothing if "asis"
2549 ((equal texinfo-paragraph-indent "asis"))
2550 ;; do no indenting in list, etc.
2551 ((> texinfo-stack-depth 0))
2552 ;; otherwise delete existing whitespace and indent
2554 (delete-region (point) (progn (skip-chars-forward " \t") (point)))
2555 (insert (make-string texinfo-paragraph-indent ? ))))
2556 (forward-paragraph 1)
2559 ;; Do not fill a section title line with asterisks, hyphens, etc. that
2560 ;; are used to underline it. This could occur if the line following
2561 ;; the underlining is not an index entry and has text within it.
2562 (let* ((previous-paragraph-separate paragraph-separate)
2564 (concat paragraph-separate "\\|[-=.]+\\|\\*\\*+"))
2565 (previous-paragraph-start paragraph-start)
2567 (concat paragraph-start "\\|[-=.]+\\|\\*\\*+")))
2569 (fill-paragraph nil)
2570 (setq paragraph-separate previous-paragraph-separate)
2571 (setq paragraph-start previous-paragraph-start))))
2573 (put 'noindent 'texinfo-format 'texinfo-noindent)
2574 (defun texinfo-noindent ()
2576 (forward-paragraph 1)
2577 (if (search-backward "@refill"
2578 (save-excursion (forward-line -1) (point)) t)
2579 () ; leave @noindent command so @refill command knows not to indent
2581 (texinfo-discard-line))))
2584 ;;; Index generation
2586 (put 'vindex 'texinfo-format 'texinfo-format-vindex)
2587 (defun texinfo-format-vindex ()
2588 (texinfo-index 'texinfo-vindex))
2590 (put 'cindex 'texinfo-format 'texinfo-format-cindex)
2591 (defun texinfo-format-cindex ()
2592 (texinfo-index 'texinfo-cindex))
2594 (put 'findex 'texinfo-format 'texinfo-format-findex)
2595 (defun texinfo-format-findex ()
2596 (texinfo-index 'texinfo-findex))
2598 (put 'pindex 'texinfo-format 'texinfo-format-pindex)
2599 (defun texinfo-format-pindex ()
2600 (texinfo-index 'texinfo-pindex))
2602 (put 'tindex 'texinfo-format 'texinfo-format-tindex)
2603 (defun texinfo-format-tindex ()
2604 (texinfo-index 'texinfo-tindex))
2606 (put 'kindex 'texinfo-format 'texinfo-format-kindex)
2607 (defun texinfo-format-kindex ()
2608 (texinfo-index 'texinfo-kindex))
2610 (defun texinfo-index (indexvar)
2611 (let ((arg (texinfo-parse-expanded-arg)))
2612 (texinfo-discard-command)
2616 ;; Region formatting may not provide last node position.
2617 (if texinfo-last-node-pos
2618 (1+ (count-lines texinfo-last-node-pos (point)))
2620 (symbol-value indexvar)))))
2622 (defconst texinfo-indexvar-alist
2623 '(("cp" . texinfo-cindex)
2624 ("fn" . texinfo-findex)
2625 ("vr" . texinfo-vindex)
2626 ("tp" . texinfo-tindex)
2627 ("pg" . texinfo-pindex)
2628 ("ky" . texinfo-kindex)))
2631 ;;; @defindex @defcodeindex
2632 (put 'defindex 'texinfo-format 'texinfo-format-defindex)
2633 (put 'defcodeindex 'texinfo-format 'texinfo-format-defindex)
2635 (defun texinfo-format-defindex ()
2636 (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa'
2637 (indexing-command (intern (concat index-name "index")))
2638 (index-formatting-command ; eg: `texinfo-format-aaindex'
2639 (intern (concat "texinfo-format-" index-name "index")))
2640 (index-alist-name ; eg: `texinfo-aaindex'
2641 (intern (concat "texinfo-" index-name "index"))))
2643 (set index-alist-name nil)
2645 (put indexing-command ; eg, aaindex
2647 index-formatting-command) ; eg, texinfo-format-aaindex
2649 ;; eg: "aa" . texinfo-aaindex
2650 (or (assoc index-name texinfo-indexvar-alist)
2651 (setq texinfo-indexvar-alist
2655 texinfo-indexvar-alist)))
2657 (fset index-formatting-command
2659 (list 'texinfo-index
2660 (list 'quote index-alist-name))))))
2663 ;;; @synindex @syncodeindex
2665 (put 'synindex 'texinfo-format 'texinfo-format-synindex)
2666 (put 'syncodeindex 'texinfo-format 'texinfo-format-synindex)
2668 (defun texinfo-format-synindex ()
2669 (let* ((args (texinfo-parse-arg-discard))
2670 (second (cdr (read-from-string args)))
2671 (joiner (symbol-name (car (read-from-string args))))
2672 (joined (symbol-name (car (read-from-string args second)))))
2674 (if (assoc joiner texinfo-short-index-cmds-alist)
2676 (cdr (assoc joiner texinfo-short-index-cmds-alist))
2678 (or (cdr (assoc joined texinfo-short-index-format-cmds-alist))
2679 (intern (concat "texinfo-format-" joined "index"))))
2681 (intern (concat joiner "index"))
2683 (or (cdr(assoc joined texinfo-short-index-format-cmds-alist))
2684 (intern (concat "texinfo-format-" joined "index")))))))
2686 (defconst texinfo-short-index-cmds-alist
2694 (defconst texinfo-short-index-format-cmds-alist
2695 '(("cp" . texinfo-format-cindex)
2696 ("fn" . texinfo-format-findex)
2697 ("vr" . texinfo-format-vindex)
2698 ("tp" . texinfo-format-tindex)
2699 ("pg" . texinfo-format-pindex)
2700 ("ky" . texinfo-format-kindex)))
2703 ;;; Sort and index (for VMS)
2705 ;; Sort an index which is in the current buffer between START and END.
2706 ;; Used on VMS, where the `sort' utility is not available.
2707 (defun texinfo-sort-region (start end)
2710 (narrow-to-region start end)
2711 (sort-subr nil 'forward-line 'end-of-line 'texinfo-sort-startkeyfun)))
2713 ;; Subroutine for sorting an index.
2714 ;; At start of a line, return a string to sort the line under.
2715 (defun texinfo-sort-startkeyfun ()
2717 (buffer-substring (point) (save-excursion (end-of-line) (point)))))
2718 ;; Canonicalize whitespace and eliminate funny chars.
2719 (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line)
2720 (setq line (concat (substring line 0 (match-beginning 0))
2722 (substring line (match-end 0) (length line)))))
2728 (put 'printindex 'texinfo-format 'texinfo-format-printindex)
2730 (defun texinfo-format-printindex ()
2731 (let ((indexelts (symbol-value
2732 (cdr (assoc (texinfo-parse-arg-discard)
2733 texinfo-indexvar-alist))))
2735 (insert "\n* Menu:\n\n")
2736 (setq opoint (point))
2737 (texinfo-print-index nil indexelts)
2739 (if (memq system-type '(vax-vms windows-nt ms-dos))
2740 (texinfo-sort-region opoint (point))
2741 (shell-command-on-region opoint (point) "sort -fd" 1))))
2743 (defun texinfo-print-index (file indexelts)
2745 (if (stringp (car (car indexelts)))
2747 (insert "* " (car (car indexelts)) ": " )
2750 (if file (concat "(" file ")") "")
2751 (nth 1 (car indexelts)) ".")
2754 (if (nth 2 (car indexelts))
2755 (format " %d." (nth 2 (car indexelts)))
2758 ;; index entries from @include'd file
2759 (texinfo-print-index (nth 1 (car indexelts))
2760 (nth 2 (car indexelts))))
2761 (setq indexelts (cdr indexelts))))
2764 ;;; Glyphs: @equiv, @error, etc
2766 ;; @equiv to show that two expressions are equivalent
2767 ;; @error to show an error message
2768 ;; @expansion to show what a macro expands to
2769 ;; @point to show the location of point in an example
2770 ;; @print to show what an evaluated expression prints
2771 ;; @result to indicate the value returned by an expression
2773 (put 'equiv 'texinfo-format 'texinfo-format-equiv)
2774 (defun texinfo-format-equiv ()
2775 (texinfo-parse-arg-discard)
2778 (put 'error 'texinfo-format 'texinfo-format-error)
2779 (defun texinfo-format-error ()
2780 (texinfo-parse-arg-discard)
2781 (insert "error-->"))
2783 (put 'expansion 'texinfo-format 'texinfo-format-expansion)
2784 (defun texinfo-format-expansion ()
2785 (texinfo-parse-arg-discard)
2788 (put 'point 'texinfo-format 'texinfo-format-point)
2789 (defun texinfo-format-point ()
2790 (texinfo-parse-arg-discard)
2793 (put 'print 'texinfo-format 'texinfo-format-print)
2794 (defun texinfo-format-print ()
2795 (texinfo-parse-arg-discard)
2798 (put 'result 'texinfo-format 'texinfo-format-result)
2799 (defun texinfo-format-result ()
2800 (texinfo-parse-arg-discard)
2806 ;; Info presumes a plain ASCII output, so the accented characters do
2807 ;; not look as they would if typeset, or output with a different
2810 ;; See the `texinfo-accent-commands' variable
2811 ;; in the section for `texinfo-append-refill'.
2812 ;; Also, see the defun for `texinfo-format-scan'
2813 ;; for single-character accent commands.
2815 ;; Command Info output Name
2817 ;; These do not have braces:
2818 ;; @^ ==> ^ circumflex accent
2819 ;; @` ==> ` grave accent
2820 ;; @' ==> ' acute accent
2821 ;; @" ==> " umlaut accent
2822 ;; @= ==> = overbar accent
2823 ;; @~ ==> ~ tilde accent
2825 ;; These have braces, but take no argument:
2826 ;; @OE{} ==> OE French-OE-ligature
2828 ;; @AA{} ==> AA Scandinavian-A-with-circle
2830 ;; @AE{} ==> AE Latin-Scandinavian-AE
2832 ;; @ss{} ==> ss German-sharp-S
2834 ;; @questiondown{} ==> ? upside-down-question-mark
2835 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
2836 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
2837 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
2838 ;; @O{} ==> O/ Scandinavian O-with-slash
2839 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
2841 ;; These have braces, and take an argument:
2842 ;; @,{c} ==> c, cedilla accent
2843 ;; @dotaccent{o} ==> .o overdot-accent
2844 ;; @ubaraccent{o} ==> _o underbar-accent
2845 ;; @udotaccent{o} ==> o-. underdot-accent
2846 ;; @H{o} ==> ""o long Hungarian umlaut
2847 ;; @ringaccent{o} ==> *o ring accent
2848 ;; @tieaccent{oo} ==> [oo tie after accent
2849 ;; @u{o} ==> (o breve accent
2850 ;; @v{o} ==> <o hacek accent
2851 ;; @dotless{i} ==> i dotless i and dotless j
2855 ;; Note: The defun texinfo-format-scan
2856 ;; looks at "[@{}^'`\",=~ *?!-]"
2857 ;; In the case of @*, a line break is inserted;
2858 ;; in the other cases, the characters are simply quoted and the @ is deleted.
2859 ;; Thus, `texinfo-format-scan' handles the following
2860 ;; single-character accent commands: @^ @` @' @" @, @- @= @~
2862 ;; @^ ==> ^ circumflex accent
2863 ;; (put '^ 'texinfo-format 'texinfo-format-circumflex-accent)
2864 ;; (defun texinfo-format-circumflex-accent ()
2865 ;; (texinfo-discard-command)
2868 ;; @` ==> ` grave accent
2869 ;; (put '\` 'texinfo-format 'texinfo-format-grave-accent)
2870 ;; (defun texinfo-format-grave-accent ()
2871 ;; (texinfo-discard-command)
2874 ;; @' ==> ' acute accent
2875 ;; (put '\' 'texinfo-format 'texinfo-format-acute-accent)
2876 ;; (defun texinfo-format-acute-accent ()
2877 ;; (texinfo-discard-command)
2880 ;; @" ==> " umlaut accent
2881 ;; (put '\" 'texinfo-format 'texinfo-format-umlaut-accent)
2882 ;; (defun texinfo-format-umlaut-accent ()
2883 ;; (texinfo-discard-command)
2886 ;; @= ==> = overbar accent
2887 ;; (put '= 'texinfo-format 'texinfo-format-overbar-accent)
2888 ;; (defun texinfo-format-overbar-accent ()
2889 ;; (texinfo-discard-command)
2892 ;; @~ ==> ~ tilde accent
2893 ;; (put '~ 'texinfo-format 'texinfo-format-tilde-accent)
2894 ;; (defun texinfo-format-tilde-accent ()
2895 ;; (texinfo-discard-command)
2898 ;; @OE{} ==> OE French-OE-ligature
2899 (put 'OE 'texinfo-format 'texinfo-format-French-OE-ligature)
2900 (defun texinfo-format-French-OE-ligature ()
2901 (insert "OE" (texinfo-parse-arg-discard))
2902 (goto-char texinfo-command-start))
2905 (put 'oe 'texinfo-format 'texinfo-format-French-oe-ligature)
2906 (defun texinfo-format-French-oe-ligature () ; lower case
2907 (insert "oe" (texinfo-parse-arg-discard))
2908 (goto-char texinfo-command-start))
2910 ;; @AA{} ==> AA Scandinavian-A-with-circle
2911 (put 'AA 'texinfo-format 'texinfo-format-Scandinavian-A-with-circle)
2912 (defun texinfo-format-Scandinavian-A-with-circle ()
2913 (insert "AA" (texinfo-parse-arg-discard))
2914 (goto-char texinfo-command-start))
2917 (put 'aa 'texinfo-format 'texinfo-format-Scandinavian-a-with-circle)
2918 (defun texinfo-format-Scandinavian-a-with-circle () ; lower case
2919 (insert "aa" (texinfo-parse-arg-discard))
2920 (goto-char texinfo-command-start))
2922 ;; @AE{} ==> AE Latin-Scandinavian-AE
2923 (put 'AE 'texinfo-format 'texinfo-format-Latin-Scandinavian-AE)
2924 (defun texinfo-format-Latin-Scandinavian-AE ()
2925 (insert "AE" (texinfo-parse-arg-discard))
2926 (goto-char texinfo-command-start))
2929 (put 'ae 'texinfo-format 'texinfo-format-Latin-Scandinavian-ae)
2930 (defun texinfo-format-Latin-Scandinavian-ae () ; lower case
2931 (insert "ae" (texinfo-parse-arg-discard))
2932 (goto-char texinfo-command-start))
2934 ;; @ss{} ==> ss German-sharp-S
2935 (put 'ss 'texinfo-format 'texinfo-format-German-sharp-S)
2936 (defun texinfo-format-German-sharp-S ()
2937 (insert "ss" (texinfo-parse-arg-discard))
2938 (goto-char texinfo-command-start))
2940 ;; @questiondown{} ==> ? upside-down-question-mark
2941 (put 'questiondown 'texinfo-format 'texinfo-format-upside-down-question-mark)
2942 (defun texinfo-format-upside-down-question-mark ()
2943 (insert "?" (texinfo-parse-arg-discard))
2944 (goto-char texinfo-command-start))
2946 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
2947 (put 'exclamdown 'texinfo-format 'texinfo-format-upside-down-exclamation-mark)
2948 (defun texinfo-format-upside-down-exclamation-mark ()
2949 (insert "!" (texinfo-parse-arg-discard))
2950 (goto-char texinfo-command-start))
2952 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
2953 (put 'L 'texinfo-format 'texinfo-format-Polish-suppressed-L)
2954 (defun texinfo-format-Polish-suppressed-L ()
2955 (insert (texinfo-parse-arg-discard) "/L")
2956 (goto-char texinfo-command-start))
2958 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
2959 (put 'l 'texinfo-format 'texinfo-format-Polish-suppressed-l-lower-case)
2960 (defun texinfo-format-Polish-suppressed-l-lower-case ()
2961 (insert (texinfo-parse-arg-discard) "/l")
2962 (goto-char texinfo-command-start))
2965 ;; @O{} ==> O/ Scandinavian O-with-slash
2966 (put 'O 'texinfo-format 'texinfo-format-Scandinavian-O-with-slash)
2967 (defun texinfo-format-Scandinavian-O-with-slash ()
2968 (insert (texinfo-parse-arg-discard) "O/")
2969 (goto-char texinfo-command-start))
2971 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
2972 (put 'o 'texinfo-format 'texinfo-format-Scandinavian-o-with-slash-lower-case)
2973 (defun texinfo-format-Scandinavian-o-with-slash-lower-case ()
2974 (insert (texinfo-parse-arg-discard) "o/")
2975 (goto-char texinfo-command-start))
2979 ;; @,{c} ==> c, cedilla accent
2980 (put ', 'texinfo-format 'texinfo-format-cedilla-accent)
2981 (defun texinfo-format-cedilla-accent ()
2982 (insert (texinfo-parse-arg-discard) ",")
2983 (goto-char texinfo-command-start))
2986 ;; @dotaccent{o} ==> .o overdot-accent
2987 (put 'dotaccent 'texinfo-format 'texinfo-format-overdot-accent)
2988 (defun texinfo-format-overdot-accent ()
2989 (insert "." (texinfo-parse-arg-discard))
2990 (goto-char texinfo-command-start))
2992 ;; @ubaraccent{o} ==> _o underbar-accent
2993 (put 'ubaraccent 'texinfo-format 'texinfo-format-underbar-accent)
2994 (defun texinfo-format-underbar-accent ()
2995 (insert "_" (texinfo-parse-arg-discard))
2996 (goto-char texinfo-command-start))
2998 ;; @udotaccent{o} ==> o-. underdot-accent
2999 (put 'udotaccent 'texinfo-format 'texinfo-format-underdot-accent)
3000 (defun texinfo-format-underdot-accent ()
3001 (insert (texinfo-parse-arg-discard) "-.")
3002 (goto-char texinfo-command-start))
3004 ;; @H{o} ==> ""o long Hungarian umlaut
3005 (put 'H 'texinfo-format 'texinfo-format-long-Hungarian-umlaut)
3006 (defun texinfo-format-long-Hungarian-umlaut ()
3007 (insert "\"\"" (texinfo-parse-arg-discard))
3008 (goto-char texinfo-command-start))
3010 ;; @ringaccent{o} ==> *o ring accent
3011 (put 'ringaccent 'texinfo-format 'texinfo-format-ring-accent)
3012 (defun texinfo-format-ring-accent ()
3013 (insert "*" (texinfo-parse-arg-discard))
3014 (goto-char texinfo-command-start))
3016 ;; @tieaccent{oo} ==> [oo tie after accent
3017 (put 'tieaccent 'texinfo-format 'texinfo-format-tie-after-accent)
3018 (defun texinfo-format-tie-after-accent ()
3019 (insert "[" (texinfo-parse-arg-discard))
3020 (goto-char texinfo-command-start))
3023 ;; @u{o} ==> (o breve accent
3024 (put 'u 'texinfo-format 'texinfo-format-breve-accent)
3025 (defun texinfo-format-breve-accent ()
3026 (insert "(" (texinfo-parse-arg-discard))
3027 (goto-char texinfo-command-start))
3029 ;; @v{o} ==> <o hacek accent
3030 (put 'v 'texinfo-format 'texinfo-format-hacek-accent)
3031 (defun texinfo-format-hacek-accent ()
3032 (insert "<" (texinfo-parse-arg-discard))
3033 (goto-char texinfo-command-start))
3036 ;; @dotless{i} ==> i dotless i and dotless j
3037 (put 'dotless 'texinfo-format 'texinfo-format-dotless)
3038 (defun texinfo-format-dotless ()
3039 (insert (texinfo-parse-arg-discard))
3040 (goto-char texinfo-command-start))
3043 ;;; Definition formatting: @deffn, @defun, etc
3045 ;; What definition formatting produces:
3047 ;; @deffn category name args...
3048 ;; In Info, `Category: name ARGS'
3049 ;; In index: name: node. line#.
3051 ;; @defvr category name
3052 ;; In Info, `Category: name'
3053 ;; In index: name: node. line#.
3055 ;; @deftp category name attributes...
3056 ;; `category name attributes...' Note: @deftp args in lower case.
3057 ;; In index: name: node. line#.
3059 ;; Specialized function-like or variable-like entity:
3061 ;; @defun, @defmac, @defspec, @defvar, @defopt
3063 ;; @defun name args In Info, `Function: name ARGS'
3064 ;; @defmac name args In Info, `Macro: name ARGS'
3065 ;; @defvar name In Info, `Variable: name'
3067 ;; In index: name: node. line#.
3069 ;; Generalized typed-function-like or typed-variable-like entity:
3070 ;; @deftypefn category data-type name args...
3071 ;; In Info, `Category: data-type name args...'
3072 ;; @deftypevr category data-type name
3073 ;; In Info, `Category: data-type name'
3074 ;; In index: name: node. line#.
3076 ;; Specialized typed-function-like or typed-variable-like entity:
3077 ;; @deftypefun data-type name args...
3078 ;; In Info, `Function: data-type name ARGS'
3079 ;; In index: name: node. line#.
3081 ;; @deftypevar data-type name
3082 ;; In Info, `Variable: data-type name'
3083 ;; In index: name: node. line#. but include args after name!?
3085 ;; Generalized object oriented entity:
3086 ;; @defop category class name args...
3087 ;; In Info, `Category on class: name ARG'
3088 ;; In index: name on class: node. line#.
3090 ;; @defcv category class name
3091 ;; In Info, `Category of class: name'
3092 ;; In index: name of class: node. line#.
3094 ;; Specialized object oriented entity:
3095 ;; @defmethod class name args...
3096 ;; In Info, `Method on class: name ARGS'
3097 ;; In index: name on class: node. line#.
3099 ;; @defivar class name
3100 ;; In Info, `Instance variable of class: name'
3101 ;; In index: name of class: node. line#.
3104 ;;; The definition formatting functions
3106 (defun texinfo-format-defun ()
3107 (texinfo-push-stack 'defun nil)
3108 (setq fill-column (- fill-column 5))
3109 (texinfo-format-defun-1 t))
3111 (defun texinfo-end-defun ()
3112 (setq fill-column (+ fill-column 5))
3113 (texinfo-discard-command)
3114 (let ((start (nth 1 (texinfo-pop-stack 'defun))))
3115 (texinfo-do-itemize start)
3116 ;; Delete extra newline inserted after header.
3121 (defun texinfo-format-defunx ()
3122 (texinfo-format-defun-1 nil))
3124 (defun texinfo-format-defun-1 (first-p)
3125 (let ((parse-args (texinfo-format-parse-defun-args))
3126 (texinfo-defun-type (get texinfo-command-name 'texinfo-defun-type)))
3127 (texinfo-discard-command)
3128 ;; Delete extra newline inserted after previous header line.
3132 (get texinfo-command-name 'texinfo-deffn-formatting-property) parse-args)
3133 ;; Insert extra newline so that paragraph filling does not mess
3134 ;; with header line.
3136 (rplaca (cdr (cdr (car texinfo-stack))) (point))
3138 (get texinfo-command-name 'texinfo-defun-indexing-property) parse-args)))
3140 ;;; Formatting the first line of a definition
3142 ;; @deffn, @defvr, @deftp
3143 (put 'deffn 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3144 (put 'deffnx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3145 (put 'defvr 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3146 (put 'defvrx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3147 (put 'deftp 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3148 (put 'deftpx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3149 (defun texinfo-format-deffn (parsed-args)
3150 ;; Generalized function-like, variable-like, or generic data-type entity:
3151 ;; @deffn category name args...
3152 ;; In Info, `Category: name ARGS'
3153 ;; @deftp category name attributes...
3154 ;; `category name attributes...' Note: @deftp args in lower case.
3155 (let ((category (car parsed-args))
3156 (name (car (cdr parsed-args)))
3157 (args (cdr (cdr parsed-args))))
3158 (insert " -- " category ": " name)
3161 (if (or (= ?& (aref (car args) 0))
3162 (eq (eval (car texinfo-defun-type)) 'deftp-type))
3164 (upcase (car args))))
3165 (setq args (cdr args)))))
3167 ;; @defun, @defmac, @defspec, @defvar, @defopt: Specialized, simple
3168 (put 'defun 'texinfo-deffn-formatting-property
3169 'texinfo-format-specialized-defun)
3170 (put 'defunx 'texinfo-deffn-formatting-property
3171 'texinfo-format-specialized-defun)
3172 (put 'defmac 'texinfo-deffn-formatting-property
3173 'texinfo-format-specialized-defun)
3174 (put 'defmacx 'texinfo-deffn-formatting-property
3175 'texinfo-format-specialized-defun)
3176 (put 'defspec 'texinfo-deffn-formatting-property
3177 'texinfo-format-specialized-defun)
3178 (put 'defspecx 'texinfo-deffn-formatting-property
3179 'texinfo-format-specialized-defun)
3180 (put 'defvar 'texinfo-deffn-formatting-property
3181 'texinfo-format-specialized-defun)
3182 (put 'defvarx 'texinfo-deffn-formatting-property
3183 'texinfo-format-specialized-defun)
3184 (put 'defopt 'texinfo-deffn-formatting-property
3185 'texinfo-format-specialized-defun)
3186 (put 'defoptx 'texinfo-deffn-formatting-property
3187 'texinfo-format-specialized-defun)
3188 (defun texinfo-format-specialized-defun (parsed-args)
3189 ;; Specialized function-like or variable-like entity:
3190 ;; @defun name args In Info, `Function: Name ARGS'
3191 ;; @defmac name args In Info, `Macro: Name ARGS'
3192 ;; @defvar name In Info, `Variable: Name'
3193 ;; Use cdr of texinfo-defun-type to determine category:
3194 (let ((category (car (cdr texinfo-defun-type)))
3195 (name (car parsed-args))
3196 (args (cdr parsed-args)))
3197 (insert " -- " category ": " name)
3200 (if (= ?& (aref (car args) 0))
3202 (upcase (car args))))
3203 (setq args (cdr args)))))
3205 ;; @deftypefn, @deftypevr: Generalized typed
3206 (put 'deftypefn 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
3207 (put 'deftypefnx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
3208 (put 'deftypevr 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
3209 (put 'deftypevrx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
3210 (defun texinfo-format-deftypefn (parsed-args)
3211 ;; Generalized typed-function-like or typed-variable-like entity:
3212 ;; @deftypefn category data-type name args...
3213 ;; In Info, `Category: data-type name args...'
3214 ;; @deftypevr category data-type name
3215 ;; In Info, `Category: data-type name'
3216 ;; Note: args in lower case, unless modified in command line.
3217 (let ((category (car parsed-args))
3218 (data-type (car (cdr parsed-args)))
3219 (name (car (cdr (cdr parsed-args))))
3220 (args (cdr (cdr (cdr parsed-args)))))
3221 (insert " -- " category ": " data-type " " name)
3223 (insert " " (car args))
3224 (setq args (cdr args)))))
3226 ;; @deftypefun, @deftypevar: Specialized typed
3227 (put 'deftypefun 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun)
3228 (put 'deftypefunx 'texinfo-deffn-formatting-property
3229 'texinfo-format-deftypefun)
3230 (put 'deftypevar 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun)
3231 (put 'deftypevarx 'texinfo-deffn-formatting-property
3232 'texinfo-format-deftypefun)
3233 (defun texinfo-format-deftypefun (parsed-args)
3234 ;; Specialized typed-function-like or typed-variable-like entity:
3235 ;; @deftypefun data-type name args...
3236 ;; In Info, `Function: data-type name ARGS'
3237 ;; @deftypevar data-type name
3238 ;; In Info, `Variable: data-type name'
3239 ;; Note: args in lower case, unless modified in command line.
3240 ;; Use cdr of texinfo-defun-type to determine category:
3241 (let ((category (car (cdr texinfo-defun-type)))
3242 (data-type (car parsed-args))
3243 (name (car (cdr parsed-args)))
3244 (args (cdr (cdr parsed-args))))
3245 (insert " -- " category ": " data-type " " name)
3247 (insert " " (car args))
3248 (setq args (cdr args)))))
3250 ;; @defop: Generalized object-oriented
3251 (put 'defop 'texinfo-deffn-formatting-property 'texinfo-format-defop)
3252 (put 'defopx 'texinfo-deffn-formatting-property 'texinfo-format-defop)
3253 (defun texinfo-format-defop (parsed-args)
3254 ;; Generalized object oriented entity:
3255 ;; @defop category class name args...
3256 ;; In Info, `Category on class: name ARG'
3257 ;; Note: args in upper case; use of `on'
3258 (let ((category (car parsed-args))
3259 (class (car (cdr parsed-args)))
3260 (name (car (cdr (cdr parsed-args))))
3261 (args (cdr (cdr (cdr parsed-args)))))
3262 (insert " -- " category " on " class ": " name)
3264 (insert " " (upcase (car args)))
3265 (setq args (cdr args)))))
3267 ;; @defcv: Generalized object-oriented
3268 (put 'defcv 'texinfo-deffn-formatting-property 'texinfo-format-defcv)
3269 (put 'defcvx 'texinfo-deffn-formatting-property 'texinfo-format-defcv)
3270 (defun texinfo-format-defcv (parsed-args)
3271 ;; Generalized object oriented entity:
3272 ;; @defcv category class name
3273 ;; In Info, `Category of class: name'
3274 ;; Note: args in upper case; use of `of'
3275 (let ((category (car parsed-args))
3276 (class (car (cdr parsed-args)))
3277 (name (car (cdr (cdr parsed-args))))
3278 (args (cdr (cdr (cdr parsed-args)))))
3279 (insert " -- " category " of " class ": " name)
3281 (insert " " (upcase (car args)))
3282 (setq args (cdr args)))))
3284 ;; @defmethod: Specialized object-oriented
3285 (put 'defmethod 'texinfo-deffn-formatting-property 'texinfo-format-defmethod)
3286 (put 'defmethodx 'texinfo-deffn-formatting-property 'texinfo-format-defmethod)
3287 (defun texinfo-format-defmethod (parsed-args)
3288 ;; Specialized object oriented entity:
3289 ;; @defmethod class name args...
3290 ;; In Info, `Method on class: name ARGS'
3291 ;; Note: args in upper case; use of `on'
3292 ;; Use cdr of texinfo-defun-type to determine category:
3293 (let ((category (car (cdr texinfo-defun-type)))
3294 (class (car parsed-args))
3295 (name (car (cdr parsed-args)))
3296 (args (cdr (cdr parsed-args))))
3297 (insert " -- " category " on " class ": " name)
3299 (insert " " (upcase (car args)))
3300 (setq args (cdr args)))))
3302 ;; @defivar: Specialized object-oriented
3303 (put 'defivar 'texinfo-deffn-formatting-property 'texinfo-format-defivar)
3304 (put 'defivarx 'texinfo-deffn-formatting-property 'texinfo-format-defivar)
3305 (defun texinfo-format-defivar (parsed-args)
3306 ;; Specialized object oriented entity:
3307 ;; @defivar class name
3308 ;; In Info, `Instance variable of class: name'
3309 ;; Note: args in upper case; use of `of'
3310 ;; Use cdr of texinfo-defun-type to determine category:
3311 (let ((category (car (cdr texinfo-defun-type)))
3312 (class (car parsed-args))
3313 (name (car (cdr parsed-args)))
3314 (args (cdr (cdr parsed-args))))
3315 (insert " -- " category " of " class ": " name)
3317 (insert " " (upcase (car args)))
3318 (setq args (cdr args)))))
3321 ;;; Indexing for definitions
3323 ;; An index entry has three parts: the `entry proper', the node name, and the
3324 ;; line number. Depending on the which command is used, the entry is
3325 ;; formatted differently:
3331 ;; @defopt all use their 1st argument as the entry-proper
3337 ;; @deftypevar all use their 2nd argument as the entry-proper
3340 ;; @deftypevr both use their 3rd argument as the entry-proper
3342 ;; @defmethod uses its 2nd and 1st arguments as an entry-proper
3343 ;; formatted: NAME on CLASS
3345 ;; @defop uses its 3rd and 2nd arguments as an entry-proper
3346 ;; formatted: NAME on CLASS
3348 ;; @defivar uses its 2nd and 1st arguments as an entry-proper
3349 ;; formatted: NAME of CLASS
3351 ;; @defcv uses its 3rd and 2nd argument as an entry-proper
3352 ;; formatted: NAME of CLASS
3354 (put 'defun 'texinfo-defun-indexing-property 'texinfo-index-defun)
3355 (put 'defunx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3356 (put 'defmac 'texinfo-defun-indexing-property 'texinfo-index-defun)
3357 (put 'defmacx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3358 (put 'defspec 'texinfo-defun-indexing-property 'texinfo-index-defun)
3359 (put 'defspecx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3360 (put 'defvar 'texinfo-defun-indexing-property 'texinfo-index-defun)
3361 (put 'defvarx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3362 (put 'defopt 'texinfo-defun-indexing-property 'texinfo-index-defun)
3363 (put 'defoptx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3364 (defun texinfo-index-defun (parsed-args)
3365 ;; use 1st parsed-arg as entry-proper
3366 ;; `index-list' will be texinfo-findex or the like
3367 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3370 ;; Three elements: entry-proper, node-name, line-number
3374 ;; Region formatting may not provide last node position.
3375 (if texinfo-last-node-pos
3376 (1+ (count-lines texinfo-last-node-pos (point)))
3378 (symbol-value index-list)))))
3380 (put 'deffn 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3381 (put 'deffnx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3382 (put 'defvr 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3383 (put 'defvrx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3384 (put 'deftp 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3385 (put 'deftpx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3386 (put 'deftypefun 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3387 (put 'deftypefunx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3388 (put 'deftypevar 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3389 (put 'deftypevarx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3390 (defun texinfo-index-deffn (parsed-args)
3391 ;; use 2nd parsed-arg as entry-proper
3392 ;; `index-list' will be texinfo-findex or the like
3393 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3396 ;; Three elements: entry-proper, node-name, line-number
3398 (car (cdr parsed-args))
3400 ;; Region formatting may not provide last node position.
3401 (if texinfo-last-node-pos
3402 (1+ (count-lines texinfo-last-node-pos (point)))
3404 (symbol-value index-list)))))
3406 (put 'deftypefn 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
3407 (put 'deftypefnx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
3408 (put 'deftypevr 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
3409 (put 'deftypevrx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
3410 (defun texinfo-index-deftypefn (parsed-args)
3411 ;; use 3rd parsed-arg as entry-proper
3412 ;; `index-list' will be texinfo-findex or the like
3413 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3416 ;; Three elements: entry-proper, node-name, line-number
3418 (car (cdr (cdr parsed-args)))
3420 ;; Region formatting may not provide last node position.
3421 (if texinfo-last-node-pos
3422 (1+ (count-lines texinfo-last-node-pos (point)))
3424 (symbol-value index-list)))))
3426 (put 'defmethod 'texinfo-defun-indexing-property 'texinfo-index-defmethod)
3427 (put 'defmethodx 'texinfo-defun-indexing-property 'texinfo-index-defmethod)
3428 (defun texinfo-index-defmethod (parsed-args)
3429 ;; use 2nd on 1st parsed-arg as entry-proper
3430 ;; `index-list' will be texinfo-findex or the like
3431 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3434 ;; Three elements: entry-proper, node-name, line-number
3437 (car (cdr parsed-args))
3440 ;; Region formatting may not provide last node position.
3441 (if texinfo-last-node-pos
3442 (1+ (count-lines texinfo-last-node-pos (point)))
3444 (symbol-value index-list)))))
3446 (put 'defop 'texinfo-defun-indexing-property 'texinfo-index-defop)
3447 (put 'defopx 'texinfo-defun-indexing-property 'texinfo-index-defop)
3448 (defun texinfo-index-defop (parsed-args)
3449 ;; use 3rd on 2nd parsed-arg as entry-proper
3450 ;; `index-list' will be texinfo-findex or the like
3451 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3454 ;; Three elements: entry-proper, node-name, line-number
3457 (car (cdr (cdr parsed-args)))
3458 (car (cdr parsed-args)))
3460 ;; Region formatting may not provide last node position.
3461 (if texinfo-last-node-pos
3462 (1+ (count-lines texinfo-last-node-pos (point)))
3464 (symbol-value index-list)))))
3466 (put 'defivar 'texinfo-defun-indexing-property 'texinfo-index-defivar)
3467 (put 'defivarx 'texinfo-defun-indexing-property 'texinfo-index-defivar)
3468 (defun texinfo-index-defivar (parsed-args)
3469 ;; use 2nd of 1st parsed-arg as entry-proper
3470 ;; `index-list' will be texinfo-findex or the like
3471 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3474 ;; Three elements: entry-proper, node-name, line-number
3477 (car (cdr parsed-args))
3480 ;; Region formatting may not provide last node position.
3481 (if texinfo-last-node-pos
3482 (1+ (count-lines texinfo-last-node-pos (point)))
3484 (symbol-value index-list)))))
3486 (put 'defcv 'texinfo-defun-indexing-property 'texinfo-index-defcv)
3487 (put 'defcvx 'texinfo-defun-indexing-property 'texinfo-index-defcv)
3488 (defun texinfo-index-defcv (parsed-args)
3489 ;; use 3rd of 2nd parsed-arg as entry-proper
3490 ;; `index-list' will be texinfo-findex or the like
3491 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3494 ;; Three elements: entry-proper, node-name, line-number
3497 (car (cdr (cdr parsed-args)))
3498 (car (cdr parsed-args)))
3500 ;; Region formatting may not provide last node position.
3501 (if texinfo-last-node-pos
3502 (1+ (count-lines texinfo-last-node-pos (point)))
3504 (symbol-value index-list)))))
3507 ;;; Properties for definitions
3509 ;; Each definition command has six properties:
3511 ;; 1. texinfo-deffn-formatting-property to format definition line
3512 ;; 2. texinfo-defun-indexing-property to create index entry
3513 ;; 3. texinfo-format formatting command
3514 ;; 4. texinfo-end end formatting command
3515 ;; 5. texinfo-defun-type type of deffn to format
3516 ;; 6. texinfo-defun-index type of index to use
3518 ;; The `x' forms of each definition command are used for the second
3519 ;; and subsequent header lines.
3521 ;; The texinfo-deffn-formatting-property and texinfo-defun-indexing-property
3522 ;; are listed just before the appropriate formatting and indexing commands.
3524 (put 'deffn 'texinfo-format 'texinfo-format-defun)
3525 (put 'deffnx 'texinfo-format 'texinfo-format-defunx)
3526 (put 'deffn 'texinfo-end 'texinfo-end-defun)
3527 (put 'deffn 'texinfo-defun-type '('deffn-type nil))
3528 (put 'deffnx 'texinfo-defun-type '('deffn-type nil))
3529 (put 'deffn 'texinfo-defun-index 'texinfo-findex)
3530 (put 'deffnx 'texinfo-defun-index 'texinfo-findex)
3532 (put 'defun 'texinfo-format 'texinfo-format-defun)
3533 (put 'defunx 'texinfo-format 'texinfo-format-defunx)
3534 (put 'defun 'texinfo-end 'texinfo-end-defun)
3535 (put 'defun 'texinfo-defun-type '('defun-type "Function"))
3536 (put 'defunx 'texinfo-defun-type '('defun-type "Function"))
3537 (put 'defun 'texinfo-defun-index 'texinfo-findex)
3538 (put 'defunx 'texinfo-defun-index 'texinfo-findex)
3540 (put 'defmac 'texinfo-format 'texinfo-format-defun)
3541 (put 'defmacx 'texinfo-format 'texinfo-format-defunx)
3542 (put 'defmac 'texinfo-end 'texinfo-end-defun)
3543 (put 'defmac 'texinfo-defun-type '('defun-type "Macro"))
3544 (put 'defmacx 'texinfo-defun-type '('defun-type "Macro"))
3545 (put 'defmac 'texinfo-defun-index 'texinfo-findex)
3546 (put 'defmacx 'texinfo-defun-index 'texinfo-findex)
3548 (put 'defspec 'texinfo-format 'texinfo-format-defun)
3549 (put 'defspecx 'texinfo-format 'texinfo-format-defunx)
3550 (put 'defspec 'texinfo-end 'texinfo-end-defun)
3551 (put 'defspec 'texinfo-defun-type '('defun-type "Special form"))
3552 (put 'defspecx 'texinfo-defun-type '('defun-type "Special form"))
3553 (put 'defspec 'texinfo-defun-index 'texinfo-findex)
3554 (put 'defspecx 'texinfo-defun-index 'texinfo-findex)
3556 (put 'defvr 'texinfo-format 'texinfo-format-defun)
3557 (put 'defvrx 'texinfo-format 'texinfo-format-defunx)
3558 (put 'defvr 'texinfo-end 'texinfo-end-defun)
3559 (put 'defvr 'texinfo-defun-type '('deffn-type nil))
3560 (put 'defvrx 'texinfo-defun-type '('deffn-type nil))
3561 (put 'defvr 'texinfo-defun-index 'texinfo-vindex)
3562 (put 'defvrx 'texinfo-defun-index 'texinfo-vindex)
3564 (put 'defvar 'texinfo-format 'texinfo-format-defun)
3565 (put 'defvarx 'texinfo-format 'texinfo-format-defunx)
3566 (put 'defvar 'texinfo-end 'texinfo-end-defun)
3567 (put 'defvar 'texinfo-defun-type '('defun-type "Variable"))
3568 (put 'defvarx 'texinfo-defun-type '('defun-type "Variable"))
3569 (put 'defvar 'texinfo-defun-index 'texinfo-vindex)
3570 (put 'defvarx 'texinfo-defun-index 'texinfo-vindex)
3572 (put 'defconst 'texinfo-format 'texinfo-format-defun)
3573 (put 'defconstx 'texinfo-format 'texinfo-format-defunx)
3574 (put 'defconst 'texinfo-end 'texinfo-end-defun)
3575 (put 'defconst 'texinfo-defun-type '('defun-type "Constant"))
3576 (put 'defconstx 'texinfo-defun-type '('defun-type "Constant"))
3577 (put 'defconst 'texinfo-defun-index 'texinfo-vindex)
3578 (put 'defconstx 'texinfo-defun-index 'texinfo-vindex)
3580 (put 'defcmd 'texinfo-format 'texinfo-format-defun)
3581 (put 'defcmdx 'texinfo-format 'texinfo-format-defunx)
3582 (put 'defcmd 'texinfo-end 'texinfo-end-defun)
3583 (put 'defcmd 'texinfo-defun-type '('defun-type "Command"))
3584 (put 'defcmdx 'texinfo-defun-type '('defun-type "Command"))
3585 (put 'defcmd 'texinfo-defun-index 'texinfo-findex)
3586 (put 'defcmdx 'texinfo-defun-index 'texinfo-findex)
3588 (put 'defopt 'texinfo-format 'texinfo-format-defun)
3589 (put 'defoptx 'texinfo-format 'texinfo-format-defunx)
3590 (put 'defopt 'texinfo-end 'texinfo-end-defun)
3591 (put 'defopt 'texinfo-defun-type '('defun-type "User Option"))
3592 (put 'defoptx 'texinfo-defun-type '('defun-type "User Option"))
3593 (put 'defopt 'texinfo-defun-index 'texinfo-vindex)
3594 (put 'defoptx 'texinfo-defun-index 'texinfo-vindex)
3596 (put 'deftp 'texinfo-format 'texinfo-format-defun)
3597 (put 'deftpx 'texinfo-format 'texinfo-format-defunx)
3598 (put 'deftp 'texinfo-end 'texinfo-end-defun)
3599 (put 'deftp 'texinfo-defun-type '('deftp-type nil))
3600 (put 'deftpx 'texinfo-defun-type '('deftp-type nil))
3601 (put 'deftp 'texinfo-defun-index 'texinfo-tindex)
3602 (put 'deftpx 'texinfo-defun-index 'texinfo-tindex)
3604 ;;; Object-oriented stuff is a little hairier.
3606 (put 'defop 'texinfo-format 'texinfo-format-defun)
3607 (put 'defopx 'texinfo-format 'texinfo-format-defunx)
3608 (put 'defop 'texinfo-end 'texinfo-end-defun)
3609 (put 'defop 'texinfo-defun-type '('defop-type nil))
3610 (put 'defopx 'texinfo-defun-type '('defop-type nil))
3611 (put 'defop 'texinfo-defun-index 'texinfo-findex)
3612 (put 'defopx 'texinfo-defun-index 'texinfo-findex)
3614 (put 'defmethod 'texinfo-format 'texinfo-format-defun)
3615 (put 'defmethodx 'texinfo-format 'texinfo-format-defunx)
3616 (put 'defmethod 'texinfo-end 'texinfo-end-defun)
3617 (put 'defmethod 'texinfo-defun-type '('defmethod-type "Method"))
3618 (put 'defmethodx 'texinfo-defun-type '('defmethod-type "Method"))
3619 (put 'defmethod 'texinfo-defun-index 'texinfo-findex)
3620 (put 'defmethodx 'texinfo-defun-index 'texinfo-findex)
3622 (put 'defcv 'texinfo-format 'texinfo-format-defun)
3623 (put 'defcvx 'texinfo-format 'texinfo-format-defunx)
3624 (put 'defcv 'texinfo-end 'texinfo-end-defun)
3625 (put 'defcv 'texinfo-defun-type '('defop-type nil))
3626 (put 'defcvx 'texinfo-defun-type '('defop-type nil))
3627 (put 'defcv 'texinfo-defun-index 'texinfo-vindex)
3628 (put 'defcvx 'texinfo-defun-index 'texinfo-vindex)
3630 (put 'defivar 'texinfo-format 'texinfo-format-defun)
3631 (put 'defivarx 'texinfo-format 'texinfo-format-defunx)
3632 (put 'defivar 'texinfo-end 'texinfo-end-defun)
3633 (put 'defivar 'texinfo-defun-type '('defmethod-type "Instance variable"))
3634 (put 'defivarx 'texinfo-defun-type '('defmethod-type "Instance variable"))
3635 (put 'defivar 'texinfo-defun-index 'texinfo-vindex)
3636 (put 'defivarx 'texinfo-defun-index 'texinfo-vindex)
3638 ;;; Typed functions and variables
3640 (put 'deftypefn 'texinfo-format 'texinfo-format-defun)
3641 (put 'deftypefnx 'texinfo-format 'texinfo-format-defunx)
3642 (put 'deftypefn 'texinfo-end 'texinfo-end-defun)
3643 (put 'deftypefn 'texinfo-defun-type '('deftypefn-type nil))
3644 (put 'deftypefnx 'texinfo-defun-type '('deftypefn-type nil))
3645 (put 'deftypefn 'texinfo-defun-index 'texinfo-findex)
3646 (put 'deftypefnx 'texinfo-defun-index 'texinfo-findex)
3648 (put 'deftypefun 'texinfo-format 'texinfo-format-defun)
3649 (put 'deftypefunx 'texinfo-format 'texinfo-format-defunx)
3650 (put 'deftypefun 'texinfo-end 'texinfo-end-defun)
3651 (put 'deftypefun 'texinfo-defun-type '('deftypefun-type "Function"))
3652 (put 'deftypefunx 'texinfo-defun-type '('deftypefun-type "Function"))
3653 (put 'deftypefun 'texinfo-defun-index 'texinfo-findex)
3654 (put 'deftypefunx 'texinfo-defun-index 'texinfo-findex)
3656 (put 'deftypevr 'texinfo-format 'texinfo-format-defun)
3657 (put 'deftypevrx 'texinfo-format 'texinfo-format-defunx)
3658 (put 'deftypevr 'texinfo-end 'texinfo-end-defun)
3659 (put 'deftypevr 'texinfo-defun-type '('deftypefn-type nil))
3660 (put 'deftypevrx 'texinfo-defun-type '('deftypefn-type nil))
3661 (put 'deftypevr 'texinfo-defun-index 'texinfo-vindex)
3662 (put 'deftypevrx 'texinfo-defun-index 'texinfo-vindex)
3664 (put 'deftypevar 'texinfo-format 'texinfo-format-defun)
3665 (put 'deftypevarx 'texinfo-format 'texinfo-format-defunx)
3666 (put 'deftypevar 'texinfo-end 'texinfo-end-defun)
3667 (put 'deftypevar 'texinfo-defun-type '('deftypevar-type "Variable"))
3668 (put 'deftypevarx 'texinfo-defun-type '('deftypevar-type "Variable"))
3669 (put 'deftypevar 'texinfo-defun-index 'texinfo-vindex)
3670 (put 'deftypevarx 'texinfo-defun-index 'texinfo-vindex)
3673 ;;; @set, @clear, @ifset, @ifclear
3675 ;; If a flag is set with @set FLAG, then text between @ifset and @end
3676 ;; ifset is formatted normally, but if the flag is is cleared with
3677 ;; @clear FLAG, then the text is not formatted; it is ignored.
3679 ;; If a flag is cleared with @clear FLAG, then text between @ifclear
3680 ;; and @end ifclear is formatted normally, but if the flag is is set with
3681 ;; @set FLAG, then the text is not formatted; it is ignored. @ifclear
3682 ;; is the opposite of @ifset.
3684 ;; If a flag is set to a string with @set FLAG,
3685 ;; replace @value{FLAG} with the string.
3686 ;; If a flag with a value is cleared,
3687 ;; @value{FLAG} is invalid,
3688 ;; as if there had never been any @set FLAG previously.
3690 (put 'clear 'texinfo-format 'texinfo-clear)
3691 (defun texinfo-clear ()
3692 "Clear the value of the flag."
3693 (let* ((arg (texinfo-parse-arg-discard))
3694 (flag (car (read-from-string arg)))
3695 (value (substring arg (cdr (read-from-string arg)))))
3696 (put flag 'texinfo-whether-setp 'flag-cleared)
3697 (put flag 'texinfo-set-value "")))
3699 (put 'set 'texinfo-format 'texinfo-set)
3700 (defun texinfo-set ()
3701 "Set the value of the flag, optionally to a string.
3702 The command `@set foo This is a string.'
3703 sets flag foo to the value: `This is a string.'
3704 The command `@value{foo}' expands to the value."
3705 (let* ((arg (texinfo-parse-arg-discard))
3706 (flag (car (read-from-string arg)))
3707 (value (substring arg (cdr (read-from-string arg)))))
3708 (put flag 'texinfo-whether-setp 'flag-set)
3709 (put flag 'texinfo-set-value value)))
3711 (put 'value 'texinfo-format 'texinfo-value)
3712 (defun texinfo-value ()
3713 "Insert the string to which the flag is set.
3714 The command `@set foo This is a string.'
3715 sets flag foo to the value: `This is a string.'
3716 The command `@value{foo}' expands to the value."
3717 (let ((arg (texinfo-parse-arg-discard)))
3719 (eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3721 (get (car (read-from-string arg)) 'texinfo-set-value))
3722 (insert (get (car (read-from-string arg)) 'texinfo-set-value)))
3723 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3725 (insert (format "{No value for \"%s\"}" arg)))
3726 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) nil)
3727 (insert (format "{No value for \"%s\"}" arg))))))
3729 (put 'ifset 'texinfo-end 'texinfo-discard-command)
3730 (put 'ifset 'texinfo-format 'texinfo-if-set)
3731 (defun texinfo-if-set ()
3732 "If set, continue formatting; else do not format region up to @end ifset"
3733 (let ((arg (texinfo-parse-arg-discard)))
3735 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3737 ;; Format the text (i.e., do not remove it); do nothing here.
3739 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3741 ;; Clear region (i.e., cause the text to be ignored).
3742 (delete-region texinfo-command-start
3743 (progn (re-search-forward "@end ifset[ \t]*\n")
3745 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3747 ;; In this case flag is neither set nor cleared.
3748 ;; Act as if set, i.e. do nothing.
3751 (put 'ifclear 'texinfo-end 'texinfo-discard-command)
3752 (put 'ifclear 'texinfo-format 'texinfo-if-clear)
3753 (defun texinfo-if-clear ()
3754 "If clear, continue formatting; if set, do not format up to @end ifset"
3755 (let ((arg (texinfo-parse-arg-discard)))
3757 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3759 ;; Clear region (i.e., cause the text to be ignored).
3760 (delete-region texinfo-command-start
3761 (progn (re-search-forward "@end ifclear[ \t]*\n")
3763 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3765 ;; Format the text (i.e., do not remove it); do nothing here.
3767 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3769 ;; In this case flag is neither set nor cleared.
3770 ;; Act as if clear, i.e. do nothing.
3775 (put 'ifeq 'texinfo-format 'texinfo-format-ifeq)
3776 (defun texinfo-format-ifeq ()
3777 "If ARG1 and ARG2 caselessly string compare to same string, perform COMMAND.
3778 Otherwise produces no output.
3781 @ifeq{ arg1 , arg1 , @code{foo}} bar
3785 @ifeq{ arg1 , arg2 , @code{foo}} bar
3789 Note that the Texinfo command and its arguments must be arguments to
3791 ;; compare-buffer-substrings does not exist in version 18; don't use
3792 (goto-char texinfo-command-end)
3793 (let* ((case-fold-search t)
3794 (stop (save-excursion (forward-sexp 1) (point)))
3796 ;; @ifeq{arg1, arg2, @command{optional-args}}
3800 (skip-chars-forward " ")
3801 (setq start (point))
3802 (search-forward "," stop t)
3803 (skip-chars-backward ", ")
3804 (buffer-substring start (point))))
3807 (search-forward "," stop t)
3808 (skip-chars-forward " ")
3809 (setq start (point))
3810 (search-forward "," stop t)
3811 (skip-chars-backward ", ")
3812 (buffer-substring start (point))))
3815 (search-forward "," stop t)
3816 (skip-chars-forward " ")
3817 (setq start (point))
3818 (goto-char (1- stop))
3819 (skip-chars-backward " ")
3820 (buffer-substring start (point)))))
3821 (delete-region texinfo-command-start stop)
3822 (if (equal arg1 arg2)
3823 (insert texinfo-command))
3824 (goto-char texinfo-command-start)))
3827 ;;; Process included files: `@include' command
3829 ;; Updated 19 October 1990
3830 ;; In the original version, include files were ignored by Info but
3831 ;; incorporated in to the printed manual. To make references to the
3832 ;; included file, the Texinfo source file has to refer to the included
3833 ;; files using the `(filename)nodename' format for referring to other
3834 ;; Info files. Also, the included files had to be formatted on their
3835 ;; own. It was just like they were another file.
3837 ;; Currently, include files are inserted into the buffer that is
3838 ;; formatted for Info. If large, the resulting info file is split and
3839 ;; tagified. For current include files to work, the master menu must
3840 ;; refer to all the nodes, and the highest level nodes in the include
3841 ;; files must have the correct next, prev, and up pointers.
3843 ;; The included file may have an @setfilename and even an @settitle,
3844 ;; but not an `\input texinfo' line.
3846 ;; Updated 24 March 1993
3847 ;; In order for @raisesections and @lowersections to work, included
3848 ;; files must be inserted into the buffer holding the outer file
3849 ;; before other Info formatting takes place. So @include is no longer
3850 ;; is treated like other @-commands.
3851 (put 'include 'texinfo-format 'texinfo-format-noop)
3853 ;; Original definition:
3854 ;; (defun texinfo-format-include ()
3855 ;; (let ((filename (texinfo-parse-arg-discard))
3856 ;; (default-directory input-directory)
3860 ;; (progn (find-file
3861 ;; (cond ((file-readable-p (concat filename ".texinfo"))
3862 ;; (concat filename ".texinfo"))
3863 ;; ((file-readable-p (concat filename ".texi"))
3864 ;; (concat filename ".texi"))
3865 ;; ((file-readable-p (concat filename ".tex"))
3866 ;; (concat filename ".tex"))
3867 ;; ((file-readable-p filename)
3869 ;; (t (error "@include'd file %s not found"
3871 ;; (texinfo-format-buffer-1))))
3872 ;; (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex))
3873 ;; (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex))
3874 ;; (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex))
3875 ;; (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex))
3876 ;; (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex))
3877 ;; (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex))))
3879 ;;(defun texinfo-subindex (indexvar file content)
3880 ;; (set indexvar (cons (list 'recurse file content)
3881 ;; (symbol-value indexvar))))
3883 ;; Second definition:
3884 ;; (put 'include 'texinfo-format 'texinfo-format-include)
3885 ;; (defun texinfo-format-include ()
3886 ;; (let ((filename (concat input-directory
3887 ;; (texinfo-parse-arg-discard)))
3888 ;; (default-directory input-directory))
3889 ;; (message "Reading: %s" filename)
3891 ;; (save-restriction
3892 ;; (narrow-to-region
3894 ;; (+ (point) (car (cdr (insert-file-contents filename)))))
3895 ;; (goto-char (point-min))
3896 ;; (texinfo-append-refill)
3897 ;; (texinfo-format-convert (point-min) (point-max))))
3898 ;; (setq last-input-buffer input-buffer) ; to bypass setfilename
3902 ;;; Numerous commands do nothing in Info
3903 ;; These commands are defined in texinfo.tex for printed output.
3906 ;;; various noops, such as @b{foo}, that take arguments in braces
3908 (put 'b 'texinfo-format 'texinfo-format-noop)
3909 (put 'i 'texinfo-format 'texinfo-format-noop)
3910 (put 'r 'texinfo-format 'texinfo-format-noop)
3911 (put 't 'texinfo-format 'texinfo-format-noop)
3912 (put 'w 'texinfo-format 'texinfo-format-noop)
3913 (put 'asis 'texinfo-format 'texinfo-format-noop)
3914 (put 'dmn 'texinfo-format 'texinfo-format-noop)
3915 (put 'math 'texinfo-format 'texinfo-format-noop)
3916 (put 'titlefont 'texinfo-format 'texinfo-format-noop)
3917 (defun texinfo-format-noop ()
3918 (insert (texinfo-parse-arg-discard))
3919 (goto-char texinfo-command-start))
3921 ;; @hyphenation command discards an argument within braces
3922 (put 'hyphenation 'texinfo-format 'texinfo-discard-command-and-arg)
3923 (defun texinfo-discard-command-and-arg ()
3924 "Discard both @-command and its argument in braces."
3925 (goto-char texinfo-command-end)
3927 (setq texinfo-command-end (point))
3928 (delete-region texinfo-command-start texinfo-command-end))
3931 ;;; Do nothing commands, such as @smallbook, that have no args and no braces
3932 ;; These must appear on a line of their own
3934 (put 'bye 'texinfo-format 'texinfo-discard-line)
3935 (put 'smallbook 'texinfo-format 'texinfo-discard-line)
3936 (put 'finalout 'texinfo-format 'texinfo-discard-line)
3937 (put 'overfullrule 'texinfo-format 'texinfo-discard-line)
3938 (put 'smallbreak 'texinfo-format 'texinfo-discard-line)
3939 (put 'medbreak 'texinfo-format 'texinfo-discard-line)
3940 (put 'bigbreak 'texinfo-format 'texinfo-discard-line)
3943 ;;; These noop commands discard the rest of the line.
3945 (put 'c 'texinfo-format 'texinfo-discard-line-with-args)
3946 (put 'comment 'texinfo-format 'texinfo-discard-line-with-args)
3947 (put 'contents 'texinfo-format 'texinfo-discard-line-with-args)
3948 (put 'group 'texinfo-end 'texinfo-discard-line-with-args)
3949 (put 'group 'texinfo-format 'texinfo-discard-line-with-args)
3950 (put 'headings 'texinfo-format 'texinfo-discard-line-with-args)
3951 (put 'setchapterstyle 'texinfo-format 'texinfo-discard-line-with-args)
3952 (put 'hsize 'texinfo-format 'texinfo-discard-line-with-args)
3953 (put 'itemindent 'texinfo-format 'texinfo-discard-line-with-args)
3954 (put 'lispnarrowing 'texinfo-format 'texinfo-discard-line-with-args)
3955 (put 'need 'texinfo-format 'texinfo-discard-line-with-args)
3956 (put 'nopara 'texinfo-format 'texinfo-discard-line-with-args)
3957 (put 'page 'texinfo-format 'texinfo-discard-line-with-args)
3958 (put 'parindent 'texinfo-format 'texinfo-discard-line-with-args)
3959 (put 'setchapternewpage 'texinfo-format 'texinfo-discard-line-with-args)
3960 (put 'setq 'texinfo-format 'texinfo-discard-line-with-args)
3961 (put 'settitle 'texinfo-format 'texinfo-discard-line-with-args)
3962 (put 'setx 'texinfo-format 'texinfo-discard-line-with-args)
3963 (put 'shortcontents 'texinfo-format 'texinfo-discard-line-with-args)
3964 (put 'shorttitlepage 'texinfo-format 'texinfo-discard-line-with-args)
3965 (put 'summarycontents 'texinfo-format 'texinfo-discard-line-with-args)
3966 (put 'input 'texinfo-format 'texinfo-discard-line-with-args)
3969 ;;; Some commands cannot be handled
3971 (defun texinfo-unsupported ()
3972 (error "%s is not handled by texinfo"
3973 (buffer-substring texinfo-command-start texinfo-command-end)))
3975 ;;; Batch formatting
3977 (defun batch-texinfo-format ()
3978 "Runs texinfo-format-buffer on the files remaining on the command line.
3979 Must be used only with -batch, and kills emacs on completion.
3980 Each file will be processed even if an error occurred previously.
3982 \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"."
3983 (if (not noninteractive)
3984 (error "batch-texinfo-format may only be used -batch."))
3985 (let ((version-control t)
3986 (auto-save-default nil)
3987 (find-file-run-dired nil)
3988 (kept-old-versions 259259)
3989 (kept-new-versions 259259))
3993 (while command-line-args-left
3994 (setq file (expand-file-name (car command-line-args-left)))
3995 (cond ((not (file-exists-p file))
3996 (message ">> %s does not exist!" file)
3998 command-line-args-left (cdr command-line-args-left)))
3999 ((file-directory-p file)
4000 (setq command-line-args-left
4001 (nconc (directory-files file)
4002 (cdr command-line-args-left))))
4004 (setq files (cons file files)
4005 command-line-args-left (cdr command-line-args-left)))))
4007 (setq file (car files)
4011 (if buffer-file-name (kill-buffer (current-buffer)))
4013 (buffer-disable-undo (current-buffer))
4014 (set-buffer-modified-p nil)
4016 (message "texinfo formatting %s..." file)
4017 (texinfo-format-buffer nil)
4018 (if (buffer-modified-p)
4019 (progn (message "Saving modified %s" (buffer-file-name))
4022 (message ">> Error: %s" (prin1-to-string err))
4023 (message ">> point at")
4024 (let ((s (buffer-substring (point)
4025 (min (+ (point) 100)
4028 (while (setq tem (string-match "\n+" s tem))
4029 (setq s (concat (substring s 0 (match-beginning 0))
4031 (substring s (match-end 0)))
4033 (message ">> %s" s))
4035 (kill-emacs error))))
4038 ;;; Place `provide' at end of file.
4041 ;;; texinfmt.el ends here.