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 (or (fboundp 'defgroup
)
31 (defmacro defgroup
(&rest ignore
) nil
))
33 (or (fboundp 'defcustom
)
34 (defmacro defcustom
(var value doc
&rest ignore
)
35 `(defvar ,var
,value
,doc
)))
37 (defvar texinfmt-version
"2.37 of 24 May 1997")
39 (defun texinfmt-version (&optional here
)
40 "Show the version of texinfmt.el in the minibuffer.
41 If optional argument HERE is non-nil, insert info at point."
44 (format "Version of \`texinfmt.el\': %s" texinfmt-version
)))
46 (insert version-string
)
48 (message "%s" version-string
)
52 ;;; Variable definitions
54 (require 'texinfo
) ; So `texinfo-footnote-style' is defined.
55 (require 'texnfo-upd
) ; So `texinfo-section-types-regexp' is defined.
57 (defvar texinfo-format-syntax-table nil
)
59 (defvar texinfo-vindex
)
60 (defvar texinfo-findex
)
61 (defvar texinfo-cindex
)
62 (defvar texinfo-pindex
)
63 (defvar texinfo-tindex
)
64 (defvar texinfo-kindex
)
65 (defvar texinfo-last-node
)
66 (defvar texinfo-node-names
)
67 (defvar texinfo-enclosure-list
)
68 (defvar texinfo-alias-list
)
70 (defvar texinfo-command-start
)
71 (defvar texinfo-command-end
)
72 (defvar texinfo-command-name
)
73 (defvar texinfo-defun-type
)
74 (defvar texinfo-last-node-pos
)
75 (defvar texinfo-stack
)
76 (defvar texinfo-short-index-cmds-alist
)
77 (defvar texinfo-short-index-format-cmds-alist
)
78 (defvar texinfo-format-filename
)
79 (defvar texinfo-footnote-number
)
80 (defvar texinfo-start-of-header
)
81 (defvar texinfo-end-of-header
)
82 (defvar texinfo-raisesections-alist
)
83 (defvar texinfo-lowersections-alist
)
87 (if texinfo-format-syntax-table
89 (setq texinfo-format-syntax-table
(make-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 ?\^q
"\\" texinfo-format-syntax-table
)
94 (modify-syntax-entry ?\
[ "." texinfo-format-syntax-table
)
95 (modify-syntax-entry ?\
] "." texinfo-format-syntax-table
)
96 (modify-syntax-entry ?\
( "." texinfo-format-syntax-table
)
97 (modify-syntax-entry ?\
) "." texinfo-format-syntax-table
)
98 (modify-syntax-entry ?
{ "(}" texinfo-format-syntax-table
)
99 (modify-syntax-entry ?
} "){" texinfo-format-syntax-table
)
100 (modify-syntax-entry ?
\' "." texinfo-format-syntax-table
))
103 ;;; Top level buffer and region formatting functions
106 (defun texinfo-format-buffer (&optional notagify
)
107 "Process the current buffer as texinfo code, into an Info file.
108 The Info file output is generated in a buffer visiting the Info file
109 name specified in the @setfilename command.
111 Non-nil argument (prefix, if interactive) means don't make tag table
112 and don't split the file if large. You can use Info-tagify and
113 Info-split to do these manually."
115 (let ((lastmessage "Formatting Info file..."))
116 (message lastmessage
)
117 (texinfo-format-buffer-1)
120 (if (> (buffer-size) 30000)
122 (message (setq lastmessage
"Making tags table for Info file..."))
124 (if (> (buffer-size) 100000)
126 (message (setq lastmessage
"Splitting Info file..."))
128 (message (concat lastmessage
129 (if (interactive-p) "done. Now save it." "done.")))))
131 (defvar texinfo-region-buffer-name
"*Info Region*"
132 "*Name of the temporary buffer used by \\[texinfo-format-region].")
135 (defun texinfo-format-region (region-beginning region-end
)
136 "Convert the current region of the Texinfo file to Info format.
137 This lets you see what that part of the file will look like in Info.
138 The command is bound to \\[texinfo-format-region]. The text that is
139 converted to Info is stored in a temporary buffer."
141 (message "Converting region to Info format...")
142 (let (texinfo-command-start
152 (texinfo-format-filename "")
153 texinfo-example-start
154 texinfo-last-node-pos
157 (texinfo-footnote-number 0)
159 (fill-column-for-info fill-column
)
160 (input-buffer (current-buffer))
161 (input-directory default-directory
)
166 ;;; Copy lines between beginning and end of header lines,
167 ;;; if any, or else copy the `@setfilename' line, if any.
171 (goto-char (point-min))
172 (let ((search-end (save-excursion (forward-line 100) (point))))
174 ;; Either copy header text.
177 (search-forward tex-start-of-header search-end t
)
179 ;; Mark beginning of header.
180 (setq header-beginning
(point)))
182 (search-forward tex-end-of-header nil t
)
184 ;; Mark end of header
185 (setq header-end
(point))))
186 ;; Or copy @filename line.
188 (goto-char (point-min))
189 (search-forward "@setfilename" search-end t
)
191 (setq header-beginning
(point))
193 (setq header-end
(point))))
198 (min header-beginning region-beginning
)
201 ;;; Find a buffer to use.
202 (switch-to-buffer (get-buffer-create texinfo-region-buffer-name
))
204 ;; Insert the header into the buffer.
206 ;; Insert the region into the buffer.
207 (insert-buffer-substring
209 (max region-beginning header-end
)
211 ;; Make sure region ends in a newline.
212 (or (= (preceding-char) ?
\n)
215 (goto-char (point-min))
217 (message "Converting region to Info format...")
218 (setq fill-column fill-column-for-info
)
219 ;; Install a syntax table useful for scanning command operands.
220 (set-syntax-table texinfo-format-syntax-table
)
222 ;; Insert @include files so `texinfo-raise-lower-sections' can
223 ;; work on them without losing track of multiple
224 ;; @raise/@lowersections commands.
225 (while (re-search-forward "^@include" nil t
)
226 (setq texinfo-command-end
(point))
227 (let ((filename (concat input-directory
228 (texinfo-parse-line-arg))))
229 (re-search-backward "^@include")
230 (delete-region (point) (save-excursion (forward-line 1) (point)))
231 (message "Reading included file: %s" filename
)
236 (+ (point) (car (cdr (insert-file-contents filename
)))))
237 (goto-char (point-min))
238 ;; Remove `@setfilename' line from included file, if any,
239 ;; so @setfilename command not duplicated.
240 (if (re-search-forward
241 "^@setfilename" (save-excursion (forward-line 100) (point)) t
)
245 (point) (save-excursion (forward-line 1) (point)))))))))
247 ;; Raise or lower level of each section, if necessary.
248 (goto-char (point-min))
249 (texinfo-raise-lower-sections)
250 ;; Append @refill to appropriate paragraphs for filling.
251 (goto-char (point-min))
252 (texinfo-append-refill)
253 ;; If the region includes the effective end of the data,
254 ;; discard everything after that.
255 (goto-char (point-max))
256 (if (re-search-backward "^@bye" nil t
)
257 (delete-region (point) (point-max)))
258 ;; Make sure buffer ends in a newline.
259 (or (= (preceding-char) ?
\n)
261 ;; Don't use a previous value of texinfo-enclosure-list.
262 (setq texinfo-enclosure-list nil
)
263 (setq texinfo-alias-list nil
)
265 (goto-char (point-min))
266 (if (looking-at "\\\\input[ \t]+texinfo")
267 (delete-region (point) (save-excursion (forward-line 1) (point))))
269 ;; Insert Info region title text.
270 (goto-char (point-min))
272 "@setfilename" (save-excursion (forward-line 100) (point)) t
)
274 (setq texinfo-command-end
(point))
276 (setq texinfo-command-start
(point))
277 (let ((arg (texinfo-parse-arg-discard)))
279 texinfo-region-buffer-name
281 (insert (file-name-nondirectory (expand-file-name arg
)))
282 (insert "', -*-Text-*-\n")))
283 ;; Else no `@setfilename' line
285 texinfo-region-buffer-name
286 " buffer -*-Text-*-\n"))
287 (insert "produced by `texinfo-format-region'\n"
289 (if (buffer-file-name input-buffer
)
291 (file-name-sans-versions
292 (file-name-nondirectory
293 (buffer-file-name input-buffer
)))
295 (concat "buffer `" (buffer-name input-buffer
) "'"))
296 "\nusing `texinfmt.el' version "
300 ;; Now convert for real.
301 (goto-char (point-min))
302 (texinfo-format-scan)
303 (goto-char (point-min))
308 (defun texi2info (&optional notagify
)
309 "Convert the current buffer (written in Texinfo code) into an Info file.
310 The Info file output is generated in a buffer visiting the Info file
311 names specified in the @setfilename command.
313 This function automatically updates all node pointers and menus, and
314 creates a master menu. This work is done on a temporary buffer that
315 is automatically removed when the Info file is created. The original
316 Texinfo source buffer is not changed.
318 Non-nil argument (prefix, if interactive) means don't make tag table
319 and don't split the file if large. You can use Info-tagify and
320 Info-split to do these manually."
322 (let ((temp-buffer (concat "*--" (buffer-name) "--temporary-buffer*" )))
323 (message "First updating nodes and menus, then creating Info file.")
325 (copy-to-buffer temp-buffer
(point-min) (point-max))
326 (switch-to-buffer temp-buffer
)
327 (texinfo-master-menu t
)
328 (message "Now creating Info file.")
330 (texinfo-format-buffer notagify
)
332 (kill-buffer temp-buffer
)))
335 ;;; Primary internal formatting function for the whole buffer.
337 (defun texinfo-format-buffer-1 ()
338 (let (texinfo-format-filename
339 texinfo-example-start
340 texinfo-command-start
344 texinfo-last-node-pos
353 (texinfo-footnote-number 0)
356 (fill-column-for-info fill-column
)
357 (input-buffer (current-buffer))
358 (input-directory default-directory
))
359 (setq texinfo-enclosure-list nil
)
360 (setq texinfo-alias-list nil
)
362 (goto-char (point-min))
363 (or (search-forward "@setfilename" nil t
)
364 (error "Texinfo file needs an `@setfilename FILENAME' line."))
365 (setq texinfo-command-end
(point))
366 (setq outfile
(texinfo-parse-line-arg)))
372 (message "Formatting Info file: %s" outfile
)
373 (setq texinfo-format-filename
374 (file-name-nondirectory (expand-file-name outfile
)))
376 (setq fill-column fill-column-for-info
)
377 (set-syntax-table texinfo-format-syntax-table
)
379 (insert-buffer-substring input-buffer
)
380 (message "Converting %s to Info format..." (buffer-name input-buffer
))
382 ;; Insert @include files so `texinfo-raise-lower-sections' can
383 ;; work on them without losing track of multiple
384 ;; @raise/@lowersections commands.
385 (goto-char (point-min))
386 (while (re-search-forward "^@include" nil t
)
387 (setq texinfo-command-end
(point))
388 (let ((filename (concat input-directory
389 (texinfo-parse-line-arg))))
390 (re-search-backward "^@include")
391 (delete-region (point) (save-excursion (forward-line 1) (point)))
392 (message "Reading included file: %s" filename
)
397 (+ (point) (car (cdr (insert-file-contents filename
)))))
398 (goto-char (point-min))
399 ;; Remove `@setfilename' line from included file, if any,
400 ;; so @setfilename command not duplicated.
401 (if (re-search-forward
403 (save-excursion (forward-line 100) (point)) t
)
407 (point) (save-excursion (forward-line 1) (point)))))))))
408 ;; Raise or lower level of each section, if necessary.
409 (goto-char (point-min))
410 (texinfo-raise-lower-sections)
411 ;; Append @refill to appropriate paragraphs
412 (goto-char (point-min))
413 (texinfo-append-refill)
414 (goto-char (point-min))
415 (search-forward "@setfilename")
417 (delete-region (point-min) (point))
418 ;; Remove @bye at end of file, if it is there.
419 (goto-char (point-max))
420 (if (search-backward "@bye" nil t
)
421 (delete-region (point) (point-max)))
422 ;; Make sure buffer ends in a newline.
423 (or (= (preceding-char) ?
\n)
425 ;; Scan the whole buffer, converting to Info format.
426 (texinfo-format-scan)
427 (goto-char (point-min))
428 ;; Insert info about how this file was made.
429 (insert "Info file: "
430 texinfo-format-filename
", -*-Text-*-\n"
431 "produced by `texinfo-format-buffer'\n"
432 ;; Date string removed so that regression testing is easier.
434 ;; (insert (format-time-string "%e %b %Y")) " "
436 (if (buffer-file-name input-buffer
)
438 (file-name-sans-versions
439 (file-name-nondirectory
440 (buffer-file-name input-buffer
)))
442 (concat "buffer `" (buffer-name input-buffer
) "'"))
443 "\nusing `texinfmt.el' version "
446 ;; Return data for indices.
448 texinfo-vindex texinfo-findex texinfo-cindex
449 texinfo-pindex texinfo-tindex texinfo-kindex
)))
452 ;;; Perform non-@-command file conversions: quotes and hyphens
454 (defun texinfo-format-convert (min max
)
455 ;; Convert left and right quotes to typewriter font quotes.
457 (while (search-forward "``" max t
)
458 (replace-match "\""))
460 (while (search-forward "''" max t
)
461 (replace-match "\""))
462 ;; Convert three hyphens in a row to two.
464 (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t
)
465 (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning
469 ;;; Handle paragraph filling
471 ;; Keep as concatinated lists for ease of maintenance
473 (defvar texinfo-no-refill-regexp
494 "Regexp specifying environments in which paragraphs are not filled.")
496 (defvar texinfo-accent-commands
529 (defvar texinfo-part-of-para-regexp
564 "@-\\|" ; @- is a descretionary hyphen (not an accent) (a noop).
565 texinfo-accent-commands
568 "Regexp specifying @-commands found within paragraphs.")
570 (defun texinfo-append-refill ()
571 "Append @refill at end of each paragraph that should be filled.
572 Do not append @refill to paragraphs within @example and similar environments.
573 Do not append @refill to paragraphs containing @w{TEXT} or @*."
575 ;; It is necessary to append @refill before other processing because
576 ;; the other processing removes information that tells Texinfo
577 ;; whether the text should or should not be filled.
579 (while (< (point) (point-max))
580 (let ((refill-blank-lines "^[ \t\n]*$")
581 (case-fold-search nil
)) ; Don't confuse @TeX and @tex....
583 ;; 1. Skip over blank lines;
584 ;; skip over lines beginning with @-commands,
585 ;; but do not skip over lines
586 ;; that are no-refill environments such as @example or
587 ;; that begin with within-paragraph @-commands such as @code.
588 (while (and (looking-at (concat "^@\\|^\\\\\\|" refill-blank-lines
))
592 texinfo-no-refill-regexp
594 texinfo-part-of-para-regexp
596 (< (point) (point-max)))
598 ;; 2. Skip over @example and similar no-refill environments.
599 (if (looking-at texinfo-no-refill-regexp
)
601 (buffer-substring (match-beginning 1) (match-end 1))))
602 (progn (re-search-forward (concat "^@end " environment
) nil t
)
605 ;; 3. Do not refill a paragraph containing @w or @*, or ending
606 ;; with @<newline> followed by a newline.
608 (>= (point) (point-max))
615 ;; Go to end of paragraph and do nothing.
617 ;; 4. Else go to end of paragraph and insert @refill
623 (save-excursion (skip-chars-backward " \t") (point)))
624 ;; `looking-at-backward' not available in v. 18.57
625 ;; (if (not (looking-at-backward "@refill\\|@bye")) ;)
626 (if (not (re-search-backward
628 (save-excursion (beginning-of-line) (point))
631 (forward-line 1))))))
634 ;;; Handle `@raisesections' and `@lowersections' commands
636 ;; These commands change the hierarchical level of chapter structuring
639 ;; @raisesections changes @subsection to @section,
640 ;; @section to @chapter,
643 ;; @lowersections changes @chapter to @section
644 ;; @subsection to @subsubsection,
647 ;; An @raisesections/@lowersections command changes only those
648 ;; structuring commands that follow the @raisesections/@lowersections
651 ;; Repeated @raisesections/@lowersections continue to raise or lower
652 ;; the heading level.
654 ;; An @lowersections command cancels an @raisesections command, and
657 ;; You cannot raise or lower "beyond" chapters or subsubsections, but
658 ;; trying to do so does not elicit an error---you just get more
659 ;; headings that mean the same thing as you keep raising or lowering
660 ;; (for example, after a single @raisesections, both @chapter and
661 ;; @section produce chapter headings).
663 (defun texinfo-raise-lower-sections ()
664 "Raise or lower the hierarchical level of chapters, sections, etc.
666 This function acts according to `@raisesections' and `@lowersections'
667 commands in the Texinfo file.
669 For example, an `@lowersections' command is useful if you wish to
670 include what is written as an outer or standalone Texinfo file in
671 another Texinfo file as an inner, included file. The `@lowersections'
672 command changes chapters to sections, sections to subsections and so
675 @raisesections changes @subsection to @section,
676 @section to @chapter,
677 @heading to @chapheading,
680 @lowersections changes @chapter to @section,
681 @subsection to @subsubsection,
682 @heading to @subheading,
685 An `@raisesections' or `@lowersections' command changes only those
686 structuring commands that follow the `@raisesections' or
687 `@lowersections' command.
689 An `@lowersections' command cancels an `@raisesections' command, and
692 Repeated use of the commands continue to raise or lower the hierarchical
693 level a step at a time.
695 An attempt to raise above `chapters' reproduces chapter commands; an
696 attempt to lower below subsubsections reproduces subsubsection
699 ;; `texinfo-section-types-regexp' is defined in `texnfo-upd.el';
700 ;; it is a regexp matching chapter, section, other headings
701 ;; (but not the top node).
703 (let (type (level 0))
707 "\\(\\(^@\\(raise\\|lower\\)sections\\)\\|\\("
708 texinfo-section-types-regexp
712 (save-excursion (setq type
(read (current-buffer))))
715 ;; 1. Increment level
716 ((eq type
'@raisesections
)
717 (setq level
(1+ level
))
719 (point) (save-excursion (forward-line 1) (point))))
721 ;; 2. Decrement level
722 ((eq type
'@lowersections
)
723 (setq level
(1- level
))
725 (point) (save-excursion (forward-line 1) (point))))
727 ;; Now handle structuring commands
730 ;; 3. Raise level when positive
736 (cdr (assq new-level texinfo-raisesections-alist
)))
737 (setq count
(1- count
)))
739 (insert (symbol-name new-level
))))
741 ;; 4. Do nothing except move point when level is zero
742 ((= level
0) (forward-line 1))
744 ;; 5. Lower level when positive
750 (cdr (assq new-level texinfo-lowersections-alist
)))
751 (setq count
(1+ count
)))
753 (insert (symbol-name new-level
))))))))))
755 (defvar texinfo-raisesections-alist
756 '((@chapter .
@chapter
) ; Cannot go higher
757 (@unnumbered .
@unnumbered
)
758 (@centerchap .
@unnumbered
)
760 (@majorheading .
@majorheading
)
761 (@chapheading .
@chapheading
)
762 (@appendix .
@appendix
)
764 (@section .
@chapter
)
765 (@unnumberedsec .
@unnumbered
)
766 (@heading .
@chapheading
)
767 (@appendixsec .
@appendix
)
769 (@subsection .
@section
)
770 (@unnumberedsubsec .
@unnumberedsec
)
771 (@subheading .
@heading
)
772 (@appendixsubsec .
@appendixsec
)
774 (@subsubsection .
@subsection
)
775 (@unnumberedsubsubsec .
@unnumberedsubsec
)
776 (@subsubheading .
@subheading
)
777 (@appendixsubsubsec .
@appendixsubsec
))
778 "*An alist of next higher levels for chapters, sections. etc.
779 For example, section to chapter, subsection to section.
780 Used by `texinfo-raise-lower-sections'.
781 The keys specify types of section; the values correspond to the next
784 (defvar texinfo-lowersections-alist
785 '((@chapter .
@section
)
786 (@unnumbered .
@unnumberedsec
)
787 (@centerchap .
@unnumberedsec
)
788 (@majorheading .
@heading
)
789 (@chapheading .
@heading
)
790 (@appendix .
@appendixsec
)
792 (@section .
@subsection
)
793 (@unnumberedsec .
@unnumberedsubsec
)
794 (@heading .
@subheading
)
795 (@appendixsec .
@appendixsubsec
)
797 (@subsection .
@subsubsection
)
798 (@unnumberedsubsec .
@unnumberedsubsubsec
)
799 (@subheading .
@subsubheading
)
800 (@appendixsubsec .
@appendixsubsubsec
)
802 (@subsubsection .
@subsubsection
) ; Cannot go lower.
803 (@unnumberedsubsubsec .
@unnumberedsubsubsec
)
804 (@subsubheading .
@subsubheading
)
805 (@appendixsubsubsec .
@appendixsubsubsec
))
806 "*An alist of next lower levels for chapters, sections. etc.
807 For example, chapter to section, section to subsection.
808 Used by `texinfo-raise-lower-sections'.
809 The keys specify types of section; the values correspond to the next
813 ;;; Perform those texinfo-to-info conversions that apply to the whole input
816 (defun texinfo-format-scan ()
817 (texinfo-format-convert (point-min) (point-max))
818 ;; Scan for @-commands.
819 (goto-char (point-min))
820 (while (search-forward "@" nil t
)
822 ;; These are the single-character accent commands: @^ @` @' @" @= @~
823 ;; In Info, they are simply quoted and the @ deleted.
824 ;; Other single-character commands:
825 ;; @* forces a line break,
826 ;; @- is a discretionary hyphenation point; does nothing in Info.
827 ;; @<space>, @<tab>, @<newline> each produce a single space,
828 ;; unless followed by a newline.
830 ;; Old version 2.34 expression: (looking-at "[@{}^'` *\"?!]")
831 (if (looking-at "[@{}^'`\"=~ \t\n*?!-]")
832 ;; @*, causes a line break.
835 ((= (following-char) ?
*)
837 (delete-region (1- (point)) (1+ (point)))
838 ;; insert return if not at end of line;
839 ;; else line is already broken.
840 (if (not (= (following-char) ?
\n))
843 ((= (following-char) ?-
)
844 (delete-region (1- (point)) (1+ (point))))
845 ;; @<space>, @<tab>, @<newline>: produce a single space,
846 ;; unless followed by a newline.
847 ((= (following-char) ?
)
848 (delete-region (1- (point)) (1+ (point)))
849 ;; insert single space if not at end of line;
850 ;; else line is already broken.
851 (if (not (= (following-char) ?
\n))
853 ((= (following-char) ?
\t)
854 (delete-region (1- (point)) (1+ (point)))
855 ;; insert single space if not at end of line;
856 ;; else line is already broken.
857 (if (not (= (following-char) ?
\n))
859 ;; following char is a carriage return
860 ((= (following-char) ?
863 (delete-region (1- (point)) (1+ (point)))
864 ;; insert single space if not at end of line;
865 ;; else line is already broken.
866 (if (not (= (following-char) ?
\n))
868 ;; Otherwise: the other characters are simply quoted. Delete the @.
872 ;; @ is followed by a command-word; find the end of the word.
873 (setq texinfo-command-start
(1- (point)))
874 (if (= (char-syntax (following-char)) ?w
)
877 (setq texinfo-command-end
(point))
878 ;; Handle let aliasing
879 (setq texinfo-command-name
883 (1+ texinfo-command-start
) texinfo-command-end
)))
884 (while (setq trial
(assoc cmdname texinfo-alias-list
))
885 (setq cmdname
(cdr trial
)))
887 ;; Call the handler for this command.
888 (let ((enclosure-type
890 (symbol-name texinfo-command-name
)
891 texinfo-enclosure-list
)))
895 (car (car (cdr enclosure-type
)))
896 (texinfo-parse-arg-discard)
897 (car (cdr (car (cdr enclosure-type
)))))
898 (goto-char texinfo-command-start
))
899 (let ((cmd (get texinfo-command-name
'texinfo-format
)))
900 (if cmd
(funcall cmd
) (texinfo-unsupported)))))))
903 (goto-char (nth 2 (car texinfo-stack
)))
904 (error "Unterminated @%s" (car (car texinfo-stack
))))))
906 (put 'begin
'texinfo-format
'texinfo-format-begin
)
907 (defun texinfo-format-begin ()
908 (texinfo-format-begin-end 'texinfo-format
))
910 (put 'end
'texinfo-format
'texinfo-format-end
)
911 (defun texinfo-format-end ()
912 (texinfo-format-begin-end 'texinfo-end
))
914 (defun texinfo-format-begin-end (prop)
915 (setq texinfo-command-name
(intern (texinfo-parse-line-arg)))
916 (let ((cmd (get texinfo-command-name prop
)))
917 (if cmd
(funcall cmd
)
918 (texinfo-unsupported))))
920 ;;; Parsing functions
922 (defun texinfo-parse-line-arg ()
923 "Return argument of @-command as string.
924 Argument is separated from command either by a space or by a brace.
925 If a space, return rest of line, with beginning and ending white
926 space removed. If a brace, return string between braces.
927 Leave point after argument."
928 (goto-char texinfo-command-end
)
929 (let ((start (point)))
930 (cond ((looking-at " ")
931 (skip-chars-forward " ")
934 (skip-chars-backward " ")
935 (delete-region (point) (progn (end-of-line) (point)))
936 (setq texinfo-command-end
(1+ (point))))
938 (setq start
(1+ (point)))
940 (setq texinfo-command-end
(point))
943 (error "Invalid texinfo command arg format")))
944 (prog1 (buffer-substring start
(point))
945 (if (eolp) (forward-char 1)))))
947 (defun texinfo-parse-expanded-arg ()
948 (goto-char texinfo-command-end
)
949 (let ((start (point))
951 (cond ((looking-at " ")
952 (skip-chars-forward " ")
955 (setq texinfo-command-end
(1+ (point))))
957 (setq start
(1+ (point)))
959 (setq texinfo-command-end
(point))
962 (error "Invalid texinfo command arg format")))
963 (setq marker
(move-marker (make-marker) texinfo-command-end
))
964 (texinfo-format-expand-region start
(point))
965 (setq texinfo-command-end
(marker-position marker
))
966 (move-marker marker nil
)
967 (prog1 (buffer-substring start
(point))
968 (if (eolp) (forward-char 1)))))
970 (defun texinfo-format-expand-region (start end
)
972 (narrow-to-region start end
)
973 (let (texinfo-command-start
977 (texinfo-format-scan))
978 (goto-char (point-max))))
980 (defun texinfo-parse-arg-discard ()
981 "Delete command and argument; return argument of command."
982 (prog1 (texinfo-parse-line-arg)
983 (texinfo-discard-command)))
985 (defun texinfo-discard-command ()
986 (delete-region texinfo-command-start texinfo-command-end
))
988 (defun texinfo-optional-braces-discard ()
989 "Discard braces following command, if any."
990 (goto-char texinfo-command-end
)
991 (let ((start (point)))
992 (cond ((looking-at "[ \t]*\n")) ; do nothing
993 ((looking-at "{") ; remove braces, if any
995 (setq texinfo-command-end
(point)))
998 "Invalid `texinfo-optional-braces-discard' format \(need braces?\)")))
999 (delete-region texinfo-command-start texinfo-command-end
)))
1001 (defun texinfo-format-parse-line-args ()
1002 (let ((start (1- (point)))
1005 (skip-chars-forward " ")
1008 (re-search-forward "[\n,]")
1010 (if (bolp) (setq next
(1- next
)))
1012 (skip-chars-backward " ")
1014 (setq args
(cons (if (> end beg
) (buffer-substring beg end
))
1017 (skip-chars-forward " "))
1018 (if (eolp) (forward-char 1))
1019 (setq texinfo-command-end
(point))
1022 (defun texinfo-format-parse-args ()
1023 (let ((start (1- (point)))
1026 (search-forward "{")
1028 (texinfo-format-expand-region
1030 (save-excursion (up-list 1) (1- (point)))))
1031 ;; The following does not handle cross references of the form:
1032 ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the
1033 ;; re-search-forward finds the first right brace after the second
1035 (while (/= (preceding-char) ?\
})
1036 (skip-chars-forward " \t\n")
1038 (re-search-forward "[},]")
1041 (skip-chars-backward " \t\n")
1045 (while (search-forward "\n" end t
)
1046 (replace-match " "))))
1047 (setq args
(cons (if (> end beg
) (buffer-substring beg end
))
1050 (if (eolp) (forward-char 1))
1051 (setq texinfo-command-end
(point))
1054 (defun texinfo-format-parse-defun-args ()
1055 (goto-char texinfo-command-end
)
1056 (let ((start (point)))
1058 (setq texinfo-command-end
(1+ (point)))
1059 (let ((marker (move-marker (make-marker) texinfo-command-end
)))
1060 (texinfo-format-expand-region start
(point))
1061 (setq texinfo-command-end
(marker-position marker
))
1062 (move-marker marker nil
))
1066 (skip-chars-forward " ")
1068 (cond ((looking-at "{")
1069 (setq beg
(1+ (point)))
1071 (setq end
(1- (point))))
1074 (re-search-forward "[\n ]")
1076 (setq end
(point))))
1077 (setq args
(cons (buffer-substring beg end
) args
))
1078 (skip-chars-forward " "))
1082 (defun texinfo-discard-line ()
1083 (goto-char texinfo-command-end
)
1084 (skip-chars-forward " \t")
1086 (error "Extraneous text at end of command line."))
1087 (goto-char texinfo-command-start
)
1089 (error "Extraneous text at beginning of command line."))
1090 (delete-region (point) (progn (forward-line 1) (point))))
1092 (defun texinfo-discard-line-with-args ()
1093 (goto-char texinfo-command-start
)
1094 (delete-region (point) (progn (forward-line 1) (point))))
1099 ;; Only `texinfo-format-buffer' handles @setfilename with this
1100 ;; definition; `texinfo-format-region' handles @setfilename, if any,
1102 (put 'setfilename
'texinfo-format
'texinfo-format-setfilename
)
1103 (defun texinfo-format-setfilename ()
1104 (texinfo-parse-arg-discard))
1106 ;;; @node, @menu, @detailmenu
1108 (put 'node
'texinfo-format
'texinfo-format-node
)
1109 (put 'nwnode
'texinfo-format
'texinfo-format-node
)
1110 (defun texinfo-format-node ()
1111 (let* ((args (texinfo-format-parse-line-args))
1116 (texinfo-discard-command)
1117 (setq texinfo-last-node name
)
1118 (let ((tem (downcase name
)))
1119 (if (assoc tem texinfo-node-names
)
1120 (error "Duplicate node name: %s" name
)
1121 (setq texinfo-node-names
(cons (list tem
) texinfo-node-names
))))
1122 (setq texinfo-footnote-number
0)
1123 ;; insert "\n\^_" unconditionally since this is what info is looking for
1124 (insert "\n\^_\nFile: " texinfo-format-filename
1127 (insert ", Next: " next
))
1129 (insert ", Prev: " prev
))
1131 (insert ", Up: " up
))
1133 (setq texinfo-last-node-pos
(point))))
1135 (put 'menu
'texinfo-format
'texinfo-format-menu
)
1136 (defun texinfo-format-menu ()
1137 (texinfo-discard-line)
1138 (insert "* Menu:\n\n"))
1140 (put 'menu
'texinfo-end
'texinfo-discard-command
)
1142 ;; The @detailmenu should be removed eventually.
1144 ;; According to Karl Berry, 31 August 1996:
1146 ;; You don't like, I don't like it. I agree, it would be better just to
1147 ;; fix the bug [in `makeinfo']. .. At this point, since inserting those
1148 ;; two commands in the Elisp fn is trivial, I don't especially want to
1149 ;; expend more effort...
1151 ;; I added a couple sentences of documentation to the manual (putting the
1152 ;; blame on makeinfo where it belongs :-().
1154 (put 'detailmenu
'texinfo-format
'texinfo-discard-line
)
1155 (put 'detailmenu
'texinfo-end
'texinfo-discard-command
)
1157 ;; (Also see `texnfo-upd.el')
1160 ;;; Cross references
1162 ;; @xref {NODE, FNAME, NAME, FILE, DOCUMENT}
1163 ;; -> *Note FNAME: (FILE)NODE
1164 ;; If FILE is missing,
1165 ;; *Note FNAME: NODE
1166 ;; If FNAME is empty and NAME is present
1168 ;; If both NAME and FNAME are missing
1170 ;; texinfo ignores the DOCUMENT argument.
1171 ;; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1172 ;; If FILE is specified, (FILE)NODE is used for xrefs.
1173 ;; If fifth argument DOCUMENT is specified, produces
1174 ;; See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1177 ;; @ref a reference that does not put `See' or `see' in
1178 ;; the hardcopy and is the same as @xref in Info
1179 (put 'ref
'texinfo-format
'texinfo-format-xref
)
1181 (put 'xref
'texinfo-format
'texinfo-format-xref
)
1182 (defun texinfo-format-xref ()
1183 (let ((args (texinfo-format-parse-args)))
1184 (texinfo-discard-command)
1186 (let ((fname (or (nth 1 args
) (nth 2 args
))))
1187 (if (null (or fname
(nth 3 args
)))
1188 (insert (car args
) "::")
1189 (insert (or fname
(car args
)) ": ")
1191 (insert "(" (nth 3 args
) ")"))
1192 (insert (car args
))))))
1194 (put 'pxref
'texinfo-format
'texinfo-format-pxref
)
1195 (defun texinfo-format-pxref ()
1196 (texinfo-format-xref)
1202 ;; @inforef{NODE, FNAME, FILE}
1203 ;; Like @xref{NODE, FNAME,,FILE} in texinfo.
1204 ;; In Tex, generates "See Info file FILE, node NODE"
1205 (put 'inforef
'texinfo-format
'texinfo-format-inforef
)
1206 (defun texinfo-format-inforef ()
1207 (let ((args (texinfo-format-parse-args)))
1208 (texinfo-discard-command)
1210 (insert "*Note " (nth 1 args
) ": (" (nth 2 args
) ")" (car args
))
1211 (insert "*Note " "(" (nth 2 args
) ")" (car args
) "::"))))
1214 ;;; Section headings
1216 (put 'majorheading
'texinfo-format
'texinfo-format-chapter
)
1217 (put 'chapheading
'texinfo-format
'texinfo-format-chapter
)
1218 (put 'ichapter
'texinfo-format
'texinfo-format-chapter
)
1219 (put 'chapter
'texinfo-format
'texinfo-format-chapter
)
1220 (put 'iappendix
'texinfo-format
'texinfo-format-chapter
)
1221 (put 'appendix
'texinfo-format
'texinfo-format-chapter
)
1222 (put 'iunnumbered
'texinfo-format
'texinfo-format-chapter
)
1223 (put 'top
'texinfo-format
'texinfo-format-chapter
)
1224 (put 'unnumbered
'texinfo-format
'texinfo-format-chapter
)
1225 (put 'centerchap
'texinfo-format
'texinfo-format-chapter
)
1226 (defun texinfo-format-chapter ()
1227 (texinfo-format-chapter-1 ?
*))
1229 (put 'heading
'texinfo-format
'texinfo-format-section
)
1230 (put 'isection
'texinfo-format
'texinfo-format-section
)
1231 (put 'section
'texinfo-format
'texinfo-format-section
)
1232 (put 'iappendixsection
'texinfo-format
'texinfo-format-section
)
1233 (put 'appendixsection
'texinfo-format
'texinfo-format-section
)
1234 (put 'iappendixsec
'texinfo-format
'texinfo-format-section
)
1235 (put 'appendixsec
'texinfo-format
'texinfo-format-section
)
1236 (put 'iunnumberedsec
'texinfo-format
'texinfo-format-section
)
1237 (put 'unnumberedsec
'texinfo-format
'texinfo-format-section
)
1238 (defun texinfo-format-section ()
1239 (texinfo-format-chapter-1 ?
=))
1241 (put 'subheading
'texinfo-format
'texinfo-format-subsection
)
1242 (put 'isubsection
'texinfo-format
'texinfo-format-subsection
)
1243 (put 'subsection
'texinfo-format
'texinfo-format-subsection
)
1244 (put 'iappendixsubsec
'texinfo-format
'texinfo-format-subsection
)
1245 (put 'appendixsubsec
'texinfo-format
'texinfo-format-subsection
)
1246 (put 'iunnumberedsubsec
'texinfo-format
'texinfo-format-subsection
)
1247 (put 'unnumberedsubsec
'texinfo-format
'texinfo-format-subsection
)
1248 (defun texinfo-format-subsection ()
1249 (texinfo-format-chapter-1 ?-
))
1251 (put 'subsubheading
'texinfo-format
'texinfo-format-subsubsection
)
1252 (put 'isubsubsection
'texinfo-format
'texinfo-format-subsubsection
)
1253 (put 'subsubsection
'texinfo-format
'texinfo-format-subsubsection
)
1254 (put 'iappendixsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1255 (put 'appendixsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1256 (put 'iunnumberedsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1257 (put 'unnumberedsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1258 (defun texinfo-format-subsubsection ()
1259 (texinfo-format-chapter-1 ?.
))
1261 (defun texinfo-format-chapter-1 (belowchar)
1262 (let ((arg (texinfo-parse-arg-discard)))
1263 (message "Formatting: %s ... " arg
) ; So we can see where we are.
1264 (insert ?
\n arg ?
\n "@SectionPAD " belowchar ?
\n)
1267 (put 'SectionPAD
'texinfo-format
'texinfo-format-sectionpad
)
1268 (defun texinfo-format-sectionpad ()
1269 (let ((str (texinfo-parse-arg-discard)))
1271 (let ((column (current-column)))
1275 (setq column
(1- column
))))
1279 ;;; Space controlling commands: @. and @:, and the soft hyphen.
1281 (put '\.
'texinfo-format
'texinfo-format-\.
)
1282 (defun texinfo-format-\.
()
1283 (texinfo-discard-command)
1286 (put '\
: 'texinfo-format
'texinfo-format-\
:)
1287 (defun texinfo-format-\
: ()
1288 (texinfo-discard-command))
1290 (put '\-
'texinfo-format
'texinfo-format-soft-hyphen
)
1291 (defun texinfo-format-soft-hyphen ()
1292 (texinfo-discard-command))
1295 ;;; @center, @sp, and @br
1297 (put 'center
'texinfo-format
'texinfo-format-center
)
1298 (defun texinfo-format-center ()
1299 (let ((arg (texinfo-parse-expanded-arg)))
1300 (texinfo-discard-command)
1304 (goto-char (1- (point)))
1305 (let ((indent-tabs-mode nil
))
1308 (put 'sp
'texinfo-format
'texinfo-format-sp
)
1309 (defun texinfo-format-sp ()
1310 (let* ((arg (texinfo-parse-arg-discard))
1312 (insert-char ?
\n num
)))
1314 (put 'br
'texinfo-format
'texinfo-format-paragraph-break
)
1315 (defun texinfo-format-paragraph-break ()
1316 "Force a paragraph break.
1317 If used within a line, follow `@br' with braces."
1318 (texinfo-optional-braces-discard)
1319 ;; insert one return if at end of line;
1320 ;; else insert two returns, to generate a blank line.
1321 (if (= (following-char) ?
\n)
1323 (insert-char ?
\n 2)))
1326 ;;; @footnote and @footnotestyle
1328 ;; In Texinfo, footnotes are created with the `@footnote' command.
1329 ;; This command is followed immediately by a left brace, then by the text of
1330 ;; the footnote, and then by a terminating right brace. The
1331 ;; template for a footnote is:
1335 ;; Info has two footnote styles:
1337 ;; * In the End of node style, all the footnotes for a single node
1338 ;; are placed at the end of that node. The footnotes are
1339 ;; separated from the rest of the node by a line of dashes with
1340 ;; the word `Footnotes' within it.
1342 ;; * In the Separate node style, all the footnotes for a single node
1343 ;; are placed in an automatically constructed node of their own.
1345 ;; Footnote style is specified by the @footnotestyle command, either
1346 ;; @footnotestyle separate
1348 ;; @footnotestyle end
1350 ;; The default is separate
1352 (defvar texinfo-footnote-style
"separate"
1353 "Footnote style, either separate or end.")
1355 (put 'footnotestyle
'texinfo-format
'texinfo-footnotestyle
)
1356 (defun texinfo-footnotestyle ()
1357 "Specify whether footnotes are at end of node or in separate nodes.
1358 Argument is either end or separate."
1359 (setq texinfo-footnote-style
(texinfo-parse-arg-discard)))
1361 (defvar texinfo-footnote-number
)
1363 (put 'footnote
'texinfo-format
'texinfo-format-footnote
)
1364 (defun texinfo-format-footnote ()
1365 "Format a footnote in either end of node or separate node style.
1366 The texinfo-footnote-style variable controls which style is used."
1367 (setq texinfo-footnote-number
(1+ texinfo-footnote-number
))
1368 (cond ((string= texinfo-footnote-style
"end")
1369 (texinfo-format-end-node))
1370 ((string= texinfo-footnote-style
"separate")
1371 (texinfo-format-separate-node))))
1373 (defun texinfo-format-separate-node ()
1374 "Format footnote in Separate node style, with notes in own node.
1375 The node is constructed automatically."
1377 (arg (texinfo-parse-line-arg))
1378 (node-name-beginning
1381 "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:")
1386 (progn (goto-char node-name-beginning
) ; skip over node command
1387 (skip-chars-forward " \t") ; and over spaces
1391 (save-excursion (end-of-line) (point)) t
) ; bound search
1393 (end-of-line) (point))))))
1394 (texinfo-discard-command) ; remove or insert whitespace, as needed
1395 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1397 (insert (format " (%d) (*Note %s-Footnotes::)"
1398 texinfo-footnote-number node-name
))
1399 (fill-paragraph nil
)
1401 (if (re-search-forward "^@node" nil
'move
)
1404 ;; two cases: for the first footnote, we must insert a node header;
1405 ;; for the second and subsequent footnotes, we need only insert
1406 ;; the text of the footnote.
1410 (concat node-name
"-Footnotes, Up: ")
1413 (progn ; already at least one footnote
1414 (setq start
(point))
1415 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1416 (fill-region start
(point)))
1417 ;; else not yet a footnote
1418 (insert "\n\^_\nFile: " texinfo-format-filename
1419 " Node: " node-name
"-Footnotes, Up: " node-name
"\n")
1420 (setq start
(point))
1421 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1422 (fill-region start
(point))))))
1424 (defun texinfo-format-end-node ()
1425 "Format footnote in the End of node style, with notes at end of node."
1427 (arg (texinfo-parse-line-arg)))
1428 (texinfo-discard-command) ; remove or insert whitespace, as needed
1429 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1431 (insert (format " (%d) " texinfo-footnote-number
))
1432 (fill-paragraph nil
)
1434 (if (search-forward "\n--------- Footnotes ---------\n" nil t
)
1435 (progn ; already have footnote, put new one before end of node
1436 (if (re-search-forward "^@node" nil
'move
)
1438 (setq start
(point))
1439 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1440 (fill-region start
(point)))
1441 ;; else no prior footnote
1442 (if (re-search-forward "^@node" nil
'move
)
1444 (insert "\n--------- Footnotes ---------\n")
1445 (setq start
(point))
1446 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))))))
1449 ;;; @itemize, @enumerate, and similar commands
1451 ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.
1452 ;; @enumerate pushes (enumerate 0 STARTPOS).
1453 ;; @item dispatches to the texinfo-item prop of the first elt of the list.
1454 ;; For itemize, this puts in and rescans the COMMANDS.
1455 ;; For enumerate, this increments the number and puts it in.
1456 ;; In either case, it puts a Backspace at the front of the line
1457 ;; which marks it not to be indented later.
1458 ;; All other lines get indented by 5 when the @end is reached.
1460 (defvar texinfo-stack-depth
0
1461 "Count of number of unpopped texinfo-push-stack calls.
1462 Used by @refill indenting command to avoid indenting within lists, etc.")
1464 (defun texinfo-push-stack (check arg
)
1465 (setq texinfo-stack-depth
(1+ texinfo-stack-depth
))
1467 (cons (list check arg texinfo-command-start
)
1470 (defun texinfo-pop-stack (check)
1471 (setq texinfo-stack-depth
(1- texinfo-stack-depth
))
1472 (if (null texinfo-stack
)
1473 (error "Unmatched @end %s" check
))
1474 (if (not (eq (car (car texinfo-stack
)) check
))
1475 (error "@end %s matches @%s"
1476 check
(car (car texinfo-stack
))))
1477 (prog1 (cdr (car texinfo-stack
))
1478 (setq texinfo-stack
(cdr texinfo-stack
))))
1480 (put 'itemize
'texinfo-format
'texinfo-itemize
)
1481 (defun texinfo-itemize ()
1484 (progn (skip-chars-forward " \t")
1487 (texinfo-parse-line-arg))))
1488 (texinfo-discard-line-with-args)
1489 (setq fill-column
(- fill-column
5)))
1491 (put 'itemize
'texinfo-end
'texinfo-end-itemize
)
1492 (defun texinfo-end-itemize ()
1493 (setq fill-column
(+ fill-column
5))
1494 (texinfo-discard-command)
1496 (texinfo-pop-stack 'itemize
)))
1497 (texinfo-do-itemize (nth 1 stacktop
))))
1499 (put 'enumerate
'texinfo-format
'texinfo-enumerate
)
1500 (defun texinfo-enumerate ()
1503 (progn (skip-chars-forward " \t")
1506 (read (current-buffer)))))
1507 (if (and (symbolp (car (cdr (car texinfo-stack
))))
1508 (> 1 (length (symbol-name (car (cdr (car texinfo-stack
)))))))
1510 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." ))
1511 (texinfo-discard-line-with-args)
1512 (setq fill-column
(- fill-column
5)))
1514 (put 'enumerate
'texinfo-end
'texinfo-end-enumerate
)
1515 (defun texinfo-end-enumerate ()
1516 (setq fill-column
(+ fill-column
5))
1517 (texinfo-discard-command)
1519 (texinfo-pop-stack 'enumerate
)))
1520 (texinfo-do-itemize (nth 1 stacktop
))))
1522 ;; @alphaenumerate never became a standard part of Texinfo
1523 (put 'alphaenumerate
'texinfo-format
'texinfo-alphaenumerate
)
1524 (defun texinfo-alphaenumerate ()
1525 (texinfo-push-stack 'alphaenumerate
(1- ?a
))
1526 (setq fill-column
(- fill-column
5))
1527 (texinfo-discard-line))
1529 (put 'alphaenumerate
'texinfo-end
'texinfo-end-alphaenumerate
)
1530 (defun texinfo-end-alphaenumerate ()
1531 (setq fill-column
(+ fill-column
5))
1532 (texinfo-discard-command)
1534 (texinfo-pop-stack 'alphaenumerate
)))
1535 (texinfo-do-itemize (nth 1 stacktop
))))
1537 ;; @capsenumerate never became a standard part of Texinfo
1538 (put 'capsenumerate
'texinfo-format
'texinfo-capsenumerate
)
1539 (defun texinfo-capsenumerate ()
1540 (texinfo-push-stack 'capsenumerate
(1- ?A
))
1541 (setq fill-column
(- fill-column
5))
1542 (texinfo-discard-line))
1544 (put 'capsenumerate
'texinfo-end
'texinfo-end-capsenumerate
)
1545 (defun texinfo-end-capsenumerate ()
1546 (setq fill-column
(+ fill-column
5))
1547 (texinfo-discard-command)
1549 (texinfo-pop-stack 'capsenumerate
)))
1550 (texinfo-do-itemize (nth 1 stacktop
))))
1552 ;; At the @end, indent all the lines within the construct
1553 ;; except those marked with backspace. FROM says where
1554 ;; construct started.
1555 (defun texinfo-do-itemize (from)
1557 (while (progn (forward-line -
1)
1559 (if (= (following-char) ?
\b)
1564 (if (not (looking-at "[ \t]*$"))
1565 (save-excursion (insert " ")))))))
1567 (put 'item
'texinfo-format
'texinfo-item
)
1568 (put 'itemx
'texinfo-format
'texinfo-item
)
1569 (defun texinfo-item ()
1570 (funcall (get (car (car texinfo-stack
)) 'texinfo-item
)))
1572 (put 'itemize
'texinfo-item
'texinfo-itemize-item
)
1573 (defun texinfo-itemize-item ()
1574 ;; (texinfo-discard-line) ; Did not handle text on same line as @item.
1575 (delete-region (1+ (point)) (save-excursion (beginning-of-line) (point)))
1576 (if (looking-at "[ \t]*[^ \t\n]+")
1577 ;; Text on same line as @item command.
1578 (insert "\b " (nth 1 (car texinfo-stack
)) " \n")
1579 ;; Else text on next line.
1580 (insert "\b " (nth 1 (car texinfo-stack
)) " "))
1583 (put 'enumerate
'texinfo-item
'texinfo-enumerate-item
)
1584 (defun texinfo-enumerate-item ()
1585 (texinfo-discard-line)
1586 (let (enumerating-symbol)
1587 (cond ((integerp (car (cdr (car texinfo-stack
))))
1588 (setq enumerating-symbol
(car (cdr (car texinfo-stack
))))
1589 (insert ?
\b (format "%3d. " enumerating-symbol
) ?
\n)
1590 (setcar (cdr (car texinfo-stack
)) (1+ enumerating-symbol
)))
1591 ((symbolp (car (cdr (car texinfo-stack
))))
1592 (setq enumerating-symbol
1593 (symbol-name (car (cdr (car texinfo-stack
)))))
1594 (if (or (equal ?\
[ (string-to-char enumerating-symbol
))
1595 (equal ?\
{ (string-to-char enumerating-symbol
)))
1597 "Too many items in enumerated list; alphabet ends at Z."))
1598 (insert ?
\b (format "%3s. " enumerating-symbol
) ?
\n)
1599 (setcar (cdr (car texinfo-stack
))
1603 (string-to-char enumerating-symbol
))))))
1606 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." )))
1609 (put 'alphaenumerate
'texinfo-item
'texinfo-alphaenumerate-item
)
1610 (defun texinfo-alphaenumerate-item ()
1611 (texinfo-discard-line)
1612 (let ((next (1+ (car (cdr (car texinfo-stack
))))))
1614 (error "More than 26 items in @alphaenumerate; get a bigger alphabet."))
1615 (setcar (cdr (car texinfo-stack
)) next
)
1616 (insert "\b " next
". \n"))
1619 (put 'capsenumerate
'texinfo-item
'texinfo-capsenumerate-item
)
1620 (defun texinfo-capsenumerate-item ()
1621 (texinfo-discard-line)
1622 (let ((next (1+ (car (cdr (car texinfo-stack
))))))
1624 (error "More than 26 items in @capsenumerate; get a bigger alphabet."))
1625 (setcar (cdr (car texinfo-stack
)) next
)
1626 (insert "\b " next
". \n"))
1632 ;; The `@table' command produces two-column tables.
1634 (put 'table
'texinfo-format
'texinfo-table
)
1635 (defun texinfo-table ()
1638 (progn (skip-chars-forward " \t")
1641 (texinfo-parse-line-arg))))
1642 (texinfo-discard-line-with-args)
1643 (setq fill-column
(- fill-column
5)))
1645 (put 'table
'texinfo-item
'texinfo-table-item
)
1646 (defun texinfo-table-item ()
1647 (let ((arg (texinfo-parse-arg-discard))
1648 (itemfont (car (cdr (car texinfo-stack
)))))
1649 (insert ?
\b itemfont ?\
{ arg
"}\n \n"))
1652 (put 'table
'texinfo-end
'texinfo-end-table
)
1653 (defun texinfo-end-table ()
1654 (setq fill-column
(+ fill-column
5))
1655 (texinfo-discard-command)
1657 (texinfo-pop-stack 'table
)))
1658 (texinfo-do-itemize (nth 1 stacktop
))))
1660 ;; @description appears to be an undocumented variant on @table that
1661 ;; does not require an arg. It fails in texinfo.tex 2.58 and is not
1662 ;; part of makeinfo.c The command appears to be a relic of the past.
1663 (put 'description
'texinfo-end
'texinfo-end-table
)
1664 (put 'description
'texinfo-format
'texinfo-description
)
1665 (defun texinfo-description ()
1666 (texinfo-push-stack 'table
"@asis")
1667 (setq fill-column
(- fill-column
5))
1668 (texinfo-discard-line))
1671 ;;; @ftable, @vtable
1673 ;; The `@ftable' and `@vtable' commands are like the `@table' command
1674 ;; but they also insert each entry in the first column of the table
1675 ;; into the function or variable index.
1677 ;; Handle the @ftable and @vtable commands:
1679 (put 'ftable
'texinfo-format
'texinfo-ftable
)
1680 (put 'vtable
'texinfo-format
'texinfo-vtable
)
1682 (defun texinfo-ftable () (texinfo-indextable 'ftable
))
1683 (defun texinfo-vtable () (texinfo-indextable 'vtable
))
1685 (defun texinfo-indextable (table-type)
1686 (texinfo-push-stack table-type
(texinfo-parse-arg-discard))
1687 (setq fill-column
(- fill-column
5)))
1689 ;; Handle the @item commands within ftable and vtable:
1691 (put 'ftable
'texinfo-item
'texinfo-ftable-item
)
1692 (put 'vtable
'texinfo-item
'texinfo-vtable-item
)
1694 (defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex
))
1695 (defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex
))
1697 (defun texinfo-indextable-item (index-type)
1698 (let ((item (texinfo-parse-arg-discard))
1699 (itemfont (car (cdr (car texinfo-stack
))))
1700 (indexvar index-type
))
1701 (insert ?
\b itemfont ?\
{ item
"}\n \n")
1704 (list item texinfo-last-node
)
1705 (symbol-value indexvar
)))
1708 ;; Handle @end ftable, @end vtable
1710 (put 'ftable
'texinfo-end
'texinfo-end-ftable
)
1711 (put 'vtable
'texinfo-end
'texinfo-end-vtable
)
1713 (defun texinfo-end-ftable () (texinfo-end-indextable 'ftable
))
1714 (defun texinfo-end-vtable () (texinfo-end-indextable 'vtable
))
1716 (defun texinfo-end-indextable (table-type)
1717 (setq fill-column
(+ fill-column
5))
1718 (texinfo-discard-command)
1720 (texinfo-pop-stack table-type
)))
1721 (texinfo-do-itemize (nth 1 stacktop
))))
1724 ;;; @multitable ... @end multitable
1726 ;; Produce a multi-column table, with as many columns as desired.
1728 ;; A multi-column table has this template:
1730 ;; @multitable {A1} {A2} {A3}
1731 ;; @item A1 @tab A2 @tab A3
1732 ;; @item B1 @tab B2 @tab B3
1733 ;; @item C1 @tab C2 @tab C3
1736 ;; where the width of the text in brackets specifies the width of the
1737 ;; respective column.
1741 ;; @multitable @columnfractions .25 .3 .45
1742 ;; @item A1 @tab A2 @tab A3
1743 ;; @item B1 @tab B2 @tab B3
1746 ;; where the fractions specify the width of each column as a percent
1747 ;; of the current width of the text (i.e., of the fill-column).
1749 ;; Long lines of text are filled within columns.
1751 ;; Using the Emacs Lisp formatter, texinfmt.el,
1752 ;; the whitespace between columns can be increased by setting
1753 ;; `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1754 ;; there is at least one blank space between columns.
1756 ;; The Emacs Lisp formatter, texinfmt.el, ignores the following four
1757 ;; commands that are defined in texinfo.tex for printed output.
1759 ;; @multitableparskip,
1760 ;; @multitableparindent,
1761 ;; @multitablecolmargin,
1762 ;; @multitablelinespace.
1764 ;; How @multitable works.
1765 ;; =====================
1767 ;; `texinfo-multitable' reads the @multitable line and determines from it
1768 ;; how wide each column should be.
1770 ;; Also, it pushes this information, along with an identifying symbol,
1771 ;; onto the `texinfo-stack'. At the @end multitable command, the stack
1772 ;; is checked for its matching @multitable command, and then popped, or
1773 ;; else an error is signaled. Also, this command pushes the location of
1774 ;; the start of the table onto the stack.
1776 ;; `texinfo-end-multitable' checks the `texinfo-stack' that the @end
1777 ;; multitable truly is ending a corresponding beginning, and if it is,
1780 ;; `texinfo-multitable-widths' is called by `texinfo-multitable'.
1781 ;; The function returns a list of the widths of each column in a
1782 ;; multi-column table, based on the information supplied by the arguments
1783 ;; to the @multitable command (by arguments, I mean the text on the rest
1784 ;; of the @multitable line, not the remainder of the multi-column table
1787 ;; `texinfo-multitable-item' formats a row within a multicolumn table.
1788 ;; This command is executed when texinfmt sees @item inside @multitable.
1789 ;; Cells in row are separated by `@tab's. Widths of cells are specified
1790 ;; by the arguments in the @multitable line. Cells are filled. All cells
1791 ;; are made to be the same height by padding their bottoms, as needed,
1794 ;; `texinfo-multitable-extract-row' is called by `texinfo-multitable-item'.
1795 ;; This function returns the text in a multitable row, as a string.
1796 ;; The start of a row is marked by an @item and the end of row is the
1797 ;; beginning of next @item or beginning of the @end multitable line.
1798 ;; Cells within a row are separated by @tab.
1800 ;; Note that @tab, the cell separators, are not treated as independent
1801 ;; Texinfo commands.
1803 (defvar texinfo-extra-inter-column-width
0
1804 "*Number of extra spaces between entries (columns) in @multitable.")
1806 (defvar texinfo-multitable-buffer-name
"*multitable-temporary-buffer*")
1807 (defvar texinfo-multitable-rectangle-name
"texinfo-multitable-temp-")
1809 ;; These commands are defined in texinfo.tex for printed output.
1810 (put 'multitableparskip
'texinfo-format
'texinfo-discard-line-with-args
)
1811 (put 'multitableparindent
'texinfo-format
'texinfo-discard-line-with-args
)
1812 (put 'multitablecolmargin
'texinfo-format
'texinfo-discard-line-with-args
)
1813 (put 'multitablelinespace
'texinfo-format
'texinfo-discard-line-with-args
)
1815 (put 'multitable
'texinfo-format
'texinfo-multitable
)
1817 (defun texinfo-multitable ()
1818 "Produce multi-column tables.
1820 A multi-column table has this template:
1822 @multitable {A1} {A2} {A3}
1823 @item A1 @tab A2 @tab A3
1824 @item B1 @tab B2 @tab B3
1825 @item C1 @tab C2 @tab C3
1828 where the width of the text in brackets specifies the width of the
1833 @multitable @columnfractions .25 .3 .45
1834 @item A1 @tab A2 @tab A3
1835 @item B1 @tab B2 @tab B3
1838 where the fractions specify the width of each column as a percent
1839 of the current width of the text (i.e., of the fill-column).
1841 Long lines of text are filled within columns.
1843 Using the Emacs Lisp formatter, texinfmt.el,
1844 the whitespace between columns can be increased by setting
1845 `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1846 there is at least one blank space between columns.
1848 The Emacs Lisp formatter, texinfmt.el, ignores the following four
1849 commands that are defined in texinfo.tex for printed output.
1852 @multitableparindent,
1853 @multitablecolmargin,
1854 @multitablelinespace."
1856 ;; This function pushes information onto the `texinfo-stack'.
1857 ;; A stack element consists of:
1858 ;; - type-of-command, i.e., multitable
1859 ;; - the information about column widths, and
1860 ;; - the position of texinfo-command-start.
1861 ;; e.g., ('multitable (1 2 3 4) 123)
1862 ;; The command line is then deleted.
1865 ;; push width information on stack
1866 (texinfo-multitable-widths))
1867 (texinfo-discard-line-with-args))
1869 (put 'multitable
'texinfo-end
'texinfo-end-multitable
)
1870 (defun texinfo-end-multitable ()
1871 "Discard the @end multitable line and pop the stack of multitable."
1872 (texinfo-discard-command)
1873 (texinfo-pop-stack 'multitable
))
1875 (defun texinfo-multitable-widths ()
1876 "Return list of widths of each column in a multi-column table."
1877 (let (texinfo-multitable-width-list)
1878 ;; Fractions format:
1879 ;; @multitable @columnfractions .25 .3 .45
1882 ;; @multitable {Column 1 template} {Column 2} {Column 3 example}
1883 ;; Place point before first argument
1884 (skip-chars-forward " \t")
1886 ;; Check for common misspelling
1887 ((looking-at "@columnfraction ")
1888 (error "In @multitable, @columnfractions misspelled"))
1889 ;; Case 1: @columnfractions .25 .3 .45
1890 ((looking-at "@columnfractions")
1893 (setq texinfo-multitable-width-list
1897 (* fill-column
(read (get-buffer (current-buffer))))))
1898 texinfo-multitable-width-list
))))
1900 ;; Case 2: {Column 1 template} {Column 2} {Column 3 example}
1902 (let ((start-of-templates (point)))
1904 (skip-chars-forward " \t")
1905 (let* ((start-of-template (1+ (point)))
1907 ;; forward-sexp works with braces in Texinfo mode
1908 (progn (forward-sexp 1) (1- (point)))))
1909 (setq texinfo-multitable-width-list
1910 (cons (- end-of-template start-of-template
)
1911 texinfo-multitable-width-list
))
1912 ;; Remove carriage return from within a template, if any.
1913 ;; This helps those those who want to use more than
1914 ;; one line's worth of words in @multitable line.
1915 (narrow-to-region start-of-template end-of-template
)
1916 (goto-char (point-min))
1917 (while (search-forward "
1920 (goto-char (point-max))
1922 (forward-char 1)))))
1927 "You probably need to specify column widths for @multitable correctly.")))
1928 ;; Check whether columns fit on page.
1929 (let ((desired-columns
1931 ;; between column spaces
1932 (length texinfo-multitable-width-list
)
1933 ;; additional between column spaces, if any
1934 texinfo-extra-inter-column-width
1935 ;; sum of spaces for each entry
1936 (apply '+ texinfo-multitable-width-list
))))
1937 (if (> desired-columns fill-column
)
1940 "Multi-column table width, %d chars, is greater than page width, %d chars."
1941 desired-columns fill-column
))))
1942 texinfo-multitable-width-list
))
1944 ;; @item A1 @tab A2 @tab A3
1945 (defun texinfo-multitable-extract-row ()
1946 "Return multitable row, as a string.
1947 End of row is beginning of next @item or beginning of @end.
1948 Cells within rows are separated by @tab."
1949 (skip-chars-forward " \t")
1950 (let* ((start (point))
1952 (re-search-forward "@item\\|@end")
1953 (match-beginning 0)))
1954 (row (progn (goto-char end
)
1955 (skip-chars-backward " ")
1956 ;; remove whitespace at end of argument
1957 (delete-region (point) end
)
1958 (buffer-substring start
(point)))))
1959 (delete-region texinfo-command-start end
)
1962 (put 'multitable
'texinfo-item
'texinfo-multitable-item
)
1963 (defun texinfo-multitable-item ()
1964 "Format a row within a multicolumn table.
1965 Cells in row are separated by @tab.
1966 Widths of cells are specified by the arguments in the @multitable line.
1967 All cells are made to be the same height.
1968 This command is executed when texinfmt sees @item inside @multitable."
1969 (let ((original-buffer (current-buffer))
1970 (table-widths (reverse (car (cdr (car texinfo-stack
)))))
1971 (existing-fill-column fill-column
)
1975 (table-entry-height 0)
1976 ;; unformatted row looks like: A1 @tab A2 @tab A3
1977 ;; extract-row command deletes the source line in the table.
1978 (unformated-row (texinfo-multitable-extract-row)))
1979 ;; Use a temporary buffer
1980 (set-buffer (get-buffer-create texinfo-multitable-buffer-name
))
1981 (delete-region (point-min) (point-max))
1982 (insert unformated-row
)
1983 (goto-char (point-min))
1984 ;; 1. Check for correct number of @tab in line.
1985 (let ((tab-number 1)) ; one @tab between two columns
1986 (while (search-forward "@tab" nil t
)
1987 (setq tab-number
(1+ tab-number
)))
1988 (if (/= tab-number
(length table-widths
))
1989 (error "Wrong number of @tab's in a @multitable row.")))
1990 (goto-char (point-min))
1991 ;; 2. Format each cell, and copy to a rectangle
1992 ;; buffer looks like this: A1 @tab A2 @tab A3
1993 ;; Cell #1: format up to @tab
1994 ;; Cell #2: format up to @tab
1995 ;; Cell #3: format up to eob
1997 (setq start
(point))
1998 (setq end
(save-excursion
1999 (if (search-forward "@tab" nil
'move
)
2000 ;; Delete the @tab command, including the @-sign
2003 (progn (forward-word -
1) (1- (point)))))
2005 ;; Set fill-column *wider* than needed to produce inter-column space
2006 (setq fill-column
(+ 1
2007 texinfo-extra-inter-column-width
2008 (nth table-column table-widths
)))
2009 (narrow-to-region start end
)
2010 ;; Remove whitespace before and after entry.
2011 (skip-chars-forward " ")
2012 (delete-region (point) (save-excursion (beginning-of-line) (point)))
2013 (goto-char (point-max))
2014 (skip-chars-backward " ")
2015 (delete-region (point) (save-excursion (end-of-line) (point)))
2016 ;; Temorarily set texinfo-stack to nil so texinfo-format-scan
2017 ;; does not see an unterminated @multitable.
2018 (let (texinfo-stack) ; nil
2019 (texinfo-format-scan))
2020 (let (fill-prefix) ; no fill prefix
2021 (fill-region (point-min) (point-max)))
2022 (setq table-entry-height
2023 (max table-entry-height
(count-lines (point-min) (point-max))))
2024 ;; 3. Move point to end of bottom line, and pad that line to fill column.
2025 (goto-char (point-min))
2026 (forward-line (1- table-entry-height
))
2027 (let* ((beg (point)) ; beginning of line
2028 ;; add one more space for inter-column spacing
2033 (progn (end-of-line) (point)) ; end of existing line
2035 (insert (make-string
2036 (if (> needed-whitespace
0) needed-whitespace
1)
2038 ;; now, put formatted cell into a rectangle
2039 (set (intern (concat texinfo-multitable-rectangle-name
2040 (int-to-string table-column
)))
2041 (extract-rectangle (point-min) (point)))
2042 (delete-region (point-min) (point))
2043 (goto-char (point-max))
2044 (setq table-column
(1+ table-column
))
2046 ;; 4. Add extra lines to rectangles so all are of same height
2047 (let ((total-number-of-columns table-column
)
2050 (while (> table-column
0)
2051 (let ((this-rectangle (int-to-string table-column
)))
2052 (while (< (length this-rectangle
) table-entry-height
)
2053 (setq this-rectangle
(append this-rectangle
'("")))))
2054 (setq table-column
(1- table-column
)))
2055 ;; 5. Insert formatted rectangles in original buffer
2056 (switch-to-buffer original-buffer
)
2057 (open-line table-entry-height
)
2058 (while (< column-number total-number-of-columns
)
2062 (concat texinfo-multitable-rectangle-name
2063 (int-to-string column-number
)))))
2066 (setq column-number
(1+ column-number
))))
2067 (kill-buffer texinfo-multitable-buffer-name
)
2068 (setq fill-column existing-fill-column
)))
2071 ;;; @ifinfo, @iftex, @tex, @ifhtml, @html
2073 (put 'ifinfo
'texinfo-format
'texinfo-discard-line
)
2074 (put 'ifinfo
'texinfo-end
'texinfo-discard-command
)
2076 (put 'iftex
'texinfo-format
'texinfo-format-iftex
)
2077 (defun texinfo-format-iftex ()
2078 (delete-region texinfo-command-start
2079 (progn (re-search-forward "@end iftex[ \t]*\n")
2082 (put 'ifhtml
'texinfo-format
'texinfo-format-ifhtml
)
2083 (defun texinfo-format-ifhtml ()
2084 (delete-region texinfo-command-start
2085 (progn (re-search-forward "@end ifhtml[ \t]*\n")
2088 (put 'tex
'texinfo-format
'texinfo-format-tex
)
2089 (defun texinfo-format-tex ()
2090 (delete-region texinfo-command-start
2091 (progn (re-search-forward "@end tex[ \t]*\n")
2094 (put 'html
'texinfo-format
'texinfo-format-html
)
2095 (defun texinfo-format-html ()
2096 (delete-region texinfo-command-start
2097 (progn (re-search-forward "@end html[ \t]*\n")
2103 (put 'titlepage
'texinfo-format
'texinfo-format-titlepage
)
2104 (defun texinfo-format-titlepage ()
2105 (delete-region texinfo-command-start
2106 (progn (re-search-forward "@end titlepage[ \t]*\n")
2109 (put 'endtitlepage
'texinfo-format
'texinfo-discard-line
)
2111 ;; @titlespec an alternative titling command; ignored by Info
2113 (put 'titlespec
'texinfo-format
'texinfo-format-titlespec
)
2114 (defun texinfo-format-titlespec ()
2115 (delete-region texinfo-command-start
2116 (progn (re-search-forward "@end titlespec[ \t]*\n")
2119 (put 'endtitlespec
'texinfo-format
'texinfo-discard-line
)
2124 (put 'today
'texinfo-format
'texinfo-format-today
)
2126 ;; Produces Day Month Year style of output. eg `1 Jan 1900'
2127 ;; The `@today{}' command requires a pair of braces, like `@dots{}'.
2128 (defun texinfo-format-today ()
2129 (texinfo-parse-arg-discard)
2130 (insert (format-time-string "%e %b %Y")))
2134 ;; Produce `Day Month Year Hour:Min' style of output.
2135 ;; eg `1 Jan 1900 13:52'
2137 (put 'timestamp
'texinfo-format
'texinfo-format-timestamp
)
2139 ;; The `@timestamp{}' command requires a pair of braces, like `@dots{}'.
2140 (defun texinfo-format-timestamp ()
2141 "Insert the current local time and date."
2142 (texinfo-parse-arg-discard)
2143 ;; For seconds and time zone, replace format string with "%e %b %Y %T %Z"
2144 (insert (format-time-string "%e %b %Y %R")))
2149 (put 'ignore
'texinfo-format
'texinfo-format-ignore
)
2150 (defun texinfo-format-ignore ()
2151 (delete-region texinfo-command-start
2152 (progn (re-search-forward "@end ignore[ \t]*\n")
2155 (put 'endignore
'texinfo-format
'texinfo-discard-line
)
2158 ;;; Define the Info enclosure command: @definfoenclose
2160 ;; A `@definfoenclose' command may be used to define a highlighting
2161 ;; command for Info, but not for TeX. A command defined using
2162 ;; `@definfoenclose' marks text by enclosing it in strings that precede
2163 ;; and follow the text.
2165 ;; Presumably, if you define a command with `@definfoenclose` for Info,
2166 ;; you will also define the same command in the TeX definitions file,
2167 ;; `texinfo.tex' in a manner appropriate for typesetting.
2169 ;; Write a `@definfoenclose' command on a line and follow it with three
2170 ;; arguments separated by commas (commas are used as separators in an
2171 ;; `@node' line in the same way). The first argument to
2172 ;; `@definfoenclose' is the @-command name \(without the `@'\); the
2173 ;; second argument is the Info start delimiter string; and the third
2174 ;; argument is the Info end delimiter string. The latter two arguments
2175 ;; enclose the highlighted text in the Info file. A delimiter string
2176 ;; may contain spaces. Neither the start nor end delimiter is
2177 ;; required. However, if you do not provide a start delimiter, you
2178 ;; must follow the command name with two commas in a row; otherwise,
2179 ;; the Info formatting commands will misinterpret the end delimiter
2180 ;; string as a start delimiter string.
2182 ;; If you do a @definfoenclose{} on the name of a pre-defined macro (such
2183 ;; as @emph{}, @strong{}, @tt{}, or @i{}) the enclosure definition will
2184 ;; override the built-in definition.
2186 ;; An enclosure command defined this way takes one argument in braces.
2188 ;; For example, you can write:
2191 ;; @definfoenclose phoo, //, \\
2194 ;; near the beginning of a Texinfo file at the beginning of the lines
2195 ;; to define `@phoo' as an Info formatting command that inserts `//'
2196 ;; before and `\\' after the argument to `@phoo'. You can then write
2197 ;; `@phoo{bar}' wherever you want `//bar\\' highlighted in Info.
2199 ;; Also, for TeX formatting, you could write
2202 ;; @global@let@phoo=@i
2205 ;; to define `@phoo' as a command that causes TeX to typeset
2206 ;; the argument to `@phoo' in italics.
2208 ;; Note that each definition applies to its own formatter: one for TeX,
2209 ;; the other for texinfo-format-buffer or texinfo-format-region.
2211 ;; Here is another example: write
2213 ;; @definfoenclose headword, , :
2215 ;; near the beginning of the file, to define `@headword' as an Info
2216 ;; formatting command that inserts nothing before and a colon after the
2217 ;; argument to `@headword'.
2219 (put 'definfoenclose
'texinfo-format
'texinfo-define-info-enclosure
)
2220 (defun texinfo-define-info-enclosure ()
2221 (let* ((args (texinfo-format-parse-line-args))
2222 (command-name (nth 0 args
))
2223 (beginning-delimiter (or (nth 1 args
) ""))
2224 (end-delimiter (or (nth 2 args
) "")))
2225 (texinfo-discard-command)
2226 (setq texinfo-enclosure-list
2232 texinfo-enclosure-list
))))
2235 ;;; @var, @code and the like
2237 (put 'var
'texinfo-format
'texinfo-format-var
)
2238 ;; @sc a small caps font for TeX; formatted as `var' in Info
2239 (put 'sc
'texinfo-format
'texinfo-format-var
)
2240 (defun texinfo-format-var ()
2241 (insert (upcase (texinfo-parse-arg-discard)))
2242 (goto-char texinfo-command-start
))
2244 (put 'url
'texinfo-format
'texinfo-format-code
)
2245 (put 'cite
'texinfo-format
'texinfo-format-code
)
2246 (put 'code
'texinfo-format
'texinfo-format-code
)
2247 (put 'file
'texinfo-format
'texinfo-format-code
)
2248 (put 'samp
'texinfo-format
'texinfo-format-code
)
2249 (defun texinfo-format-code ()
2250 (insert "`" (texinfo-parse-arg-discard) "'")
2251 (goto-char texinfo-command-start
))
2253 (put 'emph
'texinfo-format
'texinfo-format-emph
)
2254 (put 'strong
'texinfo-format
'texinfo-format-emph
)
2255 (defun texinfo-format-emph ()
2256 (insert "*" (texinfo-parse-arg-discard) "*")
2257 (goto-char texinfo-command-start
))
2259 (put 'dfn
'texinfo-format
'texinfo-format-defn
)
2260 (put 'defn
'texinfo-format
'texinfo-format-defn
)
2261 (defun texinfo-format-defn ()
2262 (insert "\"" (texinfo-parse-arg-discard) "\"")
2263 (goto-char texinfo-command-start
))
2265 (put 'email
'texinfo-format
'texinfo-format-key
)
2266 (put 'key
'texinfo-format
'texinfo-format-key
)
2267 ;; I've decided not want to have angle brackets around these -- rms.
2268 (defun texinfo-format-key ()
2269 (insert (texinfo-parse-arg-discard))
2270 (goto-char texinfo-command-start
))
2272 (put 'bullet
'texinfo-format
'texinfo-format-bullet
)
2273 (defun texinfo-format-bullet ()
2274 "Insert an asterisk.
2275 If used within a line, follow `@bullet' with braces."
2276 (texinfo-optional-braces-discard)
2282 ;; Inside of @example ... @end example and similar environments,
2283 ;; @kbd does nothing; but outside of such environments, it places
2284 ;; single quotation markes around its argument.
2286 (defvar texinfo-format-kbd-regexp
2295 "Regexp specifying environments in which @kbd does not put `...'
2298 (defvar texinfo-format-kbd-end-regexp
2307 "Regexp specifying end of environments in which @kbd does not put `...'
2308 around argument. (See `texinfo-format-kbd-regexp')")
2310 (put 'kbd
'texinfo-format
'texinfo-format-kbd
)
2311 (defun texinfo-format-kbd ()
2312 "Place single quote marks around arg, except in @example and similar."
2313 ;; Search forward for @end example closer than an @example.
2314 ;; Can stop search at nearest @node or texinfo-section-types-regexp
2318 (concat "^@node\\|\\(" texinfo-section-types-regexp
"\\)")
2320 'move-to-end
) ; if necessary, return point at end of buffer
2324 (re-search-forward texinfo-format-kbd-regexp stop
'move-to-end
)
2326 (end-example-location
2328 (re-search-forward texinfo-format-kbd-end-regexp stop
'move-to-end
)
2330 ;; If inside @example, @end example will be closer than @example
2331 ;; or end of search i.e., end-example-location less than example-location
2332 (if (>= end-example-location example-location
)
2333 ;; outside an @example or equivalent
2334 (insert "`" (texinfo-parse-arg-discard) "'")
2335 ;; else, in @example; do not surround with `...'
2336 (insert (texinfo-parse-arg-discard)))
2337 (goto-char texinfo-command-start
)))
2340 ;;; @example, @lisp, @quotation, @display, @smalllisp, @smallexample
2342 (put 'display
'texinfo-format
'texinfo-format-example
)
2343 (put 'example
'texinfo-format
'texinfo-format-example
)
2344 (put 'lisp
'texinfo-format
'texinfo-format-example
)
2345 (put 'quotation
'texinfo-format
'texinfo-format-example
)
2346 (put 'smallexample
'texinfo-format
'texinfo-format-example
)
2347 (put 'smalllisp
'texinfo-format
'texinfo-format-example
)
2348 (defun texinfo-format-example ()
2349 (texinfo-push-stack 'example nil
)
2350 (setq fill-column
(- fill-column
5))
2351 (texinfo-discard-line))
2353 (put 'example
'texinfo-end
'texinfo-end-example
)
2354 (put 'display
'texinfo-end
'texinfo-end-example
)
2355 (put 'lisp
'texinfo-end
'texinfo-end-example
)
2356 (put 'quotation
'texinfo-end
'texinfo-end-example
)
2357 (put 'smallexample
'texinfo-end
'texinfo-end-example
)
2358 (put 'smalllisp
'texinfo-end
'texinfo-end-example
)
2359 (defun texinfo-end-example ()
2360 (setq fill-column
(+ fill-column
5))
2361 (texinfo-discard-command)
2363 (texinfo-pop-stack 'example
)))
2364 (texinfo-do-itemize (nth 1 stacktop
))))
2366 (put 'exdent
'texinfo-format
'texinfo-format-exdent
)
2367 (defun texinfo-format-exdent ()
2368 (texinfo-discard-command)
2369 (delete-region (point)
2371 (skip-chars-forward " ")
2374 ;; Cancel out the deletion that texinfo-do-itemize
2375 ;; is going to do at the end of this line.
2381 ;; @direntry and @dircategory
2383 (put 'direntry
'texinfo-format
'texinfo-format-direntry
)
2384 (defun texinfo-format-direntry ()
2385 (texinfo-push-stack 'direntry nil
)
2386 (texinfo-discard-line)
2387 (insert "START-INFO-DIR-ENTRY\n\n"))
2389 (put 'direntry
'texinfo-end
'texinfo-end-direntry
)
2390 (defun texinfo-end-direntry ()
2391 (texinfo-discard-command)
2392 (insert "END-INFO-DIR-ENTRY\n\n")
2393 (texinfo-pop-stack 'direntry
))
2395 (put 'dircategory
'texinfo-format
'texinfo-format-dircategory
)
2396 (defun texinfo-format-dircategory ()
2397 (let ((str (texinfo-parse-arg-discard)))
2398 (delete-region (point)
2400 (skip-chars-forward " ")
2402 (insert "INFO-DIR-SECTION " str
"\n")))
2406 ;; The @cartouche command is a noop in Info; in a printed manual,
2407 ;; it makes a box with rounded corners.
2409 (put 'cartouche
'texinfo-format
'texinfo-discard-line
)
2410 (put 'cartouche
'texinfo-end
'texinfo-discard-command
)
2413 ;;; @flushleft and @format
2415 ;; The @flushleft command left justifies every line but leaves the
2416 ;; right end ragged. As far as Info is concerned, @flushleft is a
2417 ;; `do-nothing' command
2419 ;; The @format command is similar to @example except that it does not
2420 ;; indent; this means that in Info, @format is similar to @flushleft.
2422 (put 'format
'texinfo-format
'texinfo-format-flushleft
)
2423 (put 'flushleft
'texinfo-format
'texinfo-format-flushleft
)
2424 (defun texinfo-format-flushleft ()
2425 (texinfo-discard-line))
2427 (put 'format
'texinfo-end
'texinfo-end-flushleft
)
2428 (put 'flushleft
'texinfo-end
'texinfo-end-flushleft
)
2429 (defun texinfo-end-flushleft ()
2430 (texinfo-discard-command))
2435 ;; The @flushright command right justifies every line but leaves the
2436 ;; left end ragged. Spaces and tabs at the right ends of lines are
2437 ;; removed so that visible text lines up on the right side.
2439 (put 'flushright
'texinfo-format
'texinfo-format-flushright
)
2440 (defun texinfo-format-flushright ()
2441 (texinfo-push-stack 'flushright nil
)
2442 (texinfo-discard-line))
2444 (put 'flushright
'texinfo-end
'texinfo-end-flushright
)
2445 (defun texinfo-end-flushright ()
2446 (texinfo-discard-command)
2449 (texinfo-pop-stack 'flushright
)))
2451 (texinfo-do-flushright (nth 1 stacktop
))))
2453 (defun texinfo-do-flushright (from)
2455 (while (progn (forward-line -
1)
2464 (skip-chars-backward " \t")
2465 (delete-region (point) (progn (end-of-line) (point)))
2470 ;;; @ctrl, @TeX, @copyright, @minus, @dots, @enddots, @pounds
2472 (put 'ctrl
'texinfo-format
'texinfo-format-ctrl
)
2473 (defun texinfo-format-ctrl ()
2474 (let ((str (texinfo-parse-arg-discard)))
2475 (insert (logand 31 (aref str
0)))))
2477 (put 'TeX
'texinfo-format
'texinfo-format-TeX
)
2478 (defun texinfo-format-TeX ()
2479 (texinfo-parse-arg-discard)
2482 (put 'copyright
'texinfo-format
'texinfo-format-copyright
)
2483 (defun texinfo-format-copyright ()
2484 (texinfo-parse-arg-discard)
2487 (put 'minus
'texinfo-format
'texinfo-format-minus
)
2488 (defun texinfo-format-minus ()
2489 "Insert a minus sign.
2490 If used within a line, follow `@minus' with braces."
2491 (texinfo-optional-braces-discard)
2494 (put 'dots
'texinfo-format
'texinfo-format-dots
)
2495 (defun texinfo-format-dots ()
2496 (texinfo-parse-arg-discard)
2499 (put 'enddots
'texinfo-format
'texinfo-format-enddots
)
2500 (defun texinfo-format-enddots ()
2501 (texinfo-parse-arg-discard)
2504 (put 'pounds
'texinfo-format
'texinfo-format-pounds
)
2505 (defun texinfo-format-pounds ()
2506 (texinfo-parse-arg-discard)
2510 ;;; Refilling and indenting: @refill, @paragraphindent, @noindent
2512 ;;; Indent only those paragraphs that are refilled as a result of an
2513 ;;; @refill command.
2515 ;; * If the value is `asis', do not change the existing indentation at
2516 ;; the starts of paragraphs.
2518 ;; * If the value zero, delete any existing indentation.
2520 ;; * If the value is greater than zero, indent each paragraph by that
2521 ;; number of spaces.
2523 ;;; But do not refill paragraphs with an @refill command that are
2524 ;;; preceded by @noindent or are part of a table, list, or deffn.
2526 (defvar texinfo-paragraph-indent
"asis"
2527 "Number of spaces for @refill to indent a paragraph; else to leave as is.")
2529 (put 'paragraphindent
'texinfo-format
'texinfo-paragraphindent
)
2531 (defun texinfo-paragraphindent ()
2532 "Specify the number of spaces for @refill to indent a paragraph.
2533 Default is to leave the number of spaces as is."
2534 (let ((arg (texinfo-parse-arg-discard)))
2535 (if (string= "asis" arg
)
2536 (setq texinfo-paragraph-indent
"asis")
2537 (setq texinfo-paragraph-indent
(string-to-int arg
)))))
2539 (put 'refill
'texinfo-format
'texinfo-format-refill
)
2540 (defun texinfo-format-refill ()
2541 "Refill paragraph. Also, indent first line as set by @paragraphindent.
2542 Default is to leave paragraph indentation as is."
2543 (texinfo-discard-command)
2544 (forward-paragraph -
1)
2545 (if (looking-at "[ \t\n]*$") (forward-line 1))
2546 ;; Do not indent if an entry in a list, table, or deffn,
2547 ;; or if paragraph is preceded by @noindent.
2548 ;; Otherwise, indent
2550 ;; delete a @noindent line and do not indent paragraph
2551 ((save-excursion (forward-line -
1)
2552 (looking-at "^@noindent"))
2554 (delete-region (point) (progn (forward-line 1) (point))))
2555 ;; do nothing if "asis"
2556 ((equal texinfo-paragraph-indent
"asis"))
2557 ;; do no indenting in list, etc.
2558 ((> texinfo-stack-depth
0))
2559 ;; otherwise delete existing whitespace and indent
2561 (delete-region (point) (progn (skip-chars-forward " \t") (point)))
2562 (insert (make-string texinfo-paragraph-indent ?
))))
2563 (forward-paragraph 1)
2566 ;; Do not fill a section title line with asterisks, hyphens, etc. that
2567 ;; are used to underline it. This could occur if the line following
2568 ;; the underlining is not an index entry and has text within it.
2569 (let* ((previous-paragraph-separate paragraph-separate
)
2571 (concat paragraph-separate
"\\|[-=.]+\\|\\*\\*+"))
2572 (previous-paragraph-start paragraph-start
)
2574 (concat paragraph-start
"\\|[-=.]+\\|\\*\\*+")))
2576 (fill-paragraph nil
)
2577 (setq paragraph-separate previous-paragraph-separate
)
2578 (setq paragraph-start previous-paragraph-start
))))
2580 (put 'noindent
'texinfo-format
'texinfo-noindent
)
2581 (defun texinfo-noindent ()
2583 (forward-paragraph 1)
2584 (if (search-backward "@refill"
2585 (save-excursion (forward-line -
1) (point)) t
)
2586 () ; leave @noindent command so @refill command knows not to indent
2588 (texinfo-discard-line))))
2591 ;;; Index generation
2593 (put 'vindex
'texinfo-format
'texinfo-format-vindex
)
2594 (defun texinfo-format-vindex ()
2595 (texinfo-index 'texinfo-vindex
))
2597 (put 'cindex
'texinfo-format
'texinfo-format-cindex
)
2598 (defun texinfo-format-cindex ()
2599 (texinfo-index 'texinfo-cindex
))
2601 (put 'findex
'texinfo-format
'texinfo-format-findex
)
2602 (defun texinfo-format-findex ()
2603 (texinfo-index 'texinfo-findex
))
2605 (put 'pindex
'texinfo-format
'texinfo-format-pindex
)
2606 (defun texinfo-format-pindex ()
2607 (texinfo-index 'texinfo-pindex
))
2609 (put 'tindex
'texinfo-format
'texinfo-format-tindex
)
2610 (defun texinfo-format-tindex ()
2611 (texinfo-index 'texinfo-tindex
))
2613 (put 'kindex
'texinfo-format
'texinfo-format-kindex
)
2614 (defun texinfo-format-kindex ()
2615 (texinfo-index 'texinfo-kindex
))
2617 (defun texinfo-index (indexvar)
2618 (let ((arg (texinfo-parse-expanded-arg)))
2619 (texinfo-discard-command)
2623 ;; Region formatting may not provide last node position.
2624 (if texinfo-last-node-pos
2625 (1+ (count-lines texinfo-last-node-pos
(point)))
2627 (symbol-value indexvar
)))))
2629 (defconst texinfo-indexvar-alist
2630 '(("cp" . texinfo-cindex
)
2631 ("fn" . texinfo-findex
)
2632 ("vr" . texinfo-vindex
)
2633 ("tp" . texinfo-tindex
)
2634 ("pg" . texinfo-pindex
)
2635 ("ky" . texinfo-kindex
)))
2638 ;;; @defindex @defcodeindex
2639 (put 'defindex
'texinfo-format
'texinfo-format-defindex
)
2640 (put 'defcodeindex
'texinfo-format
'texinfo-format-defindex
)
2642 (defun texinfo-format-defindex ()
2643 (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa'
2644 (indexing-command (intern (concat index-name
"index")))
2645 (index-formatting-command ; eg: `texinfo-format-aaindex'
2646 (intern (concat "texinfo-format-" index-name
"index")))
2647 (index-alist-name ; eg: `texinfo-aaindex'
2648 (intern (concat "texinfo-" index-name
"index"))))
2650 (set index-alist-name nil
)
2652 (put indexing-command
; eg, aaindex
2654 index-formatting-command
) ; eg, texinfo-format-aaindex
2656 ;; eg: "aa" . texinfo-aaindex
2657 (or (assoc index-name texinfo-indexvar-alist
)
2658 (setq texinfo-indexvar-alist
2662 texinfo-indexvar-alist
)))
2664 (fset index-formatting-command
2666 (list 'texinfo-index
2667 (list 'quote index-alist-name
))))))
2670 ;;; @synindex @syncodeindex
2672 (put 'synindex
'texinfo-format
'texinfo-format-synindex
)
2673 (put 'syncodeindex
'texinfo-format
'texinfo-format-synindex
)
2675 (defun texinfo-format-synindex ()
2676 (let* ((args (texinfo-parse-arg-discard))
2677 (second (cdr (read-from-string args
)))
2678 (joiner (symbol-name (car (read-from-string args
))))
2679 (joined (symbol-name (car (read-from-string args second
)))))
2681 (if (assoc joiner texinfo-short-index-cmds-alist
)
2683 (cdr (assoc joiner texinfo-short-index-cmds-alist
))
2685 (or (cdr (assoc joined texinfo-short-index-format-cmds-alist
))
2686 (intern (concat "texinfo-format-" joined
"index"))))
2688 (intern (concat joiner
"index"))
2690 (or (cdr(assoc joined texinfo-short-index-format-cmds-alist
))
2691 (intern (concat "texinfo-format-" joined
"index")))))))
2693 (defconst texinfo-short-index-cmds-alist
2701 (defconst texinfo-short-index-format-cmds-alist
2702 '(("cp" . texinfo-format-cindex
)
2703 ("fn" . texinfo-format-findex
)
2704 ("vr" . texinfo-format-vindex
)
2705 ("tp" . texinfo-format-tindex
)
2706 ("pg" . texinfo-format-pindex
)
2707 ("ky" . texinfo-format-kindex
)))
2710 ;;; Sort and index (for VMS)
2712 ;; Sort an index which is in the current buffer between START and END.
2713 ;; Used on VMS, where the `sort' utility is not available.
2714 (defun texinfo-sort-region (start end
)
2717 (narrow-to-region start end
)
2718 (sort-subr nil
'forward-line
'end-of-line
'texinfo-sort-startkeyfun
)))
2720 ;; Subroutine for sorting an index.
2721 ;; At start of a line, return a string to sort the line under.
2722 (defun texinfo-sort-startkeyfun ()
2724 (buffer-substring (point) (save-excursion (end-of-line) (point)))))
2725 ;; Canonicalize whitespace and eliminate funny chars.
2726 (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line
)
2727 (setq line
(concat (substring line
0 (match-beginning 0))
2729 (substring line
(match-end 0) (length line
)))))
2735 (put 'printindex
'texinfo-format
'texinfo-format-printindex
)
2737 (defun texinfo-format-printindex ()
2738 (let ((indexelts (symbol-value
2739 (cdr (assoc (texinfo-parse-arg-discard)
2740 texinfo-indexvar-alist
))))
2742 (insert "\n* Menu:\n\n")
2743 (setq opoint
(point))
2744 (texinfo-print-index nil indexelts
)
2746 (if (memq system-type
'(vax-vms windows-nt ms-dos
))
2747 (texinfo-sort-region opoint
(point))
2748 (shell-command-on-region opoint
(point) "sort -fd" 1))))
2750 (defun texinfo-print-index (file indexelts
)
2752 (if (stringp (car (car indexelts
)))
2754 (insert "* " (car (car indexelts
)) ": " )
2757 (if file
(concat "(" file
")") "")
2758 (nth 1 (car indexelts
)) ".")
2761 (if (nth 2 (car indexelts
))
2762 (format " %d." (nth 2 (car indexelts
)))
2765 ;; index entries from @include'd file
2766 (texinfo-print-index (nth 1 (car indexelts
))
2767 (nth 2 (car indexelts
))))
2768 (setq indexelts
(cdr indexelts
))))
2771 ;;; Glyphs: @equiv, @error, etc
2773 ;; @equiv to show that two expressions are equivalent
2774 ;; @error to show an error message
2775 ;; @expansion to show what a macro expands to
2776 ;; @point to show the location of point in an example
2777 ;; @print to show what an evaluated expression prints
2778 ;; @result to indicate the value returned by an expression
2780 (put 'equiv
'texinfo-format
'texinfo-format-equiv
)
2781 (defun texinfo-format-equiv ()
2782 (texinfo-parse-arg-discard)
2785 (put 'error
'texinfo-format
'texinfo-format-error
)
2786 (defun texinfo-format-error ()
2787 (texinfo-parse-arg-discard)
2788 (insert "error-->"))
2790 (put 'expansion
'texinfo-format
'texinfo-format-expansion
)
2791 (defun texinfo-format-expansion ()
2792 (texinfo-parse-arg-discard)
2795 (put 'point
'texinfo-format
'texinfo-format-point
)
2796 (defun texinfo-format-point ()
2797 (texinfo-parse-arg-discard)
2800 (put 'print
'texinfo-format
'texinfo-format-print
)
2801 (defun texinfo-format-print ()
2802 (texinfo-parse-arg-discard)
2805 (put 'result
'texinfo-format
'texinfo-format-result
)
2806 (defun texinfo-format-result ()
2807 (texinfo-parse-arg-discard)
2813 ;; Info presumes a plain ASCII output, so the accented characters do
2814 ;; not look as they would if typeset, or output with a different
2817 ;; See the `texinfo-accent-commands' variable
2818 ;; in the section for `texinfo-append-refill'.
2819 ;; Also, see the defun for `texinfo-format-scan'
2820 ;; for single-character accent commands.
2822 ;; Command Info output Name
2824 ;; These do not have braces:
2825 ;; @^ ==> ^ circumflex accent
2826 ;; @` ==> ` grave accent
2827 ;; @' ==> ' acute accent
2828 ;; @" ==> " umlaut accent
2829 ;; @= ==> = overbar accent
2830 ;; @~ ==> ~ tilde accent
2832 ;; These have braces, but take no argument:
2833 ;; @OE{} ==> OE French-OE-ligature
2835 ;; @AA{} ==> AA Scandinavian-A-with-circle
2837 ;; @AE{} ==> AE Latin-Scandinavian-AE
2839 ;; @ss{} ==> ss German-sharp-S
2841 ;; @questiondown{} ==> ? upside-down-question-mark
2842 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
2843 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
2844 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
2845 ;; @O{} ==> O/ Scandinavian O-with-slash
2846 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
2848 ;; These have braces, and take an argument:
2849 ;; @,{c} ==> c, cedilla accent
2850 ;; @dotaccent{o} ==> .o overdot-accent
2851 ;; @ubaraccent{o} ==> _o underbar-accent
2852 ;; @udotaccent{o} ==> o-. underdot-accent
2853 ;; @H{o} ==> ""o long Hungarian umlaut
2854 ;; @ringaccent{o} ==> *o ring accent
2855 ;; @tieaccent{oo} ==> [oo tie after accent
2856 ;; @u{o} ==> (o breve accent
2857 ;; @v{o} ==> <o hacek accent
2858 ;; @dotless{i} ==> i dotless i and dotless j
2862 ;; Note: The defun texinfo-format-scan
2863 ;; looks at "[@{}^'`\",=~ *?!-]"
2864 ;; In the case of @*, a line break is inserted;
2865 ;; in the other cases, the characters are simply quoted and the @ is deleted.
2866 ;; Thus, `texinfo-format-scan' handles the following
2867 ;; single-character accent commands: @^ @` @' @" @, @- @= @~
2869 ;; @^ ==> ^ circumflex accent
2870 ;; (put '^ 'texinfo-format 'texinfo-format-circumflex-accent)
2871 ;; (defun texinfo-format-circumflex-accent ()
2872 ;; (texinfo-discard-command)
2875 ;; @` ==> ` grave accent
2876 ;; (put '\` 'texinfo-format 'texinfo-format-grave-accent)
2877 ;; (defun texinfo-format-grave-accent ()
2878 ;; (texinfo-discard-command)
2881 ;; @' ==> ' acute accent
2882 ;; (put '\' 'texinfo-format 'texinfo-format-acute-accent)
2883 ;; (defun texinfo-format-acute-accent ()
2884 ;; (texinfo-discard-command)
2887 ;; @" ==> " umlaut accent
2888 ;; (put '\" 'texinfo-format 'texinfo-format-umlaut-accent)
2889 ;; (defun texinfo-format-umlaut-accent ()
2890 ;; (texinfo-discard-command)
2893 ;; @= ==> = overbar accent
2894 ;; (put '= 'texinfo-format 'texinfo-format-overbar-accent)
2895 ;; (defun texinfo-format-overbar-accent ()
2896 ;; (texinfo-discard-command)
2899 ;; @~ ==> ~ tilde accent
2900 ;; (put '~ 'texinfo-format 'texinfo-format-tilde-accent)
2901 ;; (defun texinfo-format-tilde-accent ()
2902 ;; (texinfo-discard-command)
2905 ;; @OE{} ==> OE French-OE-ligature
2906 (put 'OE
'texinfo-format
'texinfo-format-French-OE-ligature
)
2907 (defun texinfo-format-French-OE-ligature ()
2908 (insert "OE" (texinfo-parse-arg-discard))
2909 (goto-char texinfo-command-start
))
2912 (put 'oe
'texinfo-format
'texinfo-format-French-oe-ligature
)
2913 (defun texinfo-format-French-oe-ligature () ; lower case
2914 (insert "oe" (texinfo-parse-arg-discard))
2915 (goto-char texinfo-command-start
))
2917 ;; @AA{} ==> AA Scandinavian-A-with-circle
2918 (put 'AA
'texinfo-format
'texinfo-format-Scandinavian-A-with-circle
)
2919 (defun texinfo-format-Scandinavian-A-with-circle ()
2920 (insert "AA" (texinfo-parse-arg-discard))
2921 (goto-char texinfo-command-start
))
2924 (put 'aa
'texinfo-format
'texinfo-format-Scandinavian-a-with-circle
)
2925 (defun texinfo-format-Scandinavian-a-with-circle () ; lower case
2926 (insert "aa" (texinfo-parse-arg-discard))
2927 (goto-char texinfo-command-start
))
2929 ;; @AE{} ==> AE Latin-Scandinavian-AE
2930 (put 'AE
'texinfo-format
'texinfo-format-Latin-Scandinavian-AE
)
2931 (defun texinfo-format-Latin-Scandinavian-AE ()
2932 (insert "AE" (texinfo-parse-arg-discard))
2933 (goto-char texinfo-command-start
))
2936 (put 'ae
'texinfo-format
'texinfo-format-Latin-Scandinavian-ae
)
2937 (defun texinfo-format-Latin-Scandinavian-ae () ; lower case
2938 (insert "ae" (texinfo-parse-arg-discard))
2939 (goto-char texinfo-command-start
))
2941 ;; @ss{} ==> ss German-sharp-S
2942 (put 'ss
'texinfo-format
'texinfo-format-German-sharp-S
)
2943 (defun texinfo-format-German-sharp-S ()
2944 (insert "ss" (texinfo-parse-arg-discard))
2945 (goto-char texinfo-command-start
))
2947 ;; @questiondown{} ==> ? upside-down-question-mark
2948 (put 'questiondown
'texinfo-format
'texinfo-format-upside-down-question-mark
)
2949 (defun texinfo-format-upside-down-question-mark ()
2950 (insert "?" (texinfo-parse-arg-discard))
2951 (goto-char texinfo-command-start
))
2953 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
2954 (put 'exclamdown
'texinfo-format
'texinfo-format-upside-down-exclamation-mark
)
2955 (defun texinfo-format-upside-down-exclamation-mark ()
2956 (insert "!" (texinfo-parse-arg-discard))
2957 (goto-char texinfo-command-start
))
2959 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
2960 (put 'L
'texinfo-format
'texinfo-format-Polish-suppressed-L
)
2961 (defun texinfo-format-Polish-suppressed-L ()
2962 (insert (texinfo-parse-arg-discard) "/L")
2963 (goto-char texinfo-command-start
))
2965 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
2966 (put 'l
'texinfo-format
'texinfo-format-Polish-suppressed-l-lower-case
)
2967 (defun texinfo-format-Polish-suppressed-l-lower-case ()
2968 (insert (texinfo-parse-arg-discard) "/l")
2969 (goto-char texinfo-command-start
))
2972 ;; @O{} ==> O/ Scandinavian O-with-slash
2973 (put 'O
'texinfo-format
'texinfo-format-Scandinavian-O-with-slash
)
2974 (defun texinfo-format-Scandinavian-O-with-slash ()
2975 (insert (texinfo-parse-arg-discard) "O/")
2976 (goto-char texinfo-command-start
))
2978 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
2979 (put 'o
'texinfo-format
'texinfo-format-Scandinavian-o-with-slash-lower-case
)
2980 (defun texinfo-format-Scandinavian-o-with-slash-lower-case ()
2981 (insert (texinfo-parse-arg-discard) "o/")
2982 (goto-char texinfo-command-start
))
2986 ;; @,{c} ==> c, cedilla accent
2987 (put ', 'texinfo-format
'texinfo-format-cedilla-accent
)
2988 (defun texinfo-format-cedilla-accent ()
2989 (insert (texinfo-parse-arg-discard) ",")
2990 (goto-char texinfo-command-start
))
2993 ;; @dotaccent{o} ==> .o overdot-accent
2994 (put 'dotaccent
'texinfo-format
'texinfo-format-overdot-accent
)
2995 (defun texinfo-format-overdot-accent ()
2996 (insert "." (texinfo-parse-arg-discard))
2997 (goto-char texinfo-command-start
))
2999 ;; @ubaraccent{o} ==> _o underbar-accent
3000 (put 'ubaraccent
'texinfo-format
'texinfo-format-underbar-accent
)
3001 (defun texinfo-format-underbar-accent ()
3002 (insert "_" (texinfo-parse-arg-discard))
3003 (goto-char texinfo-command-start
))
3005 ;; @udotaccent{o} ==> o-. underdot-accent
3006 (put 'udotaccent
'texinfo-format
'texinfo-format-underdot-accent
)
3007 (defun texinfo-format-underdot-accent ()
3008 (insert (texinfo-parse-arg-discard) "-.")
3009 (goto-char texinfo-command-start
))
3011 ;; @H{o} ==> ""o long Hungarian umlaut
3012 (put 'H
'texinfo-format
'texinfo-format-long-Hungarian-umlaut
)
3013 (defun texinfo-format-long-Hungarian-umlaut ()
3014 (insert "\"\"" (texinfo-parse-arg-discard))
3015 (goto-char texinfo-command-start
))
3017 ;; @ringaccent{o} ==> *o ring accent
3018 (put 'ringaccent
'texinfo-format
'texinfo-format-ring-accent
)
3019 (defun texinfo-format-ring-accent ()
3020 (insert "*" (texinfo-parse-arg-discard))
3021 (goto-char texinfo-command-start
))
3023 ;; @tieaccent{oo} ==> [oo tie after accent
3024 (put 'tieaccent
'texinfo-format
'texinfo-format-tie-after-accent
)
3025 (defun texinfo-format-tie-after-accent ()
3026 (insert "[" (texinfo-parse-arg-discard))
3027 (goto-char texinfo-command-start
))
3030 ;; @u{o} ==> (o breve accent
3031 (put 'u
'texinfo-format
'texinfo-format-breve-accent
)
3032 (defun texinfo-format-breve-accent ()
3033 (insert "(" (texinfo-parse-arg-discard))
3034 (goto-char texinfo-command-start
))
3036 ;; @v{o} ==> <o hacek accent
3037 (put 'v
'texinfo-format
'texinfo-format-hacek-accent
)
3038 (defun texinfo-format-hacek-accent ()
3039 (insert "<" (texinfo-parse-arg-discard))
3040 (goto-char texinfo-command-start
))
3043 ;; @dotless{i} ==> i dotless i and dotless j
3044 (put 'dotless
'texinfo-format
'texinfo-format-dotless
)
3045 (defun texinfo-format-dotless ()
3046 (insert (texinfo-parse-arg-discard))
3047 (goto-char texinfo-command-start
))
3050 ;;; Definition formatting: @deffn, @defun, etc
3052 ;; What definition formatting produces:
3054 ;; @deffn category name args...
3055 ;; In Info, `Category: name ARGS'
3056 ;; In index: name: node. line#.
3058 ;; @defvr category name
3059 ;; In Info, `Category: name'
3060 ;; In index: name: node. line#.
3062 ;; @deftp category name attributes...
3063 ;; `category name attributes...' Note: @deftp args in lower case.
3064 ;; In index: name: node. line#.
3066 ;; Specialized function-like or variable-like entity:
3068 ;; @defun, @defmac, @defspec, @defvar, @defopt
3070 ;; @defun name args In Info, `Function: name ARGS'
3071 ;; @defmac name args In Info, `Macro: name ARGS'
3072 ;; @defvar name In Info, `Variable: name'
3074 ;; In index: name: node. line#.
3076 ;; Generalized typed-function-like or typed-variable-like entity:
3077 ;; @deftypefn category data-type name args...
3078 ;; In Info, `Category: data-type name args...'
3079 ;; @deftypevr category data-type name
3080 ;; In Info, `Category: data-type name'
3081 ;; In index: name: node. line#.
3083 ;; Specialized typed-function-like or typed-variable-like entity:
3084 ;; @deftypefun data-type name args...
3085 ;; In Info, `Function: data-type name ARGS'
3086 ;; In index: name: node. line#.
3088 ;; @deftypevar data-type name
3089 ;; In Info, `Variable: data-type name'
3090 ;; In index: name: node. line#. but include args after name!?
3092 ;; Generalized object oriented entity:
3093 ;; @defop category class name args...
3094 ;; In Info, `Category on class: name ARG'
3095 ;; In index: name on class: node. line#.
3097 ;; @defcv category class name
3098 ;; In Info, `Category of class: name'
3099 ;; In index: name of class: node. line#.
3101 ;; Specialized object oriented entity:
3102 ;; @defmethod class name args...
3103 ;; In Info, `Method on class: name ARGS'
3104 ;; In index: name on class: node. line#.
3106 ;; @defivar class name
3107 ;; In Info, `Instance variable of class: name'
3108 ;; In index: name of class: node. line#.
3111 ;;; The definition formatting functions
3113 (defun texinfo-format-defun ()
3114 (texinfo-push-stack 'defun
nil)
3115 (setq fill-column
(- fill-column
5))
3116 (texinfo-format-defun-1 t
))
3118 (defun texinfo-end-defun ()
3119 (setq fill-column
(+ fill-column
5))
3120 (texinfo-discard-command)
3121 (let ((start (nth 1 (texinfo-pop-stack 'defun
))))
3122 (texinfo-do-itemize start
)
3123 ;; Delete extra newline inserted after header.
3128 (defun texinfo-format-defunx ()
3129 (texinfo-format-defun-1 nil
))
3131 (defun texinfo-format-defun-1 (first-p)
3132 (let ((parse-args (texinfo-format-parse-defun-args))
3133 (texinfo-defun-type (get texinfo-command-name
'texinfo-defun-type
)))
3134 (texinfo-discard-command)
3135 ;; Delete extra newline inserted after previous header line.
3139 (get texinfo-command-name
'texinfo-deffn-formatting-property
) parse-args
)
3140 ;; Insert extra newline so that paragraph filling does not mess
3141 ;; with header line.
3143 (rplaca (cdr (cdr (car texinfo-stack
))) (point))
3145 (get texinfo-command-name
'texinfo-defun-indexing-property
) parse-args
)))
3147 ;;; Formatting the first line of a definition
3149 ;; @deffn, @defvr, @deftp
3150 (put 'deffn
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3151 (put 'deffnx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3152 (put 'defvr
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3153 (put 'defvrx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3154 (put 'deftp
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3155 (put 'deftpx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3156 (defun texinfo-format-deffn (parsed-args)
3157 ;; Generalized function-like, variable-like, or generic data-type entity:
3158 ;; @deffn category name args...
3159 ;; In Info, `Category: name ARGS'
3160 ;; @deftp category name attributes...
3161 ;; `category name attributes...' Note: @deftp args in lower case.
3162 (let ((category (car parsed-args
))
3163 (name (car (cdr parsed-args
)))
3164 (args (cdr (cdr parsed-args
))))
3165 (insert " -- " category
": " name
)
3168 (if (or (= ?
& (aref (car args
) 0))
3169 (eq (eval (car texinfo-defun-type
)) 'deftp-type
))
3171 (upcase (car args
))))
3172 (setq args
(cdr args
)))))
3174 ;; @defun, @defmac, @defspec, @defvar, @defopt: Specialized, simple
3175 (put 'defun
'texinfo-deffn-formatting-property
3176 'texinfo-format-specialized-defun
)
3177 (put 'defunx
'texinfo-deffn-formatting-property
3178 'texinfo-format-specialized-defun
)
3179 (put 'defmac
'texinfo-deffn-formatting-property
3180 'texinfo-format-specialized-defun
)
3181 (put 'defmacx
'texinfo-deffn-formatting-property
3182 'texinfo-format-specialized-defun
)
3183 (put 'defspec
'texinfo-deffn-formatting-property
3184 'texinfo-format-specialized-defun
)
3185 (put 'defspecx
'texinfo-deffn-formatting-property
3186 'texinfo-format-specialized-defun
)
3187 (put 'defvar
'texinfo-deffn-formatting-property
3188 'texinfo-format-specialized-defun
)
3189 (put 'defvarx
'texinfo-deffn-formatting-property
3190 'texinfo-format-specialized-defun
)
3191 (put 'defopt
'texinfo-deffn-formatting-property
3192 'texinfo-format-specialized-defun
)
3193 (put 'defoptx
'texinfo-deffn-formatting-property
3194 'texinfo-format-specialized-defun
)
3195 (defun texinfo-format-specialized-defun (parsed-args)
3196 ;; Specialized function-like or variable-like entity:
3197 ;; @defun name args In Info, `Function: Name ARGS'
3198 ;; @defmac name args In Info, `Macro: Name ARGS'
3199 ;; @defvar name In Info, `Variable: Name'
3200 ;; Use cdr of texinfo-defun-type to determine category:
3201 (let ((category (car (cdr texinfo-defun-type
)))
3202 (name (car parsed-args
))
3203 (args (cdr parsed-args
)))
3204 (insert " -- " category
": " name
)
3207 (if (= ?
& (aref (car args
) 0))
3209 (upcase (car args
))))
3210 (setq args
(cdr args
)))))
3212 ;; @deftypefn, @deftypevr: Generalized typed
3213 (put 'deftypefn
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3214 (put 'deftypefnx
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3215 (put 'deftypevr
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3216 (put 'deftypevrx
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3217 (defun texinfo-format-deftypefn (parsed-args)
3218 ;; Generalized typed-function-like or typed-variable-like entity:
3219 ;; @deftypefn category data-type name args...
3220 ;; In Info, `Category: data-type name args...'
3221 ;; @deftypevr category data-type name
3222 ;; In Info, `Category: data-type name'
3223 ;; Note: args in lower case, unless modified in command line.
3224 (let ((category (car parsed-args
))
3225 (data-type (car (cdr parsed-args
)))
3226 (name (car (cdr (cdr parsed-args
))))
3227 (args (cdr (cdr (cdr parsed-args
)))))
3228 (insert " -- " category
": " data-type
" " name
)
3230 (insert " " (car args
))
3231 (setq args
(cdr args
)))))
3233 ;; @deftypefun, @deftypevar: Specialized typed
3234 (put 'deftypefun
'texinfo-deffn-formatting-property
'texinfo-format-deftypefun
)
3235 (put 'deftypefunx
'texinfo-deffn-formatting-property
3236 'texinfo-format-deftypefun
)
3237 (put 'deftypevar
'texinfo-deffn-formatting-property
'texinfo-format-deftypefun
)
3238 (put 'deftypevarx
'texinfo-deffn-formatting-property
3239 'texinfo-format-deftypefun
)
3240 (defun texinfo-format-deftypefun (parsed-args)
3241 ;; Specialized typed-function-like or typed-variable-like entity:
3242 ;; @deftypefun data-type name args...
3243 ;; In Info, `Function: data-type name ARGS'
3244 ;; @deftypevar data-type name
3245 ;; In Info, `Variable: data-type name'
3246 ;; Note: args in lower case, unless modified in command line.
3247 ;; Use cdr of texinfo-defun-type to determine category:
3248 (let ((category (car (cdr texinfo-defun-type
)))
3249 (data-type (car parsed-args
))
3250 (name (car (cdr parsed-args
)))
3251 (args (cdr (cdr parsed-args
))))
3252 (insert " -- " category
": " data-type
" " name
)
3254 (insert " " (car args
))
3255 (setq args
(cdr args
)))))
3257 ;; @defop: Generalized object-oriented
3258 (put 'defop
'texinfo-deffn-formatting-property
'texinfo-format-defop
)
3259 (put 'defopx
'texinfo-deffn-formatting-property
'texinfo-format-defop
)
3260 (defun texinfo-format-defop (parsed-args)
3261 ;; Generalized object oriented entity:
3262 ;; @defop category class name args...
3263 ;; In Info, `Category on class: name ARG'
3264 ;; Note: args in upper case; use of `on'
3265 (let ((category (car parsed-args
))
3266 (class (car (cdr parsed-args
)))
3267 (name (car (cdr (cdr parsed-args
))))
3268 (args (cdr (cdr (cdr parsed-args
)))))
3269 (insert " -- " category
" on " class
": " name
)
3271 (insert " " (upcase (car args
)))
3272 (setq args
(cdr args
)))))
3274 ;; @defcv: Generalized object-oriented
3275 (put 'defcv
'texinfo-deffn-formatting-property
'texinfo-format-defcv
)
3276 (put 'defcvx
'texinfo-deffn-formatting-property
'texinfo-format-defcv
)
3277 (defun texinfo-format-defcv (parsed-args)
3278 ;; Generalized object oriented entity:
3279 ;; @defcv category class name
3280 ;; In Info, `Category of class: name'
3281 ;; Note: args in upper case; use of `of'
3282 (let ((category (car parsed-args
))
3283 (class (car (cdr parsed-args
)))
3284 (name (car (cdr (cdr parsed-args
))))
3285 (args (cdr (cdr (cdr parsed-args
)))))
3286 (insert " -- " category
" of " class
": " name
)
3288 (insert " " (upcase (car args
)))
3289 (setq args
(cdr args
)))))
3291 ;; @defmethod: Specialized object-oriented
3292 (put 'defmethod
'texinfo-deffn-formatting-property
'texinfo-format-defmethod
)
3293 (put 'defmethodx
'texinfo-deffn-formatting-property
'texinfo-format-defmethod
)
3294 (defun texinfo-format-defmethod (parsed-args)
3295 ;; Specialized object oriented entity:
3296 ;; @defmethod class name args...
3297 ;; In Info, `Method on class: name ARGS'
3298 ;; Note: args in upper case; use of `on'
3299 ;; Use cdr of texinfo-defun-type to determine category:
3300 (let ((category (car (cdr texinfo-defun-type
)))
3301 (class (car parsed-args
))
3302 (name (car (cdr parsed-args
)))
3303 (args (cdr (cdr parsed-args
))))
3304 (insert " -- " category
" on " class
": " name
)
3306 (insert " " (upcase (car args
)))
3307 (setq args
(cdr args
)))))
3309 ;; @defivar: Specialized object-oriented
3310 (put 'defivar
'texinfo-deffn-formatting-property
'texinfo-format-defivar
)
3311 (put 'defivarx
'texinfo-deffn-formatting-property
'texinfo-format-defivar
)
3312 (defun texinfo-format-defivar (parsed-args)
3313 ;; Specialized object oriented entity:
3314 ;; @defivar class name
3315 ;; In Info, `Instance variable of class: name'
3316 ;; Note: args in upper case; use of `of'
3317 ;; Use cdr of texinfo-defun-type to determine category:
3318 (let ((category (car (cdr texinfo-defun-type
)))
3319 (class (car parsed-args
))
3320 (name (car (cdr parsed-args
)))
3321 (args (cdr (cdr parsed-args
))))
3322 (insert " -- " category
" of " class
": " name
)
3324 (insert " " (upcase (car args
)))
3325 (setq args
(cdr args
)))))
3328 ;;; Indexing for definitions
3330 ;; An index entry has three parts: the `entry proper', the node name, and the
3331 ;; line number. Depending on the which command is used, the entry is
3332 ;; formatted differently:
3338 ;; @defopt all use their 1st argument as the entry-proper
3344 ;; @deftypevar all use their 2nd argument as the entry-proper
3347 ;; @deftypevr both use their 3rd argument as the entry-proper
3349 ;; @defmethod uses its 2nd and 1st arguments as an entry-proper
3350 ;; formatted: NAME on CLASS
3352 ;; @defop uses its 3rd and 2nd arguments as an entry-proper
3353 ;; formatted: NAME on CLASS
3355 ;; @defivar uses its 2nd and 1st arguments as an entry-proper
3356 ;; formatted: NAME of CLASS
3358 ;; @defcv uses its 3rd and 2nd argument as an entry-proper
3359 ;; formatted: NAME of CLASS
3361 (put 'defun
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3362 (put 'defunx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3363 (put 'defmac
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3364 (put 'defmacx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3365 (put 'defspec
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3366 (put 'defspecx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3367 (put 'defvar
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3368 (put 'defvarx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3369 (put 'defopt
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3370 (put 'defoptx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3371 (defun texinfo-index-defun (parsed-args)
3372 ;; use 1st parsed-arg as entry-proper
3373 ;; `index-list' will be texinfo-findex or the like
3374 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3377 ;; Three elements: entry-proper, node-name, line-number
3381 ;; Region formatting may not provide last node position.
3382 (if texinfo-last-node-pos
3383 (1+ (count-lines texinfo-last-node-pos
(point)))
3385 (symbol-value index-list
)))))
3387 (put 'deffn
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3388 (put 'deffnx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3389 (put 'defvr
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3390 (put 'defvrx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3391 (put 'deftp
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3392 (put 'deftpx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3393 (put 'deftypefun
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3394 (put 'deftypefunx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3395 (put 'deftypevar
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3396 (put 'deftypevarx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3397 (defun texinfo-index-deffn (parsed-args)
3398 ;; use 2nd parsed-arg as entry-proper
3399 ;; `index-list' will be texinfo-findex or the like
3400 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3403 ;; Three elements: entry-proper, node-name, line-number
3405 (car (cdr parsed-args
))
3407 ;; Region formatting may not provide last node position.
3408 (if texinfo-last-node-pos
3409 (1+ (count-lines texinfo-last-node-pos
(point)))
3411 (symbol-value index-list
)))))
3413 (put 'deftypefn
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3414 (put 'deftypefnx
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3415 (put 'deftypevr
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3416 (put 'deftypevrx
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3417 (defun texinfo-index-deftypefn (parsed-args)
3418 ;; use 3rd parsed-arg as entry-proper
3419 ;; `index-list' will be texinfo-findex or the like
3420 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3423 ;; Three elements: entry-proper, node-name, line-number
3425 (car (cdr (cdr parsed-args
)))
3427 ;; Region formatting may not provide last node position.
3428 (if texinfo-last-node-pos
3429 (1+ (count-lines texinfo-last-node-pos
(point)))
3431 (symbol-value index-list
)))))
3433 (put 'defmethod
'texinfo-defun-indexing-property
'texinfo-index-defmethod
)
3434 (put 'defmethodx
'texinfo-defun-indexing-property
'texinfo-index-defmethod
)
3435 (defun texinfo-index-defmethod (parsed-args)
3436 ;; use 2nd on 1st parsed-arg as entry-proper
3437 ;; `index-list' will be texinfo-findex or the like
3438 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3441 ;; Three elements: entry-proper, node-name, line-number
3444 (car (cdr parsed-args
))
3447 ;; Region formatting may not provide last node position.
3448 (if texinfo-last-node-pos
3449 (1+ (count-lines texinfo-last-node-pos
(point)))
3451 (symbol-value index-list
)))))
3453 (put 'defop
'texinfo-defun-indexing-property
'texinfo-index-defop
)
3454 (put 'defopx
'texinfo-defun-indexing-property
'texinfo-index-defop
)
3455 (defun texinfo-index-defop (parsed-args)
3456 ;; use 3rd on 2nd parsed-arg as entry-proper
3457 ;; `index-list' will be texinfo-findex or the like
3458 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3461 ;; Three elements: entry-proper, node-name, line-number
3464 (car (cdr (cdr parsed-args
)))
3465 (car (cdr parsed-args
)))
3467 ;; Region formatting may not provide last node position.
3468 (if texinfo-last-node-pos
3469 (1+ (count-lines texinfo-last-node-pos
(point)))
3471 (symbol-value index-list
)))))
3473 (put 'defivar
'texinfo-defun-indexing-property
'texinfo-index-defivar
)
3474 (put 'defivarx
'texinfo-defun-indexing-property
'texinfo-index-defivar
)
3475 (defun texinfo-index-defivar (parsed-args)
3476 ;; use 2nd of 1st parsed-arg as entry-proper
3477 ;; `index-list' will be texinfo-findex or the like
3478 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3481 ;; Three elements: entry-proper, node-name, line-number
3484 (car (cdr parsed-args
))
3487 ;; Region formatting may not provide last node position.
3488 (if texinfo-last-node-pos
3489 (1+ (count-lines texinfo-last-node-pos
(point)))
3491 (symbol-value index-list
)))))
3493 (put 'defcv
'texinfo-defun-indexing-property
'texinfo-index-defcv
)
3494 (put 'defcvx
'texinfo-defun-indexing-property
'texinfo-index-defcv
)
3495 (defun texinfo-index-defcv (parsed-args)
3496 ;; use 3rd of 2nd parsed-arg as entry-proper
3497 ;; `index-list' will be texinfo-findex or the like
3498 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3501 ;; Three elements: entry-proper, node-name, line-number
3504 (car (cdr (cdr parsed-args
)))
3505 (car (cdr parsed-args
)))
3507 ;; Region formatting may not provide last node position.
3508 (if texinfo-last-node-pos
3509 (1+ (count-lines texinfo-last-node-pos
(point)))
3511 (symbol-value index-list
)))))
3514 ;;; Properties for definitions
3516 ;; Each definition command has six properties:
3518 ;; 1. texinfo-deffn-formatting-property to format definition line
3519 ;; 2. texinfo-defun-indexing-property to create index entry
3520 ;; 3. texinfo-format formatting command
3521 ;; 4. texinfo-end end formatting command
3522 ;; 5. texinfo-defun-type type of deffn to format
3523 ;; 6. texinfo-defun-index type of index to use
3525 ;; The `x' forms of each definition command are used for the second
3526 ;; and subsequent header lines.
3528 ;; The texinfo-deffn-formatting-property and texinfo-defun-indexing-property
3529 ;; are listed just before the appropriate formatting and indexing commands.
3531 (put 'deffn
'texinfo-format
'texinfo-format-defun
)
3532 (put 'deffnx
'texinfo-format
'texinfo-format-defunx
)
3533 (put 'deffn
'texinfo-end
'texinfo-end-defun
)
3534 (put 'deffn
'texinfo-defun-type
'('deffn-type nil
))
3535 (put 'deffnx
'texinfo-defun-type
'('deffn-type nil
))
3536 (put 'deffn
'texinfo-defun-index
'texinfo-findex
)
3537 (put 'deffnx
'texinfo-defun-index
'texinfo-findex
)
3539 (put 'defun
'texinfo-format
'texinfo-format-defun
)
3540 (put 'defunx
'texinfo-format
'texinfo-format-defunx
)
3541 (put 'defun
'texinfo-end
'texinfo-end-defun
)
3542 (put 'defun
'texinfo-defun-type
'('defun-type
"Function"))
3543 (put 'defunx
'texinfo-defun-type
'('defun-type
"Function"))
3544 (put 'defun
'texinfo-defun-index
'texinfo-findex
)
3545 (put 'defunx
'texinfo-defun-index
'texinfo-findex
)
3547 (put 'defmac
'texinfo-format
'texinfo-format-defun
)
3548 (put 'defmacx
'texinfo-format
'texinfo-format-defunx
)
3549 (put 'defmac
'texinfo-end
'texinfo-end-defun
)
3550 (put 'defmac
'texinfo-defun-type
'('defun-type
"Macro"))
3551 (put 'defmacx
'texinfo-defun-type
'('defun-type
"Macro"))
3552 (put 'defmac
'texinfo-defun-index
'texinfo-findex
)
3553 (put 'defmacx
'texinfo-defun-index
'texinfo-findex
)
3555 (put 'defspec
'texinfo-format
'texinfo-format-defun
)
3556 (put 'defspecx
'texinfo-format
'texinfo-format-defunx
)
3557 (put 'defspec
'texinfo-end
'texinfo-end-defun
)
3558 (put 'defspec
'texinfo-defun-type
'('defun-type
"Special form"))
3559 (put 'defspecx
'texinfo-defun-type
'('defun-type
"Special form"))
3560 (put 'defspec
'texinfo-defun-index
'texinfo-findex
)
3561 (put 'defspecx
'texinfo-defun-index
'texinfo-findex
)
3563 (put 'defvr
'texinfo-format
'texinfo-format-defun
)
3564 (put 'defvrx
'texinfo-format
'texinfo-format-defunx
)
3565 (put 'defvr
'texinfo-end
'texinfo-end-defun
)
3566 (put 'defvr
'texinfo-defun-type
'('deffn-type nil
))
3567 (put 'defvrx
'texinfo-defun-type
'('deffn-type nil
))
3568 (put 'defvr
'texinfo-defun-index
'texinfo-vindex
)
3569 (put 'defvrx
'texinfo-defun-index
'texinfo-vindex
)
3571 (put 'defvar
'texinfo-format
'texinfo-format-defun
)
3572 (put 'defvarx
'texinfo-format
'texinfo-format-defunx
)
3573 (put 'defvar
'texinfo-end
'texinfo-end-defun
)
3574 (put 'defvar
'texinfo-defun-type
'('defun-type
"Variable"))
3575 (put 'defvarx
'texinfo-defun-type
'('defun-type
"Variable"))
3576 (put 'defvar
'texinfo-defun-index
'texinfo-vindex
)
3577 (put 'defvarx
'texinfo-defun-index
'texinfo-vindex
)
3579 (put 'defconst
'texinfo-format
'texinfo-format-defun
)
3580 (put 'defconstx
'texinfo-format
'texinfo-format-defunx
)
3581 (put 'defconst
'texinfo-end
'texinfo-end-defun
)
3582 (put 'defconst
'texinfo-defun-type
'('defun-type
"Constant"))
3583 (put 'defconstx
'texinfo-defun-type
'('defun-type
"Constant"))
3584 (put 'defconst
'texinfo-defun-index
'texinfo-vindex
)
3585 (put 'defconstx
'texinfo-defun-index
'texinfo-vindex
)
3587 (put 'defcmd
'texinfo-format
'texinfo-format-defun
)
3588 (put 'defcmdx
'texinfo-format
'texinfo-format-defunx
)
3589 (put 'defcmd
'texinfo-end
'texinfo-end-defun
)
3590 (put 'defcmd
'texinfo-defun-type
'('defun-type
"Command"))
3591 (put 'defcmdx
'texinfo-defun-type
'('defun-type
"Command"))
3592 (put 'defcmd
'texinfo-defun-index
'texinfo-findex
)
3593 (put 'defcmdx
'texinfo-defun-index
'texinfo-findex
)
3595 (put 'defopt
'texinfo-format
'texinfo-format-defun
)
3596 (put 'defoptx
'texinfo-format
'texinfo-format-defunx
)
3597 (put 'defopt
'texinfo-end
'texinfo-end-defun
)
3598 (put 'defopt
'texinfo-defun-type
'('defun-type
"User Option"))
3599 (put 'defoptx
'texinfo-defun-type
'('defun-type
"User Option"))
3600 (put 'defopt
'texinfo-defun-index
'texinfo-vindex
)
3601 (put 'defoptx
'texinfo-defun-index
'texinfo-vindex
)
3603 (put 'deftp
'texinfo-format
'texinfo-format-defun
)
3604 (put 'deftpx
'texinfo-format
'texinfo-format-defunx
)
3605 (put 'deftp
'texinfo-end
'texinfo-end-defun
)
3606 (put 'deftp
'texinfo-defun-type
'('deftp-type nil
))
3607 (put 'deftpx
'texinfo-defun-type
'('deftp-type nil
))
3608 (put 'deftp
'texinfo-defun-index
'texinfo-tindex
)
3609 (put 'deftpx
'texinfo-defun-index
'texinfo-tindex
)
3611 ;;; Object-oriented stuff is a little hairier.
3613 (put 'defop
'texinfo-format
'texinfo-format-defun
)
3614 (put 'defopx
'texinfo-format
'texinfo-format-defunx
)
3615 (put 'defop
'texinfo-end
'texinfo-end-defun
)
3616 (put 'defop
'texinfo-defun-type
'('defop-type nil
))
3617 (put 'defopx
'texinfo-defun-type
'('defop-type nil
))
3618 (put 'defop
'texinfo-defun-index
'texinfo-findex
)
3619 (put 'defopx
'texinfo-defun-index
'texinfo-findex
)
3621 (put 'defmethod
'texinfo-format
'texinfo-format-defun
)
3622 (put 'defmethodx
'texinfo-format
'texinfo-format-defunx
)
3623 (put 'defmethod
'texinfo-end
'texinfo-end-defun
)
3624 (put 'defmethod
'texinfo-defun-type
'('defmethod-type
"Method"))
3625 (put 'defmethodx
'texinfo-defun-type
'('defmethod-type
"Method"))
3626 (put 'defmethod
'texinfo-defun-index
'texinfo-findex
)
3627 (put 'defmethodx
'texinfo-defun-index
'texinfo-findex
)
3629 (put 'defcv
'texinfo-format
'texinfo-format-defun
)
3630 (put 'defcvx
'texinfo-format
'texinfo-format-defunx
)
3631 (put 'defcv
'texinfo-end
'texinfo-end-defun
)
3632 (put 'defcv
'texinfo-defun-type
'('defop-type nil
))
3633 (put 'defcvx
'texinfo-defun-type
'('defop-type nil
))
3634 (put 'defcv
'texinfo-defun-index
'texinfo-vindex
)
3635 (put 'defcvx
'texinfo-defun-index
'texinfo-vindex
)
3637 (put 'defivar
'texinfo-format
'texinfo-format-defun
)
3638 (put 'defivarx
'texinfo-format
'texinfo-format-defunx
)
3639 (put 'defivar
'texinfo-end
'texinfo-end-defun
)
3640 (put 'defivar
'texinfo-defun-type
'('defmethod-type
"Instance variable"))
3641 (put 'defivarx
'texinfo-defun-type
'('defmethod-type
"Instance variable"))
3642 (put 'defivar
'texinfo-defun-index
'texinfo-vindex
)
3643 (put 'defivarx
'texinfo-defun-index
'texinfo-vindex
)
3645 ;;; Typed functions and variables
3647 (put 'deftypefn
'texinfo-format
'texinfo-format-defun
)
3648 (put 'deftypefnx
'texinfo-format
'texinfo-format-defunx
)
3649 (put 'deftypefn
'texinfo-end
'texinfo-end-defun
)
3650 (put 'deftypefn
'texinfo-defun-type
'('deftypefn-type nil
))
3651 (put 'deftypefnx
'texinfo-defun-type
'('deftypefn-type nil
))
3652 (put 'deftypefn
'texinfo-defun-index
'texinfo-findex
)
3653 (put 'deftypefnx
'texinfo-defun-index
'texinfo-findex
)
3655 (put 'deftypefun
'texinfo-format
'texinfo-format-defun
)
3656 (put 'deftypefunx
'texinfo-format
'texinfo-format-defunx
)
3657 (put 'deftypefun
'texinfo-end
'texinfo-end-defun
)
3658 (put 'deftypefun
'texinfo-defun-type
'('deftypefun-type
"Function"))
3659 (put 'deftypefunx
'texinfo-defun-type
'('deftypefun-type
"Function"))
3660 (put 'deftypefun
'texinfo-defun-index
'texinfo-findex
)
3661 (put 'deftypefunx
'texinfo-defun-index
'texinfo-findex
)
3663 (put 'deftypevr
'texinfo-format
'texinfo-format-defun
)
3664 (put 'deftypevrx
'texinfo-format
'texinfo-format-defunx
)
3665 (put 'deftypevr
'texinfo-end
'texinfo-end-defun
)
3666 (put 'deftypevr
'texinfo-defun-type
'('deftypefn-type nil
))
3667 (put 'deftypevrx
'texinfo-defun-type
'('deftypefn-type nil
))
3668 (put 'deftypevr
'texinfo-defun-index
'texinfo-vindex
)
3669 (put 'deftypevrx
'texinfo-defun-index
'texinfo-vindex
)
3671 (put 'deftypevar
'texinfo-format
'texinfo-format-defun
)
3672 (put 'deftypevarx
'texinfo-format
'texinfo-format-defunx
)
3673 (put 'deftypevar
'texinfo-end
'texinfo-end-defun
)
3674 (put 'deftypevar
'texinfo-defun-type
'('deftypevar-type
"Variable"))
3675 (put 'deftypevarx
'texinfo-defun-type
'('deftypevar-type
"Variable"))
3676 (put 'deftypevar
'texinfo-defun-index
'texinfo-vindex
)
3677 (put 'deftypevarx
'texinfo-defun-index
'texinfo-vindex
)
3680 ;;; @set, @clear, @ifset, @ifclear
3682 ;; If a flag is set with @set FLAG, then text between @ifset and @end
3683 ;; ifset is formatted normally, but if the flag is is cleared with
3684 ;; @clear FLAG, then the text is not formatted; it is ignored.
3686 ;; If a flag is cleared with @clear FLAG, then text between @ifclear
3687 ;; and @end ifclear is formatted normally, but if the flag is is set with
3688 ;; @set FLAG, then the text is not formatted; it is ignored. @ifclear
3689 ;; is the opposite of @ifset.
3691 ;; If a flag is set to a string with @set FLAG,
3692 ;; replace @value{FLAG} with the string.
3693 ;; If a flag with a value is cleared,
3694 ;; @value{FLAG} is invalid,
3695 ;; as if there had never been any @set FLAG previously.
3697 (put 'clear
'texinfo-format
'texinfo-clear
)
3698 (defun texinfo-clear ()
3699 "Clear the value of the flag."
3700 (let* ((arg (texinfo-parse-arg-discard))
3701 (flag (car (read-from-string arg
)))
3702 (value (substring arg
(cdr (read-from-string arg
)))))
3703 (put flag
'texinfo-whether-setp
'flag-cleared
)
3704 (put flag
'texinfo-set-value
"")))
3706 (put 'set
'texinfo-format
'texinfo-set
)
3707 (defun texinfo-set ()
3708 "Set the value of the flag, optionally to a string.
3709 The command `@set foo This is a string.'
3710 sets flag foo to the value: `This is a string.'
3711 The command `@value{foo}' expands to the value."
3712 (let* ((arg (texinfo-parse-arg-discard))
3713 (flag (car (read-from-string arg
)))
3714 (value (substring arg
(cdr (read-from-string arg
)))))
3715 (put flag
'texinfo-whether-setp
'flag-set
)
3716 (put flag
'texinfo-set-value value
)))
3718 (put 'value
'texinfo-format
'texinfo-value
)
3719 (defun texinfo-value ()
3720 "Insert the string to which the flag is set.
3721 The command `@set foo This is a string.'
3722 sets flag foo to the value: `This is a string.'
3723 The command `@value{foo}' expands to the value."
3724 (let ((arg (texinfo-parse-arg-discard)))
3726 (eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3728 (get (car (read-from-string arg
)) 'texinfo-set-value
))
3729 (insert (get (car (read-from-string arg
)) 'texinfo-set-value
)))
3730 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3732 (insert (format "{No value for \"%s\"}" arg
)))
3733 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
) nil
)
3734 (insert (format "{No value for \"%s\"}" arg
))))))
3736 (put 'ifset
'texinfo-end
'texinfo-discard-command
)
3737 (put 'ifset
'texinfo-format
'texinfo-if-set
)
3738 (defun texinfo-if-set ()
3739 "If set, continue formatting; else do not format region up to @end ifset"
3740 (let ((arg (texinfo-parse-arg-discard)))
3742 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3744 ;; Format the text (i.e., do not remove it); do nothing here.
3746 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3748 ;; Clear region (i.e., cause the text to be ignored).
3749 (delete-region texinfo-command-start
3750 (progn (re-search-forward "@end ifset[ \t]*\n")
3752 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3754 ;; In this case flag is neither set nor cleared.
3755 ;; Act as if set, i.e. do nothing.
3758 (put 'ifclear
'texinfo-end
'texinfo-discard-command
)
3759 (put 'ifclear
'texinfo-format
'texinfo-if-clear
)
3760 (defun texinfo-if-clear ()
3761 "If clear, continue formatting; if set, do not format up to @end ifset"
3762 (let ((arg (texinfo-parse-arg-discard)))
3764 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3766 ;; Clear region (i.e., cause the text to be ignored).
3767 (delete-region texinfo-command-start
3768 (progn (re-search-forward "@end ifclear[ \t]*\n")
3770 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3772 ;; Format the text (i.e., do not remove it); do nothing here.
3774 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
3776 ;; In this case flag is neither set nor cleared.
3777 ;; Act as if clear, i.e. do nothing.
3782 (put 'ifeq
'texinfo-format
'texinfo-format-ifeq
)
3783 (defun texinfo-format-ifeq ()
3784 "If ARG1 and ARG2 caselessly string compare to same string, perform COMMAND.
3785 Otherwise produces no output.
3788 @ifeq{ arg1 , arg1 , @code{foo}} bar
3792 @ifeq{ arg1 , arg2 , @code{foo}} bar
3796 Note that the Texinfo command and its arguments must be arguments to
3798 ;; compare-buffer-substrings does not exist in version 18; don't use
3799 (goto-char texinfo-command-end
)
3800 (let* ((case-fold-search t
)
3801 (stop (save-excursion (forward-sexp 1) (point)))
3803 ;; @ifeq{arg1, arg2, @command{optional-args}}
3807 (skip-chars-forward " ")
3808 (setq start
(point))
3809 (search-forward "," stop t
)
3810 (skip-chars-backward ", ")
3811 (buffer-substring start
(point))))
3814 (search-forward "," stop t
)
3815 (skip-chars-forward " ")
3816 (setq start
(point))
3817 (search-forward "," stop t
)
3818 (skip-chars-backward ", ")
3819 (buffer-substring start
(point))))
3822 (search-forward "," stop t
)
3823 (skip-chars-forward " ")
3824 (setq start
(point))
3825 (goto-char (1- stop
))
3826 (skip-chars-backward " ")
3827 (buffer-substring start
(point)))))
3828 (delete-region texinfo-command-start stop
)
3829 (if (equal arg1 arg2
)
3830 (insert texinfo-command
))
3831 (goto-char texinfo-command-start
)))
3834 ;;; Process included files: `@include' command
3836 ;; Updated 19 October 1990
3837 ;; In the original version, include files were ignored by Info but
3838 ;; incorporated in to the printed manual. To make references to the
3839 ;; included file, the Texinfo source file has to refer to the included
3840 ;; files using the `(filename)nodename' format for referring to other
3841 ;; Info files. Also, the included files had to be formatted on their
3842 ;; own. It was just like they were another file.
3844 ;; Currently, include files are inserted into the buffer that is
3845 ;; formatted for Info. If large, the resulting info file is split and
3846 ;; tagified. For current include files to work, the master menu must
3847 ;; refer to all the nodes, and the highest level nodes in the include
3848 ;; files must have the correct next, prev, and up pointers.
3850 ;; The included file may have an @setfilename and even an @settitle,
3851 ;; but not an `\input texinfo' line.
3853 ;; Updated 24 March 1993
3854 ;; In order for @raisesections and @lowersections to work, included
3855 ;; files must be inserted into the buffer holding the outer file
3856 ;; before other Info formatting takes place. So @include is no longer
3857 ;; is treated like other @-commands.
3858 (put 'include
'texinfo-format
'texinfo-format-noop
)
3860 ;; Original definition:
3861 ;; (defun texinfo-format-include ()
3862 ;; (let ((filename (texinfo-parse-arg-discard))
3863 ;; (default-directory input-directory)
3867 ;; (progn (find-file
3868 ;; (cond ((file-readable-p (concat filename ".texinfo"))
3869 ;; (concat filename ".texinfo"))
3870 ;; ((file-readable-p (concat filename ".texi"))
3871 ;; (concat filename ".texi"))
3872 ;; ((file-readable-p (concat filename ".tex"))
3873 ;; (concat filename ".tex"))
3874 ;; ((file-readable-p filename)
3876 ;; (t (error "@include'd file %s not found"
3878 ;; (texinfo-format-buffer-1))))
3879 ;; (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex))
3880 ;; (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex))
3881 ;; (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex))
3882 ;; (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex))
3883 ;; (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex))
3884 ;; (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex))))
3886 ;;(defun texinfo-subindex (indexvar file content)
3887 ;; (set indexvar (cons (list 'recurse file content)
3888 ;; (symbol-value indexvar))))
3890 ;; Second definition:
3891 ;; (put 'include 'texinfo-format 'texinfo-format-include)
3892 ;; (defun texinfo-format-include ()
3893 ;; (let ((filename (concat input-directory
3894 ;; (texinfo-parse-arg-discard)))
3895 ;; (default-directory input-directory))
3896 ;; (message "Reading: %s" filename)
3898 ;; (save-restriction
3899 ;; (narrow-to-region
3901 ;; (+ (point) (car (cdr (insert-file-contents filename)))))
3902 ;; (goto-char (point-min))
3903 ;; (texinfo-append-refill)
3904 ;; (texinfo-format-convert (point-min) (point-max))))
3905 ;; (setq last-input-buffer input-buffer) ; to bypass setfilename
3909 ;;; Numerous commands do nothing in Info
3910 ;; These commands are defined in texinfo.tex for printed output.
3913 ;;; various noops, such as @b{foo}, that take arguments in braces
3915 (put 'b
'texinfo-format
'texinfo-format-noop
)
3916 (put 'i
'texinfo-format
'texinfo-format-noop
)
3917 (put 'r
'texinfo-format
'texinfo-format-noop
)
3918 (put 't
'texinfo-format
'texinfo-format-noop
)
3919 (put 'w
'texinfo-format
'texinfo-format-noop
)
3920 (put 'asis
'texinfo-format
'texinfo-format-noop
)
3921 (put 'dmn
'texinfo-format
'texinfo-format-noop
)
3922 (put 'math
'texinfo-format
'texinfo-format-noop
)
3923 (put 'titlefont
'texinfo-format
'texinfo-format-noop
)
3924 (defun texinfo-format-noop ()
3925 (insert (texinfo-parse-arg-discard))
3926 (goto-char texinfo-command-start
))
3928 ;; @hyphenation command discards an argument within braces
3929 (put 'hyphenation
'texinfo-format
'texinfo-discard-command-and-arg
)
3930 (defun texinfo-discard-command-and-arg ()
3931 "Discard both @-command and its argument in braces."
3932 (goto-char texinfo-command-end
)
3934 (setq texinfo-command-end
(point))
3935 (delete-region texinfo-command-start texinfo-command-end
))
3938 ;;; Do nothing commands, such as @smallbook, that have no args and no braces
3939 ;; These must appear on a line of their own
3941 (put 'bye
'texinfo-format
'texinfo-discard-line
)
3942 (put 'smallbook
'texinfo-format
'texinfo-discard-line
)
3943 (put 'finalout
'texinfo-format
'texinfo-discard-line
)
3944 (put 'overfullrule
'texinfo-format
'texinfo-discard-line
)
3945 (put 'smallbreak
'texinfo-format
'texinfo-discard-line
)
3946 (put 'medbreak
'texinfo-format
'texinfo-discard-line
)
3947 (put 'bigbreak
'texinfo-format
'texinfo-discard-line
)
3950 ;;; These noop commands discard the rest of the line.
3952 (put 'c
'texinfo-format
'texinfo-discard-line-with-args
)
3953 (put 'comment
'texinfo-format
'texinfo-discard-line-with-args
)
3954 (put 'contents
'texinfo-format
'texinfo-discard-line-with-args
)
3955 (put 'group
'texinfo-end
'texinfo-discard-line-with-args
)
3956 (put 'group
'texinfo-format
'texinfo-discard-line-with-args
)
3957 (put 'headings
'texinfo-format
'texinfo-discard-line-with-args
)
3958 (put 'setchapterstyle
'texinfo-format
'texinfo-discard-line-with-args
)
3959 (put 'hsize
'texinfo-format
'texinfo-discard-line-with-args
)
3960 (put 'itemindent
'texinfo-format
'texinfo-discard-line-with-args
)
3961 (put 'lispnarrowing
'texinfo-format
'texinfo-discard-line-with-args
)
3962 (put 'need
'texinfo-format
'texinfo-discard-line-with-args
)
3963 (put 'nopara
'texinfo-format
'texinfo-discard-line-with-args
)
3964 (put 'page
'texinfo-format
'texinfo-discard-line-with-args
)
3965 (put 'parindent
'texinfo-format
'texinfo-discard-line-with-args
)
3966 (put 'setchapternewpage
'texinfo-format
'texinfo-discard-line-with-args
)
3967 (put 'setq
'texinfo-format
'texinfo-discard-line-with-args
)
3968 (put 'settitle
'texinfo-format
'texinfo-discard-line-with-args
)
3969 (put 'setx
'texinfo-format
'texinfo-discard-line-with-args
)
3970 (put 'shortcontents
'texinfo-format
'texinfo-discard-line-with-args
)
3971 (put 'shorttitlepage
'texinfo-format
'texinfo-discard-line-with-args
)
3972 (put 'summarycontents
'texinfo-format
'texinfo-discard-line-with-args
)
3973 (put 'input
'texinfo-format
'texinfo-discard-line-with-args
)
3976 ;;; Some commands cannot be handled
3978 (defun texinfo-unsupported ()
3979 (error "%s is not handled by texinfo"
3980 (buffer-substring texinfo-command-start texinfo-command-end
)))
3982 ;;; Batch formatting
3984 (defun batch-texinfo-format ()
3985 "Runs texinfo-format-buffer on the files remaining on the command line.
3986 Must be used only with -batch, and kills emacs on completion.
3987 Each file will be processed even if an error occurred previously.
3989 \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"."
3990 (if (not noninteractive
)
3991 (error "batch-texinfo-format may only be used -batch."))
3992 (let ((version-control t
)
3993 (auto-save-default nil
)
3994 (find-file-run-dired nil
)
3995 (kept-old-versions 259259)
3996 (kept-new-versions 259259))
4000 (while command-line-args-left
4001 (setq file
(expand-file-name (car command-line-args-left
)))
4002 (cond ((not (file-exists-p file
))
4003 (message ">> %s does not exist!" file
)
4005 command-line-args-left
(cdr command-line-args-left
)))
4006 ((file-directory-p file
)
4007 (setq command-line-args-left
4008 (nconc (directory-files file
)
4009 (cdr command-line-args-left
))))
4011 (setq files
(cons file files
)
4012 command-line-args-left
(cdr command-line-args-left
)))))
4014 (setq file
(car files
)
4018 (if buffer-file-name
(kill-buffer (current-buffer)))
4020 (buffer-disable-undo (current-buffer))
4021 (set-buffer-modified-p nil
)
4023 (message "texinfo formatting %s..." file
)
4024 (texinfo-format-buffer nil
)
4025 (if (buffer-modified-p)
4026 (progn (message "Saving modified %s" (buffer-file-name))
4029 (message ">> Error: %s" (prin1-to-string err
))
4030 (message ">> point at")
4031 (let ((s (buffer-substring (point)
4032 (min (+ (point) 100)
4035 (while (setq tem
(string-match "\n+" s tem
))
4036 (setq s
(concat (substring s
0 (match-beginning 0))
4038 (substring s
(match-end 0)))
4040 (message ">> %s" s
))
4042 (kill-emacs error
))))
4045 ;;; Place `provide' at end of file.
4048 ;;; texinfmt.el ends here.