1 ;;; texinfmt.el --- format Texinfo files into Info files
3 ;; Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993,
4 ;; 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003,
5 ;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
7 ;; Maintainer: Robert J. Chassell <bug-texinfo@gnu.org>
8 ;; Keywords: maint, tex, docs
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 3, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
31 ;;; Emacs lisp functions to convert Texinfo files to Info files.
33 (or (fboundp 'defgroup
)
34 (defmacro defgroup
(&rest ignore
) nil
))
36 (or (fboundp 'defcustom
)
37 (defmacro defcustom
(var value doc
&rest ignore
)
38 `(defvar ,var
,value
,doc
)))
40 (defvar texinfmt-version
"2.42 of 7 Jul 2006")
42 (defun texinfmt-version (&optional here
)
43 "Show the version of texinfmt.el in the minibuffer.
44 If optional argument HERE is non-nil, insert info at point."
47 (format "Version of \`texinfmt.el\': %s" texinfmt-version
)))
49 (insert version-string
)
51 (message "%s" version-string
)
55 ;;; Variable definitions
57 (require 'texinfo
) ; So `texinfo-footnote-style' is defined.
58 (require 'texnfo-upd
) ; So `texinfo-section-types-regexp' is defined.
60 (defvar texinfo-format-syntax-table nil
)
62 (defvar texinfo-vindex
)
63 (defvar texinfo-findex
)
64 (defvar texinfo-cindex
)
65 (defvar texinfo-pindex
)
66 (defvar texinfo-tindex
)
67 (defvar texinfo-kindex
)
68 (defvar texinfo-last-node
)
69 (defvar texinfo-node-names
)
70 (defvar texinfo-enclosure-list
)
71 (defvar texinfo-alias-list
)
72 (defvar texinfo-fold-nodename-case nil
)
74 (defvar texinfo-command-start
)
75 (defvar texinfo-command-end
)
76 (defvar texinfo-command-name
)
77 (defvar texinfo-defun-type
)
78 (defvar texinfo-last-node-pos
)
79 (defvar texinfo-stack
)
80 (defvar texinfo-short-index-cmds-alist
)
81 (defvar texinfo-short-index-format-cmds-alist
)
82 (defvar texinfo-format-filename
)
83 (defvar texinfo-footnote-number
)
84 (defvar texinfo-start-of-header
)
85 (defvar texinfo-end-of-header
)
86 (defvar texinfo-raisesections-alist
)
87 (defvar texinfo-lowersections-alist
)
91 (if texinfo-format-syntax-table
93 (setq texinfo-format-syntax-table
(make-syntax-table))
94 (modify-syntax-entry ?
\" " " texinfo-format-syntax-table
)
95 (modify-syntax-entry ?
\\ " " texinfo-format-syntax-table
)
96 (modify-syntax-entry ?
@ "\\" texinfo-format-syntax-table
)
97 (modify-syntax-entry ?\^q
"\\" texinfo-format-syntax-table
)
98 (modify-syntax-entry ?\
[ "." texinfo-format-syntax-table
)
99 (modify-syntax-entry ?\
] "." texinfo-format-syntax-table
)
100 (modify-syntax-entry ?\
( "." texinfo-format-syntax-table
)
101 (modify-syntax-entry ?\
) "." texinfo-format-syntax-table
)
102 (modify-syntax-entry ?
{ "(}" texinfo-format-syntax-table
)
103 (modify-syntax-entry ?
} "){" texinfo-format-syntax-table
)
104 (modify-syntax-entry ?
\' "." texinfo-format-syntax-table
))
107 ;;; Top level buffer and region formatting functions
110 (defun texinfo-format-buffer (&optional nosplit
)
111 "Process the current buffer as texinfo code, into an Info file.
112 The Info file output is generated in a buffer visiting the Info file
113 name specified in the @setfilename command.
115 Non-nil argument (prefix, if interactive) means don't make tag table
116 and don't split the file if large. You can use Info-tagify and
117 Info-split to do these manually."
119 (let ((lastmessage "Formatting Info file...")
120 (coding-system-for-write buffer-file-coding-system
))
121 (message lastmessage
)
123 (texinfo-format-buffer-1)
127 (if (> (buffer-size) 100000)
129 (message (setq lastmessage
"Splitting Info file..."))
131 (message (concat lastmessage
132 (if (interactive-p) "done. Now save it." "done.")))))
134 (defvar texinfo-region-buffer-name
"*Info Region*"
135 "*Name of the temporary buffer used by \\[texinfo-format-region].")
137 (defvar texinfo-pre-format-hook nil
138 "Hook called before the conversion of the Texinfo file to Info format.
139 The functions on this hook are called with argument BUFFER, the buffer
140 containing the Texinfo file.")
142 ;; These come from tex-mode.el.
143 (defvar tex-start-of-header
)
144 (defvar tex-end-of-header
)
147 (defun texinfo-format-region (region-beginning region-end
)
148 "Convert the current region of the Texinfo file to Info format.
149 This lets you see what that part of the file will look like in Info.
150 The command is bound to \\[texinfo-format-region]. The text that is
151 converted to Info is stored in a temporary buffer."
153 (message "Converting region to Info format...")
154 (let (texinfo-command-start
164 (texinfo-format-filename "")
165 texinfo-example-start
166 texinfo-last-node-pos
169 (texinfo-footnote-number 0)
171 (fill-column-for-info fill-column
)
172 (input-buffer (current-buffer))
173 (input-directory default-directory
)
178 ;;; Copy lines between beginning and end of header lines,
179 ;;; if any, or else copy the `@setfilename' line, if any.
183 (goto-char (point-min))
184 (let ((search-end (save-excursion (forward-line 100) (point))))
186 ;; Either copy header text.
189 (search-forward tex-start-of-header search-end t
)
191 ;; Mark beginning of header.
192 (setq header-beginning
(point)))
194 (search-forward tex-end-of-header nil t
)
196 ;; Mark end of header
197 (setq header-end
(point))))
198 ;; Or copy @filename line.
200 (goto-char (point-min))
201 (search-forward "@setfilename" search-end t
)
203 (setq header-beginning
(point))
205 (setq header-end
(point))))
209 (buffer-substring-no-properties
210 (min header-beginning region-beginning
)
213 ;;; Find a buffer to use.
214 (switch-to-buffer (get-buffer-create texinfo-region-buffer-name
))
215 (setq buffer-read-only t
)
216 (let ((inhibit-read-only t
))
218 ;; Insert the header into the buffer.
220 ;; Insert the region into the buffer.
221 (insert-buffer-substring
223 (max region-beginning header-end
)
225 (run-hook-with-args 'texinfo-pre-format-hook input-buffer
)
226 ;; Make sure region ends in a newline.
227 (or (= (preceding-char) ?
\n)
230 (goto-char (point-min))
232 (message "Converting region to Info format...")
233 (setq fill-column fill-column-for-info
)
234 ;; Install a syntax table useful for scanning command operands.
235 (set-syntax-table texinfo-format-syntax-table
)
237 ;; Insert @include files so `texinfo-raise-lower-sections' can
238 ;; work on them without losing track of multiple
239 ;; @raise/@lowersections commands.
240 (while (re-search-forward "^@include" nil t
)
241 (setq texinfo-command-end
(point))
242 (let ((filename (concat input-directory
243 (texinfo-parse-line-arg))))
244 (re-search-backward "^@include")
245 (delete-region (point) (save-excursion (forward-line 1) (point)))
246 (message "Reading included file: %s" filename
)
251 (+ (point) (car (cdr (insert-file-contents filename
)))))
252 (goto-char (point-min))
253 ;; Remove `@setfilename' line from included file, if any,
254 ;; so @setfilename command not duplicated.
255 (if (re-search-forward "^@setfilename" (line-end-position 100) t
)
256 (delete-region (line-beginning-position 1)
257 (line-beginning-position 2)))))))
259 ;; Raise or lower level of each section, if necessary.
260 (goto-char (point-min))
261 (texinfo-raise-lower-sections)
262 ;; Append @refill to appropriate paragraphs for filling.
263 (goto-char (point-min))
264 (texinfo-append-refill)
265 ;; If the region includes the effective end of the data,
266 ;; discard everything after that.
267 (goto-char (point-max))
268 (if (re-search-backward "^@bye" nil t
)
269 (delete-region (point) (point-max)))
270 ;; Make sure buffer ends in a newline.
271 (or (= (preceding-char) ?
\n)
273 ;; Don't use a previous value of texinfo-enclosure-list.
274 (setq texinfo-enclosure-list nil
)
275 (setq texinfo-alias-list nil
)
277 (goto-char (point-min))
278 (if (looking-at "\\\\input[ \t]+texinfo")
279 (delete-region (point) (line-beginning-position 2)))
281 ;; Insert Info region title text.
282 (goto-char (point-min))
284 "@setfilename" (save-excursion (forward-line 100) (point)) t
)
286 (setq texinfo-command-end
(point))
288 (setq texinfo-command-start
(point))
289 (let ((arg (texinfo-parse-arg-discard)))
291 texinfo-region-buffer-name
293 (insert (file-name-nondirectory (expand-file-name arg
)))
294 (insert "', -*-Text-*-\n")))
295 ;; Else no `@setfilename' line
297 texinfo-region-buffer-name
298 " buffer -*-Text-*-\n"))
299 (insert "produced by `texinfo-format-region'\n"
301 (if (buffer-file-name input-buffer
)
303 (file-name-sans-versions
304 (file-name-nondirectory
305 (buffer-file-name input-buffer
)))
307 (concat "buffer `" (buffer-name input-buffer
) "'"))
308 "\nusing `texinfmt.el' version "
312 ;; Now convert for real.
313 (goto-char (point-min))
314 (texinfo-format-scan)
315 (goto-char (point-min))
316 (Info-tagify input-buffer
)
317 (goto-char (point-min))
321 (defun texi2info (&optional nosplit
)
322 "Convert the current buffer (written in Texinfo code) into an Info file.
323 The Info file output is generated in a buffer visiting the Info file
324 names specified in the @setfilename command.
326 This function automatically updates all node pointers and menus, and
327 creates a master menu. This work is done on a temporary buffer that
328 is automatically removed when the Info file is created. The original
329 Texinfo source buffer is not changed.
331 Non-nil argument (prefix, if interactive) means don't split the file
332 if large. You can use Info-split to do this manually."
334 (let ((temp-buffer (concat "*--" (buffer-name) "--temporary-buffer*" )))
335 (message "First updating nodes and menus, then creating Info file.")
337 (copy-to-buffer temp-buffer
(point-min) (point-max))
338 (switch-to-buffer temp-buffer
)
339 (texinfo-master-menu t
)
340 (message "Now creating Info file.")
342 (texinfo-format-buffer nosplit
)
344 (kill-buffer temp-buffer
)))
347 ;;; Primary internal formatting function for the whole buffer.
349 (defun texinfo-format-buffer-1 ()
350 (let (texinfo-format-filename
351 texinfo-example-start
352 texinfo-command-start
356 texinfo-last-node-pos
365 (texinfo-footnote-number 0)
368 (fill-column-for-info fill-column
)
369 (input-buffer (current-buffer))
370 (input-directory default-directory
))
371 (setq texinfo-enclosure-list nil
)
372 (setq texinfo-alias-list nil
)
374 (goto-char (point-min))
375 (or (search-forward "@setfilename" nil t
)
376 (error "Texinfo file needs an `@setfilename FILENAME' line"))
377 (setq texinfo-command-end
(point))
378 (setq outfile
(texinfo-parse-line-arg)))
383 (buffer-disable-undo)
385 (message "Formatting Info file: %s" outfile
)
386 (setq texinfo-format-filename
387 (file-name-nondirectory (expand-file-name outfile
)))
389 (setq fill-column fill-column-for-info
)
390 (set-syntax-table texinfo-format-syntax-table
)
392 (insert-buffer-substring input-buffer
)
393 (run-hook-with-args 'texinfo-pre-format-hook input-buffer
)
394 (message "Converting %s to Info format..." (buffer-name input-buffer
))
396 ;; Insert @include files so `texinfo-raise-lower-sections' can
397 ;; work on them without losing track of multiple
398 ;; @raise/@lowersections commands.
399 (goto-char (point-min))
400 (while (re-search-forward "^@include" nil t
)
401 (setq texinfo-command-end
(point))
402 (let ((filename (concat input-directory
403 (texinfo-parse-line-arg))))
404 (re-search-backward "^@include")
405 (delete-region (point) (line-beginning-position 2))
406 (message "Reading included file: %s" filename
)
411 (+ (point) (car (cdr (insert-file-contents filename
)))))
412 (goto-char (point-min))
413 ;; Remove `@setfilename' line from included file, if any,
414 ;; so @setfilename command not duplicated.
415 (if (re-search-forward "^@setfilename" (line-end-position 100) t
)
416 (delete-region (line-beginning-position 1)
417 (line-beginning-position 2)))))))
418 ;; Raise or lower level of each section, if necessary.
419 (goto-char (point-min))
420 (texinfo-raise-lower-sections)
421 ;; Append @refill to appropriate paragraphs
422 (goto-char (point-min))
423 (texinfo-append-refill)
424 (goto-char (point-min))
425 (search-forward "@setfilename")
427 (delete-region (point-min) (point))
428 ;; Remove @bye at end of file, if it is there.
429 (goto-char (point-max))
430 (if (search-backward "@bye" nil t
)
431 (delete-region (point) (point-max)))
432 ;; Make sure buffer ends in a newline.
433 (or (= (preceding-char) ?
\n)
435 ;; Scan the whole buffer, converting to Info format.
436 (texinfo-format-scan)
437 (goto-char (point-min))
438 ;; Insert info about how this file was made.
439 (insert "Info file: "
440 texinfo-format-filename
", -*-Text-*-\n"
441 "produced by `texinfo-format-buffer'\n"
442 ;; Date string removed so that regression testing is easier.
444 ;; (insert (format-time-string "%e %b %Y")) " "
446 (if (buffer-file-name input-buffer
)
448 (file-name-sans-versions
449 (file-name-nondirectory
450 (buffer-file-name input-buffer
)))
452 (concat "buffer `" (buffer-name input-buffer
) "'"))
453 "\nusing `texinfmt.el' version "
456 ;; Return data for indices.
458 texinfo-vindex texinfo-findex texinfo-cindex
459 texinfo-pindex texinfo-tindex texinfo-kindex
)))
462 ;;; Perform non-@-command file conversions: quotes and hyphens
464 (defun texinfo-format-convert (min max
)
465 ;; Convert left and right quotes to typewriter font quotes.
467 (while (search-forward "``" max t
)
468 (replace-match "\""))
470 (while (search-forward "''" max t
)
471 (replace-match "\""))
472 ;; Convert three hyphens in a row to two.
474 (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t
)
475 (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning 2)))))
478 ;;; Handle paragraph filling
480 ;; Keep as concatinated lists for ease of maintenance
482 (defvar texinfo-no-refill-regexp
486 ;; add "itemize\\|" (from experiment of 2001 Nov 28)
487 ;; because of a problem with @end itemize@refill
488 ;; I don't know if this causes other problems.
489 ;; I suspect itemized lists don't get filled properly and a
490 ;; more precise fix is required. Bob
491 ;; commented out on 2005 Feb 28 by Bob
512 "Regexp specifying environments in which paragraphs are not filled.")
514 (defvar texinfo-accent-commands
547 (defvar texinfo-part-of-para-regexp
582 "@-\\|" ; @- is a descretionary hyphen (not an accent) (a noop).
583 texinfo-accent-commands
586 "Regexp specifying @-commands found within paragraphs.")
588 (defun texinfo-append-refill ()
589 "Append @refill at end of each paragraph that should be filled.
590 Do not append @refill to paragraphs within @example and similar environments.
591 Do not append @refill to paragraphs containing @w{TEXT} or @*."
593 ;; It is necessary to append @refill before other processing because
594 ;; the other processing removes information that tells Texinfo
595 ;; whether the text should or should not be filled.
597 (while (< (point) (point-max))
598 (let ((refill-blank-lines "^[ \t\n]*$")
599 (case-fold-search nil
)) ; Don't confuse @TeX and @tex....
601 ;; 1. Skip over blank lines;
602 ;; skip over lines beginning with @-commands,
603 ;; but do not skip over lines
604 ;; that are no-refill environments such as @example or
605 ;; that begin with within-paragraph @-commands such as @code.
606 (while (and (looking-at (concat "^@\\|^\\\\\\|" refill-blank-lines
))
610 texinfo-no-refill-regexp
612 texinfo-part-of-para-regexp
614 (< (point) (point-max)))
616 ;; 2. Skip over @example and similar no-refill environments.
617 (if (looking-at texinfo-no-refill-regexp
)
618 (let ((environment (match-string-no-properties 1)))
619 (progn (re-search-forward (concat "^@end " environment
) nil t
)
622 ;; 3. Do not refill a paragraph containing @w or @*, or ending
623 ;; with @<newline> followed by a newline.
624 (if (or (>= (point) (point-max))
627 (save-excursion (forward-paragraph) (forward-line 1) (point))
629 ;; Go to end of paragraph and do nothing.
631 ;; 4. Else go to end of paragraph and insert @refill
634 (let ((line-beg (point)))
638 (save-excursion (skip-chars-backward " \t") (point)))
640 (unless (re-search-backward "@c[ \t\n]\\|@comment[ \t\n]" line-beg t
)
642 (unless (re-search-backward "@refill\\|^[ \t]*@" line-beg t
)
644 (forward-line 1))))))
647 ;;; Handle `@raisesections' and `@lowersections' commands
649 ;; These commands change the hierarchical level of chapter structuring
652 ;; @raisesections changes @subsection to @section,
653 ;; @section to @chapter,
656 ;; @lowersections changes @chapter to @section
657 ;; @subsection to @subsubsection,
660 ;; An @raisesections/@lowersections command changes only those
661 ;; structuring commands that follow the @raisesections/@lowersections
664 ;; Repeated @raisesections/@lowersections continue to raise or lower
665 ;; the heading level.
667 ;; An @lowersections command cancels an @raisesections command, and
670 ;; You cannot raise or lower "beyond" chapters or subsubsections, but
671 ;; trying to do so does not elicit an error---you just get more
672 ;; headings that mean the same thing as you keep raising or lowering
673 ;; (for example, after a single @raisesections, both @chapter and
674 ;; @section produce chapter headings).
676 (defun texinfo-raise-lower-sections ()
677 "Raise or lower the hierarchical level of chapters, sections, etc.
679 This function acts according to `@raisesections' and `@lowersections'
680 commands in the Texinfo file.
682 For example, an `@lowersections' command is useful if you wish to
683 include what is written as an outer or standalone Texinfo file in
684 another Texinfo file as an inner, included file. The `@lowersections'
685 command changes chapters to sections, sections to subsections and so
688 @raisesections changes @subsection to @section,
689 @section to @chapter,
690 @heading to @chapheading,
693 @lowersections changes @chapter to @section,
694 @subsection to @subsubsection,
695 @heading to @subheading,
698 An `@raisesections' or `@lowersections' command changes only those
699 structuring commands that follow the `@raisesections' or
700 `@lowersections' command.
702 An `@lowersections' command cancels an `@raisesections' command, and
705 Repeated use of the commands continue to raise or lower the hierarchical
706 level a step at a time.
708 An attempt to raise above `chapters' reproduces chapter commands; an
709 attempt to lower below subsubsections reproduces subsubsection
712 ;; `texinfo-section-types-regexp' is defined in `texnfo-upd.el';
713 ;; it is a regexp matching chapter, section, other headings
714 ;; (but not the top node).
716 (let (type (level 0))
720 "\\(\\(^@\\(raise\\|lower\\)sections\\)\\|\\("
721 texinfo-section-types-regexp
725 (save-excursion (setq type
(read (current-buffer))))
728 ;; 1. Increment level
729 ((eq type
'@raisesections
)
730 (setq level
(1+ level
))
732 (point) (save-excursion (forward-line 1) (point))))
734 ;; 2. Decrement level
735 ((eq type
'@lowersections
)
736 (setq level
(1- level
))
738 (point) (save-excursion (forward-line 1) (point))))
740 ;; Now handle structuring commands
743 ;; 3. Raise level when positive
749 (cdr (assq new-level texinfo-raisesections-alist
)))
750 (setq count
(1- count
)))
752 (insert (symbol-name new-level
))))
754 ;; 4. Do nothing except move point when level is zero
755 ((= level
0) (forward-line 1))
757 ;; 5. Lower level when positive
763 (cdr (assq new-level texinfo-lowersections-alist
)))
764 (setq count
(1+ count
)))
766 (insert (symbol-name new-level
))))))))))
768 (defvar texinfo-raisesections-alist
769 '((@chapter .
@chapter
) ; Cannot go higher
770 (@unnumbered .
@unnumbered
)
771 (@centerchap .
@unnumbered
)
773 (@majorheading .
@majorheading
)
774 (@chapheading .
@chapheading
)
775 (@appendix .
@appendix
)
777 (@section .
@chapter
)
778 (@unnumberedsec .
@unnumbered
)
779 (@heading .
@chapheading
)
780 (@appendixsec .
@appendix
)
782 (@subsection .
@section
)
783 (@unnumberedsubsec .
@unnumberedsec
)
784 (@subheading .
@heading
)
785 (@appendixsubsec .
@appendixsec
)
787 (@subsubsection .
@subsection
)
788 (@unnumberedsubsubsec .
@unnumberedsubsec
)
789 (@subsubheading .
@subheading
)
790 (@appendixsubsubsec .
@appendixsubsec
))
791 "*An alist of next higher levels for chapters, sections. etc.
792 For example, section to chapter, subsection to section.
793 Used by `texinfo-raise-lower-sections'.
794 The keys specify types of section; the values correspond to the next
797 (defvar texinfo-lowersections-alist
798 '((@chapter .
@section
)
799 (@unnumbered .
@unnumberedsec
)
800 (@centerchap .
@unnumberedsec
)
801 (@majorheading .
@heading
)
802 (@chapheading .
@heading
)
803 (@appendix .
@appendixsec
)
805 (@section .
@subsection
)
806 (@unnumberedsec .
@unnumberedsubsec
)
807 (@heading .
@subheading
)
808 (@appendixsec .
@appendixsubsec
)
810 (@subsection .
@subsubsection
)
811 (@unnumberedsubsec .
@unnumberedsubsubsec
)
812 (@subheading .
@subsubheading
)
813 (@appendixsubsec .
@appendixsubsubsec
)
815 (@subsubsection .
@subsubsection
) ; Cannot go lower.
816 (@unnumberedsubsubsec .
@unnumberedsubsubsec
)
817 (@subsubheading .
@subsubheading
)
818 (@appendixsubsubsec .
@appendixsubsubsec
))
819 "*An alist of next lower levels for chapters, sections. etc.
820 For example, chapter to section, section to subsection.
821 Used by `texinfo-raise-lower-sections'.
822 The keys specify types of section; the values correspond to the next
826 ;;; Perform those texinfo-to-info conversions that apply to the whole input
829 (defun texinfo-format-scan ()
830 (texinfo-format-convert (point-min) (point-max))
831 ;; Search for @copying, which has to be first since the
832 ;; @insertcopying command then inserts the text elsewhere.
833 (goto-char (point-min))
834 (when (search-forward "@copying" nil t
)
836 (while (search-forward "@insertcopying" nil t
)
837 (delete-region (match-beginning 0) (match-end 0))
839 (texinfo-insertcopying))
840 ;; Scan for other @-commands.
841 (goto-char (point-min))
842 (while (search-forward "@" nil t
)
844 ;; These are the single-character accent commands: @^ @` @' @" @= @~
845 ;; In Info, they are simply quoted and the @ deleted.
846 ;; Other single-character commands:
847 ;; @* forces a line break,
848 ;; @- is a discretionary hyphenation point; does nothing in Info.
849 ;; @<space>, @<tab>, @<newline> each produce a single space,
850 ;; unless followed by a newline.
852 ;; Old version 2.34 expression: (looking-at "[@{}^'` *\"?!]")
853 (if (looking-at "[@{}^'`\"=~ \t\n*?!-]")
854 ;; @*, causes a line break.
857 ((= (following-char) ?
*)
859 (delete-region (1- (point)) (1+ (point)))
860 ;; insert return if not at end of line;
861 ;; else line is already broken.
862 (if (not (= (following-char) ?
\n))
865 ((= (following-char) ?-
)
866 (delete-region (1- (point)) (1+ (point))))
867 ;; @<space>, @<tab>, @<newline>: produce a single space,
868 ;; unless followed by a newline.
869 ((= (following-char) ?
)
870 (delete-region (1- (point)) (1+ (point)))
871 ;; insert single space if not at end of line;
872 ;; else line is already broken.
873 (if (not (= (following-char) ?
\n))
875 ((= (following-char) ?
\t)
876 (delete-region (1- (point)) (1+ (point)))
877 ;; insert single space if not at end of line;
878 ;; else line is already broken.
879 (if (not (= (following-char) ?
\n))
881 ;; following char is a carriage return
882 ((= (following-char) ?
\n)
884 (delete-region (1- (point)) (1+ (point)))
885 ;; insert single space if not at end of line;
886 ;; else line is already broken.
887 (if (not (= (following-char) ?
\n))
889 ;; Otherwise: the other characters are simply quoted. Delete the @.
892 ;; Be compatible with makeinfo: if @' and its ilk are
893 ;; followed by a @ without a brace, barf.
894 (if (looking-at "[\"'^`~=]")
896 (if (= (char-after (1+ (point))) ?
@)
897 (error "Use braces to give a command as an argument to @%c"
900 ;; @' etc. can optionally accept their argument in
901 ;; braces (makeinfo supports that).
902 (when (looking-at "{")
903 (let ((start (point)))
909 ;; @ is followed by a command-word; find the end of the word.
910 (setq texinfo-command-start
(1- (point)))
911 (if (= (char-syntax (following-char)) ?w
)
914 (setq texinfo-command-end
(point))
915 ;; Detect the case of two @-commands in a row;
916 ;; process just the first one.
917 (goto-char (1+ texinfo-command-start
))
918 (skip-chars-forward "^@" texinfo-command-end
)
919 (setq texinfo-command-end
(point))
920 ;; Handle let aliasing
921 (setq texinfo-command-name
924 (buffer-substring-no-properties
925 (1+ texinfo-command-start
) texinfo-command-end
)))
926 (while (setq trial
(assoc cmdname texinfo-alias-list
))
927 (setq cmdname
(cdr trial
)))
929 ;; Call the handler for this command.
930 (let ((enclosure-type
932 (symbol-name texinfo-command-name
)
933 texinfo-enclosure-list
)))
937 (car (car (cdr enclosure-type
)))
938 (texinfo-parse-arg-discard)
939 (car (cdr (car (cdr enclosure-type
)))))
940 (goto-char texinfo-command-start
))
941 (let ((cmd (get texinfo-command-name
'texinfo-format
)))
942 (if cmd
(funcall cmd
) (texinfo-unsupported)))))))
945 (goto-char (nth 2 (car texinfo-stack
)))
946 (error "Unterminated @%s" (car (car texinfo-stack
)))))
948 ;; Remove excess whitespace
949 (let ((whitespace-silent t
))
950 (whitespace-cleanup)))
952 (defvar texinfo-copying-text
""
953 "Text of the copyright notice and copying permissions.")
955 (defun texinfo-copying ()
956 "Copy the copyright notice and copying permissions from the Texinfo file,
957 as indicated by the @copying ... @end copying command;
958 insert the text with the @insertcopying command."
959 (let ((beg (progn (beginning-of-line) (point)))
960 (end (progn (re-search-forward "^@end copying[ \t]*\n") (point))))
961 (setq texinfo-copying-text
962 (buffer-substring-no-properties
963 (save-excursion (goto-char beg
) (forward-line 1) (point))
964 (save-excursion (goto-char end
) (forward-line -
1) (point))))
965 (delete-region beg end
)))
967 (defun texinfo-insertcopying ()
968 "Insert the copyright notice and copying permissions from the Texinfo file,
969 which are indicated by the @copying ... @end copying command."
970 (insert (concat "\n" texinfo-copying-text
)))
972 (put 'begin
'texinfo-format
'texinfo-format-begin
)
973 (defun texinfo-format-begin ()
974 (texinfo-format-begin-end 'texinfo-format
))
976 (put 'end
'texinfo-format
'texinfo-format-end
)
977 (defun texinfo-format-end ()
978 (texinfo-format-begin-end 'texinfo-end
))
980 (defun texinfo-format-begin-end (prop)
981 (setq texinfo-command-name
(intern (texinfo-parse-line-arg)))
982 (let ((cmd (get texinfo-command-name prop
)))
983 (if cmd
(funcall cmd
)
984 (texinfo-unsupported))))
986 ;;; Parsing functions
988 (defun texinfo-parse-line-arg ()
989 "Return argument of @-command as string.
990 Argument is separated from command either by a space or by a brace.
991 If a space, return rest of line, with beginning and ending white
992 space removed. If a brace, return string between braces.
993 Leave point after argument."
994 (goto-char texinfo-command-end
)
995 (let ((start (point)))
996 (cond ((looking-at " ")
997 (skip-chars-forward " ")
1000 (skip-chars-backward " ")
1001 (delete-region (point) (progn (end-of-line) (point)))
1002 (setq texinfo-command-end
(1+ (point))))
1004 (setq start
(1+ (point)))
1006 (setq texinfo-command-end
(point))
1009 (error "Invalid texinfo command arg format")))
1010 (prog1 (buffer-substring-no-properties start
(point))
1011 (if (eolp) (forward-char 1)))))
1013 (defun texinfo-parse-expanded-arg ()
1014 (goto-char texinfo-command-end
)
1015 (let ((start (point))
1017 (cond ((looking-at " ")
1018 (skip-chars-forward " ")
1019 (setq start
(point))
1021 (setq texinfo-command-end
(1+ (point))))
1023 (setq start
(1+ (point)))
1025 (setq texinfo-command-end
(point))
1028 (error "Invalid texinfo command arg format")))
1029 (setq marker
(move-marker (make-marker) texinfo-command-end
))
1030 (texinfo-format-expand-region start
(point))
1031 (setq texinfo-command-end
(marker-position marker
))
1032 (move-marker marker nil
)
1033 (prog1 (buffer-substring-no-properties start
(point))
1034 (if (eolp) (forward-char 1)))))
1036 (defun texinfo-format-expand-region (start end
)
1038 (narrow-to-region start end
)
1039 (let (texinfo-command-start
1041 texinfo-command-name
1043 (texinfo-format-scan))
1044 (goto-char (point-max))))
1046 (defun texinfo-parse-arg-discard ()
1047 "Delete command and argument; return argument of command."
1048 (prog1 (texinfo-parse-line-arg)
1049 (texinfo-discard-command)))
1051 (defun texinfo-discard-command ()
1052 (delete-region texinfo-command-start texinfo-command-end
))
1054 (defun texinfo-optional-braces-discard ()
1055 "Discard braces following command, if any."
1056 (goto-char texinfo-command-end
)
1057 (let ((start (point)))
1058 (cond ((looking-at "[ \t]*\n")) ; do nothing
1059 ((looking-at "{") ; remove braces, if any
1061 (setq texinfo-command-end
(point)))
1064 "Invalid `texinfo-optional-braces-discard' format \(need braces?\)")))
1065 (delete-region texinfo-command-start texinfo-command-end
)))
1067 (defun texinfo-format-parse-line-args ()
1068 (let ((start (1- (point)))
1071 (skip-chars-forward " ")
1074 (re-search-forward "[\n,]")
1076 (if (bolp) (setq next
(1- next
)))
1078 (skip-chars-backward " ")
1080 (setq args
(cons (if (> end beg
) (buffer-substring-no-properties beg end
))
1083 (skip-chars-forward " "))
1084 (if (eolp) (forward-char 1))
1085 (setq texinfo-command-end
(point))
1088 (defun texinfo-format-parse-args ()
1089 (let ((start (1- (point)))
1092 (search-forward "{")
1094 (texinfo-format-expand-region
1096 (save-excursion (up-list 1) (1- (point)))))
1097 ;; The following does not handle cross references of the form:
1098 ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the
1099 ;; re-search-forward finds the first right brace after the second
1101 (while (/= (preceding-char) ?\
})
1102 (skip-chars-forward " \t\n")
1104 (re-search-forward "[},]")
1107 (skip-chars-backward " \t\n")
1111 (while (search-forward "\n" end t
)
1112 (replace-match " "))))
1113 (setq args
(cons (if (> end beg
) (buffer-substring-no-properties beg end
))
1116 ;;(if (eolp) (forward-char 1))
1117 (setq texinfo-command-end
(point))
1120 (defun texinfo-format-parse-defun-args ()
1121 (goto-char texinfo-command-end
)
1122 (let ((start (point)))
1124 (setq texinfo-command-end
(1+ (point)))
1125 (let ((marker (move-marker (make-marker) texinfo-command-end
)))
1126 (texinfo-format-expand-region start
(point))
1127 (setq texinfo-command-end
(marker-position marker
))
1128 (move-marker marker nil
))
1132 (skip-chars-forward " ")
1134 (cond ((looking-at "{")
1135 (setq beg
(1+ (point)))
1137 (setq end
(1- (point))))
1140 (re-search-forward "[\n ]")
1142 (setq end
(point))))
1143 (setq args
(cons (buffer-substring-no-properties beg end
) args
))
1144 (skip-chars-forward " "))
1148 (defun texinfo-discard-line ()
1149 (goto-char texinfo-command-end
)
1150 (skip-chars-forward " \t")
1152 (error "Extraneous text at end of command line"))
1153 (goto-char texinfo-command-start
)
1155 (error "Extraneous text at beginning of command line"))
1156 (delete-region (point) (progn (forward-line 1) (point))))
1158 (defun texinfo-discard-line-with-args ()
1159 (goto-char texinfo-command-start
)
1160 (delete-region (point) (progn (forward-line 1) (point))))
1165 ;; Only `texinfo-format-buffer' handles @setfilename with this
1166 ;; definition; `texinfo-format-region' handles @setfilename, if any,
1168 (put 'setfilename
'texinfo-format
'texinfo-format-setfilename
)
1169 (defun texinfo-format-setfilename ()
1170 (texinfo-parse-arg-discard))
1172 ;;; @node, @menu, @detailmenu
1174 (put 'node
'texinfo-format
'texinfo-format-node
)
1175 (put 'nwnode
'texinfo-format
'texinfo-format-node
)
1176 (defun texinfo-format-node ()
1177 (let* ((args (texinfo-format-parse-line-args))
1182 (texinfo-discard-command)
1183 (setq texinfo-last-node name
)
1184 (let ((tem (if texinfo-fold-nodename-case
(downcase name
) name
)))
1185 (if (assoc tem texinfo-node-names
)
1186 (error "Duplicate node name: %s" name
)
1187 (setq texinfo-node-names
(cons (list tem
) texinfo-node-names
))))
1188 (setq texinfo-footnote-number
0)
1189 ;; insert "\n\^_" unconditionally since this is what info is looking for
1190 (insert "\n\^_\nFile: " texinfo-format-filename
1193 (insert ", Next: " next
))
1195 (insert ", Prev: " prev
))
1197 (insert ", Up: " up
))
1199 (setq texinfo-last-node-pos
(point))))
1201 (put 'anchor
'texinfo-format
'texinfo-anchor
)
1202 (defun texinfo-anchor ()
1204 (here (- (point) 7)) ; save location of beginning of `@anchor'
1205 (arg (texinfo-parse-arg-discard)))
1206 (if (looking-at " ") ; since a space may be left after -discard
1209 (let ((end (point)))
1212 (search-forward "@refill" end t
))
1213 (setq anchor-string
"@anchor-yes-refill")
1214 (setq anchor-string
"@anchor-no-refill")))
1216 (insert anchor-string
"{" arg
"}")))
1218 (put 'menu
'texinfo-format
'texinfo-format-menu
)
1219 (defun texinfo-format-menu ()
1220 (texinfo-discard-line)
1221 (insert "* Menu:\n\n"))
1223 (put 'menu
'texinfo-end
'texinfo-discard-command
)
1225 ;; The @detailmenu should be removed eventually.
1227 ;; According to Karl Berry, 31 August 1996:
1229 ;; You don't like, I don't like it. I agree, it would be better just to
1230 ;; fix the bug [in `makeinfo']. .. At this point, since inserting those
1231 ;; two commands in the Elisp fn is trivial, I don't especially want to
1232 ;; expend more effort...
1234 ;; I added a couple sentences of documentation to the manual (putting the
1235 ;; blame on makeinfo where it belongs :-().
1237 (put 'detailmenu
'texinfo-format
'texinfo-discard-line
)
1238 (put 'detailmenu
'texinfo-end
'texinfo-discard-command
)
1240 ;; (Also see `texnfo-upd.el')
1243 ;;; Cross references
1245 ;; @xref {NODE, FNAME, NAME, FILE, DOCUMENT}
1246 ;; -> *Note FNAME: (FILE)NODE
1247 ;; If FILE is missing,
1248 ;; *Note FNAME: NODE
1249 ;; If FNAME is empty and NAME is present
1251 ;; If both NAME and FNAME are missing
1253 ;; texinfo ignores the DOCUMENT argument.
1254 ;; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1255 ;; If FILE is specified, (FILE)NODE is used for xrefs.
1256 ;; If fifth argument DOCUMENT is specified, produces
1257 ;; See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1260 ;; @ref a reference that does not put `See' or `see' in
1261 ;; the hardcopy and is the same as @xref in Info
1262 (put 'ref
'texinfo-format
'texinfo-format-xref
)
1264 (put 'xref
'texinfo-format
'texinfo-format-xref
)
1265 (defun texinfo-format-xref ()
1266 (let ((args (texinfo-format-parse-args)))
1267 (texinfo-discard-command)
1269 (let ((fname (or (nth 1 args
) (nth 2 args
))))
1270 (if (null (or fname
(nth 3 args
)))
1271 (insert (car args
) "::")
1272 (insert (or fname
(car args
)) ": ")
1274 (insert "(" (nth 3 args
) ")"))
1275 (and (car args
) (insert (car args
)))))))
1277 (put 'pxref
'texinfo-format
'texinfo-format-pxref
)
1278 (defun texinfo-format-pxref ()
1279 (texinfo-format-xref)
1285 ;; @inforef{NODE, FNAME, FILE}
1286 ;; Like @xref{NODE, FNAME,,FILE} in texinfo.
1287 ;; In Tex, generates "See Info file FILE, node NODE"
1288 (put 'inforef
'texinfo-format
'texinfo-format-inforef
)
1289 (defun texinfo-format-inforef ()
1290 (let ((args (texinfo-format-parse-args)))
1291 (texinfo-discard-command)
1293 (insert "*Note " (nth 1 args
) ": (" (nth 2 args
) ")" (car args
))
1294 (insert "*Note " "(" (nth 2 args
) ")" (car args
) "::"))))
1297 ;;; URL Reference: @uref
1299 ;; @uref produces a reference to a uniform resource locator (URL).
1300 ;; It takes one mandatory argument, the URL, and one optional argument,
1301 ;; the text to display (the default is the URL itself).
1303 (put 'uref
'texinfo-format
'texinfo-format-uref
)
1304 (defun texinfo-format-uref ()
1305 "Format URL and optional URL-TITLE.
1306 Insert ` ... ' around URL if no URL-TITLE argument;
1307 otherwise, insert URL-TITLE followed by URL in parentheses."
1308 (let ((args (texinfo-format-parse-args)))
1309 (texinfo-discard-command)
1312 (insert (nth 1 args
) " (" (nth 0 args
) ")")
1313 (insert "`" (nth 0 args
) "'"))
1314 (goto-char texinfo-command-start
)))
1317 ;;; Section headings
1319 (put 'majorheading
'texinfo-format
'texinfo-format-chapter
)
1320 (put 'chapheading
'texinfo-format
'texinfo-format-chapter
)
1321 (put 'ichapter
'texinfo-format
'texinfo-format-chapter
)
1322 (put 'chapter
'texinfo-format
'texinfo-format-chapter
)
1323 (put 'iappendix
'texinfo-format
'texinfo-format-chapter
)
1324 (put 'appendix
'texinfo-format
'texinfo-format-chapter
)
1325 (put 'iunnumbered
'texinfo-format
'texinfo-format-chapter
)
1326 (put 'top
'texinfo-format
'texinfo-format-chapter
)
1327 (put 'unnumbered
'texinfo-format
'texinfo-format-chapter
)
1328 (put 'centerchap
'texinfo-format
'texinfo-format-chapter
)
1329 (defun texinfo-format-chapter ()
1330 (texinfo-format-chapter-1 ?
*))
1332 (put 'heading
'texinfo-format
'texinfo-format-section
)
1333 (put 'isection
'texinfo-format
'texinfo-format-section
)
1334 (put 'section
'texinfo-format
'texinfo-format-section
)
1335 (put 'iappendixsection
'texinfo-format
'texinfo-format-section
)
1336 (put 'appendixsection
'texinfo-format
'texinfo-format-section
)
1337 (put 'iappendixsec
'texinfo-format
'texinfo-format-section
)
1338 (put 'appendixsec
'texinfo-format
'texinfo-format-section
)
1339 (put 'iunnumberedsec
'texinfo-format
'texinfo-format-section
)
1340 (put 'unnumberedsec
'texinfo-format
'texinfo-format-section
)
1341 (defun texinfo-format-section ()
1342 (texinfo-format-chapter-1 ?
=))
1344 (put 'subheading
'texinfo-format
'texinfo-format-subsection
)
1345 (put 'isubsection
'texinfo-format
'texinfo-format-subsection
)
1346 (put 'subsection
'texinfo-format
'texinfo-format-subsection
)
1347 (put 'iappendixsubsec
'texinfo-format
'texinfo-format-subsection
)
1348 (put 'appendixsubsec
'texinfo-format
'texinfo-format-subsection
)
1349 (put 'iunnumberedsubsec
'texinfo-format
'texinfo-format-subsection
)
1350 (put 'unnumberedsubsec
'texinfo-format
'texinfo-format-subsection
)
1351 (defun texinfo-format-subsection ()
1352 (texinfo-format-chapter-1 ?-
))
1354 (put 'subsubheading
'texinfo-format
'texinfo-format-subsubsection
)
1355 (put 'isubsubsection
'texinfo-format
'texinfo-format-subsubsection
)
1356 (put 'subsubsection
'texinfo-format
'texinfo-format-subsubsection
)
1357 (put 'iappendixsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1358 (put 'appendixsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1359 (put 'iunnumberedsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1360 (put 'unnumberedsubsubsec
'texinfo-format
'texinfo-format-subsubsection
)
1361 (defun texinfo-format-subsubsection ()
1362 (texinfo-format-chapter-1 ?.
))
1364 (defun texinfo-format-chapter-1 (belowchar)
1365 (let ((arg (texinfo-parse-arg-discard)))
1366 (message "Formatting: %s ... " arg
) ; So we can see where we are.
1367 (insert ?
\n arg ?
\n "@SectionPAD " belowchar ?
\n)
1370 (put 'SectionPAD
'texinfo-format
'texinfo-format-sectionpad
)
1371 (defun texinfo-format-sectionpad ()
1372 (let ((str (texinfo-parse-arg-discard)))
1374 (let ((column (current-column)))
1378 (setq column
(1- column
))))
1382 ;;; Space controlling commands: @. and @:, and the soft hyphen.
1384 (put '\.
'texinfo-format
'texinfo-format-\.
)
1385 (defun texinfo-format-\.
()
1386 (texinfo-discard-command)
1389 (put '\
: 'texinfo-format
'texinfo-format-\
:)
1390 (defun texinfo-format-\
: ()
1391 (texinfo-discard-command))
1393 (put '\-
'texinfo-format
'texinfo-format-soft-hyphen
)
1394 (defun texinfo-format-soft-hyphen ()
1395 (texinfo-discard-command))
1398 ;;; @kbdinputstyle, @vskip, headings & footings
1399 ;; These commands for not for Info and should never
1400 ;; appear in an Info environment; but if they do,
1401 ;; this causes them to be discarded.
1404 (put 'kbdinputstyle
'texinfo-format
'texinfo-discard-line-with-args
)
1407 (put 'vskip
'texinfo-format
'texinfo-discard-line-with-args
)
1409 ;; headings & footings
1410 (put 'evenfooting
'texinfo-format
'texinfo-discard-line-with-args
)
1411 (put 'evenheading
'texinfo-format
'texinfo-discard-line-with-args
)
1412 (put 'oddfooting
'texinfo-format
'texinfo-discard-line-with-args
)
1413 (put 'oddheading
'texinfo-format
'texinfo-discard-line-with-args
)
1414 (put 'everyfooting
'texinfo-format
'texinfo-discard-line-with-args
)
1415 (put 'everyheading
'texinfo-format
'texinfo-discard-line-with-args
)
1418 ;;; @documentdescription ... @end documentdescription
1419 ;; This command is for HTML output and should never
1420 ;; appear in an Info environment; but if it does,
1421 ;; this causes it to be discarded.
1423 (put 'documentdescription
'texinfo-format
'texinfo-format-documentdescription
)
1424 (defun texinfo-format-documentdescription ()
1425 (delete-region texinfo-command-start
1426 (progn (re-search-forward "^@end documentdescription[ \t]*\n")
1431 ;;; @center, @sp, and @br
1433 (put 'center
'texinfo-format
'texinfo-format-center
)
1434 (defun texinfo-format-center ()
1435 (let ((arg (texinfo-parse-expanded-arg)))
1436 (texinfo-discard-command)
1440 (goto-char (1- (point)))
1441 (let ((indent-tabs-mode nil
))
1444 (put 'sp
'texinfo-format
'texinfo-format-sp
)
1445 (defun texinfo-format-sp ()
1446 (let* ((arg (texinfo-parse-arg-discard))
1448 (insert-char ?
\n num
)))
1450 (put 'br
'texinfo-format
'texinfo-format-paragraph-break
)
1451 (defun texinfo-format-paragraph-break ()
1452 "Force a paragraph break.
1453 If used within a line, follow `@br' with braces."
1454 (texinfo-optional-braces-discard)
1455 ;; insert one return if at end of line;
1456 ;; else insert two returns, to generate a blank line.
1457 (if (= (following-char) ?
\n)
1459 (insert-char ?
\n 2)))
1462 ;;; @footnote and @footnotestyle
1464 ;; In Texinfo, footnotes are created with the `@footnote' command.
1465 ;; This command is followed immediately by a left brace, then by the text of
1466 ;; the footnote, and then by a terminating right brace. The
1467 ;; template for a footnote is:
1471 ;; Info has two footnote styles:
1473 ;; * In the End of node style, all the footnotes for a single node
1474 ;; are placed at the end of that node. The footnotes are
1475 ;; separated from the rest of the node by a line of dashes with
1476 ;; the word `Footnotes' within it.
1478 ;; * In the Separate node style, all the footnotes for a single node
1479 ;; are placed in an automatically constructed node of their own.
1481 ;; Footnote style is specified by the @footnotestyle command, either
1482 ;; @footnotestyle separate
1484 ;; @footnotestyle end
1486 ;; The default is separate
1488 (defvar texinfo-footnote-style
"separate"
1489 "Footnote style, either separate or end.")
1491 (put 'footnotestyle
'texinfo-format
'texinfo-footnotestyle
)
1492 (defun texinfo-footnotestyle ()
1493 "Specify whether footnotes are at end of node or in separate nodes.
1494 Argument is either end or separate."
1495 (setq texinfo-footnote-style
(texinfo-parse-arg-discard)))
1497 (defvar texinfo-footnote-number
)
1499 (put 'footnote
'texinfo-format
'texinfo-format-footnote
)
1500 (defun texinfo-format-footnote ()
1501 "Format a footnote in either end of node or separate node style.
1502 The texinfo-footnote-style variable controls which style is used."
1503 (setq texinfo-footnote-number
(1+ texinfo-footnote-number
))
1504 (cond ((string= texinfo-footnote-style
"end")
1505 (texinfo-format-end-node))
1506 ((string= texinfo-footnote-style
"separate")
1507 (texinfo-format-separate-node))))
1509 (defun texinfo-format-separate-node ()
1510 "Format footnote in Separate node style, with notes in own node.
1511 The node is constructed automatically."
1513 (arg (texinfo-parse-line-arg))
1514 (node-name-beginning
1517 "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:")
1521 (buffer-substring-no-properties
1522 (progn (goto-char node-name-beginning
) ; skip over node command
1523 (skip-chars-forward " \t") ; and over spaces
1527 (save-excursion (end-of-line) (point)) t
) ; bound search
1529 (end-of-line) (point))))))
1530 (texinfo-discard-command) ; remove or insert whitespace, as needed
1531 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1533 (insert (format " (%d) (*Note %s-Footnotes::)"
1534 texinfo-footnote-number node-name
))
1535 (fill-paragraph nil
)
1537 (if (re-search-forward "^@node" nil
'move
)
1540 ;; two cases: for the first footnote, we must insert a node header;
1541 ;; for the second and subsequent footnotes, we need only insert
1542 ;; the text of the footnote.
1546 (concat node-name
"-Footnotes, Up: ")
1549 (progn ; already at least one footnote
1550 (setq start
(point))
1551 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1552 (fill-region start
(point)))
1553 ;; else not yet a footnote
1554 (insert "\n\^_\nFile: " texinfo-format-filename
1555 " Node: " node-name
"-Footnotes, Up: " node-name
"\n")
1556 (setq start
(point))
1557 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1558 (narrow-to-region (save-excursion (goto-char start
) (point)) (point))
1559 (fill-region (point-min) (point-max))
1562 (defun texinfo-format-end-node ()
1563 "Format footnote in the End of node style, with notes at end of node."
1565 (arg (texinfo-parse-line-arg)))
1566 (texinfo-discard-command) ; remove or insert whitespace, as needed
1567 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1569 (insert (format " (%d) " texinfo-footnote-number
))
1570 (fill-paragraph nil
)
1572 (if (search-forward "\n--------- Footnotes ---------\n" nil t
)
1573 (progn ; already have footnote, put new one before end of node
1574 (if (re-search-forward "^@node" nil
'move
)
1576 (setq start
(point))
1577 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))
1578 (fill-region start
(point)))
1579 ;; else no prior footnote
1580 (if (re-search-forward "^@node" nil
'move
)
1582 (insert "\n--------- Footnotes ---------\n")
1583 (setq start
(point))
1584 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg
))))))
1587 ;;; @itemize, @enumerate, and similar commands
1589 ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.
1590 ;; @enumerate pushes (enumerate 0 STARTPOS).
1591 ;; @item dispatches to the texinfo-item prop of the first elt of the list.
1592 ;; For itemize, this puts in and rescans the COMMANDS.
1593 ;; For enumerate, this increments the number and puts it in.
1594 ;; In either case, it puts a Backspace at the front of the line
1595 ;; which marks it not to be indented later.
1596 ;; All other lines get indented by 5 when the @end is reached.
1598 (defvar texinfo-stack-depth
0
1599 "Count of number of unpopped texinfo-push-stack calls.
1600 Used by @refill indenting command to avoid indenting within lists, etc.")
1602 (defun texinfo-push-stack (check arg
)
1603 (setq texinfo-stack-depth
(1+ texinfo-stack-depth
))
1605 (cons (list check arg texinfo-command-start
)
1608 (defun texinfo-pop-stack (check)
1609 (setq texinfo-stack-depth
(1- texinfo-stack-depth
))
1610 (if (null texinfo-stack
)
1611 (error "Unmatched @end %s" check
))
1612 (if (not (eq (car (car texinfo-stack
)) check
))
1613 (error "@end %s matches @%s"
1614 check
(car (car texinfo-stack
))))
1615 (prog1 (cdr (car texinfo-stack
))
1616 (setq texinfo-stack
(cdr texinfo-stack
))))
1618 (put 'itemize
'texinfo-format
'texinfo-itemize
)
1619 (defun texinfo-itemize ()
1622 (progn (skip-chars-forward " \t")
1625 (texinfo-parse-line-arg))))
1626 (texinfo-discard-line-with-args)
1627 (setq fill-column
(- fill-column
5)))
1629 (put 'itemize
'texinfo-end
'texinfo-end-itemize
)
1630 (defun texinfo-end-itemize ()
1631 (setq fill-column
(+ fill-column
5))
1632 (texinfo-discard-command)
1634 (texinfo-pop-stack 'itemize
)))
1635 (texinfo-do-itemize (nth 1 stacktop
))))
1637 (put 'enumerate
'texinfo-format
'texinfo-enumerate
)
1638 (defun texinfo-enumerate ()
1641 (progn (skip-chars-forward " \t")
1644 (read (current-buffer)))))
1645 (if (and (symbolp (car (cdr (car texinfo-stack
))))
1646 (> 1 (length (symbol-name (car (cdr (car texinfo-stack
)))))))
1648 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." ))
1649 (texinfo-discard-line-with-args)
1650 (setq fill-column
(- fill-column
5)))
1652 (put 'enumerate
'texinfo-end
'texinfo-end-enumerate
)
1653 (defun texinfo-end-enumerate ()
1654 (setq fill-column
(+ fill-column
5))
1655 (texinfo-discard-command)
1657 (texinfo-pop-stack 'enumerate
)))
1658 (texinfo-do-itemize (nth 1 stacktop
))))
1660 ;; @alphaenumerate never became a standard part of Texinfo
1661 (put 'alphaenumerate
'texinfo-format
'texinfo-alphaenumerate
)
1662 (defun texinfo-alphaenumerate ()
1663 (texinfo-push-stack 'alphaenumerate
(1- ?a
))
1664 (setq fill-column
(- fill-column
5))
1665 (texinfo-discard-line))
1667 (put 'alphaenumerate
'texinfo-end
'texinfo-end-alphaenumerate
)
1668 (defun texinfo-end-alphaenumerate ()
1669 (setq fill-column
(+ fill-column
5))
1670 (texinfo-discard-command)
1672 (texinfo-pop-stack 'alphaenumerate
)))
1673 (texinfo-do-itemize (nth 1 stacktop
))))
1675 ;; @capsenumerate never became a standard part of Texinfo
1676 (put 'capsenumerate
'texinfo-format
'texinfo-capsenumerate
)
1677 (defun texinfo-capsenumerate ()
1678 (texinfo-push-stack 'capsenumerate
(1- ?A
))
1679 (setq fill-column
(- fill-column
5))
1680 (texinfo-discard-line))
1682 (put 'capsenumerate
'texinfo-end
'texinfo-end-capsenumerate
)
1683 (defun texinfo-end-capsenumerate ()
1684 (setq fill-column
(+ fill-column
5))
1685 (texinfo-discard-command)
1687 (texinfo-pop-stack 'capsenumerate
)))
1688 (texinfo-do-itemize (nth 1 stacktop
))))
1690 ;; At the @end, indent all the lines within the construct
1691 ;; except those marked with backspace. FROM says where
1692 ;; construct started.
1693 (defun texinfo-do-itemize (from)
1695 (while (progn (forward-line -
1)
1697 (if (= (following-char) ?
\b)
1702 (if (not (looking-at "[ \t]*$"))
1703 (save-excursion (insert " ")))))))
1705 (put 'item
'texinfo-format
'texinfo-item
)
1706 (put 'itemx
'texinfo-format
'texinfo-item
)
1707 (defun texinfo-item ()
1708 (funcall (get (car (car texinfo-stack
)) 'texinfo-item
)))
1710 (put 'itemize
'texinfo-item
'texinfo-itemize-item
)
1711 (defun texinfo-itemize-item ()
1712 ;; (texinfo-discard-line) ; Did not handle text on same line as @item.
1713 (delete-region (1+ (point)) (save-excursion (beginning-of-line) (point)))
1714 (if (looking-at "[ \t]*[^ \t\n]+")
1715 ;; Text on same line as @item command.
1716 (insert "\b " (nth 1 (car texinfo-stack
)) " \n")
1717 ;; Else text on next line.
1718 (insert "\b " (nth 1 (car texinfo-stack
)) " "))
1721 (put 'enumerate
'texinfo-item
'texinfo-enumerate-item
)
1722 (defun texinfo-enumerate-item ()
1723 (texinfo-discard-line)
1724 (let (enumerating-symbol)
1725 (cond ((integerp (car (cdr (car texinfo-stack
))))
1726 (setq enumerating-symbol
(car (cdr (car texinfo-stack
))))
1727 (insert ?
\b (format "%3d. " enumerating-symbol
) ?
\n)
1728 (setcar (cdr (car texinfo-stack
)) (1+ enumerating-symbol
)))
1729 ((symbolp (car (cdr (car texinfo-stack
))))
1730 (setq enumerating-symbol
1731 (symbol-name (car (cdr (car texinfo-stack
)))))
1732 (if (or (equal ?\
[ (string-to-char enumerating-symbol
))
1733 (equal ?\
{ (string-to-char enumerating-symbol
)))
1735 "Too many items in enumerated list; alphabet ends at Z."))
1736 (insert ?
\b (format "%3s. " enumerating-symbol
) ?
\n)
1737 (setcar (cdr (car texinfo-stack
))
1741 (string-to-char enumerating-symbol
))))))
1744 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." )))
1747 (put 'alphaenumerate
'texinfo-item
'texinfo-alphaenumerate-item
)
1748 (defun texinfo-alphaenumerate-item ()
1749 (texinfo-discard-line)
1750 (let ((next (1+ (car (cdr (car texinfo-stack
))))))
1752 (error "More than 26 items in @alphaenumerate; get a bigger alphabet"))
1753 (setcar (cdr (car texinfo-stack
)) next
)
1754 (insert "\b " next
". \n"))
1757 (put 'capsenumerate
'texinfo-item
'texinfo-capsenumerate-item
)
1758 (defun texinfo-capsenumerate-item ()
1759 (texinfo-discard-line)
1760 (let ((next (1+ (car (cdr (car texinfo-stack
))))))
1762 (error "More than 26 items in @capsenumerate; get a bigger alphabet"))
1763 (setcar (cdr (car texinfo-stack
)) next
)
1764 (insert "\b " next
". \n"))
1770 ;; The `@table' command produces two-column tables.
1772 (put 'table
'texinfo-format
'texinfo-table
)
1773 (defun texinfo-table ()
1776 (progn (skip-chars-forward " \t")
1779 (texinfo-parse-line-arg))))
1780 (texinfo-discard-line-with-args)
1781 (setq fill-column
(- fill-column
5)))
1783 (put 'table
'texinfo-item
'texinfo-table-item
)
1784 (defun texinfo-table-item ()
1785 (let ((arg (texinfo-parse-arg-discard))
1786 (itemfont (car (cdr (car texinfo-stack
)))))
1787 (insert ?
\b itemfont ?\
{ arg
"}\n \n"))
1790 (put 'table
'texinfo-end
'texinfo-end-table
)
1791 (defun texinfo-end-table ()
1792 (setq fill-column
(+ fill-column
5))
1793 (texinfo-discard-command)
1795 (texinfo-pop-stack 'table
)))
1796 (texinfo-do-itemize (nth 1 stacktop
))))
1798 ;; @description appears to be an undocumented variant on @table that
1799 ;; does not require an arg. It fails in texinfo.tex 2.58 and is not
1800 ;; part of makeinfo.c The command appears to be a relic of the past.
1801 (put 'description
'texinfo-end
'texinfo-end-table
)
1802 (put 'description
'texinfo-format
'texinfo-description
)
1803 (defun texinfo-description ()
1804 (texinfo-push-stack 'table
"@asis")
1805 (setq fill-column
(- fill-column
5))
1806 (texinfo-discard-line))
1809 ;;; @ftable, @vtable
1811 ;; The `@ftable' and `@vtable' commands are like the `@table' command
1812 ;; but they also insert each entry in the first column of the table
1813 ;; into the function or variable index.
1815 ;; Handle the @ftable and @vtable commands:
1817 (put 'ftable
'texinfo-format
'texinfo-ftable
)
1818 (put 'vtable
'texinfo-format
'texinfo-vtable
)
1820 (defun texinfo-ftable () (texinfo-indextable 'ftable
))
1821 (defun texinfo-vtable () (texinfo-indextable 'vtable
))
1823 (defun texinfo-indextable (table-type)
1824 (texinfo-push-stack table-type
(texinfo-parse-arg-discard))
1825 (setq fill-column
(- fill-column
5)))
1827 ;; Handle the @item commands within ftable and vtable:
1829 (put 'ftable
'texinfo-item
'texinfo-ftable-item
)
1830 (put 'vtable
'texinfo-item
'texinfo-vtable-item
)
1832 (defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex
))
1833 (defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex
))
1835 (defun texinfo-indextable-item (index-type)
1836 (let ((item (texinfo-parse-arg-discard))
1837 (itemfont (car (cdr (car texinfo-stack
))))
1838 (indexvar index-type
))
1839 (insert ?
\b itemfont ?\
{ item
"}\n \n")
1842 (list item texinfo-last-node
)
1843 (symbol-value indexvar
)))
1846 ;; Handle @end ftable, @end vtable
1848 (put 'ftable
'texinfo-end
'texinfo-end-ftable
)
1849 (put 'vtable
'texinfo-end
'texinfo-end-vtable
)
1851 (defun texinfo-end-ftable () (texinfo-end-indextable 'ftable
))
1852 (defun texinfo-end-vtable () (texinfo-end-indextable 'vtable
))
1854 (defun texinfo-end-indextable (table-type)
1855 (setq fill-column
(+ fill-column
5))
1856 (texinfo-discard-command)
1858 (texinfo-pop-stack table-type
)))
1859 (texinfo-do-itemize (nth 1 stacktop
))))
1862 ;;; @multitable ... @end multitable
1864 ;; Produce a multi-column table, with as many columns as desired.
1866 ;; A multi-column table has this template:
1868 ;; @multitable {A1} {A2} {A3}
1869 ;; @item A1 @tab A2 @tab A3
1870 ;; @item B1 @tab B2 @tab B3
1871 ;; @item C1 @tab C2 @tab C3
1874 ;; where the width of the text in brackets specifies the width of the
1875 ;; respective column.
1879 ;; @multitable @columnfractions .25 .3 .45
1880 ;; @item A1 @tab A2 @tab A3
1881 ;; @item B1 @tab B2 @tab B3
1884 ;; where the fractions specify the width of each column as a percent
1885 ;; of the current width of the text (i.e., of the fill-column).
1887 ;; Long lines of text are filled within columns.
1889 ;; Using the Emacs Lisp formatter, texinfmt.el,
1890 ;; the whitespace between columns can be increased by setting
1891 ;; `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1892 ;; there is at least one blank space between columns.
1894 ;; The Emacs Lisp formatter, texinfmt.el, ignores the following four
1895 ;; commands that are defined in texinfo.tex for printed output.
1897 ;; @multitableparskip,
1898 ;; @multitableparindent,
1899 ;; @multitablecolmargin,
1900 ;; @multitablelinespace.
1902 ;; How @multitable works.
1903 ;; =====================
1905 ;; `texinfo-multitable' reads the @multitable line and determines from it
1906 ;; how wide each column should be.
1908 ;; Also, it pushes this information, along with an identifying symbol,
1909 ;; onto the `texinfo-stack'. At the @end multitable command, the stack
1910 ;; is checked for its matching @multitable command, and then popped, or
1911 ;; else an error is signaled. Also, this command pushes the location of
1912 ;; the start of the table onto the stack.
1914 ;; `texinfo-end-multitable' checks the `texinfo-stack' that the @end
1915 ;; multitable truly is ending a corresponding beginning, and if it is,
1918 ;; `texinfo-multitable-widths' is called by `texinfo-multitable'.
1919 ;; The function returns a list of the widths of each column in a
1920 ;; multi-column table, based on the information supplied by the arguments
1921 ;; to the @multitable command (by arguments, I mean the text on the rest
1922 ;; of the @multitable line, not the remainder of the multi-column table
1925 ;; `texinfo-multitable-item' formats a row within a multicolumn table.
1926 ;; This command is executed when texinfmt sees @item inside @multitable.
1927 ;; Cells in row are separated by `@tab's. Widths of cells are specified
1928 ;; by the arguments in the @multitable line. Cells are filled. All cells
1929 ;; are made to be the same height by padding their bottoms, as needed,
1932 ;; `texinfo-multitable-extract-row' is called by `texinfo-multitable-item'.
1933 ;; This function returns the text in a multitable row, as a string.
1934 ;; The start of a row is marked by an @item and the end of row is the
1935 ;; beginning of next @item or beginning of the @end multitable line.
1936 ;; Cells within a row are separated by @tab.
1938 ;; Note that @tab, the cell separators, are not treated as independent
1939 ;; Texinfo commands.
1941 (defvar texinfo-extra-inter-column-width
0
1942 "*Number of extra spaces between entries (columns) in @multitable.")
1944 (defvar texinfo-multitable-buffer-name
"*multitable-temporary-buffer*")
1945 (defvar texinfo-multitable-rectangle-name
"texinfo-multitable-temp-")
1947 ;; These commands are defined in texinfo.tex for printed output.
1948 (put 'multitableparskip
'texinfo-format
'texinfo-discard-line-with-args
)
1949 (put 'multitableparindent
'texinfo-format
'texinfo-discard-line-with-args
)
1950 (put 'multitablecolmargin
'texinfo-format
'texinfo-discard-line-with-args
)
1951 (put 'multitablelinespace
'texinfo-format
'texinfo-discard-line-with-args
)
1953 (put 'multitable
'texinfo-format
'texinfo-multitable
)
1955 (defun texinfo-multitable ()
1956 "Produce multi-column tables.
1958 A multi-column table has this template:
1960 @multitable {A1} {A2} {A3}
1961 @item A1 @tab A2 @tab A3
1962 @item B1 @tab B2 @tab B3
1963 @item C1 @tab C2 @tab C3
1966 where the width of the text in brackets specifies the width of the
1971 @multitable @columnfractions .25 .3 .45
1972 @item A1 @tab A2 @tab A3
1973 @item B1 @tab B2 @tab B3
1976 where the fractions specify the width of each column as a percent
1977 of the current width of the text (i.e., of the fill-column).
1979 Long lines of text are filled within columns.
1981 Using the Emacs Lisp formatter, texinfmt.el,
1982 the whitespace between columns can be increased by setting
1983 `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1984 there is at least one blank space between columns.
1986 The Emacs Lisp formatter, texinfmt.el, ignores the following four
1987 commands that are defined in texinfo.tex for printed output.
1990 @multitableparindent,
1991 @multitablecolmargin,
1992 @multitablelinespace."
1994 ;; This function pushes information onto the `texinfo-stack'.
1995 ;; A stack element consists of:
1996 ;; - type-of-command, i.e., multitable
1997 ;; - the information about column widths, and
1998 ;; - the position of texinfo-command-start.
1999 ;; e.g., ('multitable (1 2 3 4) 123)
2000 ;; The command line is then deleted.
2003 ;; push width information on stack
2004 (texinfo-multitable-widths))
2005 (texinfo-discard-line-with-args))
2007 (put 'multitable
'texinfo-end
'texinfo-end-multitable
)
2008 (defun texinfo-end-multitable ()
2009 "Discard the @end multitable line and pop the stack of multitable."
2010 (texinfo-discard-command)
2011 (texinfo-pop-stack 'multitable
))
2013 (defun texinfo-multitable-widths ()
2014 "Return list of widths of each column in a multi-column table."
2015 (let (texinfo-multitable-width-list)
2016 ;; Fractions format:
2017 ;; @multitable @columnfractions .25 .3 .45
2020 ;; @multitable {Column 1 template} {Column 2} {Column 3 example}
2021 ;; Place point before first argument
2022 (skip-chars-forward " \t")
2024 ;; Check for common misspelling
2025 ((looking-at "@columnfraction ")
2026 (error "In @multitable, @columnfractions misspelled"))
2027 ;; Case 1: @columnfractions .25 .3 .45
2028 ((looking-at "@columnfractions")
2031 (setq texinfo-multitable-width-list
2035 (* fill-column
(read (get-buffer (current-buffer))))))
2036 texinfo-multitable-width-list
))))
2038 ;; Case 2: {Column 1 template} {Column 2} {Column 3 example}
2040 (let ((start-of-templates (point)))
2042 (skip-chars-forward " \t")
2043 (let* ((start-of-template (1+ (point)))
2045 ;; forward-sexp works with braces in Texinfo mode
2046 (progn (forward-sexp 1) (1- (point)))))
2047 (setq texinfo-multitable-width-list
2048 (cons (- end-of-template start-of-template
)
2049 texinfo-multitable-width-list
))
2050 ;; Remove carriage return from within a template, if any.
2051 ;; This helps those those who want to use more than
2052 ;; one line's worth of words in @multitable line.
2053 (narrow-to-region start-of-template end-of-template
)
2054 (goto-char (point-min))
2055 (while (search-forward "
2058 (goto-char (point-max))
2060 (forward-char 1)))))
2065 "You probably need to specify column widths for @multitable correctly.")))
2066 ;; Check whether columns fit on page.
2067 (let ((desired-columns
2069 ;; between column spaces
2070 (length texinfo-multitable-width-list
)
2071 ;; additional between column spaces, if any
2072 texinfo-extra-inter-column-width
2073 ;; sum of spaces for each entry
2074 (apply '+ texinfo-multitable-width-list
))))
2075 (if (> desired-columns fill-column
)
2078 "Multi-column table width, %d chars, is greater than page width, %d chars."
2079 desired-columns fill-column
))))
2080 texinfo-multitable-width-list
))
2082 ;; @item A1 @tab A2 @tab A3
2083 (defun texinfo-multitable-extract-row ()
2084 "Return multitable row, as a string.
2085 End of row is beginning of next @item or beginning of @end.
2086 Cells within rows are separated by @tab."
2087 (skip-chars-forward " \t")
2088 (let* ((start (point))
2090 (re-search-forward "@item\\|@end")
2091 (match-beginning 0)))
2092 (row (progn (goto-char end
)
2093 (skip-chars-backward " ")
2094 ;; remove whitespace at end of argument
2095 (delete-region (point) end
)
2096 (buffer-substring-no-properties start
(point)))))
2097 (delete-region texinfo-command-start end
)
2100 (put 'multitable
'texinfo-item
'texinfo-multitable-item
)
2101 (defun texinfo-multitable-item ()
2102 "Format a row within a multicolumn table.
2103 Cells in row are separated by @tab.
2104 Widths of cells are specified by the arguments in the @multitable line.
2105 All cells are made to be the same height.
2106 This command is executed when texinfmt sees @item inside @multitable."
2107 (let ((original-buffer (current-buffer))
2108 (table-widths (reverse (car (cdr (car texinfo-stack
)))))
2109 (existing-fill-column fill-column
)
2113 (table-entry-height 0)
2114 ;; unformatted row looks like: A1 @tab A2 @tab A3
2115 ;; extract-row command deletes the source line in the table.
2116 (unformated-row (texinfo-multitable-extract-row)))
2117 ;; Use a temporary buffer
2118 (set-buffer (get-buffer-create texinfo-multitable-buffer-name
))
2119 (delete-region (point-min) (point-max))
2120 (insert unformated-row
)
2121 (goto-char (point-min))
2122 ;; 1. Check for correct number of @tab in line.
2123 (let ((tab-number 1)) ; one @tab between two columns
2124 (while (search-forward "@tab" nil t
)
2125 (setq tab-number
(1+ tab-number
)))
2126 (let ((needed-tabs (- (length table-widths
) tab-number
)))
2127 (when (> needed-tabs
0)
2128 (goto-char (point-min))
2130 (while (> needed-tabs
0)
2131 (insert "@w{ }\n@tab")
2132 (setq needed-tabs
(1- needed-tabs
))
2134 "Added @tabs and empty spaces to a @multitable row")))))
2135 (goto-char (point-min))
2136 ;; 2. Format each cell, and copy to a rectangle
2137 ;; buffer looks like this: A1 @tab A2 @tab A3
2138 ;; Cell #1: format up to @tab
2139 ;; Cell #2: format up to @tab
2140 ;; Cell #3: format up to eob
2142 (setq start
(point))
2143 (setq end
(save-excursion
2144 (if (search-forward "@tab" nil
'move
)
2145 ;; Delete the @tab command, including the @-sign
2148 (progn (forward-word -
1) (1- (point)))))
2150 ;; Set fill-column *wider* than needed to produce inter-column space
2151 (setq fill-column
(+ 1
2152 texinfo-extra-inter-column-width
2153 (nth table-column table-widths
)))
2154 (narrow-to-region start end
)
2155 ;; Remove whitespace before and after entry.
2156 (skip-chars-forward " ")
2157 (delete-region (point) (save-excursion (beginning-of-line) (point)))
2158 (goto-char (point-max))
2159 (skip-chars-backward " ")
2160 (delete-region (point) (save-excursion (end-of-line) (point)))
2161 ;; Temporarily set texinfo-stack to nil so texinfo-format-scan
2162 ;; does not see an unterminated @multitable.
2163 (let (texinfo-stack) ; nil
2164 (texinfo-format-scan))
2165 (let (fill-prefix) ; no fill prefix
2166 (fill-region (point-min) (point-max)))
2167 (setq table-entry-height
2168 (max table-entry-height
(count-lines (point-min) (point-max))))
2169 ;; 3. Move point to end of bottom line, and pad that line to fill column.
2170 (goto-char (point-min))
2171 (forward-line (1- table-entry-height
))
2172 (let* ((beg (point)) ; beginning of line
2173 ;; add one more space for inter-column spacing
2178 (progn (end-of-line) (point)) ; end of existing line
2180 (insert (make-string
2181 (if (> needed-whitespace
0) needed-whitespace
1)
2183 ;; now, put formatted cell into a rectangle
2184 (set (intern (concat texinfo-multitable-rectangle-name
2185 (int-to-string table-column
)))
2186 (extract-rectangle (point-min) (point)))
2187 (delete-region (point-min) (point))
2188 (goto-char (point-max))
2189 (setq table-column
(1+ table-column
))
2191 ;; 4. Add extra lines to rectangles so all are of same height
2192 (let ((total-number-of-columns table-column
)
2195 (while (> table-column
0)
2196 (let ((this-rectangle (int-to-string table-column
)))
2197 (while (< (length this-rectangle
) table-entry-height
)
2198 (setq this-rectangle
(append this-rectangle
'("")))))
2199 (setq table-column
(1- table-column
)))
2200 ;; 5. Insert formatted rectangles in original buffer
2201 (switch-to-buffer original-buffer
)
2202 (open-line table-entry-height
)
2203 (while (< column-number total-number-of-columns
)
2207 (concat texinfo-multitable-rectangle-name
2208 (int-to-string column-number
)))))
2211 (setq column-number
(1+ column-number
))))
2212 (kill-buffer texinfo-multitable-buffer-name
)
2213 (setq fill-column existing-fill-column
)))
2217 ;; Use only the FILENAME argument to the command.
2218 ;; In Info, ignore the other arguments.
2220 (put 'image
'texinfo-format
'texinfo-format-image
)
2221 (defun texinfo-format-image ()
2222 "Insert an image from an an file ending in .txt.
2223 Use only the FILENAME arg; for Info, ignore the other arguments to @image."
2224 (let ((args (texinfo-format-parse-args))
2226 (when (null (nth 0 args
))
2227 (error "Invalid image command"))
2228 (texinfo-discard-command)
2229 ;; makeinfo uses FILENAME.txt
2230 (setq filename
(format "%s.txt" (nth 0 args
)))
2231 (message "Reading included file: %s" filename
)
2232 ;; verbatim for Info output
2233 (goto-char (+ (point) (cadr (insert-file-contents filename
))))
2234 (message "Reading included file: %s...done" filename
)))
2237 ;;; @ifinfo, @iftex, @tex, @ifhtml, @html, @ifplaintext, @ifxml, @xml
2238 ;; @ifnottex, @ifnotinfo, @ifnothtml, @ifnotplaintext, @ifnotxml
2240 (put 'ifinfo
'texinfo-format
'texinfo-discard-line
)
2241 (put 'ifinfo
'texinfo-end
'texinfo-discard-command
)
2243 (put 'iftex
'texinfo-format
'texinfo-format-iftex
)
2244 (defun texinfo-format-iftex ()
2245 (delete-region texinfo-command-start
2246 (re-search-forward "@end iftex[ \t]*\n")))
2248 (put 'ifhtml
'texinfo-format
'texinfo-format-ifhtml
)
2249 (defun texinfo-format-ifhtml ()
2250 (delete-region texinfo-command-start
2251 (re-search-forward "@end ifhtml[ \t]*\n")))
2253 (put 'ifplaintext
'texinfo-format
'texinfo-format-ifplaintext
)
2254 (defun texinfo-format-ifplaintext ()
2255 (delete-region texinfo-command-start
2256 (re-search-forward "@end ifplaintext[ \t]*\n")))
2258 (put 'ifxml
'texinfo-format
'texinfo-format-ifxml
)
2259 (defun texinfo-format-ifxml ()
2260 (delete-region texinfo-command-start
2261 (progn (re-search-forward "^@end ifxml[ \t]*\n")
2264 (put 'tex
'texinfo-format
'texinfo-format-tex
)
2265 (defun texinfo-format-tex ()
2266 (delete-region texinfo-command-start
2267 (re-search-forward "@end tex[ \t]*\n")))
2269 (put 'html
'texinfo-format
'texinfo-format-html
)
2270 (defun texinfo-format-html ()
2271 (delete-region texinfo-command-start
2272 (re-search-forward "@end html[ \t]*\n")))
2274 (put 'xml
'texinfo-format
'texinfo-format-xml
)
2275 (defun texinfo-format-xml ()
2276 (delete-region texinfo-command-start
2277 (progn (re-search-forward "^@end xml[ \t]*\n")
2280 (put 'ifnotinfo
'texinfo-format
'texinfo-format-ifnotinfo
)
2281 (defun texinfo-format-ifnotinfo ()
2282 (delete-region texinfo-command-start
2283 (re-search-forward "@end ifnotinfo[ \t]*\n")))
2285 (put 'ifnotplaintext
'texinfo-format
'texinfo-discard-line
)
2286 (put 'ifnotplaintext
'texinfo-end
'texinfo-discard-command
)
2288 (put 'ifnottex
'texinfo-format
'texinfo-discard-line
)
2289 (put 'ifnottex
'texinfo-end
'texinfo-discard-command
)
2291 (put 'ifnothtml
'texinfo-format
'texinfo-discard-line
)
2292 (put 'ifnothtml
'texinfo-end
'texinfo-discard-command
)
2294 (put 'ifnotxml
'texinfo-format
'texinfo-discard-line
)
2295 (put 'ifnotxml
'texinfo-end
'texinfo-discard-command
)
2300 (put 'titlepage
'texinfo-format
'texinfo-format-titlepage
)
2301 (defun texinfo-format-titlepage ()
2302 (delete-region texinfo-command-start
2303 (re-search-forward "@end titlepage[ \t]*\n")))
2305 (put 'endtitlepage
'texinfo-format
'texinfo-discard-line
)
2307 ;; @titlespec an alternative titling command; ignored by Info
2309 (put 'titlespec
'texinfo-format
'texinfo-format-titlespec
)
2310 (defun texinfo-format-titlespec ()
2311 (delete-region texinfo-command-start
2312 (re-search-forward "@end titlespec[ \t]*\n")))
2314 (put 'endtitlespec
'texinfo-format
'texinfo-discard-line
)
2319 (put 'today
'texinfo-format
'texinfo-format-today
)
2321 ;; Produces Day Month Year style of output. eg `1 Jan 1900'
2322 ;; The `@today{}' command requires a pair of braces, like `@dots{}'.
2323 (defun texinfo-format-today ()
2324 (texinfo-parse-arg-discard)
2325 (insert (format-time-string "%e %b %Y")))
2329 ;; Produce `Day Month Year Hour:Min' style of output.
2330 ;; eg `1 Jan 1900 13:52'
2332 (put 'timestamp
'texinfo-format
'texinfo-format-timestamp
)
2334 ;; The `@timestamp{}' command requires a pair of braces, like `@dots{}'.
2335 (defun texinfo-format-timestamp ()
2336 "Insert the current local time and date."
2337 (texinfo-parse-arg-discard)
2338 ;; For seconds and time zone, replace format string with "%e %b %Y %T %Z"
2339 (insert (format-time-string "%e %b %Y %R")))
2344 (put 'ignore
'texinfo-format
'texinfo-format-ignore
)
2345 (defun texinfo-format-ignore ()
2346 (delete-region texinfo-command-start
2347 (re-search-forward "@end ignore[ \t]*\n")))
2349 (put 'endignore
'texinfo-format
'texinfo-discard-line
)
2352 ;;; Define the Info enclosure command: @definfoenclose
2354 ;; A `@definfoenclose' command may be used to define a highlighting
2355 ;; command for Info, but not for TeX. A command defined using
2356 ;; `@definfoenclose' marks text by enclosing it in strings that precede
2357 ;; and follow the text.
2359 ;; Presumably, if you define a command with `@definfoenclose` for Info,
2360 ;; you will also define the same command in the TeX definitions file,
2361 ;; `texinfo.tex' in a manner appropriate for typesetting.
2363 ;; Write a `@definfoenclose' command on a line and follow it with three
2364 ;; arguments separated by commas (commas are used as separators in an
2365 ;; `@node' line in the same way). The first argument to
2366 ;; `@definfoenclose' is the @-command name \(without the `@'\); the
2367 ;; second argument is the Info start delimiter string; and the third
2368 ;; argument is the Info end delimiter string. The latter two arguments
2369 ;; enclose the highlighted text in the Info file. A delimiter string
2370 ;; may contain spaces. Neither the start nor end delimiter is
2371 ;; required. However, if you do not provide a start delimiter, you
2372 ;; must follow the command name with two commas in a row; otherwise,
2373 ;; the Info formatting commands will misinterpret the end delimiter
2374 ;; string as a start delimiter string.
2376 ;; If you do a @definfoenclose{} on the name of a pre-defined macro (such
2377 ;; as @emph{}, @strong{}, @tt{}, or @i{}) the enclosure definition will
2378 ;; override the built-in definition.
2380 ;; An enclosure command defined this way takes one argument in braces.
2382 ;; For example, you can write:
2385 ;; @definfoenclose phoo, //, \\
2388 ;; near the beginning of a Texinfo file at the beginning of the lines
2389 ;; to define `@phoo' as an Info formatting command that inserts `//'
2390 ;; before and `\\' after the argument to `@phoo'. You can then write
2391 ;; `@phoo{bar}' wherever you want `//bar\\' highlighted in Info.
2393 ;; Also, for TeX formatting, you could write
2396 ;; @global@let@phoo=@i
2399 ;; to define `@phoo' as a command that causes TeX to typeset
2400 ;; the argument to `@phoo' in italics.
2402 ;; Note that each definition applies to its own formatter: one for TeX,
2403 ;; the other for texinfo-format-buffer or texinfo-format-region.
2405 ;; Here is another example: write
2407 ;; @definfoenclose headword, , :
2409 ;; near the beginning of the file, to define `@headword' as an Info
2410 ;; formatting command that inserts nothing before and a colon after the
2411 ;; argument to `@headword'.
2413 (put 'definfoenclose
'texinfo-format
'texinfo-define-info-enclosure
)
2414 (defun texinfo-define-info-enclosure ()
2415 (let* ((args (texinfo-format-parse-line-args))
2416 (command-name (nth 0 args
))
2417 (beginning-delimiter (or (nth 1 args
) ""))
2418 (end-delimiter (or (nth 2 args
) "")))
2419 (texinfo-discard-command)
2420 (setq texinfo-enclosure-list
2426 texinfo-enclosure-list
))))
2431 (put 'alias
'texinfo-format
'texinfo-alias
)
2432 (defun texinfo-alias ()
2433 (let ((start (1- (point)))
2435 (skip-chars-forward " ")
2436 (save-excursion (end-of-line) (setq texinfo-command-end
(point)))
2437 (if (not (looking-at "\\([^=]+\\)=\\(.*\\)"))
2438 (error "Invalid alias command")
2439 (setq texinfo-alias-list
2442 (match-string-no-properties 1)
2443 (match-string-no-properties 2))
2444 texinfo-alias-list
))
2445 (texinfo-discard-command))
2450 ;;; @var, @code and the like
2452 (put 'var
'texinfo-format
'texinfo-format-var
)
2453 ;; @sc a small caps font for TeX; formatted as `var' in Info
2454 (put 'sc
'texinfo-format
'texinfo-format-var
)
2455 ;; @acronym for abbreviations in all caps, such as `NASA'.
2456 ;; Convert all letters to uppercase if they are not already.
2457 (put 'acronym
'texinfo-format
'texinfo-format-var
)
2458 (defun texinfo-format-var ()
2459 (let ((arg (texinfo-parse-expanded-arg)))
2460 (texinfo-discard-command)
2461 (insert (upcase arg
))))
2463 (put 'cite
'texinfo-format
'texinfo-format-code
)
2464 (put 'code
'texinfo-format
'texinfo-format-code
)
2465 ;; @command (for command names)
2466 (put 'command
'texinfo-format
'texinfo-format-code
)
2467 ;; @env (for environment variables)
2468 (put 'env
'texinfo-format
'texinfo-format-code
)
2469 (put 'file
'texinfo-format
'texinfo-format-code
)
2470 (put 'samp
'texinfo-format
'texinfo-format-code
)
2471 (put 'url
'texinfo-format
'texinfo-format-code
)
2472 (defun texinfo-format-code ()
2473 (insert "`" (texinfo-parse-arg-discard) "'")
2474 (goto-char texinfo-command-start
))
2476 ;; @option (for command-line options) must be different from @code
2477 ;; because of its special formatting in @table; namely that it does
2478 ;; not lead to inserted ` ... ' in a table, but does elsewhere.
2479 (put 'option
'texinfo-format
'texinfo-format-option
)
2480 (defun texinfo-format-option ()
2481 "Insert ` ... ' around arg unless inside a table; in that case, no quotes."
2482 ;; `looking-at-backward' not available in v. 18.57, 20.2
2483 (if (not (search-backward "\b" ; searched-for character is a control-H
2484 (save-excursion (beginning-of-line) (point))
2486 (insert "`" (texinfo-parse-arg-discard) "'")
2487 (insert (texinfo-parse-arg-discard)))
2488 (goto-char texinfo-command-start
))
2490 (put 'emph
'texinfo-format
'texinfo-format-emph
)
2491 (put 'strong
'texinfo-format
'texinfo-format-emph
)
2492 (defun texinfo-format-emph ()
2493 (insert "*" (texinfo-parse-arg-discard) "*")
2494 (goto-char texinfo-command-start
))
2496 (put 'dfn
'texinfo-format
'texinfo-format-defn
)
2497 (put 'defn
'texinfo-format
'texinfo-format-defn
)
2498 (defun texinfo-format-defn ()
2499 (insert "\"" (texinfo-parse-arg-discard) "\"")
2500 (goto-char texinfo-command-start
))
2502 (put 'email
'texinfo-format
'texinfo-format-email
)
2503 (defun texinfo-format-email ()
2504 "Format email address and optional following full name.
2505 Insert full name, if present, followed by email address
2506 surrounded by in angle brackets."
2507 (let ((args (texinfo-format-parse-args)))
2508 (texinfo-discard-command)
2511 (insert (nth 1 args
) " "))
2512 (insert "<" (nth 0 args
) ">")))
2514 (put 'key
'texinfo-format
'texinfo-format-key
)
2515 ;; I've decided not want to have angle brackets around these -- rms.
2516 (defun texinfo-format-key ()
2517 (insert (texinfo-parse-arg-discard))
2518 (goto-char texinfo-command-start
))
2520 ;; @verb{<char>TEXT<char>} (in `makeinfo' 4.1 and later)
2521 (put 'verb
'texinfo-format
'texinfo-format-verb
)
2522 (defun texinfo-format-verb ()
2523 "Format text between non-quoted unique delimiter characters verbatim.
2524 Enclose the verbatim text, including the delimiters, in braces. Print
2525 text exactly as written (but not the delimiters) in a fixed-width.
2527 For example, @verb\{|@|\} results in @ and
2528 @verb\{+@'e?`!`+} results in @'e?`!`."
2530 (let ((delimiter (buffer-substring-no-properties
2531 (1+ texinfo-command-end
) (+ 2 texinfo-command-end
))))
2532 (unless (looking-at "{")
2533 (error "Not found: @verb start brace"))
2534 (delete-region texinfo-command-start
(+ 2 texinfo-command-end
))
2535 (search-forward delimiter
))
2536 (delete-backward-char 1)
2537 (unless (looking-at "}")
2538 (error "Not found: @verb end brace"))
2541 ;; as of 2002 Dec 10
2542 ;; see (texinfo)Block Enclosing Commands
2545 ;; as of 2002 Dec 10
2546 ;; see (texinfo)verbatiminclude
2547 ;; need: @verbatiminclude FILENAME
2549 (put 'bullet
'texinfo-format
'texinfo-format-bullet
)
2550 (defun texinfo-format-bullet ()
2551 "Insert an asterisk.
2552 If used within a line, follow `@bullet' with braces."
2553 (texinfo-optional-braces-discard)
2559 ;; Inside of @example ... @end example and similar environments,
2560 ;; @kbd does nothing; but outside of such environments, it places
2561 ;; single quotation marks around its argument.
2563 (defvar texinfo-format-kbd-regexp
2573 "Regexp specifying environments in which @kbd does not put `...'
2576 (defvar texinfo-format-kbd-end-regexp
2586 "Regexp specifying end of environments in which @kbd does not put `...'
2587 around argument. (See `texinfo-format-kbd-regexp')")
2589 (put 'kbd
'texinfo-format
'texinfo-format-kbd
)
2590 (defun texinfo-format-kbd ()
2591 "Place single quote marks around arg, except in @example and similar."
2592 ;; Search forward for @end example closer than an @example.
2593 ;; Can stop search at nearest @node or texinfo-section-types-regexp
2597 (concat "^@node\\|\\(" texinfo-section-types-regexp
"\\)")
2599 'move-to-end
) ; if necessary, return point at end of buffer
2603 (re-search-forward texinfo-format-kbd-regexp stop
'move-to-end
)
2605 (end-example-location
2607 (re-search-forward texinfo-format-kbd-end-regexp stop
'move-to-end
)
2609 ;; If inside @example, @end example will be closer than @example
2610 ;; or end of search i.e., end-example-location less than example-location
2611 (if (>= end-example-location example-location
)
2612 ;; outside an @example or equivalent
2613 (insert "`" (texinfo-parse-arg-discard) "'")
2614 ;; else, in @example; do not surround with `...'
2615 (insert (texinfo-parse-arg-discard)))
2616 (goto-char texinfo-command-start
)))
2619 ;;; @example, @lisp, @quotation, @display, @smalllisp, @smallexample,
2622 (put 'display
'texinfo-format
'texinfo-format-example
)
2623 (put 'smalldisplay
'texinfo-format
'texinfo-format-example
)
2624 (put 'example
'texinfo-format
'texinfo-format-example
)
2625 (put 'lisp
'texinfo-format
'texinfo-format-example
)
2626 (put 'quotation
'texinfo-format
'texinfo-format-example
)
2627 (put 'smallexample
'texinfo-format
'texinfo-format-example
)
2628 (put 'smalllisp
'texinfo-format
'texinfo-format-example
)
2629 (defun texinfo-format-example ()
2630 (texinfo-push-stack 'example nil
)
2631 (setq fill-column
(- fill-column
5))
2632 (texinfo-discard-line))
2634 (put 'example
'texinfo-end
'texinfo-end-example
)
2635 (put 'display
'texinfo-end
'texinfo-end-example
)
2636 (put 'smalldisplay
'texinfo-end
'texinfo-end-example
)
2637 (put 'lisp
'texinfo-end
'texinfo-end-example
)
2638 (put 'quotation
'texinfo-end
'texinfo-end-example
)
2639 (put 'smallexample
'texinfo-end
'texinfo-end-example
)
2640 (put 'smalllisp
'texinfo-end
'texinfo-end-example
)
2641 (defun texinfo-end-example ()
2642 (setq fill-column
(+ fill-column
5))
2643 (texinfo-discard-command)
2645 (texinfo-pop-stack 'example
)))
2646 (texinfo-do-itemize (nth 1 stacktop
))))
2648 (put 'exdent
'texinfo-format
'texinfo-format-exdent
)
2649 (defun texinfo-format-exdent ()
2650 (texinfo-discard-command)
2651 (delete-region (point)
2653 (skip-chars-forward " ")
2656 ;; Cancel out the deletion that texinfo-do-itemize
2657 ;; is going to do at the end of this line.
2663 ;; @direntry and @dircategory
2665 (put 'direntry
'texinfo-format
'texinfo-format-direntry
)
2666 (defun texinfo-format-direntry ()
2667 (texinfo-push-stack 'direntry nil
)
2668 (texinfo-discard-line)
2669 (insert "START-INFO-DIR-ENTRY\n"))
2671 (put 'direntry
'texinfo-end
'texinfo-end-direntry
)
2672 (defun texinfo-end-direntry ()
2673 (texinfo-discard-command)
2674 (insert "END-INFO-DIR-ENTRY\n\n")
2675 (texinfo-pop-stack 'direntry
))
2677 (put 'dircategory
'texinfo-format
'texinfo-format-dircategory
)
2678 (defun texinfo-format-dircategory ()
2679 (let ((str (texinfo-parse-arg-discard)))
2680 (delete-region (point)
2682 (skip-chars-forward " ")
2684 (insert "INFO-DIR-SECTION " str
"\n")))
2688 ;; The @cartouche command is a noop in Info; in a printed manual,
2689 ;; it makes a box with rounded corners.
2691 (put 'cartouche
'texinfo-format
'texinfo-discard-line
)
2692 (put 'cartouche
'texinfo-end
'texinfo-discard-command
)
2695 ;;; @flushleft and @format
2697 ;; The @flushleft command left justifies every line but leaves the
2698 ;; right end ragged. As far as Info is concerned, @flushleft is a
2699 ;; `do-nothing' command
2701 ;; The @format command is similar to @example except that it does not
2702 ;; indent; this means that in Info, @format is similar to @flushleft.
2704 (put 'format
'texinfo-format
'texinfo-format-flushleft
)
2705 (put 'smallformat
'texinfo-format
'texinfo-format-flushleft
)
2706 (put 'flushleft
'texinfo-format
'texinfo-format-flushleft
)
2707 (defun texinfo-format-flushleft ()
2708 (texinfo-discard-line))
2710 (put 'format
'texinfo-end
'texinfo-end-flushleft
)
2711 (put 'smallformat
'texinfo-end
'texinfo-end-flushleft
)
2712 (put 'flushleft
'texinfo-end
'texinfo-end-flushleft
)
2713 (defun texinfo-end-flushleft ()
2714 (texinfo-discard-command))
2719 ;; The @flushright command right justifies every line but leaves the
2720 ;; left end ragged. Spaces and tabs at the right ends of lines are
2721 ;; removed so that visible text lines up on the right side.
2723 (put 'flushright
'texinfo-format
'texinfo-format-flushright
)
2724 (defun texinfo-format-flushright ()
2725 (texinfo-push-stack 'flushright nil
)
2726 (texinfo-discard-line))
2728 (put 'flushright
'texinfo-end
'texinfo-end-flushright
)
2729 (defun texinfo-end-flushright ()
2730 (texinfo-discard-command)
2733 (texinfo-pop-stack 'flushright
)))
2735 (texinfo-do-flushright (nth 1 stacktop
))))
2737 (defun texinfo-do-flushright (from)
2739 (while (progn (forward-line -
1)
2748 (skip-chars-backward " \t")
2749 (delete-region (point) (progn (end-of-line) (point)))
2754 ;;; @ctrl, @TeX, @copyright, @minus, @dots, @enddots, @pounds
2756 (put 'ctrl
'texinfo-format
'texinfo-format-ctrl
)
2757 (defun texinfo-format-ctrl ()
2758 (let ((str (texinfo-parse-arg-discard)))
2759 (insert (logand 31 (aref str
0)))))
2761 (put 'TeX
'texinfo-format
'texinfo-format-TeX
)
2762 (defun texinfo-format-TeX ()
2763 (texinfo-parse-arg-discard)
2766 (put 'copyright
'texinfo-format
'texinfo-format-copyright
)
2767 (defun texinfo-format-copyright ()
2768 (texinfo-parse-arg-discard)
2771 (put 'minus
'texinfo-format
'texinfo-format-minus
)
2772 (defun texinfo-format-minus ()
2773 "Insert a minus sign.
2774 If used within a line, follow `@minus' with braces."
2775 (texinfo-optional-braces-discard)
2778 (put 'dots
'texinfo-format
'texinfo-format-dots
)
2779 (defun texinfo-format-dots ()
2780 (texinfo-parse-arg-discard)
2783 (put 'enddots
'texinfo-format
'texinfo-format-enddots
)
2784 (defun texinfo-format-enddots ()
2785 (texinfo-parse-arg-discard)
2788 (put 'pounds
'texinfo-format
'texinfo-format-pounds
)
2789 (defun texinfo-format-pounds ()
2790 (texinfo-parse-arg-discard)
2794 ;;; Refilling and indenting: @refill, @paragraphindent, @noindent
2796 ;;; Indent only those paragraphs that are refilled as a result of an
2797 ;;; @refill command.
2799 ;; * If the value is `asis', do not change the existing indentation at
2800 ;; the starts of paragraphs.
2802 ;; * If the value zero, delete any existing indentation.
2804 ;; * If the value is greater than zero, indent each paragraph by that
2805 ;; number of spaces.
2807 ;;; But do not refill paragraphs with an @refill command that are
2808 ;;; preceded by @noindent or are part of a table, list, or deffn.
2810 (defvar texinfo-paragraph-indent
"asis"
2811 "Number of spaces for @refill to indent a paragraph; else to leave as is.")
2813 (put 'paragraphindent
'texinfo-format
'texinfo-paragraphindent
)
2815 (defun texinfo-paragraphindent ()
2816 "Specify the number of spaces for @refill to indent a paragraph.
2817 Default is to leave the number of spaces as is."
2818 (let ((arg (texinfo-parse-arg-discard)))
2819 (if (string= "asis" arg
)
2820 (setq texinfo-paragraph-indent
"asis")
2821 (setq texinfo-paragraph-indent
(string-to-number arg
)))))
2823 (put 'refill
'texinfo-format
'texinfo-format-refill
)
2824 (defun texinfo-format-refill ()
2825 "Refill paragraph. Also, indent first line as set by @paragraphindent.
2826 Default is to leave paragraph indentation as is."
2827 (texinfo-discard-command)
2828 (let ((position (point-marker)))
2829 (forward-paragraph -
1)
2830 (if (looking-at "[ \t\n]*$") (forward-line 1))
2831 ;; Do not indent if an entry in a list, table, or deffn,
2832 ;; or if paragraph is preceded by @noindent.
2833 ;; Otherwise, indent
2835 ;; delete a @noindent line and do not indent paragraph
2836 ((save-excursion (forward-line -
1)
2837 (looking-at "^@noindent"))
2839 (delete-region (point) (progn (forward-line 1) (point))))
2840 ;; do nothing if "asis"
2841 ((equal texinfo-paragraph-indent
"asis"))
2842 ;; do no indenting in list, etc.
2843 ((> texinfo-stack-depth
0))
2844 ;; otherwise delete existing whitespace and indent
2846 (delete-region (point) (progn (skip-chars-forward " \t") (point)))
2847 (insert (make-string texinfo-paragraph-indent ?
))))
2848 (forward-paragraph 1)
2851 ;; Do not fill a section title line with asterisks, hyphens, etc. that
2852 ;; are used to underline it. This could occur if the line following
2853 ;; the underlining is not an index entry and has text within it.
2854 (let* ((previous-paragraph-separate paragraph-separate
)
2856 (concat paragraph-separate
"\\|[-=.]+\\|\\*\\*+"))
2857 (previous-paragraph-start paragraph-start
)
2859 (concat paragraph-start
"\\|[-=.]+\\|\\*\\*+")))
2861 (fill-paragraph nil
)
2862 (setq paragraph-separate previous-paragraph-separate
)
2863 (setq paragraph-start previous-paragraph-start
)))
2864 (goto-char position
)))
2866 (put 'noindent
'texinfo-format
'texinfo-noindent
)
2867 (defun texinfo-noindent ()
2869 (forward-paragraph 1)
2870 (if (search-backward "@refill"
2871 (save-excursion (forward-line -
1) (point)) t
)
2872 () ; leave @noindent command so @refill command knows not to indent
2874 (texinfo-discard-line))))
2877 ;;; Index generation
2879 (put 'vindex
'texinfo-format
'texinfo-format-vindex
)
2880 (defun texinfo-format-vindex ()
2881 (texinfo-index 'texinfo-vindex
))
2883 (put 'cindex
'texinfo-format
'texinfo-format-cindex
)
2884 (defun texinfo-format-cindex ()
2885 (texinfo-index 'texinfo-cindex
))
2887 (put 'findex
'texinfo-format
'texinfo-format-findex
)
2888 (defun texinfo-format-findex ()
2889 (texinfo-index 'texinfo-findex
))
2891 (put 'pindex
'texinfo-format
'texinfo-format-pindex
)
2892 (defun texinfo-format-pindex ()
2893 (texinfo-index 'texinfo-pindex
))
2895 (put 'tindex
'texinfo-format
'texinfo-format-tindex
)
2896 (defun texinfo-format-tindex ()
2897 (texinfo-index 'texinfo-tindex
))
2899 (put 'kindex
'texinfo-format
'texinfo-format-kindex
)
2900 (defun texinfo-format-kindex ()
2901 (texinfo-index 'texinfo-kindex
))
2903 (defun texinfo-index (indexvar)
2904 (let ((arg (texinfo-parse-expanded-arg)))
2905 (texinfo-discard-command)
2909 ;; Region formatting may not provide last node position.
2910 (if texinfo-last-node-pos
2911 (1+ (count-lines texinfo-last-node-pos
(point)))
2913 (symbol-value indexvar
)))))
2915 (defvar texinfo-indexvar-alist
2916 '(("cp" . texinfo-cindex
)
2917 ("fn" . texinfo-findex
)
2918 ("vr" . texinfo-vindex
)
2919 ("tp" . texinfo-tindex
)
2920 ("pg" . texinfo-pindex
)
2921 ("ky" . texinfo-kindex
)))
2924 ;;; @defindex @defcodeindex
2925 (put 'defindex
'texinfo-format
'texinfo-format-defindex
)
2926 (put 'defcodeindex
'texinfo-format
'texinfo-format-defindex
)
2928 (defun texinfo-format-defindex ()
2929 (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa'
2930 (indexing-command (intern (concat index-name
"index")))
2931 (index-formatting-command ; eg: `texinfo-format-aaindex'
2932 (intern (concat "texinfo-format-" index-name
"index")))
2933 (index-alist-name ; eg: `texinfo-aaindex'
2934 (intern (concat "texinfo-" index-name
"index"))))
2936 (set index-alist-name nil
)
2938 (put indexing-command
; eg, aaindex
2940 index-formatting-command
) ; eg, texinfo-format-aaindex
2942 ;; eg: "aa" . texinfo-aaindex
2943 (or (assoc index-name texinfo-indexvar-alist
)
2944 (setq texinfo-indexvar-alist
2948 texinfo-indexvar-alist
)))
2950 (fset index-formatting-command
2952 (list 'texinfo-index
2953 (list 'quote index-alist-name
))))))
2956 ;;; @synindex @syncodeindex
2958 (put 'synindex
'texinfo-format
'texinfo-format-synindex
)
2959 (put 'syncodeindex
'texinfo-format
'texinfo-format-synindex
)
2961 (defun texinfo-format-synindex ()
2962 (let* ((args (texinfo-parse-arg-discard))
2963 (second (cdr (read-from-string args
)))
2964 (joiner (symbol-name (car (read-from-string args
))))
2965 (joined (symbol-name (car (read-from-string args second
)))))
2967 (if (assoc joiner texinfo-short-index-cmds-alist
)
2969 (cdr (assoc joiner texinfo-short-index-cmds-alist
))
2971 (or (cdr (assoc joined texinfo-short-index-format-cmds-alist
))
2972 (intern (concat "texinfo-format-" joined
"index"))))
2974 (intern (concat joiner
"index"))
2976 (or (cdr(assoc joined texinfo-short-index-format-cmds-alist
))
2977 (intern (concat "texinfo-format-" joined
"index")))))))
2979 (defconst texinfo-short-index-cmds-alist
2987 (defconst texinfo-short-index-format-cmds-alist
2988 '(("cp" . texinfo-format-cindex
)
2989 ("fn" . texinfo-format-findex
)
2990 ("vr" . texinfo-format-vindex
)
2991 ("tp" . texinfo-format-tindex
)
2992 ("pg" . texinfo-format-pindex
)
2993 ("ky" . texinfo-format-kindex
)))
2996 ;;; Sort and index (for VMS)
2998 ;; Sort an index which is in the current buffer between START and END.
2999 ;; Used on VMS, where the `sort' utility is not available.
3000 (defun texinfo-sort-region (start end
)
3003 (narrow-to-region start end
)
3004 (goto-char (point-min))
3005 (sort-subr nil
'forward-line
'end-of-line
'texinfo-sort-startkeyfun
)))
3007 ;; Subroutine for sorting an index.
3008 ;; At start of a line, return a string to sort the line under.
3009 (defun texinfo-sort-startkeyfun ()
3010 (let ((line (buffer-substring-no-properties (point) (line-end-position))))
3011 ;; Canonicalize whitespace and eliminate funny chars.
3012 (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line
)
3013 (setq line
(concat (substring line
0 (match-beginning 0))
3015 (substring line
(match-end 0)))))
3021 (put 'printindex
'texinfo-format
'texinfo-format-printindex
)
3023 (defun texinfo-format-printindex ()
3024 (let ((indexelts (symbol-value
3025 (cdr (assoc (texinfo-parse-arg-discard)
3026 texinfo-indexvar-alist
))))
3028 (insert "\n* Menu:\n\n")
3029 (setq opoint
(point))
3030 (texinfo-print-index nil indexelts
)
3032 (if (memq system-type
'(vax-vms windows-nt ms-dos
))
3033 (texinfo-sort-region opoint
(point))
3034 (shell-command-on-region opoint
(point) "sort -fd" 1))))
3036 (defun texinfo-print-index (file indexelts
)
3038 (if (stringp (car (car indexelts
)))
3040 (insert "* " (car (car indexelts
)) ": " )
3043 (if file
(concat "(" file
")") "")
3044 (nth 1 (car indexelts
)) ".")
3047 (if (nth 2 (car indexelts
))
3048 (format " (line %3d)" (1+ (nth 2 (car indexelts
))))
3051 ;; index entries from @include'd file
3052 (texinfo-print-index (nth 1 (car indexelts
))
3053 (nth 2 (car indexelts
))))
3054 (setq indexelts
(cdr indexelts
))))
3057 ;;; Glyphs: @equiv, @error, etc
3059 ;; @equiv to show that two expressions are equivalent
3060 ;; @error to show an error message
3061 ;; @expansion to show what a macro expands to
3062 ;; @point to show the location of point in an example
3063 ;; @print to show what an evaluated expression prints
3064 ;; @result to indicate the value returned by an expression
3066 (put 'equiv
'texinfo-format
'texinfo-format-equiv
)
3067 (defun texinfo-format-equiv ()
3068 (texinfo-parse-arg-discard)
3071 (put 'error
'texinfo-format
'texinfo-format-error
)
3072 (defun texinfo-format-error ()
3073 (texinfo-parse-arg-discard)
3074 (insert "error-->"))
3076 (put 'expansion
'texinfo-format
'texinfo-format-expansion
)
3077 (defun texinfo-format-expansion ()
3078 (texinfo-parse-arg-discard)
3081 (put 'point
'texinfo-format
'texinfo-format-point
)
3082 (defun texinfo-format-point ()
3083 (texinfo-parse-arg-discard)
3086 (put 'print
'texinfo-format
'texinfo-format-print
)
3087 (defun texinfo-format-print ()
3088 (texinfo-parse-arg-discard)
3091 (put 'result
'texinfo-format
'texinfo-format-result
)
3092 (defun texinfo-format-result ()
3093 (texinfo-parse-arg-discard)
3099 ;; Info presumes a plain ASCII output, so the accented characters do
3100 ;; not look as they would if typeset, or output with a different
3103 ;; See the `texinfo-accent-commands' variable
3104 ;; in the section for `texinfo-append-refill'.
3105 ;; Also, see the defun for `texinfo-format-scan'
3106 ;; for single-character accent commands.
3108 ;; Command Info output Name
3110 ;; These do not have braces:
3111 ;; @^ ==> ^ circumflex accent
3112 ;; @` ==> ` grave accent
3113 ;; @' ==> ' acute accent
3114 ;; @" ==> " umlaut accent
3115 ;; @= ==> = overbar accent
3116 ;; @~ ==> ~ tilde accent
3118 ;; These have braces, but take no argument:
3119 ;; @OE{} ==> OE French-OE-ligature
3121 ;; @AA{} ==> AA Scandinavian-A-with-circle
3123 ;; @AE{} ==> AE Latin-Scandinavian-AE
3125 ;; @ss{} ==> ss German-sharp-S
3127 ;; @questiondown{} ==> ? upside-down-question-mark
3128 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
3129 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
3130 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
3131 ;; @O{} ==> O/ Scandinavian O-with-slash
3132 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
3134 ;; These have braces, and take an argument:
3135 ;; @,{c} ==> c, cedilla accent
3136 ;; @dotaccent{o} ==> .o overdot-accent
3137 ;; @ubaraccent{o} ==> _o underbar-accent
3138 ;; @udotaccent{o} ==> o-. underdot-accent
3139 ;; @H{o} ==> ""o long Hungarian umlaut
3140 ;; @ringaccent{o} ==> *o ring accent
3141 ;; @tieaccent{oo} ==> [oo tie after accent
3142 ;; @u{o} ==> (o breve accent
3143 ;; @v{o} ==> <o hacek accent
3144 ;; @dotless{i} ==> i dotless i and dotless j
3148 ;; Note: The defun texinfo-format-scan
3149 ;; looks at "[@{}^'`\",=~ *?!-]"
3150 ;; In the case of @*, a line break is inserted;
3151 ;; in the other cases, the characters are simply quoted and the @ is deleted.
3152 ;; Thus, `texinfo-format-scan' handles the following
3153 ;; single-character accent commands: @^ @` @' @" @, @- @= @~
3155 ;; @^ ==> ^ circumflex accent
3156 ;; (put '^ 'texinfo-format 'texinfo-format-circumflex-accent)
3157 ;; (defun texinfo-format-circumflex-accent ()
3158 ;; (texinfo-discard-command)
3161 ;; @` ==> ` grave accent
3162 ;; (put '\` 'texinfo-format 'texinfo-format-grave-accent)
3163 ;; (defun texinfo-format-grave-accent ()
3164 ;; (texinfo-discard-command)
3167 ;; @' ==> ' acute accent
3168 ;; (put '\' 'texinfo-format 'texinfo-format-acute-accent)
3169 ;; (defun texinfo-format-acute-accent ()
3170 ;; (texinfo-discard-command)
3173 ;; @" ==> " umlaut accent
3174 ;; (put '\" 'texinfo-format 'texinfo-format-umlaut-accent)
3175 ;; (defun texinfo-format-umlaut-accent ()
3176 ;; (texinfo-discard-command)
3179 ;; @= ==> = overbar accent
3180 ;; (put '= 'texinfo-format 'texinfo-format-overbar-accent)
3181 ;; (defun texinfo-format-overbar-accent ()
3182 ;; (texinfo-discard-command)
3185 ;; @~ ==> ~ tilde accent
3186 ;; (put '~ 'texinfo-format 'texinfo-format-tilde-accent)
3187 ;; (defun texinfo-format-tilde-accent ()
3188 ;; (texinfo-discard-command)
3191 ;; @OE{} ==> OE French-OE-ligature
3192 (put 'OE
'texinfo-format
'texinfo-format-French-OE-ligature
)
3193 (defun texinfo-format-French-OE-ligature ()
3194 (insert "OE" (texinfo-parse-arg-discard))
3195 (goto-char texinfo-command-start
))
3198 (put 'oe
'texinfo-format
'texinfo-format-French-oe-ligature
)
3199 (defun texinfo-format-French-oe-ligature () ; lower case
3200 (insert "oe" (texinfo-parse-arg-discard))
3201 (goto-char texinfo-command-start
))
3203 ;; @AA{} ==> AA Scandinavian-A-with-circle
3204 (put 'AA
'texinfo-format
'texinfo-format-Scandinavian-A-with-circle
)
3205 (defun texinfo-format-Scandinavian-A-with-circle ()
3206 (insert "AA" (texinfo-parse-arg-discard))
3207 (goto-char texinfo-command-start
))
3210 (put 'aa
'texinfo-format
'texinfo-format-Scandinavian-a-with-circle
)
3211 (defun texinfo-format-Scandinavian-a-with-circle () ; lower case
3212 (insert "aa" (texinfo-parse-arg-discard))
3213 (goto-char texinfo-command-start
))
3215 ;; @AE{} ==> AE Latin-Scandinavian-AE
3216 (put 'AE
'texinfo-format
'texinfo-format-Latin-Scandinavian-AE
)
3217 (defun texinfo-format-Latin-Scandinavian-AE ()
3218 (insert "AE" (texinfo-parse-arg-discard))
3219 (goto-char texinfo-command-start
))
3222 (put 'ae
'texinfo-format
'texinfo-format-Latin-Scandinavian-ae
)
3223 (defun texinfo-format-Latin-Scandinavian-ae () ; lower case
3224 (insert "ae" (texinfo-parse-arg-discard))
3225 (goto-char texinfo-command-start
))
3227 ;; @ss{} ==> ss German-sharp-S
3228 (put 'ss
'texinfo-format
'texinfo-format-German-sharp-S
)
3229 (defun texinfo-format-German-sharp-S ()
3230 (insert "ss" (texinfo-parse-arg-discard))
3231 (goto-char texinfo-command-start
))
3233 ;; @questiondown{} ==> ? upside-down-question-mark
3234 (put 'questiondown
'texinfo-format
'texinfo-format-upside-down-question-mark
)
3235 (defun texinfo-format-upside-down-question-mark ()
3236 (insert "?" (texinfo-parse-arg-discard))
3237 (goto-char texinfo-command-start
))
3239 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
3240 (put 'exclamdown
'texinfo-format
'texinfo-format-upside-down-exclamation-mark
)
3241 (defun texinfo-format-upside-down-exclamation-mark ()
3242 (insert "!" (texinfo-parse-arg-discard))
3243 (goto-char texinfo-command-start
))
3245 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
3246 (put 'L
'texinfo-format
'texinfo-format-Polish-suppressed-L
)
3247 (defun texinfo-format-Polish-suppressed-L ()
3248 (insert (texinfo-parse-arg-discard) "/L")
3249 (goto-char texinfo-command-start
))
3251 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
3252 (put 'l
'texinfo-format
'texinfo-format-Polish-suppressed-l-lower-case
)
3253 (defun texinfo-format-Polish-suppressed-l-lower-case ()
3254 (insert (texinfo-parse-arg-discard) "/l")
3255 (goto-char texinfo-command-start
))
3258 ;; @O{} ==> O/ Scandinavian O-with-slash
3259 (put 'O
'texinfo-format
'texinfo-format-Scandinavian-O-with-slash
)
3260 (defun texinfo-format-Scandinavian-O-with-slash ()
3261 (insert (texinfo-parse-arg-discard) "O/")
3262 (goto-char texinfo-command-start
))
3264 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
3265 (put 'o
'texinfo-format
'texinfo-format-Scandinavian-o-with-slash-lower-case
)
3266 (defun texinfo-format-Scandinavian-o-with-slash-lower-case ()
3267 (insert (texinfo-parse-arg-discard) "o/")
3268 (goto-char texinfo-command-start
))
3272 ;; @,{c} ==> c, cedilla accent
3273 (put '\
, 'texinfo-format
'texinfo-format-cedilla-accent
)
3274 (defun texinfo-format-cedilla-accent ()
3275 (insert (texinfo-parse-arg-discard) ",")
3276 (goto-char texinfo-command-start
))
3279 ;; @dotaccent{o} ==> .o overdot-accent
3280 (put 'dotaccent
'texinfo-format
'texinfo-format-overdot-accent
)
3281 (defun texinfo-format-overdot-accent ()
3282 (insert "." (texinfo-parse-arg-discard))
3283 (goto-char texinfo-command-start
))
3285 ;; @ubaraccent{o} ==> _o underbar-accent
3286 (put 'ubaraccent
'texinfo-format
'texinfo-format-underbar-accent
)
3287 (defun texinfo-format-underbar-accent ()
3288 (insert "_" (texinfo-parse-arg-discard))
3289 (goto-char texinfo-command-start
))
3291 ;; @udotaccent{o} ==> o-. underdot-accent
3292 (put 'udotaccent
'texinfo-format
'texinfo-format-underdot-accent
)
3293 (defun texinfo-format-underdot-accent ()
3294 (insert (texinfo-parse-arg-discard) "-.")
3295 (goto-char texinfo-command-start
))
3297 ;; @H{o} ==> ""o long Hungarian umlaut
3298 (put 'H
'texinfo-format
'texinfo-format-long-Hungarian-umlaut
)
3299 (defun texinfo-format-long-Hungarian-umlaut ()
3300 (insert "\"\"" (texinfo-parse-arg-discard))
3301 (goto-char texinfo-command-start
))
3303 ;; @ringaccent{o} ==> *o ring accent
3304 (put 'ringaccent
'texinfo-format
'texinfo-format-ring-accent
)
3305 (defun texinfo-format-ring-accent ()
3306 (insert "*" (texinfo-parse-arg-discard))
3307 (goto-char texinfo-command-start
))
3309 ;; @tieaccent{oo} ==> [oo tie after accent
3310 (put 'tieaccent
'texinfo-format
'texinfo-format-tie-after-accent
)
3311 (defun texinfo-format-tie-after-accent ()
3312 (insert "[" (texinfo-parse-arg-discard))
3313 (goto-char texinfo-command-start
))
3316 ;; @u{o} ==> (o breve accent
3317 (put 'u
'texinfo-format
'texinfo-format-breve-accent
)
3318 (defun texinfo-format-breve-accent ()
3319 (insert "(" (texinfo-parse-arg-discard))
3320 (goto-char texinfo-command-start
))
3322 ;; @v{o} ==> <o hacek accent
3323 (put 'v
'texinfo-format
'texinfo-format-hacek-accent
)
3324 (defun texinfo-format-hacek-accent ()
3325 (insert "<" (texinfo-parse-arg-discard))
3326 (goto-char texinfo-command-start
))
3329 ;; @dotless{i} ==> i dotless i and dotless j
3330 (put 'dotless
'texinfo-format
'texinfo-format-dotless
)
3331 (defun texinfo-format-dotless ()
3332 (insert (texinfo-parse-arg-discard))
3333 (goto-char texinfo-command-start
))
3336 ;;; Definition formatting: @deffn, @defun, etc
3338 ;; What definition formatting produces:
3340 ;; @deffn category name args...
3341 ;; In Info, `Category: name ARGS'
3342 ;; In index: name: node. line#.
3344 ;; @defvr category name
3345 ;; In Info, `Category: name'
3346 ;; In index: name: node. line#.
3348 ;; @deftp category name attributes...
3349 ;; `category name attributes...' Note: @deftp args in lower case.
3350 ;; In index: name: node. line#.
3352 ;; Specialized function-like or variable-like entity:
3354 ;; @defun, @defmac, @defspec, @defvar, @defopt
3356 ;; @defun name args In Info, `Function: name ARGS'
3357 ;; @defmac name args In Info, `Macro: name ARGS'
3358 ;; @defvar name In Info, `Variable: name'
3360 ;; In index: name: node. line#.
3362 ;; Generalized typed-function-like or typed-variable-like entity:
3363 ;; @deftypefn category data-type name args...
3364 ;; In Info, `Category: data-type name args...'
3365 ;; @deftypevr category data-type name
3366 ;; In Info, `Category: data-type name'
3367 ;; In index: name: node. line#.
3369 ;; Specialized typed-function-like or typed-variable-like entity:
3370 ;; @deftypefun data-type name args...
3371 ;; In Info, `Function: data-type name ARGS'
3372 ;; In index: name: node. line#.
3374 ;; @deftypevar data-type name
3375 ;; In Info, `Variable: data-type name'
3376 ;; In index: name: node. line#. but include args after name!?
3378 ;; Generalized object oriented entity:
3379 ;; @defop category class name args...
3380 ;; In Info, `Category on class: name ARG'
3381 ;; In index: name on class: node. line#.
3383 ;; @defcv category class name
3384 ;; In Info, `Category of class: name'
3385 ;; In index: name of class: node. line#.
3387 ;; Specialized object oriented entity:
3388 ;; @defmethod class name args...
3389 ;; In Info, `Method on class: name ARGS'
3390 ;; In index: name on class: node. line#.
3392 ;; @defivar class name
3393 ;; In Info, `Instance variable of class: name'
3394 ;; In index: name of class: node. line#.
3397 ;;; The definition formatting functions
3399 (defun texinfo-format-defun ()
3400 (texinfo-push-stack 'defun
nil)
3401 (setq fill-column
(- fill-column
5))
3402 (texinfo-format-defun-1 t
))
3404 (defun texinfo-end-defun ()
3405 (setq fill-column
(+ fill-column
5))
3406 (texinfo-discard-command)
3407 (let ((start (nth 1 (texinfo-pop-stack 'defun
))))
3408 (texinfo-do-itemize start
)
3409 ;; Delete extra newline inserted after header.
3414 (defun texinfo-format-defunx ()
3415 (texinfo-format-defun-1 nil
))
3417 (defun texinfo-format-defun-1 (first-p)
3418 (let ((parse-args (texinfo-format-parse-defun-args))
3419 (texinfo-defun-type (get texinfo-command-name
'texinfo-defun-type
)))
3420 (texinfo-discard-command)
3421 ;; Delete extra newline inserted after previous header line.
3425 (get texinfo-command-name
'texinfo-deffn-formatting-property
) parse-args
)
3426 ;; Insert extra newline so that paragraph filling does not mess
3427 ;; with header line.
3429 (rplaca (cdr (cdr (car texinfo-stack
))) (point))
3431 (get texinfo-command-name
'texinfo-defun-indexing-property
) parse-args
)))
3433 ;;; Formatting the first line of a definition
3435 ;; @deffn, @defvr, @deftp
3436 (put 'deffn
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3437 (put 'deffnx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3438 (put 'defvr
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3439 (put 'defvrx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3440 (put 'deftp
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3441 (put 'deftpx
'texinfo-deffn-formatting-property
'texinfo-format-deffn
)
3442 (defun texinfo-format-deffn (parsed-args)
3443 ;; Generalized function-like, variable-like, or generic data-type entity:
3444 ;; @deffn category name args...
3445 ;; In Info, `Category: name ARGS'
3446 ;; @deftp category name attributes...
3447 ;; `category name attributes...' Note: @deftp args in lower case.
3448 (let ((category (car parsed-args
))
3449 (name (car (cdr parsed-args
)))
3450 (args (cdr (cdr parsed-args
))))
3451 (insert " -- " category
": " name
)
3454 (if (or (= ?
& (aref (car args
) 0))
3455 (eq (eval (car texinfo-defun-type
)) 'deftp-type
))
3457 (upcase (car args
))))
3458 (setq args
(cdr args
)))))
3460 ;; @defun, @defmac, @defspec, @defvar, @defopt: Specialized, simple
3461 (put 'defun
'texinfo-deffn-formatting-property
3462 'texinfo-format-specialized-defun
)
3463 (put 'defunx
'texinfo-deffn-formatting-property
3464 'texinfo-format-specialized-defun
)
3465 (put 'defmac
'texinfo-deffn-formatting-property
3466 'texinfo-format-specialized-defun
)
3467 (put 'defmacx
'texinfo-deffn-formatting-property
3468 'texinfo-format-specialized-defun
)
3469 (put 'defspec
'texinfo-deffn-formatting-property
3470 'texinfo-format-specialized-defun
)
3471 (put 'defspecx
'texinfo-deffn-formatting-property
3472 'texinfo-format-specialized-defun
)
3473 (put 'defvar
'texinfo-deffn-formatting-property
3474 'texinfo-format-specialized-defun
)
3475 (put 'defvarx
'texinfo-deffn-formatting-property
3476 'texinfo-format-specialized-defun
)
3477 (put 'defopt
'texinfo-deffn-formatting-property
3478 'texinfo-format-specialized-defun
)
3479 (put 'defoptx
'texinfo-deffn-formatting-property
3480 'texinfo-format-specialized-defun
)
3481 (defun texinfo-format-specialized-defun (parsed-args)
3482 ;; Specialized function-like or variable-like entity:
3483 ;; @defun name args In Info, `Function: Name ARGS'
3484 ;; @defmac name args In Info, `Macro: Name ARGS'
3485 ;; @defvar name In Info, `Variable: Name'
3486 ;; Use cdr of texinfo-defun-type to determine category:
3487 (let ((category (car (cdr texinfo-defun-type
)))
3488 (name (car parsed-args
))
3489 (args (cdr parsed-args
)))
3490 (insert " -- " category
": " name
)
3493 (if (= ?
& (aref (car args
) 0))
3495 (upcase (car args
))))
3496 (setq args
(cdr args
)))))
3498 ;; @deftypefn, @deftypevr: Generalized typed
3499 (put 'deftypefn
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3500 (put 'deftypefnx
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3501 (put 'deftypevr
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3502 (put 'deftypevrx
'texinfo-deffn-formatting-property
'texinfo-format-deftypefn
)
3503 (defun texinfo-format-deftypefn (parsed-args)
3504 ;; Generalized typed-function-like or typed-variable-like entity:
3505 ;; @deftypefn category data-type name args...
3506 ;; In Info, `Category: data-type name args...'
3507 ;; @deftypevr category data-type name
3508 ;; In Info, `Category: data-type name'
3509 ;; Note: args in lower case, unless modified in command line.
3510 (let ((category (car parsed-args
))
3511 (data-type (car (cdr parsed-args
)))
3512 (name (car (cdr (cdr parsed-args
))))
3513 (args (cdr (cdr (cdr parsed-args
)))))
3514 (insert " -- " category
": " data-type
" " name
)
3516 (insert " " (car args
))
3517 (setq args
(cdr args
)))))
3519 ;; @deftypefun, @deftypevar: Specialized typed
3520 (put 'deftypefun
'texinfo-deffn-formatting-property
'texinfo-format-deftypefun
)
3521 (put 'deftypefunx
'texinfo-deffn-formatting-property
3522 'texinfo-format-deftypefun
)
3523 (put 'deftypevar
'texinfo-deffn-formatting-property
'texinfo-format-deftypefun
)
3524 (put 'deftypevarx
'texinfo-deffn-formatting-property
3525 'texinfo-format-deftypefun
)
3526 (defun texinfo-format-deftypefun (parsed-args)
3527 ;; Specialized typed-function-like or typed-variable-like entity:
3528 ;; @deftypefun data-type name args...
3529 ;; In Info, `Function: data-type name ARGS'
3530 ;; @deftypevar data-type name
3531 ;; In Info, `Variable: data-type name'
3532 ;; Note: args in lower case, unless modified in command line.
3533 ;; Use cdr of texinfo-defun-type to determine category:
3534 (let ((category (car (cdr texinfo-defun-type
)))
3535 (data-type (car parsed-args
))
3536 (name (car (cdr parsed-args
)))
3537 (args (cdr (cdr parsed-args
))))
3538 (insert " -- " category
": " data-type
" " name
)
3540 (insert " " (car args
))
3541 (setq args
(cdr args
)))))
3543 ;; @defop: Generalized object-oriented
3544 (put 'defop
'texinfo-deffn-formatting-property
'texinfo-format-defop
)
3545 (put 'defopx
'texinfo-deffn-formatting-property
'texinfo-format-defop
)
3546 (defun texinfo-format-defop (parsed-args)
3547 ;; Generalized object oriented entity:
3548 ;; @defop category class name args...
3549 ;; In Info, `Category on class: name ARG'
3550 ;; Note: args in upper case; use of `on'
3551 (let ((category (car parsed-args
))
3552 (class (car (cdr parsed-args
)))
3553 (name (car (cdr (cdr parsed-args
))))
3554 (args (cdr (cdr (cdr parsed-args
)))))
3555 (insert " -- " category
" on " class
": " name
)
3557 (insert " " (upcase (car args
)))
3558 (setq args
(cdr args
)))))
3560 ;; @defcv: Generalized object-oriented
3561 (put 'defcv
'texinfo-deffn-formatting-property
'texinfo-format-defcv
)
3562 (put 'defcvx
'texinfo-deffn-formatting-property
'texinfo-format-defcv
)
3563 (defun texinfo-format-defcv (parsed-args)
3564 ;; Generalized object oriented entity:
3565 ;; @defcv category class name
3566 ;; In Info, `Category of class: name'
3567 ;; Note: args in upper case; use of `of'
3568 (let ((category (car parsed-args
))
3569 (class (car (cdr parsed-args
)))
3570 (name (car (cdr (cdr parsed-args
))))
3571 (args (cdr (cdr (cdr parsed-args
)))))
3572 (insert " -- " category
" of " class
": " name
)
3574 (insert " " (upcase (car args
)))
3575 (setq args
(cdr args
)))))
3577 ;; @defmethod: Specialized object-oriented
3578 (put 'defmethod
'texinfo-deffn-formatting-property
'texinfo-format-defmethod
)
3579 (put 'defmethodx
'texinfo-deffn-formatting-property
'texinfo-format-defmethod
)
3580 (defun texinfo-format-defmethod (parsed-args)
3581 ;; Specialized object oriented entity:
3582 ;; @defmethod class name args...
3583 ;; In Info, `Method on class: name ARGS'
3584 ;; Note: args in upper case; use of `on'
3585 ;; Use cdr of texinfo-defun-type to determine category:
3586 (let ((category (car (cdr texinfo-defun-type
)))
3587 (class (car parsed-args
))
3588 (name (car (cdr parsed-args
)))
3589 (args (cdr (cdr parsed-args
))))
3590 (insert " -- " category
" on " class
": " name
)
3592 (insert " " (upcase (car args
)))
3593 (setq args
(cdr args
)))))
3595 ;; @defivar: Specialized object-oriented
3596 (put 'defivar
'texinfo-deffn-formatting-property
'texinfo-format-defivar
)
3597 (put 'defivarx
'texinfo-deffn-formatting-property
'texinfo-format-defivar
)
3598 (defun texinfo-format-defivar (parsed-args)
3599 ;; Specialized object oriented entity:
3600 ;; @defivar class name
3601 ;; In Info, `Instance variable of class: name'
3602 ;; Note: args in upper case; use of `of'
3603 ;; Use cdr of texinfo-defun-type to determine category:
3604 (let ((category (car (cdr texinfo-defun-type
)))
3605 (class (car parsed-args
))
3606 (name (car (cdr parsed-args
)))
3607 (args (cdr (cdr parsed-args
))))
3608 (insert " -- " category
" of " class
": " name
)
3610 (insert " " (upcase (car args
)))
3611 (setq args
(cdr args
)))))
3614 ;;; Indexing for definitions
3616 ;; An index entry has three parts: the `entry proper', the node name, and the
3617 ;; line number. Depending on the which command is used, the entry is
3618 ;; formatted differently:
3624 ;; @defopt all use their 1st argument as the entry-proper
3630 ;; @deftypevar all use their 2nd argument as the entry-proper
3633 ;; @deftypevr both use their 3rd argument as the entry-proper
3635 ;; @defmethod uses its 2nd and 1st arguments as an entry-proper
3636 ;; formatted: NAME on CLASS
3638 ;; @defop uses its 3rd and 2nd arguments as an entry-proper
3639 ;; formatted: NAME on CLASS
3641 ;; @defivar uses its 2nd and 1st arguments as an entry-proper
3642 ;; formatted: NAME of CLASS
3644 ;; @defcv uses its 3rd and 2nd argument as an entry-proper
3645 ;; formatted: NAME of CLASS
3647 (put 'defun
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3648 (put 'defunx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3649 (put 'defmac
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3650 (put 'defmacx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3651 (put 'defspec
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3652 (put 'defspecx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3653 (put 'defvar
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3654 (put 'defvarx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3655 (put 'defopt
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3656 (put 'defoptx
'texinfo-defun-indexing-property
'texinfo-index-defun
)
3657 (defun texinfo-index-defun (parsed-args)
3658 ;; use 1st parsed-arg as entry-proper
3659 ;; `index-list' will be texinfo-findex or the like
3660 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3663 ;; Three elements: entry-proper, node-name, line-number
3667 ;; Region formatting may not provide last node position.
3668 (if texinfo-last-node-pos
3669 (1+ (count-lines texinfo-last-node-pos
(point)))
3671 (symbol-value index-list
)))))
3673 (put 'deffn
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3674 (put 'deffnx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3675 (put 'defvr
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3676 (put 'defvrx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3677 (put 'deftp
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3678 (put 'deftpx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3679 (put 'deftypefun
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3680 (put 'deftypefunx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3681 (put 'deftypevar
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3682 (put 'deftypevarx
'texinfo-defun-indexing-property
'texinfo-index-deffn
)
3683 (defun texinfo-index-deffn (parsed-args)
3684 ;; use 2nd parsed-arg as entry-proper
3685 ;; `index-list' will be texinfo-findex or the like
3686 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3689 ;; Three elements: entry-proper, node-name, line-number
3691 (car (cdr parsed-args
))
3693 ;; Region formatting may not provide last node position.
3694 (if texinfo-last-node-pos
3695 (1+ (count-lines texinfo-last-node-pos
(point)))
3697 (symbol-value index-list
)))))
3699 (put 'deftypefn
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3700 (put 'deftypefnx
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3701 (put 'deftypevr
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3702 (put 'deftypevrx
'texinfo-defun-indexing-property
'texinfo-index-deftypefn
)
3703 (defun texinfo-index-deftypefn (parsed-args)
3704 ;; use 3rd parsed-arg as entry-proper
3705 ;; `index-list' will be texinfo-findex or the like
3706 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3709 ;; Three elements: entry-proper, node-name, line-number
3711 (car (cdr (cdr parsed-args
)))
3713 ;; Region formatting may not provide last node position.
3714 (if texinfo-last-node-pos
3715 (1+ (count-lines texinfo-last-node-pos
(point)))
3717 (symbol-value index-list
)))))
3719 (put 'defmethod
'texinfo-defun-indexing-property
'texinfo-index-defmethod
)
3720 (put 'defmethodx
'texinfo-defun-indexing-property
'texinfo-index-defmethod
)
3721 (defun texinfo-index-defmethod (parsed-args)
3722 ;; use 2nd on 1st parsed-arg as entry-proper
3723 ;; `index-list' will be texinfo-findex or the like
3724 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3727 ;; Three elements: entry-proper, node-name, line-number
3730 (car (cdr parsed-args
))
3733 ;; Region formatting may not provide last node position.
3734 (if texinfo-last-node-pos
3735 (1+ (count-lines texinfo-last-node-pos
(point)))
3737 (symbol-value index-list
)))))
3739 (put 'defop
'texinfo-defun-indexing-property
'texinfo-index-defop
)
3740 (put 'defopx
'texinfo-defun-indexing-property
'texinfo-index-defop
)
3741 (defun texinfo-index-defop (parsed-args)
3742 ;; use 3rd on 2nd parsed-arg as entry-proper
3743 ;; `index-list' will be texinfo-findex or the like
3744 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3747 ;; Three elements: entry-proper, node-name, line-number
3750 (car (cdr (cdr parsed-args
)))
3751 (car (cdr parsed-args
)))
3753 ;; Region formatting may not provide last node position.
3754 (if texinfo-last-node-pos
3755 (1+ (count-lines texinfo-last-node-pos
(point)))
3757 (symbol-value index-list
)))))
3759 (put 'defivar
'texinfo-defun-indexing-property
'texinfo-index-defivar
)
3760 (put 'defivarx
'texinfo-defun-indexing-property
'texinfo-index-defivar
)
3761 (defun texinfo-index-defivar (parsed-args)
3762 ;; use 2nd of 1st parsed-arg as entry-proper
3763 ;; `index-list' will be texinfo-findex or the like
3764 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3767 ;; Three elements: entry-proper, node-name, line-number
3770 (car (cdr parsed-args
))
3773 ;; Region formatting may not provide last node position.
3774 (if texinfo-last-node-pos
3775 (1+ (count-lines texinfo-last-node-pos
(point)))
3777 (symbol-value index-list
)))))
3779 (put 'defcv
'texinfo-defun-indexing-property
'texinfo-index-defcv
)
3780 (put 'defcvx
'texinfo-defun-indexing-property
'texinfo-index-defcv
)
3781 (defun texinfo-index-defcv (parsed-args)
3782 ;; use 3rd of 2nd parsed-arg as entry-proper
3783 ;; `index-list' will be texinfo-findex or the like
3784 (let ((index-list (get texinfo-command-name
'texinfo-defun-index
)))
3787 ;; Three elements: entry-proper, node-name, line-number
3790 (car (cdr (cdr parsed-args
)))
3791 (car (cdr parsed-args
)))
3793 ;; Region formatting may not provide last node position.
3794 (if texinfo-last-node-pos
3795 (1+ (count-lines texinfo-last-node-pos
(point)))
3797 (symbol-value index-list
)))))
3800 ;;; Properties for definitions
3802 ;; Each definition command has six properties:
3804 ;; 1. texinfo-deffn-formatting-property to format definition line
3805 ;; 2. texinfo-defun-indexing-property to create index entry
3806 ;; 3. texinfo-format formatting command
3807 ;; 4. texinfo-end end formatting command
3808 ;; 5. texinfo-defun-type type of deffn to format
3809 ;; 6. texinfo-defun-index type of index to use
3811 ;; The `x' forms of each definition command are used for the second
3812 ;; and subsequent header lines.
3814 ;; The texinfo-deffn-formatting-property and texinfo-defun-indexing-property
3815 ;; are listed just before the appropriate formatting and indexing commands.
3817 (put 'deffn
'texinfo-format
'texinfo-format-defun
)
3818 (put 'deffnx
'texinfo-format
'texinfo-format-defunx
)
3819 (put 'deffn
'texinfo-end
'texinfo-end-defun
)
3820 (put 'deffn
'texinfo-defun-type
'('deffn-type nil
))
3821 (put 'deffnx
'texinfo-defun-type
'('deffn-type nil
))
3822 (put 'deffn
'texinfo-defun-index
'texinfo-findex
)
3823 (put 'deffnx
'texinfo-defun-index
'texinfo-findex
)
3825 (put 'defun
'texinfo-format
'texinfo-format-defun
)
3826 (put 'defunx
'texinfo-format
'texinfo-format-defunx
)
3827 (put 'defun
'texinfo-end
'texinfo-end-defun
)
3828 (put 'defun
'texinfo-defun-type
'('defun-type
"Function"))
3829 (put 'defunx
'texinfo-defun-type
'('defun-type
"Function"))
3830 (put 'defun
'texinfo-defun-index
'texinfo-findex
)
3831 (put 'defunx
'texinfo-defun-index
'texinfo-findex
)
3833 (put 'defmac
'texinfo-format
'texinfo-format-defun
)
3834 (put 'defmacx
'texinfo-format
'texinfo-format-defunx
)
3835 (put 'defmac
'texinfo-end
'texinfo-end-defun
)
3836 (put 'defmac
'texinfo-defun-type
'('defun-type
"Macro"))
3837 (put 'defmacx
'texinfo-defun-type
'('defun-type
"Macro"))
3838 (put 'defmac
'texinfo-defun-index
'texinfo-findex
)
3839 (put 'defmacx
'texinfo-defun-index
'texinfo-findex
)
3841 (put 'defspec
'texinfo-format
'texinfo-format-defun
)
3842 (put 'defspecx
'texinfo-format
'texinfo-format-defunx
)
3843 (put 'defspec
'texinfo-end
'texinfo-end-defun
)
3844 (put 'defspec
'texinfo-defun-type
'('defun-type
"Special form"))
3845 (put 'defspecx
'texinfo-defun-type
'('defun-type
"Special form"))
3846 (put 'defspec
'texinfo-defun-index
'texinfo-findex
)
3847 (put 'defspecx
'texinfo-defun-index
'texinfo-findex
)
3849 (put 'defvr
'texinfo-format
'texinfo-format-defun
)
3850 (put 'defvrx
'texinfo-format
'texinfo-format-defunx
)
3851 (put 'defvr
'texinfo-end
'texinfo-end-defun
)
3852 (put 'defvr
'texinfo-defun-type
'('deffn-type nil
))
3853 (put 'defvrx
'texinfo-defun-type
'('deffn-type nil
))
3854 (put 'defvr
'texinfo-defun-index
'texinfo-vindex
)
3855 (put 'defvrx
'texinfo-defun-index
'texinfo-vindex
)
3857 (put 'defvar
'texinfo-format
'texinfo-format-defun
)
3858 (put 'defvarx
'texinfo-format
'texinfo-format-defunx
)
3859 (put 'defvar
'texinfo-end
'texinfo-end-defun
)
3860 (put 'defvar
'texinfo-defun-type
'('defun-type
"Variable"))
3861 (put 'defvarx
'texinfo-defun-type
'('defun-type
"Variable"))
3862 (put 'defvar
'texinfo-defun-index
'texinfo-vindex
)
3863 (put 'defvarx
'texinfo-defun-index
'texinfo-vindex
)
3865 (put 'defconst
'texinfo-format
'texinfo-format-defun
)
3866 (put 'defconstx
'texinfo-format
'texinfo-format-defunx
)
3867 (put 'defconst
'texinfo-end
'texinfo-end-defun
)
3868 (put 'defconst
'texinfo-defun-type
'('defun-type
"Constant"))
3869 (put 'defconstx
'texinfo-defun-type
'('defun-type
"Constant"))
3870 (put 'defconst
'texinfo-defun-index
'texinfo-vindex
)
3871 (put 'defconstx
'texinfo-defun-index
'texinfo-vindex
)
3873 (put 'defcmd
'texinfo-format
'texinfo-format-defun
)
3874 (put 'defcmdx
'texinfo-format
'texinfo-format-defunx
)
3875 (put 'defcmd
'texinfo-end
'texinfo-end-defun
)
3876 (put 'defcmd
'texinfo-defun-type
'('defun-type
"Command"))
3877 (put 'defcmdx
'texinfo-defun-type
'('defun-type
"Command"))
3878 (put 'defcmd
'texinfo-defun-index
'texinfo-findex
)
3879 (put 'defcmdx
'texinfo-defun-index
'texinfo-findex
)
3881 (put 'defopt
'texinfo-format
'texinfo-format-defun
)
3882 (put 'defoptx
'texinfo-format
'texinfo-format-defunx
)
3883 (put 'defopt
'texinfo-end
'texinfo-end-defun
)
3884 (put 'defopt
'texinfo-defun-type
'('defun-type
"User Option"))
3885 (put 'defoptx
'texinfo-defun-type
'('defun-type
"User Option"))
3886 (put 'defopt
'texinfo-defun-index
'texinfo-vindex
)
3887 (put 'defoptx
'texinfo-defun-index
'texinfo-vindex
)
3889 (put 'deftp
'texinfo-format
'texinfo-format-defun
)
3890 (put 'deftpx
'texinfo-format
'texinfo-format-defunx
)
3891 (put 'deftp
'texinfo-end
'texinfo-end-defun
)
3892 (put 'deftp
'texinfo-defun-type
'('deftp-type nil
))
3893 (put 'deftpx
'texinfo-defun-type
'('deftp-type nil
))
3894 (put 'deftp
'texinfo-defun-index
'texinfo-tindex
)
3895 (put 'deftpx
'texinfo-defun-index
'texinfo-tindex
)
3897 ;;; Object-oriented stuff is a little hairier.
3899 (put 'defop
'texinfo-format
'texinfo-format-defun
)
3900 (put 'defopx
'texinfo-format
'texinfo-format-defunx
)
3901 (put 'defop
'texinfo-end
'texinfo-end-defun
)
3902 (put 'defop
'texinfo-defun-type
'('defop-type nil
))
3903 (put 'defopx
'texinfo-defun-type
'('defop-type nil
))
3904 (put 'defop
'texinfo-defun-index
'texinfo-findex
)
3905 (put 'defopx
'texinfo-defun-index
'texinfo-findex
)
3907 (put 'defmethod
'texinfo-format
'texinfo-format-defun
)
3908 (put 'defmethodx
'texinfo-format
'texinfo-format-defunx
)
3909 (put 'defmethod
'texinfo-end
'texinfo-end-defun
)
3910 (put 'defmethod
'texinfo-defun-type
'('defmethod-type
"Method"))
3911 (put 'defmethodx
'texinfo-defun-type
'('defmethod-type
"Method"))
3912 (put 'defmethod
'texinfo-defun-index
'texinfo-findex
)
3913 (put 'defmethodx
'texinfo-defun-index
'texinfo-findex
)
3915 (put 'defcv
'texinfo-format
'texinfo-format-defun
)
3916 (put 'defcvx
'texinfo-format
'texinfo-format-defunx
)
3917 (put 'defcv
'texinfo-end
'texinfo-end-defun
)
3918 (put 'defcv
'texinfo-defun-type
'('defop-type nil
))
3919 (put 'defcvx
'texinfo-defun-type
'('defop-type nil
))
3920 (put 'defcv
'texinfo-defun-index
'texinfo-vindex
)
3921 (put 'defcvx
'texinfo-defun-index
'texinfo-vindex
)
3923 (put 'defivar
'texinfo-format
'texinfo-format-defun
)
3924 (put 'defivarx
'texinfo-format
'texinfo-format-defunx
)
3925 (put 'defivar
'texinfo-end
'texinfo-end-defun
)
3926 (put 'defivar
'texinfo-defun-type
'('defmethod-type
"Instance variable"))
3927 (put 'defivarx
'texinfo-defun-type
'('defmethod-type
"Instance variable"))
3928 (put 'defivar
'texinfo-defun-index
'texinfo-vindex
)
3929 (put 'defivarx
'texinfo-defun-index
'texinfo-vindex
)
3931 ;;; Typed functions and variables
3933 (put 'deftypefn
'texinfo-format
'texinfo-format-defun
)
3934 (put 'deftypefnx
'texinfo-format
'texinfo-format-defunx
)
3935 (put 'deftypefn
'texinfo-end
'texinfo-end-defun
)
3936 (put 'deftypefn
'texinfo-defun-type
'('deftypefn-type nil
))
3937 (put 'deftypefnx
'texinfo-defun-type
'('deftypefn-type nil
))
3938 (put 'deftypefn
'texinfo-defun-index
'texinfo-findex
)
3939 (put 'deftypefnx
'texinfo-defun-index
'texinfo-findex
)
3941 (put 'deftypefun
'texinfo-format
'texinfo-format-defun
)
3942 (put 'deftypefunx
'texinfo-format
'texinfo-format-defunx
)
3943 (put 'deftypefun
'texinfo-end
'texinfo-end-defun
)
3944 (put 'deftypefun
'texinfo-defun-type
'('deftypefun-type
"Function"))
3945 (put 'deftypefunx
'texinfo-defun-type
'('deftypefun-type
"Function"))
3946 (put 'deftypefun
'texinfo-defun-index
'texinfo-findex
)
3947 (put 'deftypefunx
'texinfo-defun-index
'texinfo-findex
)
3949 (put 'deftypevr
'texinfo-format
'texinfo-format-defun
)
3950 (put 'deftypevrx
'texinfo-format
'texinfo-format-defunx
)
3951 (put 'deftypevr
'texinfo-end
'texinfo-end-defun
)
3952 (put 'deftypevr
'texinfo-defun-type
'('deftypefn-type nil
))
3953 (put 'deftypevrx
'texinfo-defun-type
'('deftypefn-type nil
))
3954 (put 'deftypevr
'texinfo-defun-index
'texinfo-vindex
)
3955 (put 'deftypevrx
'texinfo-defun-index
'texinfo-vindex
)
3957 (put 'deftypevar
'texinfo-format
'texinfo-format-defun
)
3958 (put 'deftypevarx
'texinfo-format
'texinfo-format-defunx
)
3959 (put 'deftypevar
'texinfo-end
'texinfo-end-defun
)
3960 (put 'deftypevar
'texinfo-defun-type
'('deftypevar-type
"Variable"))
3961 (put 'deftypevarx
'texinfo-defun-type
'('deftypevar-type
"Variable"))
3962 (put 'deftypevar
'texinfo-defun-index
'texinfo-vindex
)
3963 (put 'deftypevarx
'texinfo-defun-index
'texinfo-vindex
)
3966 ;;; @set, @clear, @ifset, @ifclear
3968 ;; If a flag is set with @set FLAG, then text between @ifset and @end
3969 ;; ifset is formatted normally, but if the flag is is cleared with
3970 ;; @clear FLAG, then the text is not formatted; it is ignored.
3972 ;; If a flag is cleared with @clear FLAG, then text between @ifclear
3973 ;; and @end ifclear is formatted normally, but if the flag is is set with
3974 ;; @set FLAG, then the text is not formatted; it is ignored. @ifclear
3975 ;; is the opposite of @ifset.
3977 ;; If a flag is set to a string with @set FLAG,
3978 ;; replace @value{FLAG} with the string.
3979 ;; If a flag with a value is cleared,
3980 ;; @value{FLAG} is invalid,
3981 ;; as if there had never been any @set FLAG previously.
3983 (put 'clear
'texinfo-format
'texinfo-clear
)
3984 (defun texinfo-clear ()
3985 "Clear the value of the flag."
3986 (let* ((arg (texinfo-parse-arg-discard))
3987 (flag (car (read-from-string arg
)))
3988 (value (substring arg
(cdr (read-from-string arg
)))))
3989 (put flag
'texinfo-whether-setp
'flag-cleared
)
3990 (put flag
'texinfo-set-value
"")))
3992 (put 'set
'texinfo-format
'texinfo-set
)
3993 (defun texinfo-set ()
3994 "Set the value of the flag, optionally to a string.
3995 The command `@set foo This is a string.'
3996 sets flag foo to the value: `This is a string.'
3997 The command `@value{foo}' expands to the value."
3998 (let* ((arg (texinfo-parse-arg-discard))
3999 (flag (car (read-from-string arg
)))
4000 (value (substring arg
(cdr (read-from-string arg
)))))
4001 (if (string-match "^[ \t]+" value
)
4002 (setq value
(substring value
(match-end 0))))
4003 (put flag
'texinfo-whether-setp
'flag-set
)
4004 (put flag
'texinfo-set-value value
)))
4006 (put 'value
'texinfo-format
'texinfo-value
)
4007 (defun texinfo-value ()
4008 "Insert the string to which the flag is set.
4009 The command `@set foo This is a string.'
4010 sets flag foo to the value: `This is a string.'
4011 The command `@value{foo}' expands to the value."
4012 (let ((arg (texinfo-parse-arg-discard)))
4014 (eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4016 (get (car (read-from-string arg
)) 'texinfo-set-value
))
4017 (insert (get (car (read-from-string arg
)) 'texinfo-set-value
)))
4018 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4020 (insert (format "{No value for \"%s\"}" arg
)))
4021 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
) nil
)
4022 (insert (format "{No value for \"%s\"}" arg
))))))
4024 (put 'ifset
'texinfo-end
'texinfo-discard-command
)
4025 (put 'ifset
'texinfo-format
'texinfo-if-set
)
4026 (defun texinfo-if-set ()
4027 "If set, continue formatting; else do not format region up to @end ifset"
4028 (let ((arg (texinfo-parse-arg-discard)))
4030 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4032 ;; Format the text (i.e., do not remove it); do nothing here.
4034 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4036 ;; Clear region (i.e., cause the text to be ignored).
4037 (delete-region texinfo-command-start
4038 (re-search-forward "@end ifset[ \t]*\n")))
4039 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4041 ;; In this case flag is neither set nor cleared.
4042 ;; Act as if set, i.e. do nothing.
4045 (put 'ifclear
'texinfo-end
'texinfo-discard-command
)
4046 (put 'ifclear
'texinfo-format
'texinfo-if-clear
)
4047 (defun texinfo-if-clear ()
4048 "If clear, continue formatting; if set, do not format up to @end ifset"
4049 (let ((arg (texinfo-parse-arg-discard)))
4051 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4053 ;; Clear region (i.e., cause the text to be ignored).
4054 (delete-region texinfo-command-start
4055 (re-search-forward "@end ifclear[ \t]*\n")))
4056 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4058 ;; Format the text (i.e., do not remove it); do nothing here.
4060 ((eq (get (car (read-from-string arg
)) 'texinfo-whether-setp
)
4062 ;; In this case flag is neither set nor cleared.
4063 ;; Act as if clear, i.e. do nothing.
4068 (put 'ifeq
'texinfo-format
'texinfo-format-ifeq
)
4069 (defun texinfo-format-ifeq ()
4070 "If ARG1 and ARG2 caselessly string compare to same string, perform COMMAND.
4071 Otherwise produces no output.
4074 @ifeq{ arg1 , arg1 , @code{foo}} bar
4078 @ifeq{ arg1 , arg2 , @code{foo}} bar
4082 Note that the Texinfo command and its arguments must be arguments to
4084 ;; compare-buffer-substrings does not exist in version 18; don't use
4085 (goto-char texinfo-command-end
)
4086 (let* ((case-fold-search t
)
4087 (stop (save-excursion (forward-sexp 1) (point)))
4089 ;; @ifeq{arg1, arg2, @command{optional-args}}
4093 (skip-chars-forward " ")
4094 (setq start
(point))
4095 (search-forward "," stop t
)
4096 (skip-chars-backward ", ")
4097 (buffer-substring-no-properties start
(point))))
4100 (search-forward "," stop t
)
4101 (skip-chars-forward " ")
4102 (setq start
(point))
4103 (search-forward "," stop t
)
4104 (skip-chars-backward ", ")
4105 (buffer-substring-no-properties start
(point))))
4108 (search-forward "," stop t
)
4109 (skip-chars-forward " ")
4110 (setq start
(point))
4111 (goto-char (1- stop
))
4112 (skip-chars-backward " ")
4113 (buffer-substring-no-properties start
(point)))))
4114 (delete-region texinfo-command-start stop
)
4115 (if (equal arg1 arg2
)
4116 (insert texinfo-command
))
4117 (goto-char texinfo-command-start
)))
4120 ;;; Process included files: `@include' command
4122 ;; Updated 19 October 1990
4123 ;; In the original version, include files were ignored by Info but
4124 ;; incorporated in to the printed manual. To make references to the
4125 ;; included file, the Texinfo source file has to refer to the included
4126 ;; files using the `(filename)nodename' format for referring to other
4127 ;; Info files. Also, the included files had to be formatted on their
4128 ;; own. It was just like they were another file.
4130 ;; Currently, include files are inserted into the buffer that is
4131 ;; formatted for Info. If large, the resulting info file is split and
4132 ;; tagified. For current include files to work, the master menu must
4133 ;; refer to all the nodes, and the highest level nodes in the include
4134 ;; files must have the correct next, prev, and up pointers.
4136 ;; The included file may have an @setfilename and even an @settitle,
4137 ;; but not an `\input texinfo' line.
4139 ;; Updated 24 March 1993
4140 ;; In order for @raisesections and @lowersections to work, included
4141 ;; files must be inserted into the buffer holding the outer file
4142 ;; before other Info formatting takes place. So @include is no longer
4143 ;; is treated like other @-commands.
4144 (put 'include
'texinfo-format
'texinfo-format-noop
)
4146 ;; Original definition:
4147 ;; (defun texinfo-format-include ()
4148 ;; (let ((filename (texinfo-parse-arg-discard))
4149 ;; (default-directory input-directory)
4153 ;; (progn (find-file
4154 ;; (cond ((file-readable-p (concat filename ".texinfo"))
4155 ;; (concat filename ".texinfo"))
4156 ;; ((file-readable-p (concat filename ".texi"))
4157 ;; (concat filename ".texi"))
4158 ;; ((file-readable-p (concat filename ".tex"))
4159 ;; (concat filename ".tex"))
4160 ;; ((file-readable-p filename)
4162 ;; (t (error "@include'd file %s not found"
4164 ;; (texinfo-format-buffer-1))))
4165 ;; (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex))
4166 ;; (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex))
4167 ;; (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex))
4168 ;; (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex))
4169 ;; (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex))
4170 ;; (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex))))
4172 ;;(defun texinfo-subindex (indexvar file content)
4173 ;; (set indexvar (cons (list 'recurse file content)
4174 ;; (symbol-value indexvar))))
4176 ;; Second definition:
4177 ;; (put 'include 'texinfo-format 'texinfo-format-include)
4178 ;; (defun texinfo-format-include ()
4179 ;; (let ((filename (concat input-directory
4180 ;; (texinfo-parse-arg-discard)))
4181 ;; (default-directory input-directory))
4182 ;; (message "Reading: %s" filename)
4184 ;; (save-restriction
4185 ;; (narrow-to-region
4187 ;; (+ (point) (car (cdr (insert-file-contents filename)))))
4188 ;; (goto-char (point-min))
4189 ;; (texinfo-append-refill)
4190 ;; (texinfo-format-convert (point-min) (point-max))))
4191 ;; (setq last-input-buffer input-buffer) ; to bypass setfilename
4195 ;;; Numerous commands do nothing in Info
4196 ;; These commands are defined in texinfo.tex for printed output.
4199 ;;; various noops, such as @b{foo}, that take arguments in braces
4201 (put 'b
'texinfo-format
'texinfo-format-noop
)
4202 (put 'i
'texinfo-format
'texinfo-format-noop
)
4203 (put 'r
'texinfo-format
'texinfo-format-noop
)
4204 (put 't
'texinfo-format
'texinfo-format-noop
)
4205 (put 'w
'texinfo-format
'texinfo-format-noop
)
4206 (put 'asis
'texinfo-format
'texinfo-format-noop
)
4207 (put 'dmn
'texinfo-format
'texinfo-format-noop
)
4208 (put 'math
'texinfo-format
'texinfo-format-noop
)
4209 (put 'titlefont
'texinfo-format
'texinfo-format-noop
)
4210 (defun texinfo-format-noop ()
4211 (insert (texinfo-parse-arg-discard))
4212 (goto-char texinfo-command-start
))
4214 ;; @hyphenation command discards an argument within braces
4215 (put 'hyphenation
'texinfo-format
'texinfo-discard-command-and-arg
)
4216 (defun texinfo-discard-command-and-arg ()
4217 "Discard both @-command and its argument in braces."
4218 (goto-char texinfo-command-end
)
4220 (setq texinfo-command-end
(point))
4221 (delete-region texinfo-command-start texinfo-command-end
))
4224 ;;; Do nothing commands, such as @smallbook, that have no args and no braces
4225 ;; These must appear on a line of their own
4227 (put 'bye
'texinfo-format
'texinfo-discard-line
)
4228 (put 'smallbook
'texinfo-format
'texinfo-discard-line
)
4229 (put 'finalout
'texinfo-format
'texinfo-discard-line
)
4230 (put 'overfullrule
'texinfo-format
'texinfo-discard-line
)
4231 (put 'smallbreak
'texinfo-format
'texinfo-discard-line
)
4232 (put 'medbreak
'texinfo-format
'texinfo-discard-line
)
4233 (put 'bigbreak
'texinfo-format
'texinfo-discard-line
)
4234 (put 'afourpaper
'texinfo-format
'texinfo-discard-line
)
4235 (put 'afivepaper
'texinfo-format
'texinfo-discard-line
)
4236 (put 'afourlatex
'texinfo-format
'texinfo-discard-line
)
4237 (put 'afourwide
'texinfo-format
'texinfo-discard-line
)
4240 ;;; These noop commands discard the rest of the line.
4242 (put 'c
'texinfo-format
'texinfo-discard-line-with-args
)
4243 (put 'comment
'texinfo-format
'texinfo-discard-line-with-args
)
4244 (put 'contents
'texinfo-format
'texinfo-discard-line-with-args
)
4245 (put 'group
'texinfo-end
'texinfo-discard-line-with-args
)
4246 (put 'group
'texinfo-format
'texinfo-discard-line-with-args
)
4247 (put 'headings
'texinfo-format
'texinfo-discard-line-with-args
)
4248 (put 'setchapterstyle
'texinfo-format
'texinfo-discard-line-with-args
)
4249 (put 'hsize
'texinfo-format
'texinfo-discard-line-with-args
)
4250 (put 'itemindent
'texinfo-format
'texinfo-discard-line-with-args
)
4251 (put 'lispnarrowing
'texinfo-format
'texinfo-discard-line-with-args
)
4252 (put 'need
'texinfo-format
'texinfo-discard-line-with-args
)
4253 (put 'nopara
'texinfo-format
'texinfo-discard-line-with-args
)
4255 ;; @novalidate suppresses cross-reference checking and auxiliary file
4256 ;; creation with TeX. The Info-validate command checks that every
4257 ;; node pointer points to an existing node. Since this Info command
4258 ;; is not invoked automatically, the @novalidate command is irrelevant
4259 ;; and not supported by texinfmt.el
4260 (put 'novalidate
'texinfo-format
'texinfo-discard-line-with-args
)
4262 (put 'page
'texinfo-format
'texinfo-discard-line-with-args
)
4263 (put 'pagesizes
'texinfo-format
'texinfo-discard-line-with-args
)
4264 (put 'parindent
'texinfo-format
'texinfo-discard-line-with-args
)
4265 (put 'setchapternewpage
'texinfo-format
'texinfo-discard-line-with-args
)
4266 (put 'setq
'texinfo-format
'texinfo-discard-line-with-args
)
4268 (put 'setcontentsaftertitlepage
4269 'texinfo-format
'texinfo-discard-line-with-args
)
4270 (put 'setshortcontentsaftertitlepage
4271 'texinfo-format
'texinfo-discard-line-with-args
)
4273 (put 'settitle
'texinfo-format
'texinfo-discard-line-with-args
)
4274 (put 'setx
'texinfo-format
'texinfo-discard-line-with-args
)
4275 (put 'shortcontents
'texinfo-format
'texinfo-discard-line-with-args
)
4276 (put 'shorttitlepage
'texinfo-format
'texinfo-discard-line-with-args
)
4277 (put 'summarycontents
'texinfo-format
'texinfo-discard-line-with-args
)
4278 (put 'input
'texinfo-format
'texinfo-discard-line-with-args
)
4280 (put 'documentlanguage
'texinfo-format
'texinfo-discard-line-with-args
)
4281 (put 'documentencoding
'texinfo-format
'texinfo-discard-line-with-args
)
4285 ;;; Some commands cannot be handled
4287 (defun texinfo-unsupported ()
4288 (error "%s is not handled by texinfo"
4289 (buffer-substring-no-properties texinfo-command-start texinfo-command-end
)))
4291 ;;; Batch formatting
4293 (defun batch-texinfo-format ()
4294 "Runs texinfo-format-buffer on the files remaining on the command line.
4295 Must be used only with -batch, and kills Emacs on completion.
4296 Each file will be processed even if an error occurred previously.
4298 \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"."
4299 (if (not noninteractive
)
4300 (error "batch-texinfo-format may only be used -batch"))
4301 (let ((version-control t
)
4302 (auto-save-default nil
)
4303 (find-file-run-dired nil
)
4304 (kept-old-versions 259259)
4305 (kept-new-versions 259259))
4309 (while command-line-args-left
4310 (setq file
(expand-file-name (car command-line-args-left
)))
4311 (cond ((not (file-exists-p file
))
4312 (message ">> %s does not exist!" file
)
4314 command-line-args-left
(cdr command-line-args-left
)))
4315 ((file-directory-p file
)
4316 (setq command-line-args-left
4317 (nconc (directory-files file
)
4318 (cdr command-line-args-left
))))
4320 (setq files
(cons file files
)
4321 command-line-args-left
(cdr command-line-args-left
)))))
4323 (setq file
(car files
)
4327 (if buffer-file-name
(kill-buffer (current-buffer)))
4329 (buffer-disable-undo (current-buffer))
4330 (set-buffer-modified-p nil
)
4332 (message "texinfo formatting %s..." file
)
4333 (texinfo-format-buffer nil
)
4334 (if (buffer-modified-p)
4335 (progn (message "Saving modified %s" (buffer-file-name))
4338 (message ">> Error: %s" (prin1-to-string err
))
4339 (message ">> point at")
4340 (let ((s (buffer-substring-no-properties (point)
4341 (min (+ (point) 100)
4344 (while (setq tem
(string-match "\n+" s tem
))
4345 (setq s
(concat (substring s
0 (match-beginning 0))
4347 (substring s
(match-end 0)))
4349 (message ">> %s" s
))
4351 (kill-emacs error
))))
4354 ;;; Place `provide' at end of file.
4357 ;;; arch-tag: 1e8d9a2d-bca0-40a0-ac6c-dab01bc6f725
4358 ;;; texinfmt.el ends here