(access_keymap): Return the cdr of the binding of
[emacs.git] / lisp / textmodes / texinfmt.el
blob01f49921b4ce05bedf872b535984fc7c73749b46
1 ;;; texinfmt.el --- format Texinfo files into Info files
3 ;; Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993,
4 ;; 1994, 1995, 1996, 1997, 1998, 2000, 2001
5 ;; Free Software Foundation, Inc.
7 ;; Maintainer: Robert J. Chassell <bug-texinfo@gnu.org>
8 ;; Keywords: maint, tex, docs
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
27 ;;; Commentary:
29 ;;; Code:
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.38 of 3 July 1998")
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."
45 (interactive "P")
46 (let ((version-string
47 (format "Version of \`texinfmt.el\': %s" texinfmt-version)))
48 (if here
49 (insert version-string)
50 (if (interactive-p)
51 (message "%s" version-string)
52 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)
89 ;;; Syntax table
91 (if texinfo-format-syntax-table
92 nil
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
109 ;;;###autoload
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."
118 (interactive "P")
119 (let ((lastmessage "Formatting Info file...")
120 (coding-system-for-write buffer-file-coding-system))
121 (message lastmessage)
122 (widen)
123 (texinfo-format-buffer-1)
124 (Info-tagify)
125 (if nosplit
127 (if (> (buffer-size) 100000)
128 (progn
129 (message (setq lastmessage "Splitting Info file..."))
130 (Info-split))))
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 ;;;###autoload
138 (defun texinfo-format-region (region-beginning region-end)
139 "Convert the current region of the Texinfo file to Info format.
140 This lets you see what that part of the file will look like in Info.
141 The command is bound to \\[texinfo-format-region]. The text that is
142 converted to Info is stored in a temporary buffer."
143 (interactive "r")
144 (message "Converting region to Info format...")
145 (let (texinfo-command-start
146 texinfo-command-end
147 texinfo-command-name
148 texinfo-vindex
149 texinfo-findex
150 texinfo-cindex
151 texinfo-pindex
152 texinfo-tindex
153 texinfo-kindex
154 texinfo-stack
155 (texinfo-format-filename "")
156 texinfo-example-start
157 texinfo-last-node-pos
158 texinfo-last-node
159 texinfo-node-names
160 (texinfo-footnote-number 0)
161 last-input-buffer
162 (fill-column-for-info fill-column)
163 (input-buffer (current-buffer))
164 (input-directory default-directory)
165 (header-text "")
166 (header-beginning 1)
167 (header-end 1))
169 ;;; Copy lines between beginning and end of header lines,
170 ;;; if any, or else copy the `@setfilename' line, if any.
171 (save-excursion
172 (save-restriction
173 (widen)
174 (goto-char (point-min))
175 (let ((search-end (save-excursion (forward-line 100) (point))))
176 (if (or
177 ;; Either copy header text.
178 (and
179 (prog1
180 (search-forward tex-start-of-header search-end t)
181 (forward-line 1)
182 ;; Mark beginning of header.
183 (setq header-beginning (point)))
184 (prog1
185 (search-forward tex-end-of-header nil t)
186 (beginning-of-line)
187 ;; Mark end of header
188 (setq header-end (point))))
189 ;; Or copy @filename line.
190 (prog2
191 (goto-char (point-min))
192 (search-forward "@setfilename" search-end t)
193 (beginning-of-line)
194 (setq header-beginning (point))
195 (forward-line 1)
196 (setq header-end (point))))
198 ;; Copy header
199 (setq header-text
200 (buffer-substring
201 (min header-beginning region-beginning)
202 header-end))))))
204 ;;; Find a buffer to use.
205 (switch-to-buffer (get-buffer-create texinfo-region-buffer-name))
206 (erase-buffer)
207 ;; Insert the header into the buffer.
208 (insert header-text)
209 ;; Insert the region into the buffer.
210 (insert-buffer-substring
211 input-buffer
212 (max region-beginning header-end)
213 region-end)
214 ;; Make sure region ends in a newline.
215 (or (= (preceding-char) ?\n)
216 (insert "\n"))
218 (goto-char (point-min))
219 (texinfo-mode)
220 (message "Converting region to Info format...")
221 (setq fill-column fill-column-for-info)
222 ;; Install a syntax table useful for scanning command operands.
223 (set-syntax-table texinfo-format-syntax-table)
225 ;; Insert @include files so `texinfo-raise-lower-sections' can
226 ;; work on them without losing track of multiple
227 ;; @raise/@lowersections commands.
228 (while (re-search-forward "^@include" nil t)
229 (setq texinfo-command-end (point))
230 (let ((filename (concat input-directory
231 (texinfo-parse-line-arg))))
232 (re-search-backward "^@include")
233 (delete-region (point) (save-excursion (forward-line 1) (point)))
234 (message "Reading included file: %s" filename)
235 (save-excursion
236 (save-restriction
237 (narrow-to-region
238 (point)
239 (+ (point) (car (cdr (insert-file-contents filename)))))
240 (goto-char (point-min))
241 ;; Remove `@setfilename' line from included file, if any,
242 ;; so @setfilename command not duplicated.
243 (if (re-search-forward
244 "^@setfilename" (save-excursion (forward-line 100) (point)) t)
245 (progn
246 (beginning-of-line)
247 (delete-region
248 (point) (save-excursion (forward-line 1) (point)))))))))
250 ;; Raise or lower level of each section, if necessary.
251 (goto-char (point-min))
252 (texinfo-raise-lower-sections)
253 ;; Append @refill to appropriate paragraphs for filling.
254 (goto-char (point-min))
255 (texinfo-append-refill)
256 ;; If the region includes the effective end of the data,
257 ;; discard everything after that.
258 (goto-char (point-max))
259 (if (re-search-backward "^@bye" nil t)
260 (delete-region (point) (point-max)))
261 ;; Make sure buffer ends in a newline.
262 (or (= (preceding-char) ?\n)
263 (insert "\n"))
264 ;; Don't use a previous value of texinfo-enclosure-list.
265 (setq texinfo-enclosure-list nil)
266 (setq texinfo-alias-list nil)
268 (goto-char (point-min))
269 (if (looking-at "\\\\input[ \t]+texinfo")
270 (delete-region (point) (save-excursion (forward-line 1) (point))))
272 ;; Insert Info region title text.
273 (goto-char (point-min))
274 (if (search-forward
275 "@setfilename" (save-excursion (forward-line 100) (point)) t)
276 (progn
277 (setq texinfo-command-end (point))
278 (beginning-of-line)
279 (setq texinfo-command-start (point))
280 (let ((arg (texinfo-parse-arg-discard)))
281 (insert " "
282 texinfo-region-buffer-name
283 " buffer for: `")
284 (insert (file-name-nondirectory (expand-file-name arg)))
285 (insert "', -*-Text-*-\n")))
286 ;; Else no `@setfilename' line
287 (insert " "
288 texinfo-region-buffer-name
289 " buffer -*-Text-*-\n"))
290 (insert "produced by `texinfo-format-region'\n"
291 "from a region in: "
292 (if (buffer-file-name input-buffer)
293 (concat "`"
294 (file-name-sans-versions
295 (file-name-nondirectory
296 (buffer-file-name input-buffer)))
297 "'")
298 (concat "buffer `" (buffer-name input-buffer) "'"))
299 "\nusing `texinfmt.el' version "
300 texinfmt-version
301 ".\n\n")
303 ;; Now convert for real.
304 (goto-char (point-min))
305 (texinfo-format-scan)
306 (goto-char (point-min))
307 (Info-tagify input-buffer)
308 (goto-char (point-min))
309 (message "Done.")))
311 ;;;###autoload
312 (defun texi2info (&optional nosplit)
313 "Convert the current buffer (written in Texinfo code) into an Info file.
314 The Info file output is generated in a buffer visiting the Info file
315 names specified in the @setfilename command.
317 This function automatically updates all node pointers and menus, and
318 creates a master menu. This work is done on a temporary buffer that
319 is automatically removed when the Info file is created. The original
320 Texinfo source buffer is not changed.
322 Non-nil argument (prefix, if interactive) means don't split the file
323 if large. You can use Info-split to do this manually."
324 (interactive "P")
325 (let ((temp-buffer (concat "*--" (buffer-name) "--temporary-buffer*" )))
326 (message "First updating nodes and menus, then creating Info file.")
327 ;; (sit-for 2)
328 (copy-to-buffer temp-buffer (point-min) (point-max))
329 (switch-to-buffer temp-buffer)
330 (texinfo-master-menu t)
331 (message "Now creating Info file.")
332 (sit-for 2)
333 (texinfo-format-buffer nosplit)
334 (save-buffer)
335 (kill-buffer temp-buffer)))
338 ;;; Primary internal formatting function for the whole buffer.
340 (defun texinfo-format-buffer-1 ()
341 (let (texinfo-format-filename
342 texinfo-example-start
343 texinfo-command-start
344 texinfo-command-end
345 texinfo-command-name
346 texinfo-last-node
347 texinfo-last-node-pos
348 texinfo-vindex
349 texinfo-findex
350 texinfo-cindex
351 texinfo-pindex
352 texinfo-tindex
353 texinfo-kindex
354 texinfo-stack
355 texinfo-node-names
356 (texinfo-footnote-number 0)
357 last-input-buffer
358 outfile
359 (fill-column-for-info fill-column)
360 (input-buffer (current-buffer))
361 (input-directory default-directory))
362 (setq texinfo-enclosure-list nil)
363 (setq texinfo-alias-list nil)
364 (save-excursion
365 (goto-char (point-min))
366 (or (search-forward "@setfilename" nil t)
367 (error "Texinfo file needs an `@setfilename FILENAME' line"))
368 (setq texinfo-command-end (point))
369 (setq outfile (texinfo-parse-line-arg)))
371 (find-file outfile)
372 (texinfo-mode)
373 (erase-buffer)
375 (message "Formatting Info file: %s" outfile)
376 (setq texinfo-format-filename
377 (file-name-nondirectory (expand-file-name outfile)))
379 (setq fill-column fill-column-for-info)
380 (set-syntax-table texinfo-format-syntax-table)
382 (insert-buffer-substring input-buffer)
383 (message "Converting %s to Info format..." (buffer-name input-buffer))
385 ;; Insert @include files so `texinfo-raise-lower-sections' can
386 ;; work on them without losing track of multiple
387 ;; @raise/@lowersections commands.
388 (goto-char (point-min))
389 (while (re-search-forward "^@include" nil t)
390 (setq texinfo-command-end (point))
391 (let ((filename (concat input-directory
392 (texinfo-parse-line-arg))))
393 (re-search-backward "^@include")
394 (delete-region (point) (save-excursion (forward-line 1) (point)))
395 (message "Reading included file: %s" filename)
396 (save-excursion
397 (save-restriction
398 (narrow-to-region
399 (point)
400 (+ (point) (car (cdr (insert-file-contents filename)))))
401 (goto-char (point-min))
402 ;; Remove `@setfilename' line from included file, if any,
403 ;; so @setfilename command not duplicated.
404 (if (re-search-forward
405 "^@setfilename"
406 (save-excursion (forward-line 100) (point)) t)
407 (progn
408 (beginning-of-line)
409 (delete-region
410 (point) (save-excursion (forward-line 1) (point)))))))))
411 ;; Raise or lower level of each section, if necessary.
412 (goto-char (point-min))
413 (texinfo-raise-lower-sections)
414 ;; Append @refill to appropriate paragraphs
415 (goto-char (point-min))
416 (texinfo-append-refill)
417 (goto-char (point-min))
418 (search-forward "@setfilename")
419 (beginning-of-line)
420 (delete-region (point-min) (point))
421 ;; Remove @bye at end of file, if it is there.
422 (goto-char (point-max))
423 (if (search-backward "@bye" nil t)
424 (delete-region (point) (point-max)))
425 ;; Make sure buffer ends in a newline.
426 (or (= (preceding-char) ?\n)
427 (insert "\n"))
428 ;; Scan the whole buffer, converting to Info format.
429 (texinfo-format-scan)
430 (goto-char (point-min))
431 ;; Insert info about how this file was made.
432 (insert "Info file: "
433 texinfo-format-filename ", -*-Text-*-\n"
434 "produced by `texinfo-format-buffer'\n"
435 ;; Date string removed so that regression testing is easier.
436 ;; "on "
437 ;; (insert (format-time-string "%e %b %Y")) " "
438 "from file"
439 (if (buffer-file-name input-buffer)
440 (concat " `"
441 (file-name-sans-versions
442 (file-name-nondirectory
443 (buffer-file-name input-buffer)))
444 "'")
445 (concat "buffer `" (buffer-name input-buffer) "'"))
446 "\nusing `texinfmt.el' version "
447 texinfmt-version
448 ".\n\n")
449 ;; Return data for indices.
450 (list outfile
451 texinfo-vindex texinfo-findex texinfo-cindex
452 texinfo-pindex texinfo-tindex texinfo-kindex)))
455 ;;; Perform non-@-command file conversions: quotes and hyphens
457 (defun texinfo-format-convert (min max)
458 ;; Convert left and right quotes to typewriter font quotes.
459 (goto-char min)
460 (while (search-forward "``" max t)
461 (replace-match "\""))
462 (goto-char min)
463 (while (search-forward "''" max t)
464 (replace-match "\""))
465 ;; Convert three hyphens in a row to two.
466 (goto-char min)
467 (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t)
468 (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning
469 2)))))
472 ;;; Handle paragraph filling
474 ;; Keep as concatinated lists for ease of maintenance
476 (defvar texinfo-no-refill-regexp
477 (concat
478 "^@"
479 "\\("
480 "direntry\\|"
481 "lisp\\|"
482 "smalllisp\\|"
483 "example\\|"
484 "smallexample\\|"
485 "display\\|"
486 "smalldisplay\\|"
487 "format\\|"
488 "smallformat\\|"
489 "flushleft\\|"
490 "flushright\\|"
491 "menu\\|"
492 "multitable\\|"
493 "titlepage\\|"
494 "iftex\\|"
495 "ifhtml\\|"
496 "tex\\|"
497 "html"
498 "\\)")
499 "Regexp specifying environments in which paragraphs are not filled.")
501 (defvar texinfo-accent-commands
502 (concat
503 "@^\\|"
504 "@`\\|"
505 "@'\\|"
506 "@\"\\|"
507 "@,\\|"
508 "@=\\|"
509 "@~\\|"
510 "@OE{\\|"
511 "@oe{\\|"
512 "@AA{\\|"
513 "@aa{\\|"
514 "@AE{\\|"
515 "@ae{\\|"
516 "@ss{\\|"
517 "@questiondown{\\|"
518 "@exclamdown{\\|"
519 "@L{\\|"
520 "@l{\\|"
521 "@O{\\|"
522 "@o{\\|"
523 "@dotaccent{\\|"
524 "@ubaraccent{\\|"
525 "@d{\\|"
526 "@H{\\|"
527 "@ringaccent{\\|"
528 "@tieaccent{\\|"
529 "@u{\\|"
530 "@v{\\|"
531 "@dotless{"
534 (defvar texinfo-part-of-para-regexp
535 (concat
536 "^@"
537 "\\("
538 "b{\\|"
539 "bullet{\\|"
540 "cite{\\|"
541 "code{\\|"
542 "email{\\|"
543 "emph{\\|"
544 "equiv{\\|"
545 "error{\\|"
546 "expansion{\\|"
547 "file{\\|"
548 "i{\\|"
549 "inforef{\\|"
550 "kbd{\\|"
551 "key{\\|"
552 "lisp{\\|"
553 "minus{\\|"
554 "point{\\|"
555 "print{\\|"
556 "pxref{\\|"
557 "r{\\|"
558 "ref{\\|"
559 "result{\\|"
560 "samp{\\|"
561 "sc{\\|"
562 "t{\\|"
563 "TeX{\\|"
564 "today{\\|"
565 "url{\\|"
566 "var{\\|"
567 "w{\\|"
568 "xref{\\|"
569 "@-\\|" ; @- is a descretionary hyphen (not an accent) (a noop).
570 texinfo-accent-commands
571 "\\)"
573 "Regexp specifying @-commands found within paragraphs.")
575 (defun texinfo-append-refill ()
576 "Append @refill at end of each paragraph that should be filled.
577 Do not append @refill to paragraphs within @example and similar environments.
578 Do not append @refill to paragraphs containing @w{TEXT} or @*."
580 ;; It is necessary to append @refill before other processing because
581 ;; the other processing removes information that tells Texinfo
582 ;; whether the text should or should not be filled.
584 (while (< (point) (point-max))
585 (let ((refill-blank-lines "^[ \t\n]*$")
586 (case-fold-search nil)) ; Don't confuse @TeX and @tex....
587 (beginning-of-line)
588 ;; 1. Skip over blank lines;
589 ;; skip over lines beginning with @-commands,
590 ;; but do not skip over lines
591 ;; that are no-refill environments such as @example or
592 ;; that begin with within-paragraph @-commands such as @code.
593 (while (and (looking-at (concat "^@\\|^\\\\\\|" refill-blank-lines))
594 (not (looking-at
595 (concat
596 "\\("
597 texinfo-no-refill-regexp
598 "\\|"
599 texinfo-part-of-para-regexp
600 "\\)")))
601 (< (point) (point-max)))
602 (forward-line 1))
603 ;; 2. Skip over @example and similar no-refill environments.
604 (if (looking-at texinfo-no-refill-regexp)
605 (let ((environment
606 (buffer-substring (match-beginning 1) (match-end 1))))
607 (progn (re-search-forward (concat "^@end " environment) nil t)
608 (forward-line 1)))
609 ;; Else
610 ;; 3. Do not refill a paragraph containing @w or @*, or ending
611 ;; with @<newline> followed by a newline.
612 (if (or
613 (>= (point) (point-max))
614 (re-search-forward
615 "@w{\\|@\\*\\|@\n\n"
616 (save-excursion
617 (forward-paragraph)
618 (forward-line 1)
619 (point)) t))
620 ;; Go to end of paragraph and do nothing.
621 (forward-paragraph)
622 ;; 4. Else go to end of paragraph and insert @refill
623 (forward-paragraph)
624 (forward-line -1)
625 (let ((line-beg (point)))
626 (end-of-line)
627 (delete-region
628 (point)
629 (save-excursion (skip-chars-backward " \t") (point)))
630 (forward-char 1)
631 (unless (re-search-backward "@c[ \t\n]\\|@comment[ \t\n]" line-beg t)
632 (forward-char -1))
633 (unless (re-search-backward "@refill\\|@bye" line-beg t)
634 (insert "@refill")))
635 (forward-line 1))))))
638 ;;; Handle `@raisesections' and `@lowersections' commands
640 ;; These commands change the hierarchical level of chapter structuring
641 ;; commands.
643 ;; @raisesections changes @subsection to @section,
644 ;; @section to @chapter,
645 ;; etc.
647 ;; @lowersections changes @chapter to @section
648 ;; @subsection to @subsubsection,
649 ;; etc.
651 ;; An @raisesections/@lowersections command changes only those
652 ;; structuring commands that follow the @raisesections/@lowersections
653 ;; command.
655 ;; Repeated @raisesections/@lowersections continue to raise or lower
656 ;; the heading level.
658 ;; An @lowersections command cancels an @raisesections command, and
659 ;; vice versa.
661 ;; You cannot raise or lower "beyond" chapters or subsubsections, but
662 ;; trying to do so does not elicit an error---you just get more
663 ;; headings that mean the same thing as you keep raising or lowering
664 ;; (for example, after a single @raisesections, both @chapter and
665 ;; @section produce chapter headings).
667 (defun texinfo-raise-lower-sections ()
668 "Raise or lower the hierarchical level of chapters, sections, etc.
670 This function acts according to `@raisesections' and `@lowersections'
671 commands in the Texinfo file.
673 For example, an `@lowersections' command is useful if you wish to
674 include what is written as an outer or standalone Texinfo file in
675 another Texinfo file as an inner, included file. The `@lowersections'
676 command changes chapters to sections, sections to subsections and so
679 @raisesections changes @subsection to @section,
680 @section to @chapter,
681 @heading to @chapheading,
682 etc.
684 @lowersections changes @chapter to @section,
685 @subsection to @subsubsection,
686 @heading to @subheading,
687 etc.
689 An `@raisesections' or `@lowersections' command changes only those
690 structuring commands that follow the `@raisesections' or
691 `@lowersections' command.
693 An `@lowersections' command cancels an `@raisesections' command, and
694 vice versa.
696 Repeated use of the commands continue to raise or lower the hierarchical
697 level a step at a time.
699 An attempt to raise above `chapters' reproduces chapter commands; an
700 attempt to lower below subsubsections reproduces subsubsection
701 commands."
703 ;; `texinfo-section-types-regexp' is defined in `texnfo-upd.el';
704 ;; it is a regexp matching chapter, section, other headings
705 ;; (but not the top node).
707 (let (type (level 0))
708 (while
709 (re-search-forward
710 (concat
711 "\\(\\(^@\\(raise\\|lower\\)sections\\)\\|\\("
712 texinfo-section-types-regexp
713 "\\)\\)")
714 nil t)
715 (beginning-of-line)
716 (save-excursion (setq type (read (current-buffer))))
717 (cond
719 ;; 1. Increment level
720 ((eq type '@raisesections)
721 (setq level (1+ level))
722 (delete-region
723 (point) (save-excursion (forward-line 1) (point))))
725 ;; 2. Decrement level
726 ((eq type '@lowersections)
727 (setq level (1- level))
728 (delete-region
729 (point) (save-excursion (forward-line 1) (point))))
731 ;; Now handle structuring commands
732 ((cond
734 ;; 3. Raise level when positive
735 ((> level 0)
736 (let ((count level)
737 (new-level type))
738 (while (> count 0)
739 (setq new-level
740 (cdr (assq new-level texinfo-raisesections-alist)))
741 (setq count (1- count)))
742 (kill-word 1)
743 (insert (symbol-name new-level))))
745 ;; 4. Do nothing except move point when level is zero
746 ((= level 0) (forward-line 1))
748 ;; 5. Lower level when positive
749 ((< level 0)
750 (let ((count level)
751 (new-level type))
752 (while (< count 0)
753 (setq new-level
754 (cdr (assq new-level texinfo-lowersections-alist)))
755 (setq count (1+ count)))
756 (kill-word 1)
757 (insert (symbol-name new-level))))))))))
759 (defvar texinfo-raisesections-alist
760 '((@chapter . @chapter) ; Cannot go higher
761 (@unnumbered . @unnumbered)
762 (@centerchap . @unnumbered)
764 (@majorheading . @majorheading)
765 (@chapheading . @chapheading)
766 (@appendix . @appendix)
768 (@section . @chapter)
769 (@unnumberedsec . @unnumbered)
770 (@heading . @chapheading)
771 (@appendixsec . @appendix)
773 (@subsection . @section)
774 (@unnumberedsubsec . @unnumberedsec)
775 (@subheading . @heading)
776 (@appendixsubsec . @appendixsec)
778 (@subsubsection . @subsection)
779 (@unnumberedsubsubsec . @unnumberedsubsec)
780 (@subsubheading . @subheading)
781 (@appendixsubsubsec . @appendixsubsec))
782 "*An alist of next higher levels for chapters, sections. etc.
783 For example, section to chapter, subsection to section.
784 Used by `texinfo-raise-lower-sections'.
785 The keys specify types of section; the values correspond to the next
786 higher types.")
788 (defvar texinfo-lowersections-alist
789 '((@chapter . @section)
790 (@unnumbered . @unnumberedsec)
791 (@centerchap . @unnumberedsec)
792 (@majorheading . @heading)
793 (@chapheading . @heading)
794 (@appendix . @appendixsec)
796 (@section . @subsection)
797 (@unnumberedsec . @unnumberedsubsec)
798 (@heading . @subheading)
799 (@appendixsec . @appendixsubsec)
801 (@subsection . @subsubsection)
802 (@unnumberedsubsec . @unnumberedsubsubsec)
803 (@subheading . @subsubheading)
804 (@appendixsubsec . @appendixsubsubsec)
806 (@subsubsection . @subsubsection) ; Cannot go lower.
807 (@unnumberedsubsubsec . @unnumberedsubsubsec)
808 (@subsubheading . @subsubheading)
809 (@appendixsubsubsec . @appendixsubsubsec))
810 "*An alist of next lower levels for chapters, sections. etc.
811 For example, chapter to section, section to subsection.
812 Used by `texinfo-raise-lower-sections'.
813 The keys specify types of section; the values correspond to the next
814 lower types.")
817 ;;; Perform those texinfo-to-info conversions that apply to the whole input
818 ;;; uniformly.
820 (defun texinfo-format-scan ()
821 (texinfo-format-convert (point-min) (point-max))
822 ;; Scan for @-commands.
823 (goto-char (point-min))
824 (while (search-forward "@" nil t)
826 ;; These are the single-character accent commands: @^ @` @' @" @= @~
827 ;; In Info, they are simply quoted and the @ deleted.
828 ;; Other single-character commands:
829 ;; @* forces a line break,
830 ;; @- is a discretionary hyphenation point; does nothing in Info.
831 ;; @<space>, @<tab>, @<newline> each produce a single space,
832 ;; unless followed by a newline.
834 ;; Old version 2.34 expression: (looking-at "[@{}^'` *\"?!]")
835 (if (looking-at "[@{}^'`\"=~ \t\n*?!-]")
836 ;; @*, causes a line break.
837 (cond
838 ;; @*, a line break
839 ((= (following-char) ?*)
840 ;; remove command
841 (delete-region (1- (point)) (1+ (point)))
842 ;; insert return if not at end of line;
843 ;; else line is already broken.
844 (if (not (= (following-char) ?\n))
845 (insert ?\n)))
846 ;; @-, deleted
847 ((= (following-char) ?-)
848 (delete-region (1- (point)) (1+ (point))))
849 ;; @<space>, @<tab>, @<newline>: produce a single space,
850 ;; unless followed by a newline.
851 ((= (following-char) ? )
852 (delete-region (1- (point)) (1+ (point)))
853 ;; insert single space if not at end of line;
854 ;; else line is already broken.
855 (if (not (= (following-char) ?\n))
856 (insert ? )))
857 ((= (following-char) ?\t)
858 (delete-region (1- (point)) (1+ (point)))
859 ;; insert single space if not at end of line;
860 ;; else line is already broken.
861 (if (not (= (following-char) ?\n))
862 (insert ? )))
863 ;; following char is a carriage return
864 ((= (following-char) ?\n)
865 ;; remove command
866 (delete-region (1- (point)) (1+ (point)))
867 ;; insert single space if not at end of line;
868 ;; else line is already broken.
869 (if (not (= (following-char) ?\n))
870 (insert ? )))
871 ;; Otherwise: the other characters are simply quoted. Delete the @.
873 (delete-char -1)
874 ;; Be compatible with makeinfo: if @' and its ilk are
875 ;; followed by a @ without a brace, barf.
876 (if (looking-at "[\"'^`~=]")
877 (progn
878 (if (= (char-after (1+ (point))) ?@)
879 (error "Use braces to give a command as an argument to @%c"
880 (following-char)))
881 (forward-char 1)
882 ;; @' etc. can optionally accept their argument in
883 ;; braces (makeinfo supports that).
884 (when (looking-at "{")
885 (let ((start (point)))
886 (forward-list 1)
887 (delete-char -1)
888 (goto-char start)
889 (delete-char 1))))
890 (forward-char 1))))
891 ;; @ is followed by a command-word; find the end of the word.
892 (setq texinfo-command-start (1- (point)))
893 (if (= (char-syntax (following-char)) ?w)
894 (forward-word 1)
895 (forward-char 1))
896 (setq texinfo-command-end (point))
897 ;; Detect the case of two @-commands in a row;
898 ;; process just the first one.
899 (goto-char (1+ texinfo-command-start))
900 (skip-chars-forward "^@" texinfo-command-end)
901 (setq texinfo-command-end (point))
902 ;; Handle let aliasing
903 (setq texinfo-command-name
904 (let (trial
905 (cmdname
906 (buffer-substring
907 (1+ texinfo-command-start) texinfo-command-end)))
908 (while (setq trial (assoc cmdname texinfo-alias-list))
909 (setq cmdname (cdr trial)))
910 (intern cmdname)))
911 ;; Call the handler for this command.
912 (let ((enclosure-type
913 (assoc
914 (symbol-name texinfo-command-name)
915 texinfo-enclosure-list)))
916 (if enclosure-type
917 (progn
918 (insert
919 (car (car (cdr enclosure-type)))
920 (texinfo-parse-arg-discard)
921 (car (cdr (car (cdr enclosure-type)))))
922 (goto-char texinfo-command-start))
923 (let ((cmd (get texinfo-command-name 'texinfo-format)))
924 (if cmd (funcall cmd) (texinfo-unsupported)))))))
926 (cond (texinfo-stack
927 (goto-char (nth 2 (car texinfo-stack)))
928 (error "Unterminated @%s" (car (car texinfo-stack))))))
930 (put 'begin 'texinfo-format 'texinfo-format-begin)
931 (defun texinfo-format-begin ()
932 (texinfo-format-begin-end 'texinfo-format))
934 (put 'end 'texinfo-format 'texinfo-format-end)
935 (defun texinfo-format-end ()
936 (texinfo-format-begin-end 'texinfo-end))
938 (defun texinfo-format-begin-end (prop)
939 (setq texinfo-command-name (intern (texinfo-parse-line-arg)))
940 (let ((cmd (get texinfo-command-name prop)))
941 (if cmd (funcall cmd)
942 (texinfo-unsupported))))
944 ;;; Parsing functions
946 (defun texinfo-parse-line-arg ()
947 "Return argument of @-command as string.
948 Argument is separated from command either by a space or by a brace.
949 If a space, return rest of line, with beginning and ending white
950 space removed. If a brace, return string between braces.
951 Leave point after argument."
952 (goto-char texinfo-command-end)
953 (let ((start (point)))
954 (cond ((looking-at " ")
955 (skip-chars-forward " ")
956 (setq start (point))
957 (end-of-line)
958 (skip-chars-backward " ")
959 (delete-region (point) (progn (end-of-line) (point)))
960 (setq texinfo-command-end (1+ (point))))
961 ((looking-at "{")
962 (setq start (1+ (point)))
963 (forward-list 1)
964 (setq texinfo-command-end (point))
965 (forward-char -1))
967 (error "Invalid texinfo command arg format")))
968 (prog1 (buffer-substring start (point))
969 (if (eolp) (forward-char 1)))))
971 (defun texinfo-parse-expanded-arg ()
972 (goto-char texinfo-command-end)
973 (let ((start (point))
974 marker)
975 (cond ((looking-at " ")
976 (skip-chars-forward " ")
977 (setq start (point))
978 (end-of-line)
979 (setq texinfo-command-end (1+ (point))))
980 ((looking-at "{")
981 (setq start (1+ (point)))
982 (forward-list 1)
983 (setq texinfo-command-end (point))
984 (forward-char -1))
986 (error "Invalid texinfo command arg format")))
987 (setq marker (move-marker (make-marker) texinfo-command-end))
988 (texinfo-format-expand-region start (point))
989 (setq texinfo-command-end (marker-position marker))
990 (move-marker marker nil)
991 (prog1 (buffer-substring start (point))
992 (if (eolp) (forward-char 1)))))
994 (defun texinfo-format-expand-region (start end)
995 (save-restriction
996 (narrow-to-region start end)
997 (let (texinfo-command-start
998 texinfo-command-end
999 texinfo-command-name
1000 texinfo-stack)
1001 (texinfo-format-scan))
1002 (goto-char (point-max))))
1004 (defun texinfo-parse-arg-discard ()
1005 "Delete command and argument; return argument of command."
1006 (prog1 (texinfo-parse-line-arg)
1007 (texinfo-discard-command)))
1009 (defun texinfo-discard-command ()
1010 (delete-region texinfo-command-start texinfo-command-end))
1012 (defun texinfo-optional-braces-discard ()
1013 "Discard braces following command, if any."
1014 (goto-char texinfo-command-end)
1015 (let ((start (point)))
1016 (cond ((looking-at "[ \t]*\n")) ; do nothing
1017 ((looking-at "{") ; remove braces, if any
1018 (forward-list 1)
1019 (setq texinfo-command-end (point)))
1021 (error
1022 "Invalid `texinfo-optional-braces-discard' format \(need braces?\)")))
1023 (delete-region texinfo-command-start texinfo-command-end)))
1025 (defun texinfo-format-parse-line-args ()
1026 (let ((start (1- (point)))
1027 next beg end
1028 args)
1029 (skip-chars-forward " ")
1030 (while (not (eolp))
1031 (setq beg (point))
1032 (re-search-forward "[\n,]")
1033 (setq next (point))
1034 (if (bolp) (setq next (1- next)))
1035 (forward-char -1)
1036 (skip-chars-backward " ")
1037 (setq end (point))
1038 (setq args (cons (if (> end beg) (buffer-substring beg end))
1039 args))
1040 (goto-char next)
1041 (skip-chars-forward " "))
1042 (if (eolp) (forward-char 1))
1043 (setq texinfo-command-end (point))
1044 (nreverse args)))
1046 (defun texinfo-format-parse-args ()
1047 (let ((start (1- (point)))
1048 next beg end
1049 args)
1050 (search-forward "{")
1051 (save-excursion
1052 (texinfo-format-expand-region
1053 (point)
1054 (save-excursion (up-list 1) (1- (point)))))
1055 ;; The following does not handle cross references of the form:
1056 ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the
1057 ;; re-search-forward finds the first right brace after the second
1058 ;; comma.
1059 (while (/= (preceding-char) ?\})
1060 (skip-chars-forward " \t\n")
1061 (setq beg (point))
1062 (re-search-forward "[},]")
1063 (setq next (point))
1064 (forward-char -1)
1065 (skip-chars-backward " \t\n")
1066 (setq end (point))
1067 (cond ((< beg end)
1068 (goto-char beg)
1069 (while (search-forward "\n" end t)
1070 (replace-match " "))))
1071 (setq args (cons (if (> end beg) (buffer-substring beg end))
1072 args))
1073 (goto-char next))
1074 ;;(if (eolp) (forward-char 1))
1075 (setq texinfo-command-end (point))
1076 (nreverse args)))
1078 (defun texinfo-format-parse-defun-args ()
1079 (goto-char texinfo-command-end)
1080 (let ((start (point)))
1081 (end-of-line)
1082 (setq texinfo-command-end (1+ (point)))
1083 (let ((marker (move-marker (make-marker) texinfo-command-end)))
1084 (texinfo-format-expand-region start (point))
1085 (setq texinfo-command-end (marker-position marker))
1086 (move-marker marker nil))
1087 (goto-char start)
1088 (let ((args '())
1089 beg end)
1090 (skip-chars-forward " ")
1091 (while (not (eolp))
1092 (cond ((looking-at "{")
1093 (setq beg (1+ (point)))
1094 (forward-list 1)
1095 (setq end (1- (point))))
1097 (setq beg (point))
1098 (re-search-forward "[\n ]")
1099 (forward-char -1)
1100 (setq end (point))))
1101 (setq args (cons (buffer-substring beg end) args))
1102 (skip-chars-forward " "))
1103 (forward-char 1)
1104 (nreverse args))))
1106 (defun texinfo-discard-line ()
1107 (goto-char texinfo-command-end)
1108 (skip-chars-forward " \t")
1109 (or (eolp)
1110 (error "Extraneous text at end of command line"))
1111 (goto-char texinfo-command-start)
1112 (or (bolp)
1113 (error "Extraneous text at beginning of command line"))
1114 (delete-region (point) (progn (forward-line 1) (point))))
1116 (defun texinfo-discard-line-with-args ()
1117 (goto-char texinfo-command-start)
1118 (delete-region (point) (progn (forward-line 1) (point))))
1121 ;;; @setfilename
1123 ;; Only `texinfo-format-buffer' handles @setfilename with this
1124 ;; definition; `texinfo-format-region' handles @setfilename, if any,
1125 ;; specially.
1126 (put 'setfilename 'texinfo-format 'texinfo-format-setfilename)
1127 (defun texinfo-format-setfilename ()
1128 (texinfo-parse-arg-discard))
1130 ;;; @node, @menu, @detailmenu
1132 (put 'node 'texinfo-format 'texinfo-format-node)
1133 (put 'nwnode 'texinfo-format 'texinfo-format-node)
1134 (defun texinfo-format-node ()
1135 (let* ((args (texinfo-format-parse-line-args))
1136 (name (nth 0 args))
1137 (next (nth 1 args))
1138 (prev (nth 2 args))
1139 (up (nth 3 args)))
1140 (texinfo-discard-command)
1141 (setq texinfo-last-node name)
1142 (let ((tem (if texinfo-fold-nodename-case (downcase name) name)))
1143 (if (assoc tem texinfo-node-names)
1144 (error "Duplicate node name: %s" name)
1145 (setq texinfo-node-names (cons (list tem) texinfo-node-names))))
1146 (setq texinfo-footnote-number 0)
1147 ;; insert "\n\^_" unconditionally since this is what info is looking for
1148 (insert "\n\^_\nFile: " texinfo-format-filename
1149 ", Node: " name)
1150 (if next
1151 (insert ", Next: " next))
1152 (if prev
1153 (insert ", Prev: " prev))
1154 (if up
1155 (insert ", Up: " up))
1156 (insert ?\n)
1157 (setq texinfo-last-node-pos (point))))
1159 (put 'anchor 'texinfo-format 'texinfo-anchor)
1160 (defun texinfo-anchor ()
1161 (let (anchor-string
1162 (here (- (point) 7)) ; save location of beginning of `@anchor'
1163 (arg (texinfo-parse-arg-discard)))
1164 (if (looking-at " ") ; since a space may be left after -discard
1165 (delete-char 1))
1166 (forward-paragraph)
1167 (let ((end (point)))
1168 (if (save-excursion
1169 (backward-word 1)
1170 (search-forward "@refill" end t))
1171 (setq anchor-string "@anchor-yes-refill")
1172 (setq anchor-string "@anchor-no-refill")))
1173 (goto-char here)
1174 (insert anchor-string "{" arg "}")))
1176 (put 'menu 'texinfo-format 'texinfo-format-menu)
1177 (defun texinfo-format-menu ()
1178 (texinfo-discard-line)
1179 (insert "* Menu:\n\n"))
1181 (put 'menu 'texinfo-end 'texinfo-discard-command)
1183 ;; The @detailmenu should be removed eventually.
1185 ;; According to Karl Berry, 31 August 1996:
1187 ;; You don't like, I don't like it. I agree, it would be better just to
1188 ;; fix the bug [in `makeinfo']. .. At this point, since inserting those
1189 ;; two commands in the Elisp fn is trivial, I don't especially want to
1190 ;; expend more effort...
1192 ;; I added a couple sentences of documentation to the manual (putting the
1193 ;; blame on makeinfo where it belongs :-().
1195 (put 'detailmenu 'texinfo-format 'texinfo-discard-line)
1196 (put 'detailmenu 'texinfo-end 'texinfo-discard-command)
1198 ;; (Also see `texnfo-upd.el')
1201 ;;; Cross references
1203 ;; @xref {NODE, FNAME, NAME, FILE, DOCUMENT}
1204 ;; -> *Note FNAME: (FILE)NODE
1205 ;; If FILE is missing,
1206 ;; *Note FNAME: NODE
1207 ;; If FNAME is empty and NAME is present
1208 ;; *Note NAME: Node
1209 ;; If both NAME and FNAME are missing
1210 ;; *Note NODE::
1211 ;; texinfo ignores the DOCUMENT argument.
1212 ;; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1213 ;; If FILE is specified, (FILE)NODE is used for xrefs.
1214 ;; If fifth argument DOCUMENT is specified, produces
1215 ;; See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
1216 ;; of DOCUMENT
1218 ;; @ref a reference that does not put `See' or `see' in
1219 ;; the hardcopy and is the same as @xref in Info
1220 (put 'ref 'texinfo-format 'texinfo-format-xref)
1222 (put 'xref 'texinfo-format 'texinfo-format-xref)
1223 (defun texinfo-format-xref ()
1224 (let ((args (texinfo-format-parse-args)))
1225 (texinfo-discard-command)
1226 (insert "*Note ")
1227 (let ((fname (or (nth 1 args) (nth 2 args))))
1228 (if (null (or fname (nth 3 args)))
1229 (insert (car args) "::")
1230 (insert (or fname (car args)) ": ")
1231 (if (nth 3 args)
1232 (insert "(" (nth 3 args) ")"))
1233 (and (car args) (insert (car args)))))))
1235 (put 'pxref 'texinfo-format 'texinfo-format-pxref)
1236 (defun texinfo-format-pxref ()
1237 (texinfo-format-xref)
1238 (or (save-excursion
1239 (forward-char -2)
1240 (looking-at "::"))
1241 (insert ".")))
1243 ;; @inforef{NODE, FNAME, FILE}
1244 ;; Like @xref{NODE, FNAME,,FILE} in texinfo.
1245 ;; In Tex, generates "See Info file FILE, node NODE"
1246 (put 'inforef 'texinfo-format 'texinfo-format-inforef)
1247 (defun texinfo-format-inforef ()
1248 (let ((args (texinfo-format-parse-args)))
1249 (texinfo-discard-command)
1250 (if (nth 1 args)
1251 (insert "*Note " (nth 1 args) ": (" (nth 2 args) ")" (car args))
1252 (insert "*Note " "(" (nth 2 args) ")" (car args) "::"))))
1255 ;;; URL Reference: @uref
1257 ;; @uref produces a reference to a uniform resource locator (URL).
1258 ;; It takes one mandatory argument, the URL, and one optional argument,
1259 ;; the text to display (the default is the URL itself).
1261 (put 'uref 'texinfo-format 'texinfo-format-uref)
1262 (defun texinfo-format-uref ()
1263 "Format URL and optional URL-TITLE.
1264 Insert ` ... ' around URL if no URL-TITLE argument;
1265 otherwise, insert URL-TITLE followed by URL in parentheses."
1266 (let ((args (texinfo-format-parse-args)))
1267 (texinfo-discard-command)
1268 ;; if url-title
1269 (if (nth 1 args)
1270 (insert (nth 1 args) " (" (nth 0 args) ")")
1271 (insert "`" (nth 0 args) "'"))
1272 (goto-char texinfo-command-start)))
1275 ;;; Section headings
1277 (put 'majorheading 'texinfo-format 'texinfo-format-chapter)
1278 (put 'chapheading 'texinfo-format 'texinfo-format-chapter)
1279 (put 'ichapter 'texinfo-format 'texinfo-format-chapter)
1280 (put 'chapter 'texinfo-format 'texinfo-format-chapter)
1281 (put 'iappendix 'texinfo-format 'texinfo-format-chapter)
1282 (put 'appendix 'texinfo-format 'texinfo-format-chapter)
1283 (put 'iunnumbered 'texinfo-format 'texinfo-format-chapter)
1284 (put 'top 'texinfo-format 'texinfo-format-chapter)
1285 (put 'unnumbered 'texinfo-format 'texinfo-format-chapter)
1286 (put 'centerchap 'texinfo-format 'texinfo-format-chapter)
1287 (defun texinfo-format-chapter ()
1288 (texinfo-format-chapter-1 ?*))
1290 (put 'heading 'texinfo-format 'texinfo-format-section)
1291 (put 'isection 'texinfo-format 'texinfo-format-section)
1292 (put 'section 'texinfo-format 'texinfo-format-section)
1293 (put 'iappendixsection 'texinfo-format 'texinfo-format-section)
1294 (put 'appendixsection 'texinfo-format 'texinfo-format-section)
1295 (put 'iappendixsec 'texinfo-format 'texinfo-format-section)
1296 (put 'appendixsec 'texinfo-format 'texinfo-format-section)
1297 (put 'iunnumberedsec 'texinfo-format 'texinfo-format-section)
1298 (put 'unnumberedsec 'texinfo-format 'texinfo-format-section)
1299 (defun texinfo-format-section ()
1300 (texinfo-format-chapter-1 ?=))
1302 (put 'subheading 'texinfo-format 'texinfo-format-subsection)
1303 (put 'isubsection 'texinfo-format 'texinfo-format-subsection)
1304 (put 'subsection 'texinfo-format 'texinfo-format-subsection)
1305 (put 'iappendixsubsec 'texinfo-format 'texinfo-format-subsection)
1306 (put 'appendixsubsec 'texinfo-format 'texinfo-format-subsection)
1307 (put 'iunnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
1308 (put 'unnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
1309 (defun texinfo-format-subsection ()
1310 (texinfo-format-chapter-1 ?-))
1312 (put 'subsubheading 'texinfo-format 'texinfo-format-subsubsection)
1313 (put 'isubsubsection 'texinfo-format 'texinfo-format-subsubsection)
1314 (put 'subsubsection 'texinfo-format 'texinfo-format-subsubsection)
1315 (put 'iappendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
1316 (put 'appendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
1317 (put 'iunnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
1318 (put 'unnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
1319 (defun texinfo-format-subsubsection ()
1320 (texinfo-format-chapter-1 ?.))
1322 (defun texinfo-format-chapter-1 (belowchar)
1323 (let ((arg (texinfo-parse-arg-discard)))
1324 (message "Formatting: %s ... " arg) ; So we can see where we are.
1325 (insert ?\n arg ?\n "@SectionPAD " belowchar ?\n)
1326 (forward-line -2)))
1328 (put 'SectionPAD 'texinfo-format 'texinfo-format-sectionpad)
1329 (defun texinfo-format-sectionpad ()
1330 (let ((str (texinfo-parse-arg-discard)))
1331 (forward-char -1)
1332 (let ((column (current-column)))
1333 (forward-char 1)
1334 (while (> column 0)
1335 (insert str)
1336 (setq column (1- column))))
1337 (insert ?\n)))
1340 ;;; Space controlling commands: @. and @:, and the soft hyphen.
1342 (put '\. 'texinfo-format 'texinfo-format-\.)
1343 (defun texinfo-format-\. ()
1344 (texinfo-discard-command)
1345 (insert "."))
1347 (put '\: 'texinfo-format 'texinfo-format-\:)
1348 (defun texinfo-format-\: ()
1349 (texinfo-discard-command))
1351 (put '\- 'texinfo-format 'texinfo-format-soft-hyphen)
1352 (defun texinfo-format-soft-hyphen ()
1353 (texinfo-discard-command))
1356 ;;; @center, @sp, and @br
1358 (put 'center 'texinfo-format 'texinfo-format-center)
1359 (defun texinfo-format-center ()
1360 (let ((arg (texinfo-parse-expanded-arg)))
1361 (texinfo-discard-command)
1362 (insert arg)
1363 (insert ?\n)
1364 (save-restriction
1365 (goto-char (1- (point)))
1366 (let ((indent-tabs-mode nil))
1367 (center-line)))))
1369 (put 'sp 'texinfo-format 'texinfo-format-sp)
1370 (defun texinfo-format-sp ()
1371 (let* ((arg (texinfo-parse-arg-discard))
1372 (num (read arg)))
1373 (insert-char ?\n num)))
1375 (put 'br 'texinfo-format 'texinfo-format-paragraph-break)
1376 (defun texinfo-format-paragraph-break ()
1377 "Force a paragraph break.
1378 If used within a line, follow `@br' with braces."
1379 (texinfo-optional-braces-discard)
1380 ;; insert one return if at end of line;
1381 ;; else insert two returns, to generate a blank line.
1382 (if (= (following-char) ?\n)
1383 (insert ?\n)
1384 (insert-char ?\n 2)))
1387 ;;; @footnote and @footnotestyle
1389 ;; In Texinfo, footnotes are created with the `@footnote' command.
1390 ;; This command is followed immediately by a left brace, then by the text of
1391 ;; the footnote, and then by a terminating right brace. The
1392 ;; template for a footnote is:
1394 ;; @footnote{TEXT}
1396 ;; Info has two footnote styles:
1398 ;; * In the End of node style, all the footnotes for a single node
1399 ;; are placed at the end of that node. The footnotes are
1400 ;; separated from the rest of the node by a line of dashes with
1401 ;; the word `Footnotes' within it.
1403 ;; * In the Separate node style, all the footnotes for a single node
1404 ;; are placed in an automatically constructed node of their own.
1406 ;; Footnote style is specified by the @footnotestyle command, either
1407 ;; @footnotestyle separate
1408 ;; or
1409 ;; @footnotestyle end
1411 ;; The default is separate
1413 (defvar texinfo-footnote-style "separate"
1414 "Footnote style, either separate or end.")
1416 (put 'footnotestyle 'texinfo-format 'texinfo-footnotestyle)
1417 (defun texinfo-footnotestyle ()
1418 "Specify whether footnotes are at end of node or in separate nodes.
1419 Argument is either end or separate."
1420 (setq texinfo-footnote-style (texinfo-parse-arg-discard)))
1422 (defvar texinfo-footnote-number)
1424 (put 'footnote 'texinfo-format 'texinfo-format-footnote)
1425 (defun texinfo-format-footnote ()
1426 "Format a footnote in either end of node or separate node style.
1427 The texinfo-footnote-style variable controls which style is used."
1428 (setq texinfo-footnote-number (1+ texinfo-footnote-number))
1429 (cond ((string= texinfo-footnote-style "end")
1430 (texinfo-format-end-node))
1431 ((string= texinfo-footnote-style "separate")
1432 (texinfo-format-separate-node))))
1434 (defun texinfo-format-separate-node ()
1435 "Format footnote in Separate node style, with notes in own node.
1436 The node is constructed automatically."
1437 (let* (start
1438 (arg (texinfo-parse-line-arg))
1439 (node-name-beginning
1440 (save-excursion
1441 (re-search-backward
1442 "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:")
1443 (match-end 0)))
1444 (node-name
1445 (save-excursion
1446 (buffer-substring
1447 (progn (goto-char node-name-beginning) ; skip over node command
1448 (skip-chars-forward " \t") ; and over spaces
1449 (point))
1450 (if (search-forward
1452 (save-excursion (end-of-line) (point)) t) ; bound search
1453 (1- (point))
1454 (end-of-line) (point))))))
1455 (texinfo-discard-command) ; remove or insert whitespace, as needed
1456 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1457 (point))
1458 (insert (format " (%d) (*Note %s-Footnotes::)"
1459 texinfo-footnote-number node-name))
1460 (fill-paragraph nil)
1461 (save-excursion
1462 (if (re-search-forward "^@node" nil 'move)
1463 (forward-line -1))
1465 ;; two cases: for the first footnote, we must insert a node header;
1466 ;; for the second and subsequent footnotes, we need only insert
1467 ;; the text of the footnote.
1469 (if (save-excursion
1470 (re-search-backward
1471 (concat node-name "-Footnotes, Up: ")
1472 node-name-beginning
1474 (progn ; already at least one footnote
1475 (setq start (point))
1476 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
1477 (fill-region start (point)))
1478 ;; else not yet a footnote
1479 (insert "\n\^_\nFile: " texinfo-format-filename
1480 " Node: " node-name "-Footnotes, Up: " node-name "\n")
1481 (setq start (point))
1482 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
1483 (fill-region start (point))))))
1485 (defun texinfo-format-end-node ()
1486 "Format footnote in the End of node style, with notes at end of node."
1487 (let (start
1488 (arg (texinfo-parse-line-arg)))
1489 (texinfo-discard-command) ; remove or insert whitespace, as needed
1490 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
1491 (point))
1492 (insert (format " (%d) " texinfo-footnote-number))
1493 (fill-paragraph nil)
1494 (save-excursion
1495 (if (search-forward "\n--------- Footnotes ---------\n" nil t)
1496 (progn ; already have footnote, put new one before end of node
1497 (if (re-search-forward "^@node" nil 'move)
1498 (forward-line -1))
1499 (setq start (point))
1500 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
1501 (fill-region start (point)))
1502 ;; else no prior footnote
1503 (if (re-search-forward "^@node" nil 'move)
1504 (forward-line -1))
1505 (insert "\n--------- Footnotes ---------\n")
1506 (setq start (point))
1507 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))))))
1510 ;;; @itemize, @enumerate, and similar commands
1512 ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.
1513 ;; @enumerate pushes (enumerate 0 STARTPOS).
1514 ;; @item dispatches to the texinfo-item prop of the first elt of the list.
1515 ;; For itemize, this puts in and rescans the COMMANDS.
1516 ;; For enumerate, this increments the number and puts it in.
1517 ;; In either case, it puts a Backspace at the front of the line
1518 ;; which marks it not to be indented later.
1519 ;; All other lines get indented by 5 when the @end is reached.
1521 (defvar texinfo-stack-depth 0
1522 "Count of number of unpopped texinfo-push-stack calls.
1523 Used by @refill indenting command to avoid indenting within lists, etc.")
1525 (defun texinfo-push-stack (check arg)
1526 (setq texinfo-stack-depth (1+ texinfo-stack-depth))
1527 (setq texinfo-stack
1528 (cons (list check arg texinfo-command-start)
1529 texinfo-stack)))
1531 (defun texinfo-pop-stack (check)
1532 (setq texinfo-stack-depth (1- texinfo-stack-depth))
1533 (if (null texinfo-stack)
1534 (error "Unmatched @end %s" check))
1535 (if (not (eq (car (car texinfo-stack)) check))
1536 (error "@end %s matches @%s"
1537 check (car (car texinfo-stack))))
1538 (prog1 (cdr (car texinfo-stack))
1539 (setq texinfo-stack (cdr texinfo-stack))))
1541 (put 'itemize 'texinfo-format 'texinfo-itemize)
1542 (defun texinfo-itemize ()
1543 (texinfo-push-stack
1544 'itemize
1545 (progn (skip-chars-forward " \t")
1546 (if (eolp)
1547 "@bullet"
1548 (texinfo-parse-line-arg))))
1549 (texinfo-discard-line-with-args)
1550 (setq fill-column (- fill-column 5)))
1552 (put 'itemize 'texinfo-end 'texinfo-end-itemize)
1553 (defun texinfo-end-itemize ()
1554 (setq fill-column (+ fill-column 5))
1555 (texinfo-discard-command)
1556 (let ((stacktop
1557 (texinfo-pop-stack 'itemize)))
1558 (texinfo-do-itemize (nth 1 stacktop))))
1560 (put 'enumerate 'texinfo-format 'texinfo-enumerate)
1561 (defun texinfo-enumerate ()
1562 (texinfo-push-stack
1563 'enumerate
1564 (progn (skip-chars-forward " \t")
1565 (if (eolp)
1567 (read (current-buffer)))))
1568 (if (and (symbolp (car (cdr (car texinfo-stack))))
1569 (> 1 (length (symbol-name (car (cdr (car texinfo-stack)))))))
1570 (error
1571 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." ))
1572 (texinfo-discard-line-with-args)
1573 (setq fill-column (- fill-column 5)))
1575 (put 'enumerate 'texinfo-end 'texinfo-end-enumerate)
1576 (defun texinfo-end-enumerate ()
1577 (setq fill-column (+ fill-column 5))
1578 (texinfo-discard-command)
1579 (let ((stacktop
1580 (texinfo-pop-stack 'enumerate)))
1581 (texinfo-do-itemize (nth 1 stacktop))))
1583 ;; @alphaenumerate never became a standard part of Texinfo
1584 (put 'alphaenumerate 'texinfo-format 'texinfo-alphaenumerate)
1585 (defun texinfo-alphaenumerate ()
1586 (texinfo-push-stack 'alphaenumerate (1- ?a))
1587 (setq fill-column (- fill-column 5))
1588 (texinfo-discard-line))
1590 (put 'alphaenumerate 'texinfo-end 'texinfo-end-alphaenumerate)
1591 (defun texinfo-end-alphaenumerate ()
1592 (setq fill-column (+ fill-column 5))
1593 (texinfo-discard-command)
1594 (let ((stacktop
1595 (texinfo-pop-stack 'alphaenumerate)))
1596 (texinfo-do-itemize (nth 1 stacktop))))
1598 ;; @capsenumerate never became a standard part of Texinfo
1599 (put 'capsenumerate 'texinfo-format 'texinfo-capsenumerate)
1600 (defun texinfo-capsenumerate ()
1601 (texinfo-push-stack 'capsenumerate (1- ?A))
1602 (setq fill-column (- fill-column 5))
1603 (texinfo-discard-line))
1605 (put 'capsenumerate 'texinfo-end 'texinfo-end-capsenumerate)
1606 (defun texinfo-end-capsenumerate ()
1607 (setq fill-column (+ fill-column 5))
1608 (texinfo-discard-command)
1609 (let ((stacktop
1610 (texinfo-pop-stack 'capsenumerate)))
1611 (texinfo-do-itemize (nth 1 stacktop))))
1613 ;; At the @end, indent all the lines within the construct
1614 ;; except those marked with backspace. FROM says where
1615 ;; construct started.
1616 (defun texinfo-do-itemize (from)
1617 (save-excursion
1618 (while (progn (forward-line -1)
1619 (>= (point) from))
1620 (if (= (following-char) ?\b)
1621 (save-excursion
1622 (delete-char 1)
1623 (end-of-line)
1624 (delete-char 6))
1625 (if (not (looking-at "[ \t]*$"))
1626 (save-excursion (insert " ")))))))
1628 (put 'item 'texinfo-format 'texinfo-item)
1629 (put 'itemx 'texinfo-format 'texinfo-item)
1630 (defun texinfo-item ()
1631 (funcall (get (car (car texinfo-stack)) 'texinfo-item)))
1633 (put 'itemize 'texinfo-item 'texinfo-itemize-item)
1634 (defun texinfo-itemize-item ()
1635 ;; (texinfo-discard-line) ; Did not handle text on same line as @item.
1636 (delete-region (1+ (point)) (save-excursion (beginning-of-line) (point)))
1637 (if (looking-at "[ \t]*[^ \t\n]+")
1638 ;; Text on same line as @item command.
1639 (insert "\b " (nth 1 (car texinfo-stack)) " \n")
1640 ;; Else text on next line.
1641 (insert "\b " (nth 1 (car texinfo-stack)) " "))
1642 (forward-line -1))
1644 (put 'enumerate 'texinfo-item 'texinfo-enumerate-item)
1645 (defun texinfo-enumerate-item ()
1646 (texinfo-discard-line)
1647 (let (enumerating-symbol)
1648 (cond ((integerp (car (cdr (car texinfo-stack))))
1649 (setq enumerating-symbol (car (cdr (car texinfo-stack))))
1650 (insert ?\b (format "%3d. " enumerating-symbol) ?\n)
1651 (setcar (cdr (car texinfo-stack)) (1+ enumerating-symbol)))
1652 ((symbolp (car (cdr (car texinfo-stack))))
1653 (setq enumerating-symbol
1654 (symbol-name (car (cdr (car texinfo-stack)))))
1655 (if (or (equal ?\[ (string-to-char enumerating-symbol))
1656 (equal ?\{ (string-to-char enumerating-symbol)))
1657 (error
1658 "Too many items in enumerated list; alphabet ends at Z."))
1659 (insert ?\b (format "%3s. " enumerating-symbol) ?\n)
1660 (setcar (cdr (car texinfo-stack))
1661 (make-symbol
1662 (char-to-string
1663 (1+
1664 (string-to-char enumerating-symbol))))))
1666 (error
1667 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." )))
1668 (forward-line -1)))
1670 (put 'alphaenumerate 'texinfo-item 'texinfo-alphaenumerate-item)
1671 (defun texinfo-alphaenumerate-item ()
1672 (texinfo-discard-line)
1673 (let ((next (1+ (car (cdr (car texinfo-stack))))))
1674 (if (> next ?z)
1675 (error "More than 26 items in @alphaenumerate; get a bigger alphabet"))
1676 (setcar (cdr (car texinfo-stack)) next)
1677 (insert "\b " next ". \n"))
1678 (forward-line -1))
1680 (put 'capsenumerate 'texinfo-item 'texinfo-capsenumerate-item)
1681 (defun texinfo-capsenumerate-item ()
1682 (texinfo-discard-line)
1683 (let ((next (1+ (car (cdr (car texinfo-stack))))))
1684 (if (> next ?Z)
1685 (error "More than 26 items in @capsenumerate; get a bigger alphabet"))
1686 (setcar (cdr (car texinfo-stack)) next)
1687 (insert "\b " next ". \n"))
1688 (forward-line -1))
1691 ;;; @table
1693 ;; The `@table' command produces two-column tables.
1695 (put 'table 'texinfo-format 'texinfo-table)
1696 (defun texinfo-table ()
1697 (texinfo-push-stack
1698 'table
1699 (progn (skip-chars-forward " \t")
1700 (if (eolp)
1701 "@asis"
1702 (texinfo-parse-line-arg))))
1703 (texinfo-discard-line-with-args)
1704 (setq fill-column (- fill-column 5)))
1706 (put 'table 'texinfo-item 'texinfo-table-item)
1707 (defun texinfo-table-item ()
1708 (let ((arg (texinfo-parse-arg-discard))
1709 (itemfont (car (cdr (car texinfo-stack)))))
1710 (insert ?\b itemfont ?\{ arg "}\n \n"))
1711 (forward-line -2))
1713 (put 'table 'texinfo-end 'texinfo-end-table)
1714 (defun texinfo-end-table ()
1715 (setq fill-column (+ fill-column 5))
1716 (texinfo-discard-command)
1717 (let ((stacktop
1718 (texinfo-pop-stack 'table)))
1719 (texinfo-do-itemize (nth 1 stacktop))))
1721 ;; @description appears to be an undocumented variant on @table that
1722 ;; does not require an arg. It fails in texinfo.tex 2.58 and is not
1723 ;; part of makeinfo.c The command appears to be a relic of the past.
1724 (put 'description 'texinfo-end 'texinfo-end-table)
1725 (put 'description 'texinfo-format 'texinfo-description)
1726 (defun texinfo-description ()
1727 (texinfo-push-stack 'table "@asis")
1728 (setq fill-column (- fill-column 5))
1729 (texinfo-discard-line))
1732 ;;; @ftable, @vtable
1734 ;; The `@ftable' and `@vtable' commands are like the `@table' command
1735 ;; but they also insert each entry in the first column of the table
1736 ;; into the function or variable index.
1738 ;; Handle the @ftable and @vtable commands:
1740 (put 'ftable 'texinfo-format 'texinfo-ftable)
1741 (put 'vtable 'texinfo-format 'texinfo-vtable)
1743 (defun texinfo-ftable () (texinfo-indextable 'ftable))
1744 (defun texinfo-vtable () (texinfo-indextable 'vtable))
1746 (defun texinfo-indextable (table-type)
1747 (texinfo-push-stack table-type (texinfo-parse-arg-discard))
1748 (setq fill-column (- fill-column 5)))
1750 ;; Handle the @item commands within ftable and vtable:
1752 (put 'ftable 'texinfo-item 'texinfo-ftable-item)
1753 (put 'vtable 'texinfo-item 'texinfo-vtable-item)
1755 (defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex))
1756 (defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex))
1758 (defun texinfo-indextable-item (index-type)
1759 (let ((item (texinfo-parse-arg-discard))
1760 (itemfont (car (cdr (car texinfo-stack))))
1761 (indexvar index-type))
1762 (insert ?\b itemfont ?\{ item "}\n \n")
1763 (set indexvar
1764 (cons
1765 (list item texinfo-last-node)
1766 (symbol-value indexvar)))
1767 (forward-line -2)))
1769 ;; Handle @end ftable, @end vtable
1771 (put 'ftable 'texinfo-end 'texinfo-end-ftable)
1772 (put 'vtable 'texinfo-end 'texinfo-end-vtable)
1774 (defun texinfo-end-ftable () (texinfo-end-indextable 'ftable))
1775 (defun texinfo-end-vtable () (texinfo-end-indextable 'vtable))
1777 (defun texinfo-end-indextable (table-type)
1778 (setq fill-column (+ fill-column 5))
1779 (texinfo-discard-command)
1780 (let ((stacktop
1781 (texinfo-pop-stack table-type)))
1782 (texinfo-do-itemize (nth 1 stacktop))))
1785 ;;; @multitable ... @end multitable
1787 ;; Produce a multi-column table, with as many columns as desired.
1789 ;; A multi-column table has this template:
1791 ;; @multitable {A1} {A2} {A3}
1792 ;; @item A1 @tab A2 @tab A3
1793 ;; @item B1 @tab B2 @tab B3
1794 ;; @item C1 @tab C2 @tab C3
1795 ;; @end multitable
1797 ;; where the width of the text in brackets specifies the width of the
1798 ;; respective column.
1800 ;; Or else:
1802 ;; @multitable @columnfractions .25 .3 .45
1803 ;; @item A1 @tab A2 @tab A3
1804 ;; @item B1 @tab B2 @tab B3
1805 ;; @end multitable
1807 ;; where the fractions specify the width of each column as a percent
1808 ;; of the current width of the text (i.e., of the fill-column).
1810 ;; Long lines of text are filled within columns.
1812 ;; Using the Emacs Lisp formatter, texinfmt.el,
1813 ;; the whitespace between columns can be increased by setting
1814 ;; `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1815 ;; there is at least one blank space between columns.
1817 ;; The Emacs Lisp formatter, texinfmt.el, ignores the following four
1818 ;; commands that are defined in texinfo.tex for printed output.
1820 ;; @multitableparskip,
1821 ;; @multitableparindent,
1822 ;; @multitablecolmargin,
1823 ;; @multitablelinespace.
1825 ;; How @multitable works.
1826 ;; =====================
1828 ;; `texinfo-multitable' reads the @multitable line and determines from it
1829 ;; how wide each column should be.
1831 ;; Also, it pushes this information, along with an identifying symbol,
1832 ;; onto the `texinfo-stack'. At the @end multitable command, the stack
1833 ;; is checked for its matching @multitable command, and then popped, or
1834 ;; else an error is signaled. Also, this command pushes the location of
1835 ;; the start of the table onto the stack.
1837 ;; `texinfo-end-multitable' checks the `texinfo-stack' that the @end
1838 ;; multitable truly is ending a corresponding beginning, and if it is,
1839 ;; pops the stack.
1841 ;; `texinfo-multitable-widths' is called by `texinfo-multitable'.
1842 ;; The function returns a list of the widths of each column in a
1843 ;; multi-column table, based on the information supplied by the arguments
1844 ;; to the @multitable command (by arguments, I mean the text on the rest
1845 ;; of the @multitable line, not the remainder of the multi-column table
1846 ;; environment).
1848 ;; `texinfo-multitable-item' formats a row within a multicolumn table.
1849 ;; This command is executed when texinfmt sees @item inside @multitable.
1850 ;; Cells in row are separated by `@tab's. Widths of cells are specified
1851 ;; by the arguments in the @multitable line. Cells are filled. All cells
1852 ;; are made to be the same height by padding their bottoms, as needed,
1853 ;; with blanks.
1855 ;; `texinfo-multitable-extract-row' is called by `texinfo-multitable-item'.
1856 ;; This function returns the text in a multitable row, as a string.
1857 ;; The start of a row is marked by an @item and the end of row is the
1858 ;; beginning of next @item or beginning of the @end multitable line.
1859 ;; Cells within a row are separated by @tab.
1861 ;; Note that @tab, the cell separators, are not treated as independent
1862 ;; Texinfo commands.
1864 (defvar texinfo-extra-inter-column-width 0
1865 "*Number of extra spaces between entries (columns) in @multitable.")
1867 (defvar texinfo-multitable-buffer-name "*multitable-temporary-buffer*")
1868 (defvar texinfo-multitable-rectangle-name "texinfo-multitable-temp-")
1870 ;; These commands are defined in texinfo.tex for printed output.
1871 (put 'multitableparskip 'texinfo-format 'texinfo-discard-line-with-args)
1872 (put 'multitableparindent 'texinfo-format 'texinfo-discard-line-with-args)
1873 (put 'multitablecolmargin 'texinfo-format 'texinfo-discard-line-with-args)
1874 (put 'multitablelinespace 'texinfo-format 'texinfo-discard-line-with-args)
1876 (put 'multitable 'texinfo-format 'texinfo-multitable)
1878 (defun texinfo-multitable ()
1879 "Produce multi-column tables.
1881 A multi-column table has this template:
1883 @multitable {A1} {A2} {A3}
1884 @item A1 @tab A2 @tab A3
1885 @item B1 @tab B2 @tab B3
1886 @item C1 @tab C2 @tab C3
1887 @end multitable
1889 where the width of the text in brackets specifies the width of the
1890 respective column.
1892 Or else:
1894 @multitable @columnfractions .25 .3 .45
1895 @item A1 @tab A2 @tab A3
1896 @item B1 @tab B2 @tab B3
1897 @end multitable
1899 where the fractions specify the width of each column as a percent
1900 of the current width of the text (i.e., of the fill-column).
1902 Long lines of text are filled within columns.
1904 Using the Emacs Lisp formatter, texinfmt.el,
1905 the whitespace between columns can be increased by setting
1906 `texinfo-extra-inter-column-width' to a value greater than 0. By default,
1907 there is at least one blank space between columns.
1909 The Emacs Lisp formatter, texinfmt.el, ignores the following four
1910 commands that are defined in texinfo.tex for printed output.
1912 @multitableparskip,
1913 @multitableparindent,
1914 @multitablecolmargin,
1915 @multitablelinespace."
1917 ;; This function pushes information onto the `texinfo-stack'.
1918 ;; A stack element consists of:
1919 ;; - type-of-command, i.e., multitable
1920 ;; - the information about column widths, and
1921 ;; - the position of texinfo-command-start.
1922 ;; e.g., ('multitable (1 2 3 4) 123)
1923 ;; The command line is then deleted.
1924 (texinfo-push-stack
1925 'multitable
1926 ;; push width information on stack
1927 (texinfo-multitable-widths))
1928 (texinfo-discard-line-with-args))
1930 (put 'multitable 'texinfo-end 'texinfo-end-multitable)
1931 (defun texinfo-end-multitable ()
1932 "Discard the @end multitable line and pop the stack of multitable."
1933 (texinfo-discard-command)
1934 (texinfo-pop-stack 'multitable))
1936 (defun texinfo-multitable-widths ()
1937 "Return list of widths of each column in a multi-column table."
1938 (let (texinfo-multitable-width-list)
1939 ;; Fractions format:
1940 ;; @multitable @columnfractions .25 .3 .45
1942 ;; Template format:
1943 ;; @multitable {Column 1 template} {Column 2} {Column 3 example}
1944 ;; Place point before first argument
1945 (skip-chars-forward " \t")
1946 (cond
1947 ;; Check for common misspelling
1948 ((looking-at "@columnfraction ")
1949 (error "In @multitable, @columnfractions misspelled"))
1950 ;; Case 1: @columnfractions .25 .3 .45
1951 ((looking-at "@columnfractions")
1952 (forward-word 1)
1953 (while (not (eolp))
1954 (setq texinfo-multitable-width-list
1955 (cons
1956 (truncate
1958 (* fill-column (read (get-buffer (current-buffer))))))
1959 texinfo-multitable-width-list))))
1961 ;; Case 2: {Column 1 template} {Column 2} {Column 3 example}
1962 ((looking-at "{")
1963 (let ((start-of-templates (point)))
1964 (while (not (eolp))
1965 (skip-chars-forward " \t")
1966 (let* ((start-of-template (1+ (point)))
1967 (end-of-template
1968 ;; forward-sexp works with braces in Texinfo mode
1969 (progn (forward-sexp 1) (1- (point)))))
1970 (setq texinfo-multitable-width-list
1971 (cons (- end-of-template start-of-template)
1972 texinfo-multitable-width-list))
1973 ;; Remove carriage return from within a template, if any.
1974 ;; This helps those those who want to use more than
1975 ;; one line's worth of words in @multitable line.
1976 (narrow-to-region start-of-template end-of-template)
1977 (goto-char (point-min))
1978 (while (search-forward "
1979 " nil t)
1980 (delete-char -1))
1981 (goto-char (point-max))
1982 (widen)
1983 (forward-char 1)))))
1985 ;; Case 3: Trouble
1987 (error
1988 "You probably need to specify column widths for @multitable correctly.")))
1989 ;; Check whether columns fit on page.
1990 (let ((desired-columns
1992 ;; between column spaces
1993 (length texinfo-multitable-width-list)
1994 ;; additional between column spaces, if any
1995 texinfo-extra-inter-column-width
1996 ;; sum of spaces for each entry
1997 (apply '+ texinfo-multitable-width-list))))
1998 (if (> desired-columns fill-column)
1999 (error
2000 (format
2001 "Multi-column table width, %d chars, is greater than page width, %d chars."
2002 desired-columns fill-column))))
2003 texinfo-multitable-width-list))
2005 ;; @item A1 @tab A2 @tab A3
2006 (defun texinfo-multitable-extract-row ()
2007 "Return multitable row, as a string.
2008 End of row is beginning of next @item or beginning of @end.
2009 Cells within rows are separated by @tab."
2010 (skip-chars-forward " \t")
2011 (let* ((start (point))
2012 (end (progn
2013 (re-search-forward "@item\\|@end")
2014 (match-beginning 0)))
2015 (row (progn (goto-char end)
2016 (skip-chars-backward " ")
2017 ;; remove whitespace at end of argument
2018 (delete-region (point) end)
2019 (buffer-substring start (point)))))
2020 (delete-region texinfo-command-start end)
2021 row))
2023 (put 'multitable 'texinfo-item 'texinfo-multitable-item)
2024 (defun texinfo-multitable-item ()
2025 "Format a row within a multicolumn table.
2026 Cells in row are separated by @tab.
2027 Widths of cells are specified by the arguments in the @multitable line.
2028 All cells are made to be the same height.
2029 This command is executed when texinfmt sees @item inside @multitable."
2030 (let ((original-buffer (current-buffer))
2031 (table-widths (reverse (car (cdr (car texinfo-stack)))))
2032 (existing-fill-column fill-column)
2033 start
2035 (table-column 0)
2036 (table-entry-height 0)
2037 ;; unformatted row looks like: A1 @tab A2 @tab A3
2038 ;; extract-row command deletes the source line in the table.
2039 (unformated-row (texinfo-multitable-extract-row)))
2040 ;; Use a temporary buffer
2041 (set-buffer (get-buffer-create texinfo-multitable-buffer-name))
2042 (delete-region (point-min) (point-max))
2043 (insert unformated-row)
2044 (goto-char (point-min))
2045 ;; 1. Check for correct number of @tab in line.
2046 (let ((tab-number 1)) ; one @tab between two columns
2047 (while (search-forward "@tab" nil t)
2048 (setq tab-number (1+ tab-number)))
2049 (if (/= tab-number (length table-widths))
2050 (error "Wrong number of @tab's in a @multitable row")))
2051 (goto-char (point-min))
2052 ;; 2. Format each cell, and copy to a rectangle
2053 ;; buffer looks like this: A1 @tab A2 @tab A3
2054 ;; Cell #1: format up to @tab
2055 ;; Cell #2: format up to @tab
2056 ;; Cell #3: format up to eob
2057 (while (not (eobp))
2058 (setq start (point))
2059 (setq end (save-excursion
2060 (if (search-forward "@tab" nil 'move)
2061 ;; Delete the @tab command, including the @-sign
2062 (delete-region
2063 (point)
2064 (progn (forward-word -1) (1- (point)))))
2065 (point)))
2066 ;; Set fill-column *wider* than needed to produce inter-column space
2067 (setq fill-column (+ 1
2068 texinfo-extra-inter-column-width
2069 (nth table-column table-widths)))
2070 (narrow-to-region start end)
2071 ;; Remove whitespace before and after entry.
2072 (skip-chars-forward " ")
2073 (delete-region (point) (save-excursion (beginning-of-line) (point)))
2074 (goto-char (point-max))
2075 (skip-chars-backward " ")
2076 (delete-region (point) (save-excursion (end-of-line) (point)))
2077 ;; Temorarily set texinfo-stack to nil so texinfo-format-scan
2078 ;; does not see an unterminated @multitable.
2079 (let (texinfo-stack) ; nil
2080 (texinfo-format-scan))
2081 (let (fill-prefix) ; no fill prefix
2082 (fill-region (point-min) (point-max)))
2083 (setq table-entry-height
2084 (max table-entry-height (count-lines (point-min) (point-max))))
2085 ;; 3. Move point to end of bottom line, and pad that line to fill column.
2086 (goto-char (point-min))
2087 (forward-line (1- table-entry-height))
2088 (let* ((beg (point)) ; beginning of line
2089 ;; add one more space for inter-column spacing
2090 (needed-whitespace
2092 (- fill-column
2094 (progn (end-of-line) (point)) ; end of existing line
2095 beg)))))
2096 (insert (make-string
2097 (if (> needed-whitespace 0) needed-whitespace 1)
2098 ? )))
2099 ;; now, put formatted cell into a rectangle
2100 (set (intern (concat texinfo-multitable-rectangle-name
2101 (int-to-string table-column)))
2102 (extract-rectangle (point-min) (point)))
2103 (delete-region (point-min) (point))
2104 (goto-char (point-max))
2105 (setq table-column (1+ table-column))
2106 (widen))
2107 ;; 4. Add extra lines to rectangles so all are of same height
2108 (let ((total-number-of-columns table-column)
2109 (column-number 0)
2110 here)
2111 (while (> table-column 0)
2112 (let ((this-rectangle (int-to-string table-column)))
2113 (while (< (length this-rectangle) table-entry-height)
2114 (setq this-rectangle (append this-rectangle '("")))))
2115 (setq table-column (1- table-column)))
2116 ;; 5. Insert formatted rectangles in original buffer
2117 (switch-to-buffer original-buffer)
2118 (open-line table-entry-height)
2119 (while (< column-number total-number-of-columns)
2120 (setq here (point))
2121 (insert-rectangle
2122 (eval (intern
2123 (concat texinfo-multitable-rectangle-name
2124 (int-to-string column-number)))))
2125 (goto-char here)
2126 (end-of-line)
2127 (setq column-number (1+ column-number))))
2128 (kill-buffer texinfo-multitable-buffer-name)
2129 (setq fill-column existing-fill-column)))
2132 ;;; @ifinfo, @iftex, @tex, @ifhtml, @html, @ifnottex
2134 (put 'ifinfo 'texinfo-format 'texinfo-discard-line)
2135 (put 'ifinfo 'texinfo-end 'texinfo-discard-command)
2137 (put 'iftex 'texinfo-format 'texinfo-format-iftex)
2138 (defun texinfo-format-iftex ()
2139 (delete-region texinfo-command-start
2140 (progn (re-search-forward "@end iftex[ \t]*\n")
2141 (point))))
2143 (put 'ifhtml 'texinfo-format 'texinfo-format-ifhtml)
2144 (defun texinfo-format-ifhtml ()
2145 (delete-region texinfo-command-start
2146 (progn (re-search-forward "@end ifhtml[ \t]*\n")
2147 (point))))
2149 (put 'tex 'texinfo-format 'texinfo-format-tex)
2150 (defun texinfo-format-tex ()
2151 (delete-region texinfo-command-start
2152 (progn (re-search-forward "@end tex[ \t]*\n")
2153 (point))))
2155 (put 'html 'texinfo-format 'texinfo-format-html)
2156 (defun texinfo-format-html ()
2157 (delete-region texinfo-command-start
2158 (progn (re-search-forward "@end html[ \t]*\n")
2159 (point))))
2161 (put 'ifnottex 'texinfo-format 'texinfo-discard-line)
2162 (put 'ifnottex 'texinfo-end 'texinfo-discard-command)
2165 ;;; @titlepage
2167 (put 'titlepage 'texinfo-format 'texinfo-format-titlepage)
2168 (defun texinfo-format-titlepage ()
2169 (delete-region texinfo-command-start
2170 (progn (re-search-forward "@end titlepage[ \t]*\n")
2171 (point))))
2173 (put 'endtitlepage 'texinfo-format 'texinfo-discard-line)
2175 ;; @titlespec an alternative titling command; ignored by Info
2177 (put 'titlespec 'texinfo-format 'texinfo-format-titlespec)
2178 (defun texinfo-format-titlespec ()
2179 (delete-region texinfo-command-start
2180 (progn (re-search-forward "@end titlespec[ \t]*\n")
2181 (point))))
2183 (put 'endtitlespec 'texinfo-format 'texinfo-discard-line)
2186 ;;; @today
2188 (put 'today 'texinfo-format 'texinfo-format-today)
2190 ;; Produces Day Month Year style of output. eg `1 Jan 1900'
2191 ;; The `@today{}' command requires a pair of braces, like `@dots{}'.
2192 (defun texinfo-format-today ()
2193 (texinfo-parse-arg-discard)
2194 (insert (format-time-string "%e %b %Y")))
2197 ;;; @timestamp{}
2198 ;; Produce `Day Month Year Hour:Min' style of output.
2199 ;; eg `1 Jan 1900 13:52'
2201 (put 'timestamp 'texinfo-format 'texinfo-format-timestamp)
2203 ;; The `@timestamp{}' command requires a pair of braces, like `@dots{}'.
2204 (defun texinfo-format-timestamp ()
2205 "Insert the current local time and date."
2206 (texinfo-parse-arg-discard)
2207 ;; For seconds and time zone, replace format string with "%e %b %Y %T %Z"
2208 (insert (format-time-string "%e %b %Y %R")))
2211 ;;; @ignore
2213 (put 'ignore 'texinfo-format 'texinfo-format-ignore)
2214 (defun texinfo-format-ignore ()
2215 (delete-region texinfo-command-start
2216 (progn (re-search-forward "@end ignore[ \t]*\n")
2217 (point))))
2219 (put 'endignore 'texinfo-format 'texinfo-discard-line)
2222 ;;; Define the Info enclosure command: @definfoenclose
2224 ;; A `@definfoenclose' command may be used to define a highlighting
2225 ;; command for Info, but not for TeX. A command defined using
2226 ;; `@definfoenclose' marks text by enclosing it in strings that precede
2227 ;; and follow the text.
2229 ;; Presumably, if you define a command with `@definfoenclose` for Info,
2230 ;; you will also define the same command in the TeX definitions file,
2231 ;; `texinfo.tex' in a manner appropriate for typesetting.
2233 ;; Write a `@definfoenclose' command on a line and follow it with three
2234 ;; arguments separated by commas (commas are used as separators in an
2235 ;; `@node' line in the same way). The first argument to
2236 ;; `@definfoenclose' is the @-command name \(without the `@'\); the
2237 ;; second argument is the Info start delimiter string; and the third
2238 ;; argument is the Info end delimiter string. The latter two arguments
2239 ;; enclose the highlighted text in the Info file. A delimiter string
2240 ;; may contain spaces. Neither the start nor end delimiter is
2241 ;; required. However, if you do not provide a start delimiter, you
2242 ;; must follow the command name with two commas in a row; otherwise,
2243 ;; the Info formatting commands will misinterpret the end delimiter
2244 ;; string as a start delimiter string.
2246 ;; If you do a @definfoenclose{} on the name of a pre-defined macro (such
2247 ;; as @emph{}, @strong{}, @tt{}, or @i{}) the enclosure definition will
2248 ;; override the built-in definition.
2250 ;; An enclosure command defined this way takes one argument in braces.
2252 ;; For example, you can write:
2254 ;; @ifinfo
2255 ;; @definfoenclose phoo, //, \\
2256 ;; @end ifinfo
2258 ;; near the beginning of a Texinfo file at the beginning of the lines
2259 ;; to define `@phoo' as an Info formatting command that inserts `//'
2260 ;; before and `\\' after the argument to `@phoo'. You can then write
2261 ;; `@phoo{bar}' wherever you want `//bar\\' highlighted in Info.
2263 ;; Also, for TeX formatting, you could write
2265 ;; @iftex
2266 ;; @global@let@phoo=@i
2267 ;; @end iftex
2269 ;; to define `@phoo' as a command that causes TeX to typeset
2270 ;; the argument to `@phoo' in italics.
2272 ;; Note that each definition applies to its own formatter: one for TeX,
2273 ;; the other for texinfo-format-buffer or texinfo-format-region.
2275 ;; Here is another example: write
2277 ;; @definfoenclose headword, , :
2279 ;; near the beginning of the file, to define `@headword' as an Info
2280 ;; formatting command that inserts nothing before and a colon after the
2281 ;; argument to `@headword'.
2283 (put 'definfoenclose 'texinfo-format 'texinfo-define-info-enclosure)
2284 (defun texinfo-define-info-enclosure ()
2285 (let* ((args (texinfo-format-parse-line-args))
2286 (command-name (nth 0 args))
2287 (beginning-delimiter (or (nth 1 args) ""))
2288 (end-delimiter (or (nth 2 args) "")))
2289 (texinfo-discard-command)
2290 (setq texinfo-enclosure-list
2291 (cons
2292 (list command-name
2293 (list
2294 beginning-delimiter
2295 end-delimiter))
2296 texinfo-enclosure-list))))
2299 ;;; @alias
2301 (put 'alias 'texinfo-format 'texinfo-alias)
2302 (defun texinfo-alias ()
2303 (let ((start (1- (point)))
2304 args)
2305 (skip-chars-forward " ")
2306 (save-excursion (end-of-line) (setq texinfo-command-end (point)))
2307 (if (not (looking-at "\\([^=]+\\)=\\(.*\\)"))
2308 (error "Invalid alias command")
2309 (setq texinfo-alias-list
2310 (cons
2311 (cons
2312 (buffer-substring (match-beginning 1) (match-end 1))
2313 (buffer-substring (match-beginning 2) (match-end 2)))
2314 texinfo-alias-list))
2315 (texinfo-discard-command))
2320 ;;; @var, @code and the like
2322 (put 'var 'texinfo-format 'texinfo-format-var)
2323 ;; @sc a small caps font for TeX; formatted as `var' in Info
2324 (put 'sc 'texinfo-format 'texinfo-format-var)
2325 ;; @acronym for abbreviations in all caps, such as `NASA'.
2326 ;; Convert all letters to uppercase if they are not already.
2327 (put 'acronym 'texinfo-format 'texinfo-format-var)
2328 (defun texinfo-format-var ()
2329 (let ((arg (texinfo-parse-expanded-arg)))
2330 (texinfo-discard-command)
2331 (insert (upcase arg))))
2333 (put 'cite 'texinfo-format 'texinfo-format-code)
2334 (put 'code 'texinfo-format 'texinfo-format-code)
2335 ;; @command (for command names)
2336 (put 'command 'texinfo-format 'texinfo-format-code)
2337 ;; @env (for environment variables)
2338 (put 'env 'texinfo-format 'texinfo-format-code)
2339 (put 'file 'texinfo-format 'texinfo-format-code)
2340 (put 'samp 'texinfo-format 'texinfo-format-code)
2341 (put 'url 'texinfo-format 'texinfo-format-code)
2342 (defun texinfo-format-code ()
2343 (insert "`" (texinfo-parse-arg-discard) "'")
2344 (goto-char texinfo-command-start))
2346 ;; @option (for command-line options) must be different from @code
2347 ;; because of its special formatting in @table; namely that it does
2348 ;; not lead to inserted ` ... ' in a table, but does elsewhere.
2349 (put 'option 'texinfo-format 'texinfo-format-option)
2350 (defun texinfo-format-option ()
2351 "Insert ` ... ' around arg unless inside a table; in that case, no quotes."
2352 ;; `looking-at-backward' not available in v. 18.57, 20.2
2353 (if (not (search-backward "\b" ; searched-for character is a control-H
2354 (save-excursion (beginning-of-line) (point))
2356 (insert "`" (texinfo-parse-arg-discard) "'")
2357 (insert (texinfo-parse-arg-discard)))
2358 (goto-char texinfo-command-start))
2360 (put 'emph 'texinfo-format 'texinfo-format-emph)
2361 (put 'strong 'texinfo-format 'texinfo-format-emph)
2362 (defun texinfo-format-emph ()
2363 (insert "*" (texinfo-parse-arg-discard) "*")
2364 (goto-char texinfo-command-start))
2366 (put 'dfn 'texinfo-format 'texinfo-format-defn)
2367 (put 'defn 'texinfo-format 'texinfo-format-defn)
2368 (defun texinfo-format-defn ()
2369 (insert "\"" (texinfo-parse-arg-discard) "\"")
2370 (goto-char texinfo-command-start))
2372 (put 'email 'texinfo-format 'texinfo-format-email)
2373 (defun texinfo-format-email ()
2374 "Format email address and optional following full name.
2375 Insert full name, if present, followed by email address
2376 surrounded by in angle brackets."
2377 (let ((args (texinfo-format-parse-args)))
2378 (texinfo-discard-command)
2379 ;; if full-name
2380 (if (nth 1 args)
2381 (insert (nth 1 args) " "))
2382 (insert "<" (nth 0 args) ">")))
2384 (put 'key 'texinfo-format 'texinfo-format-key)
2385 ;; I've decided not want to have angle brackets around these -- rms.
2386 (defun texinfo-format-key ()
2387 (insert (texinfo-parse-arg-discard))
2388 (goto-char texinfo-command-start))
2390 (put 'bullet 'texinfo-format 'texinfo-format-bullet)
2391 (defun texinfo-format-bullet ()
2392 "Insert an asterisk.
2393 If used within a line, follow `@bullet' with braces."
2394 (texinfo-optional-braces-discard)
2395 (insert "*"))
2398 ;;; @kbd
2400 ;; Inside of @example ... @end example and similar environments,
2401 ;; @kbd does nothing; but outside of such environments, it places
2402 ;; single quotation markes around its argument.
2404 (defvar texinfo-format-kbd-regexp
2405 (concat
2406 "^@"
2407 "\\("
2408 "display\\|"
2409 "example\\|"
2410 "smallexample\\|"
2411 "lisp\\|"
2412 "smalllisp"
2413 "\\)")
2414 "Regexp specifying environments in which @kbd does not put `...'
2415 around argument.")
2417 (defvar texinfo-format-kbd-end-regexp
2418 (concat
2419 "^@end "
2420 "\\("
2421 "display\\|"
2422 "example\\|"
2423 "smallexample\\|"
2424 "lisp\\|"
2425 "smalllisp"
2426 "\\)")
2427 "Regexp specifying end of environments in which @kbd does not put `...'
2428 around argument. (See `texinfo-format-kbd-regexp')")
2430 (put 'kbd 'texinfo-format 'texinfo-format-kbd)
2431 (defun texinfo-format-kbd ()
2432 "Place single quote marks around arg, except in @example and similar."
2433 ;; Search forward for @end example closer than an @example.
2434 ;; Can stop search at nearest @node or texinfo-section-types-regexp
2435 (let* ((stop
2436 (save-excursion
2437 (re-search-forward
2438 (concat "^@node\\|\\(" texinfo-section-types-regexp "\\)")
2440 'move-to-end) ; if necessary, return point at end of buffer
2441 (point)))
2442 (example-location
2443 (save-excursion
2444 (re-search-forward texinfo-format-kbd-regexp stop 'move-to-end)
2445 (point)))
2446 (end-example-location
2447 (save-excursion
2448 (re-search-forward texinfo-format-kbd-end-regexp stop 'move-to-end)
2449 (point))))
2450 ;; If inside @example, @end example will be closer than @example
2451 ;; or end of search i.e., end-example-location less than example-location
2452 (if (>= end-example-location example-location)
2453 ;; outside an @example or equivalent
2454 (insert "`" (texinfo-parse-arg-discard) "'")
2455 ;; else, in @example; do not surround with `...'
2456 (insert (texinfo-parse-arg-discard)))
2457 (goto-char texinfo-command-start)))
2460 ;;; @example, @lisp, @quotation, @display, @smalllisp, @smallexample,
2461 ;; @smalldisplay
2463 (put 'display 'texinfo-format 'texinfo-format-example)
2464 (put 'smalldisplay 'texinfo-format 'texinfo-format-example)
2465 (put 'example 'texinfo-format 'texinfo-format-example)
2466 (put 'lisp 'texinfo-format 'texinfo-format-example)
2467 (put 'quotation 'texinfo-format 'texinfo-format-example)
2468 (put 'smallexample 'texinfo-format 'texinfo-format-example)
2469 (put 'smalllisp 'texinfo-format 'texinfo-format-example)
2470 (defun texinfo-format-example ()
2471 (texinfo-push-stack 'example nil)
2472 (setq fill-column (- fill-column 5))
2473 (texinfo-discard-line))
2475 (put 'example 'texinfo-end 'texinfo-end-example)
2476 (put 'display 'texinfo-end 'texinfo-end-example)
2477 (put 'smalldisplay 'texinfo-end 'texinfo-end-example)
2478 (put 'lisp 'texinfo-end 'texinfo-end-example)
2479 (put 'quotation 'texinfo-end 'texinfo-end-example)
2480 (put 'smallexample 'texinfo-end 'texinfo-end-example)
2481 (put 'smalllisp 'texinfo-end 'texinfo-end-example)
2482 (defun texinfo-end-example ()
2483 (setq fill-column (+ fill-column 5))
2484 (texinfo-discard-command)
2485 (let ((stacktop
2486 (texinfo-pop-stack 'example)))
2487 (texinfo-do-itemize (nth 1 stacktop))))
2489 (put 'exdent 'texinfo-format 'texinfo-format-exdent)
2490 (defun texinfo-format-exdent ()
2491 (texinfo-discard-command)
2492 (delete-region (point)
2493 (progn
2494 (skip-chars-forward " ")
2495 (point)))
2496 (insert ?\b)
2497 ;; Cancel out the deletion that texinfo-do-itemize
2498 ;; is going to do at the end of this line.
2499 (save-excursion
2500 (end-of-line)
2501 (insert "\n ")))
2504 ;; @direntry and @dircategory
2506 (put 'direntry 'texinfo-format 'texinfo-format-direntry)
2507 (defun texinfo-format-direntry ()
2508 (texinfo-push-stack 'direntry nil)
2509 (texinfo-discard-line)
2510 (insert "START-INFO-DIR-ENTRY\n"))
2512 (put 'direntry 'texinfo-end 'texinfo-end-direntry)
2513 (defun texinfo-end-direntry ()
2514 (texinfo-discard-command)
2515 (insert "END-INFO-DIR-ENTRY\n\n")
2516 (texinfo-pop-stack 'direntry))
2518 (put 'dircategory 'texinfo-format 'texinfo-format-dircategory)
2519 (defun texinfo-format-dircategory ()
2520 (let ((str (texinfo-parse-arg-discard)))
2521 (delete-region (point)
2522 (progn
2523 (skip-chars-forward " ")
2524 (point)))
2525 (insert "INFO-DIR-SECTION " str "\n")))
2527 ;;; @cartouche
2529 ;; The @cartouche command is a noop in Info; in a printed manual,
2530 ;; it makes a box with rounded corners.
2532 (put 'cartouche 'texinfo-format 'texinfo-discard-line)
2533 (put 'cartouche 'texinfo-end 'texinfo-discard-command)
2536 ;;; @flushleft and @format
2538 ;; The @flushleft command left justifies every line but leaves the
2539 ;; right end ragged. As far as Info is concerned, @flushleft is a
2540 ;; `do-nothing' command
2542 ;; The @format command is similar to @example except that it does not
2543 ;; indent; this means that in Info, @format is similar to @flushleft.
2545 (put 'format 'texinfo-format 'texinfo-format-flushleft)
2546 (put 'smallformat 'texinfo-format 'texinfo-format-flushleft)
2547 (put 'flushleft 'texinfo-format 'texinfo-format-flushleft)
2548 (defun texinfo-format-flushleft ()
2549 (texinfo-discard-line))
2551 (put 'format 'texinfo-end 'texinfo-end-flushleft)
2552 (put 'smallformat 'texinfo-end 'texinfo-end-flushleft)
2553 (put 'flushleft 'texinfo-end 'texinfo-end-flushleft)
2554 (defun texinfo-end-flushleft ()
2555 (texinfo-discard-command))
2558 ;;; @flushright
2560 ;; The @flushright command right justifies every line but leaves the
2561 ;; left end ragged. Spaces and tabs at the right ends of lines are
2562 ;; removed so that visible text lines up on the right side.
2564 (put 'flushright 'texinfo-format 'texinfo-format-flushright)
2565 (defun texinfo-format-flushright ()
2566 (texinfo-push-stack 'flushright nil)
2567 (texinfo-discard-line))
2569 (put 'flushright 'texinfo-end 'texinfo-end-flushright)
2570 (defun texinfo-end-flushright ()
2571 (texinfo-discard-command)
2573 (let ((stacktop
2574 (texinfo-pop-stack 'flushright)))
2576 (texinfo-do-flushright (nth 1 stacktop))))
2578 (defun texinfo-do-flushright (from)
2579 (save-excursion
2580 (while (progn (forward-line -1)
2581 (>= (point) from))
2583 (beginning-of-line)
2584 (insert
2585 (make-string
2586 (- fill-column
2587 (save-excursion
2588 (end-of-line)
2589 (skip-chars-backward " \t")
2590 (delete-region (point) (progn (end-of-line) (point)))
2591 (current-column)))
2592 ? )))))
2595 ;;; @ctrl, @TeX, @copyright, @minus, @dots, @enddots, @pounds
2597 (put 'ctrl 'texinfo-format 'texinfo-format-ctrl)
2598 (defun texinfo-format-ctrl ()
2599 (let ((str (texinfo-parse-arg-discard)))
2600 (insert (logand 31 (aref str 0)))))
2602 (put 'TeX 'texinfo-format 'texinfo-format-TeX)
2603 (defun texinfo-format-TeX ()
2604 (texinfo-parse-arg-discard)
2605 (insert "TeX"))
2607 (put 'copyright 'texinfo-format 'texinfo-format-copyright)
2608 (defun texinfo-format-copyright ()
2609 (texinfo-parse-arg-discard)
2610 (insert "(C)"))
2612 (put 'minus 'texinfo-format 'texinfo-format-minus)
2613 (defun texinfo-format-minus ()
2614 "Insert a minus sign.
2615 If used within a line, follow `@minus' with braces."
2616 (texinfo-optional-braces-discard)
2617 (insert "-"))
2619 (put 'dots 'texinfo-format 'texinfo-format-dots)
2620 (defun texinfo-format-dots ()
2621 (texinfo-parse-arg-discard)
2622 (insert "..."))
2624 (put 'enddots 'texinfo-format 'texinfo-format-enddots)
2625 (defun texinfo-format-enddots ()
2626 (texinfo-parse-arg-discard)
2627 (insert "...."))
2629 (put 'pounds 'texinfo-format 'texinfo-format-pounds)
2630 (defun texinfo-format-pounds ()
2631 (texinfo-parse-arg-discard)
2632 (insert "#"))
2635 ;;; Refilling and indenting: @refill, @paragraphindent, @noindent
2637 ;;; Indent only those paragraphs that are refilled as a result of an
2638 ;;; @refill command.
2640 ;; * If the value is `asis', do not change the existing indentation at
2641 ;; the starts of paragraphs.
2643 ;; * If the value zero, delete any existing indentation.
2645 ;; * If the value is greater than zero, indent each paragraph by that
2646 ;; number of spaces.
2648 ;;; But do not refill paragraphs with an @refill command that are
2649 ;;; preceded by @noindent or are part of a table, list, or deffn.
2651 (defvar texinfo-paragraph-indent "asis"
2652 "Number of spaces for @refill to indent a paragraph; else to leave as is.")
2654 (put 'paragraphindent 'texinfo-format 'texinfo-paragraphindent)
2656 (defun texinfo-paragraphindent ()
2657 "Specify the number of spaces for @refill to indent a paragraph.
2658 Default is to leave the number of spaces as is."
2659 (let ((arg (texinfo-parse-arg-discard)))
2660 (if (string= "asis" arg)
2661 (setq texinfo-paragraph-indent "asis")
2662 (setq texinfo-paragraph-indent (string-to-int arg)))))
2664 (put 'refill 'texinfo-format 'texinfo-format-refill)
2665 (defun texinfo-format-refill ()
2666 "Refill paragraph. Also, indent first line as set by @paragraphindent.
2667 Default is to leave paragraph indentation as is."
2668 (texinfo-discard-command)
2669 (let ((position (point-marker)))
2670 (forward-paragraph -1)
2671 (if (looking-at "[ \t\n]*$") (forward-line 1))
2672 ;; Do not indent if an entry in a list, table, or deffn,
2673 ;; or if paragraph is preceded by @noindent.
2674 ;; Otherwise, indent
2675 (cond
2676 ;; delete a @noindent line and do not indent paragraph
2677 ((save-excursion (forward-line -1)
2678 (looking-at "^@noindent"))
2679 (forward-line -1)
2680 (delete-region (point) (progn (forward-line 1) (point))))
2681 ;; do nothing if "asis"
2682 ((equal texinfo-paragraph-indent "asis"))
2683 ;; do no indenting in list, etc.
2684 ((> texinfo-stack-depth 0))
2685 ;; otherwise delete existing whitespace and indent
2687 (delete-region (point) (progn (skip-chars-forward " \t") (point)))
2688 (insert (make-string texinfo-paragraph-indent ? ))))
2689 (forward-paragraph 1)
2690 (forward-line -1)
2691 (end-of-line)
2692 ;; Do not fill a section title line with asterisks, hyphens, etc. that
2693 ;; are used to underline it. This could occur if the line following
2694 ;; the underlining is not an index entry and has text within it.
2695 (let* ((previous-paragraph-separate paragraph-separate)
2696 (paragraph-separate
2697 (concat paragraph-separate "\\|[-=.]+\\|\\*\\*+"))
2698 (previous-paragraph-start paragraph-start)
2699 (paragraph-start
2700 (concat paragraph-start "\\|[-=.]+\\|\\*\\*+")))
2701 (unwind-protect
2702 (fill-paragraph nil)
2703 (setq paragraph-separate previous-paragraph-separate)
2704 (setq paragraph-start previous-paragraph-start)))
2705 (goto-char position)))
2707 (put 'noindent 'texinfo-format 'texinfo-noindent)
2708 (defun texinfo-noindent ()
2709 (save-excursion
2710 (forward-paragraph 1)
2711 (if (search-backward "@refill"
2712 (save-excursion (forward-line -1) (point)) t)
2713 () ; leave @noindent command so @refill command knows not to indent
2714 ;; else
2715 (texinfo-discard-line))))
2718 ;;; Index generation
2720 (put 'vindex 'texinfo-format 'texinfo-format-vindex)
2721 (defun texinfo-format-vindex ()
2722 (texinfo-index 'texinfo-vindex))
2724 (put 'cindex 'texinfo-format 'texinfo-format-cindex)
2725 (defun texinfo-format-cindex ()
2726 (texinfo-index 'texinfo-cindex))
2728 (put 'findex 'texinfo-format 'texinfo-format-findex)
2729 (defun texinfo-format-findex ()
2730 (texinfo-index 'texinfo-findex))
2732 (put 'pindex 'texinfo-format 'texinfo-format-pindex)
2733 (defun texinfo-format-pindex ()
2734 (texinfo-index 'texinfo-pindex))
2736 (put 'tindex 'texinfo-format 'texinfo-format-tindex)
2737 (defun texinfo-format-tindex ()
2738 (texinfo-index 'texinfo-tindex))
2740 (put 'kindex 'texinfo-format 'texinfo-format-kindex)
2741 (defun texinfo-format-kindex ()
2742 (texinfo-index 'texinfo-kindex))
2744 (defun texinfo-index (indexvar)
2745 (let ((arg (texinfo-parse-expanded-arg)))
2746 (texinfo-discard-command)
2747 (set indexvar
2748 (cons (list arg
2749 texinfo-last-node
2750 ;; Region formatting may not provide last node position.
2751 (if texinfo-last-node-pos
2752 (1+ (count-lines texinfo-last-node-pos (point)))
2754 (symbol-value indexvar)))))
2756 (defconst texinfo-indexvar-alist
2757 '(("cp" . texinfo-cindex)
2758 ("fn" . texinfo-findex)
2759 ("vr" . texinfo-vindex)
2760 ("tp" . texinfo-tindex)
2761 ("pg" . texinfo-pindex)
2762 ("ky" . texinfo-kindex)))
2765 ;;; @defindex @defcodeindex
2766 (put 'defindex 'texinfo-format 'texinfo-format-defindex)
2767 (put 'defcodeindex 'texinfo-format 'texinfo-format-defindex)
2769 (defun texinfo-format-defindex ()
2770 (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa'
2771 (indexing-command (intern (concat index-name "index")))
2772 (index-formatting-command ; eg: `texinfo-format-aaindex'
2773 (intern (concat "texinfo-format-" index-name "index")))
2774 (index-alist-name ; eg: `texinfo-aaindex'
2775 (intern (concat "texinfo-" index-name "index"))))
2777 (set index-alist-name nil)
2779 (put indexing-command ; eg, aaindex
2780 'texinfo-format
2781 index-formatting-command) ; eg, texinfo-format-aaindex
2783 ;; eg: "aa" . texinfo-aaindex
2784 (or (assoc index-name texinfo-indexvar-alist)
2785 (setq texinfo-indexvar-alist
2786 (cons
2787 (cons index-name
2788 index-alist-name)
2789 texinfo-indexvar-alist)))
2791 (fset index-formatting-command
2792 (list 'lambda 'nil
2793 (list 'texinfo-index
2794 (list 'quote index-alist-name))))))
2797 ;;; @synindex @syncodeindex
2799 (put 'synindex 'texinfo-format 'texinfo-format-synindex)
2800 (put 'syncodeindex 'texinfo-format 'texinfo-format-synindex)
2802 (defun texinfo-format-synindex ()
2803 (let* ((args (texinfo-parse-arg-discard))
2804 (second (cdr (read-from-string args)))
2805 (joiner (symbol-name (car (read-from-string args))))
2806 (joined (symbol-name (car (read-from-string args second)))))
2808 (if (assoc joiner texinfo-short-index-cmds-alist)
2809 (put
2810 (cdr (assoc joiner texinfo-short-index-cmds-alist))
2811 'texinfo-format
2812 (or (cdr (assoc joined texinfo-short-index-format-cmds-alist))
2813 (intern (concat "texinfo-format-" joined "index"))))
2814 (put
2815 (intern (concat joiner "index"))
2816 'texinfo-format
2817 (or (cdr(assoc joined texinfo-short-index-format-cmds-alist))
2818 (intern (concat "texinfo-format-" joined "index")))))))
2820 (defconst texinfo-short-index-cmds-alist
2821 '(("cp" . cindex)
2822 ("fn" . findex)
2823 ("vr" . vindex)
2824 ("tp" . tindex)
2825 ("pg" . pindex)
2826 ("ky" . kindex)))
2828 (defconst texinfo-short-index-format-cmds-alist
2829 '(("cp" . texinfo-format-cindex)
2830 ("fn" . texinfo-format-findex)
2831 ("vr" . texinfo-format-vindex)
2832 ("tp" . texinfo-format-tindex)
2833 ("pg" . texinfo-format-pindex)
2834 ("ky" . texinfo-format-kindex)))
2837 ;;; Sort and index (for VMS)
2839 ;; Sort an index which is in the current buffer between START and END.
2840 ;; Used on VMS, where the `sort' utility is not available.
2841 (defun texinfo-sort-region (start end)
2842 (require 'sort)
2843 (save-restriction
2844 (narrow-to-region start end)
2845 (goto-char (point-min))
2846 (sort-subr nil 'forward-line 'end-of-line 'texinfo-sort-startkeyfun)))
2848 ;; Subroutine for sorting an index.
2849 ;; At start of a line, return a string to sort the line under.
2850 (defun texinfo-sort-startkeyfun ()
2851 (let ((line
2852 (buffer-substring (point) (save-excursion (end-of-line) (point)))))
2853 ;; Canonicalize whitespace and eliminate funny chars.
2854 (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line)
2855 (setq line (concat (substring line 0 (match-beginning 0))
2857 (substring line (match-end 0) (length line)))))
2858 line))
2861 ;;; @printindex
2863 (put 'printindex 'texinfo-format 'texinfo-format-printindex)
2865 (defun texinfo-format-printindex ()
2866 (let ((indexelts (symbol-value
2867 (cdr (assoc (texinfo-parse-arg-discard)
2868 texinfo-indexvar-alist))))
2869 opoint)
2870 (insert "\n* Menu:\n\n")
2871 (setq opoint (point))
2872 (texinfo-print-index nil indexelts)
2874 (if (memq system-type '(vax-vms windows-nt ms-dos))
2875 (texinfo-sort-region opoint (point))
2876 (shell-command-on-region opoint (point) "sort -fd" 1))))
2878 (defun texinfo-print-index (file indexelts)
2879 (while indexelts
2880 (if (stringp (car (car indexelts)))
2881 (progn
2882 (insert "* " (car (car indexelts)) ": " )
2883 (indent-to 32)
2884 (insert
2885 (if file (concat "(" file ")") "")
2886 (nth 1 (car indexelts)) ".")
2887 (indent-to 54)
2888 (insert
2889 (if (nth 2 (car indexelts))
2890 (format " %d." (nth 2 (car indexelts)))
2892 "\n"))
2893 ;; index entries from @include'd file
2894 (texinfo-print-index (nth 1 (car indexelts))
2895 (nth 2 (car indexelts))))
2896 (setq indexelts (cdr indexelts))))
2899 ;;; Glyphs: @equiv, @error, etc
2901 ;; @equiv to show that two expressions are equivalent
2902 ;; @error to show an error message
2903 ;; @expansion to show what a macro expands to
2904 ;; @point to show the location of point in an example
2905 ;; @print to show what an evaluated expression prints
2906 ;; @result to indicate the value returned by an expression
2908 (put 'equiv 'texinfo-format 'texinfo-format-equiv)
2909 (defun texinfo-format-equiv ()
2910 (texinfo-parse-arg-discard)
2911 (insert "=="))
2913 (put 'error 'texinfo-format 'texinfo-format-error)
2914 (defun texinfo-format-error ()
2915 (texinfo-parse-arg-discard)
2916 (insert "error-->"))
2918 (put 'expansion 'texinfo-format 'texinfo-format-expansion)
2919 (defun texinfo-format-expansion ()
2920 (texinfo-parse-arg-discard)
2921 (insert "==>"))
2923 (put 'point 'texinfo-format 'texinfo-format-point)
2924 (defun texinfo-format-point ()
2925 (texinfo-parse-arg-discard)
2926 (insert "-!-"))
2928 (put 'print 'texinfo-format 'texinfo-format-print)
2929 (defun texinfo-format-print ()
2930 (texinfo-parse-arg-discard)
2931 (insert "-|"))
2933 (put 'result 'texinfo-format 'texinfo-format-result)
2934 (defun texinfo-format-result ()
2935 (texinfo-parse-arg-discard)
2936 (insert "=>"))
2939 ;;; Accent commands
2941 ;; Info presumes a plain ASCII output, so the accented characters do
2942 ;; not look as they would if typeset, or output with a different
2943 ;; character set.
2945 ;; See the `texinfo-accent-commands' variable
2946 ;; in the section for `texinfo-append-refill'.
2947 ;; Also, see the defun for `texinfo-format-scan'
2948 ;; for single-character accent commands.
2950 ;; Command Info output Name
2952 ;; These do not have braces:
2953 ;; @^ ==> ^ circumflex accent
2954 ;; @` ==> ` grave accent
2955 ;; @' ==> ' acute accent
2956 ;; @" ==> " umlaut accent
2957 ;; @= ==> = overbar accent
2958 ;; @~ ==> ~ tilde accent
2960 ;; These have braces, but take no argument:
2961 ;; @OE{} ==> OE French-OE-ligature
2962 ;; @oe{} ==> oe
2963 ;; @AA{} ==> AA Scandinavian-A-with-circle
2964 ;; @aa{} ==> aa
2965 ;; @AE{} ==> AE Latin-Scandinavian-AE
2966 ;; @ae{} ==> ae
2967 ;; @ss{} ==> ss German-sharp-S
2969 ;; @questiondown{} ==> ? upside-down-question-mark
2970 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
2971 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
2972 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
2973 ;; @O{} ==> O/ Scandinavian O-with-slash
2974 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
2976 ;; These have braces, and take an argument:
2977 ;; @,{c} ==> c, cedilla accent
2978 ;; @dotaccent{o} ==> .o overdot-accent
2979 ;; @ubaraccent{o} ==> _o underbar-accent
2980 ;; @udotaccent{o} ==> o-. underdot-accent
2981 ;; @H{o} ==> ""o long Hungarian umlaut
2982 ;; @ringaccent{o} ==> *o ring accent
2983 ;; @tieaccent{oo} ==> [oo tie after accent
2984 ;; @u{o} ==> (o breve accent
2985 ;; @v{o} ==> <o hacek accent
2986 ;; @dotless{i} ==> i dotless i and dotless j
2988 ;; ==========
2990 ;; Note: The defun texinfo-format-scan
2991 ;; looks at "[@{}^'`\",=~ *?!-]"
2992 ;; In the case of @*, a line break is inserted;
2993 ;; in the other cases, the characters are simply quoted and the @ is deleted.
2994 ;; Thus, `texinfo-format-scan' handles the following
2995 ;; single-character accent commands: @^ @` @' @" @, @- @= @~
2997 ;; @^ ==> ^ circumflex accent
2998 ;; (put '^ 'texinfo-format 'texinfo-format-circumflex-accent)
2999 ;; (defun texinfo-format-circumflex-accent ()
3000 ;; (texinfo-discard-command)
3001 ;; (insert "^"))
3003 ;; @` ==> ` grave accent
3004 ;; (put '\` 'texinfo-format 'texinfo-format-grave-accent)
3005 ;; (defun texinfo-format-grave-accent ()
3006 ;; (texinfo-discard-command)
3007 ;; (insert "\`"))
3009 ;; @' ==> ' acute accent
3010 ;; (put '\' 'texinfo-format 'texinfo-format-acute-accent)
3011 ;; (defun texinfo-format-acute-accent ()
3012 ;; (texinfo-discard-command)
3013 ;; (insert "'"))
3015 ;; @" ==> " umlaut accent
3016 ;; (put '\" 'texinfo-format 'texinfo-format-umlaut-accent)
3017 ;; (defun texinfo-format-umlaut-accent ()
3018 ;; (texinfo-discard-command)
3019 ;; (insert "\""))
3021 ;; @= ==> = overbar accent
3022 ;; (put '= 'texinfo-format 'texinfo-format-overbar-accent)
3023 ;; (defun texinfo-format-overbar-accent ()
3024 ;; (texinfo-discard-command)
3025 ;; (insert "="))
3027 ;; @~ ==> ~ tilde accent
3028 ;; (put '~ 'texinfo-format 'texinfo-format-tilde-accent)
3029 ;; (defun texinfo-format-tilde-accent ()
3030 ;; (texinfo-discard-command)
3031 ;; (insert "~"))
3033 ;; @OE{} ==> OE French-OE-ligature
3034 (put 'OE 'texinfo-format 'texinfo-format-French-OE-ligature)
3035 (defun texinfo-format-French-OE-ligature ()
3036 (insert "OE" (texinfo-parse-arg-discard))
3037 (goto-char texinfo-command-start))
3039 ;; @oe{} ==> oe
3040 (put 'oe 'texinfo-format 'texinfo-format-French-oe-ligature)
3041 (defun texinfo-format-French-oe-ligature () ; lower case
3042 (insert "oe" (texinfo-parse-arg-discard))
3043 (goto-char texinfo-command-start))
3045 ;; @AA{} ==> AA Scandinavian-A-with-circle
3046 (put 'AA 'texinfo-format 'texinfo-format-Scandinavian-A-with-circle)
3047 (defun texinfo-format-Scandinavian-A-with-circle ()
3048 (insert "AA" (texinfo-parse-arg-discard))
3049 (goto-char texinfo-command-start))
3051 ;; @aa{} ==> aa
3052 (put 'aa 'texinfo-format 'texinfo-format-Scandinavian-a-with-circle)
3053 (defun texinfo-format-Scandinavian-a-with-circle () ; lower case
3054 (insert "aa" (texinfo-parse-arg-discard))
3055 (goto-char texinfo-command-start))
3057 ;; @AE{} ==> AE Latin-Scandinavian-AE
3058 (put 'AE 'texinfo-format 'texinfo-format-Latin-Scandinavian-AE)
3059 (defun texinfo-format-Latin-Scandinavian-AE ()
3060 (insert "AE" (texinfo-parse-arg-discard))
3061 (goto-char texinfo-command-start))
3063 ;; @ae{} ==> ae
3064 (put 'ae 'texinfo-format 'texinfo-format-Latin-Scandinavian-ae)
3065 (defun texinfo-format-Latin-Scandinavian-ae () ; lower case
3066 (insert "ae" (texinfo-parse-arg-discard))
3067 (goto-char texinfo-command-start))
3069 ;; @ss{} ==> ss German-sharp-S
3070 (put 'ss 'texinfo-format 'texinfo-format-German-sharp-S)
3071 (defun texinfo-format-German-sharp-S ()
3072 (insert "ss" (texinfo-parse-arg-discard))
3073 (goto-char texinfo-command-start))
3075 ;; @questiondown{} ==> ? upside-down-question-mark
3076 (put 'questiondown 'texinfo-format 'texinfo-format-upside-down-question-mark)
3077 (defun texinfo-format-upside-down-question-mark ()
3078 (insert "?" (texinfo-parse-arg-discard))
3079 (goto-char texinfo-command-start))
3081 ;; @exclamdown{} ==> ! upside-down-exclamation-mark
3082 (put 'exclamdown 'texinfo-format 'texinfo-format-upside-down-exclamation-mark)
3083 (defun texinfo-format-upside-down-exclamation-mark ()
3084 (insert "!" (texinfo-parse-arg-discard))
3085 (goto-char texinfo-command-start))
3087 ;; @L{} ==> L/ Polish suppressed-L (Lslash)
3088 (put 'L 'texinfo-format 'texinfo-format-Polish-suppressed-L)
3089 (defun texinfo-format-Polish-suppressed-L ()
3090 (insert (texinfo-parse-arg-discard) "/L")
3091 (goto-char texinfo-command-start))
3093 ;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case)
3094 (put 'l 'texinfo-format 'texinfo-format-Polish-suppressed-l-lower-case)
3095 (defun texinfo-format-Polish-suppressed-l-lower-case ()
3096 (insert (texinfo-parse-arg-discard) "/l")
3097 (goto-char texinfo-command-start))
3100 ;; @O{} ==> O/ Scandinavian O-with-slash
3101 (put 'O 'texinfo-format 'texinfo-format-Scandinavian-O-with-slash)
3102 (defun texinfo-format-Scandinavian-O-with-slash ()
3103 (insert (texinfo-parse-arg-discard) "O/")
3104 (goto-char texinfo-command-start))
3106 ;; @o{} ==> o/ Scandinavian O-with-slash (lower case)
3107 (put 'o 'texinfo-format 'texinfo-format-Scandinavian-o-with-slash-lower-case)
3108 (defun texinfo-format-Scandinavian-o-with-slash-lower-case ()
3109 (insert (texinfo-parse-arg-discard) "o/")
3110 (goto-char texinfo-command-start))
3112 ;; Take arguments
3114 ;; @,{c} ==> c, cedilla accent
3115 (put ', 'texinfo-format 'texinfo-format-cedilla-accent)
3116 (defun texinfo-format-cedilla-accent ()
3117 (insert (texinfo-parse-arg-discard) ",")
3118 (goto-char texinfo-command-start))
3121 ;; @dotaccent{o} ==> .o overdot-accent
3122 (put 'dotaccent 'texinfo-format 'texinfo-format-overdot-accent)
3123 (defun texinfo-format-overdot-accent ()
3124 (insert "." (texinfo-parse-arg-discard))
3125 (goto-char texinfo-command-start))
3127 ;; @ubaraccent{o} ==> _o underbar-accent
3128 (put 'ubaraccent 'texinfo-format 'texinfo-format-underbar-accent)
3129 (defun texinfo-format-underbar-accent ()
3130 (insert "_" (texinfo-parse-arg-discard))
3131 (goto-char texinfo-command-start))
3133 ;; @udotaccent{o} ==> o-. underdot-accent
3134 (put 'udotaccent 'texinfo-format 'texinfo-format-underdot-accent)
3135 (defun texinfo-format-underdot-accent ()
3136 (insert (texinfo-parse-arg-discard) "-.")
3137 (goto-char texinfo-command-start))
3139 ;; @H{o} ==> ""o long Hungarian umlaut
3140 (put 'H 'texinfo-format 'texinfo-format-long-Hungarian-umlaut)
3141 (defun texinfo-format-long-Hungarian-umlaut ()
3142 (insert "\"\"" (texinfo-parse-arg-discard))
3143 (goto-char texinfo-command-start))
3145 ;; @ringaccent{o} ==> *o ring accent
3146 (put 'ringaccent 'texinfo-format 'texinfo-format-ring-accent)
3147 (defun texinfo-format-ring-accent ()
3148 (insert "*" (texinfo-parse-arg-discard))
3149 (goto-char texinfo-command-start))
3151 ;; @tieaccent{oo} ==> [oo tie after accent
3152 (put 'tieaccent 'texinfo-format 'texinfo-format-tie-after-accent)
3153 (defun texinfo-format-tie-after-accent ()
3154 (insert "[" (texinfo-parse-arg-discard))
3155 (goto-char texinfo-command-start))
3158 ;; @u{o} ==> (o breve accent
3159 (put 'u 'texinfo-format 'texinfo-format-breve-accent)
3160 (defun texinfo-format-breve-accent ()
3161 (insert "(" (texinfo-parse-arg-discard))
3162 (goto-char texinfo-command-start))
3164 ;; @v{o} ==> <o hacek accent
3165 (put 'v 'texinfo-format 'texinfo-format-hacek-accent)
3166 (defun texinfo-format-hacek-accent ()
3167 (insert "<" (texinfo-parse-arg-discard))
3168 (goto-char texinfo-command-start))
3171 ;; @dotless{i} ==> i dotless i and dotless j
3172 (put 'dotless 'texinfo-format 'texinfo-format-dotless)
3173 (defun texinfo-format-dotless ()
3174 (insert (texinfo-parse-arg-discard))
3175 (goto-char texinfo-command-start))
3178 ;;; Definition formatting: @deffn, @defun, etc
3180 ;; What definition formatting produces:
3182 ;; @deffn category name args...
3183 ;; In Info, `Category: name ARGS'
3184 ;; In index: name: node. line#.
3186 ;; @defvr category name
3187 ;; In Info, `Category: name'
3188 ;; In index: name: node. line#.
3190 ;; @deftp category name attributes...
3191 ;; `category name attributes...' Note: @deftp args in lower case.
3192 ;; In index: name: node. line#.
3194 ;; Specialized function-like or variable-like entity:
3196 ;; @defun, @defmac, @defspec, @defvar, @defopt
3198 ;; @defun name args In Info, `Function: name ARGS'
3199 ;; @defmac name args In Info, `Macro: name ARGS'
3200 ;; @defvar name In Info, `Variable: name'
3201 ;; etc.
3202 ;; In index: name: node. line#.
3204 ;; Generalized typed-function-like or typed-variable-like entity:
3205 ;; @deftypefn category data-type name args...
3206 ;; In Info, `Category: data-type name args...'
3207 ;; @deftypevr category data-type name
3208 ;; In Info, `Category: data-type name'
3209 ;; In index: name: node. line#.
3211 ;; Specialized typed-function-like or typed-variable-like entity:
3212 ;; @deftypefun data-type name args...
3213 ;; In Info, `Function: data-type name ARGS'
3214 ;; In index: name: node. line#.
3216 ;; @deftypevar data-type name
3217 ;; In Info, `Variable: data-type name'
3218 ;; In index: name: node. line#. but include args after name!?
3220 ;; Generalized object oriented entity:
3221 ;; @defop category class name args...
3222 ;; In Info, `Category on class: name ARG'
3223 ;; In index: name on class: node. line#.
3225 ;; @defcv category class name
3226 ;; In Info, `Category of class: name'
3227 ;; In index: name of class: node. line#.
3229 ;; Specialized object oriented entity:
3230 ;; @defmethod class name args...
3231 ;; In Info, `Method on class: name ARGS'
3232 ;; In index: name on class: node. line#.
3234 ;; @defivar class name
3235 ;; In Info, `Instance variable of class: name'
3236 ;; In index: name of class: node. line#.
3239 ;;; The definition formatting functions
3241 (defun texinfo-format-defun ()
3242 (texinfo-push-stack 'defun nil)
3243 (setq fill-column (- fill-column 5))
3244 (texinfo-format-defun-1 t))
3246 (defun texinfo-end-defun ()
3247 (setq fill-column (+ fill-column 5))
3248 (texinfo-discard-command)
3249 (let ((start (nth 1 (texinfo-pop-stack 'defun))))
3250 (texinfo-do-itemize start)
3251 ;; Delete extra newline inserted after header.
3252 (save-excursion
3253 (goto-char start)
3254 (delete-char -1))))
3256 (defun texinfo-format-defunx ()
3257 (texinfo-format-defun-1 nil))
3259 (defun texinfo-format-defun-1 (first-p)
3260 (let ((parse-args (texinfo-format-parse-defun-args))
3261 (texinfo-defun-type (get texinfo-command-name 'texinfo-defun-type)))
3262 (texinfo-discard-command)
3263 ;; Delete extra newline inserted after previous header line.
3264 (if (not first-p)
3265 (delete-char -1))
3266 (funcall
3267 (get texinfo-command-name 'texinfo-deffn-formatting-property) parse-args)
3268 ;; Insert extra newline so that paragraph filling does not mess
3269 ;; with header line.
3270 (insert "\n\n")
3271 (rplaca (cdr (cdr (car texinfo-stack))) (point))
3272 (funcall
3273 (get texinfo-command-name 'texinfo-defun-indexing-property) parse-args)))
3275 ;;; Formatting the first line of a definition
3277 ;; @deffn, @defvr, @deftp
3278 (put 'deffn 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3279 (put 'deffnx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3280 (put 'defvr 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3281 (put 'defvrx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3282 (put 'deftp 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3283 (put 'deftpx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
3284 (defun texinfo-format-deffn (parsed-args)
3285 ;; Generalized function-like, variable-like, or generic data-type entity:
3286 ;; @deffn category name args...
3287 ;; In Info, `Category: name ARGS'
3288 ;; @deftp category name attributes...
3289 ;; `category name attributes...' Note: @deftp args in lower case.
3290 (let ((category (car parsed-args))
3291 (name (car (cdr parsed-args)))
3292 (args (cdr (cdr parsed-args))))
3293 (insert " -- " category ": " name)
3294 (while args
3295 (insert " "
3296 (if (or (= ?& (aref (car args) 0))
3297 (eq (eval (car texinfo-defun-type)) 'deftp-type))
3298 (car args)
3299 (upcase (car args))))
3300 (setq args (cdr args)))))
3302 ;; @defun, @defmac, @defspec, @defvar, @defopt: Specialized, simple
3303 (put 'defun 'texinfo-deffn-formatting-property
3304 'texinfo-format-specialized-defun)
3305 (put 'defunx 'texinfo-deffn-formatting-property
3306 'texinfo-format-specialized-defun)
3307 (put 'defmac 'texinfo-deffn-formatting-property
3308 'texinfo-format-specialized-defun)
3309 (put 'defmacx 'texinfo-deffn-formatting-property
3310 'texinfo-format-specialized-defun)
3311 (put 'defspec 'texinfo-deffn-formatting-property
3312 'texinfo-format-specialized-defun)
3313 (put 'defspecx 'texinfo-deffn-formatting-property
3314 'texinfo-format-specialized-defun)
3315 (put 'defvar 'texinfo-deffn-formatting-property
3316 'texinfo-format-specialized-defun)
3317 (put 'defvarx 'texinfo-deffn-formatting-property
3318 'texinfo-format-specialized-defun)
3319 (put 'defopt 'texinfo-deffn-formatting-property
3320 'texinfo-format-specialized-defun)
3321 (put 'defoptx 'texinfo-deffn-formatting-property
3322 'texinfo-format-specialized-defun)
3323 (defun texinfo-format-specialized-defun (parsed-args)
3324 ;; Specialized function-like or variable-like entity:
3325 ;; @defun name args In Info, `Function: Name ARGS'
3326 ;; @defmac name args In Info, `Macro: Name ARGS'
3327 ;; @defvar name In Info, `Variable: Name'
3328 ;; Use cdr of texinfo-defun-type to determine category:
3329 (let ((category (car (cdr texinfo-defun-type)))
3330 (name (car parsed-args))
3331 (args (cdr parsed-args)))
3332 (insert " -- " category ": " name)
3333 (while args
3334 (insert " "
3335 (if (= ?& (aref (car args) 0))
3336 (car args)
3337 (upcase (car args))))
3338 (setq args (cdr args)))))
3340 ;; @deftypefn, @deftypevr: Generalized typed
3341 (put 'deftypefn 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
3342 (put 'deftypefnx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
3343 (put 'deftypevr 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
3344 (put 'deftypevrx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
3345 (defun texinfo-format-deftypefn (parsed-args)
3346 ;; Generalized typed-function-like or typed-variable-like entity:
3347 ;; @deftypefn category data-type name args...
3348 ;; In Info, `Category: data-type name args...'
3349 ;; @deftypevr category data-type name
3350 ;; In Info, `Category: data-type name'
3351 ;; Note: args in lower case, unless modified in command line.
3352 (let ((category (car parsed-args))
3353 (data-type (car (cdr parsed-args)))
3354 (name (car (cdr (cdr parsed-args))))
3355 (args (cdr (cdr (cdr parsed-args)))))
3356 (insert " -- " category ": " data-type " " name)
3357 (while args
3358 (insert " " (car args))
3359 (setq args (cdr args)))))
3361 ;; @deftypefun, @deftypevar: Specialized typed
3362 (put 'deftypefun 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun)
3363 (put 'deftypefunx 'texinfo-deffn-formatting-property
3364 'texinfo-format-deftypefun)
3365 (put 'deftypevar 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun)
3366 (put 'deftypevarx 'texinfo-deffn-formatting-property
3367 'texinfo-format-deftypefun)
3368 (defun texinfo-format-deftypefun (parsed-args)
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 ;; @deftypevar data-type name
3373 ;; In Info, `Variable: data-type name'
3374 ;; Note: args in lower case, unless modified in command line.
3375 ;; Use cdr of texinfo-defun-type to determine category:
3376 (let ((category (car (cdr texinfo-defun-type)))
3377 (data-type (car parsed-args))
3378 (name (car (cdr parsed-args)))
3379 (args (cdr (cdr parsed-args))))
3380 (insert " -- " category ": " data-type " " name)
3381 (while args
3382 (insert " " (car args))
3383 (setq args (cdr args)))))
3385 ;; @defop: Generalized object-oriented
3386 (put 'defop 'texinfo-deffn-formatting-property 'texinfo-format-defop)
3387 (put 'defopx 'texinfo-deffn-formatting-property 'texinfo-format-defop)
3388 (defun texinfo-format-defop (parsed-args)
3389 ;; Generalized object oriented entity:
3390 ;; @defop category class name args...
3391 ;; In Info, `Category on class: name ARG'
3392 ;; Note: args in upper case; use of `on'
3393 (let ((category (car parsed-args))
3394 (class (car (cdr parsed-args)))
3395 (name (car (cdr (cdr parsed-args))))
3396 (args (cdr (cdr (cdr parsed-args)))))
3397 (insert " -- " category " on " class ": " name)
3398 (while args
3399 (insert " " (upcase (car args)))
3400 (setq args (cdr args)))))
3402 ;; @defcv: Generalized object-oriented
3403 (put 'defcv 'texinfo-deffn-formatting-property 'texinfo-format-defcv)
3404 (put 'defcvx 'texinfo-deffn-formatting-property 'texinfo-format-defcv)
3405 (defun texinfo-format-defcv (parsed-args)
3406 ;; Generalized object oriented entity:
3407 ;; @defcv category class name
3408 ;; In Info, `Category of class: name'
3409 ;; Note: args in upper case; use of `of'
3410 (let ((category (car parsed-args))
3411 (class (car (cdr parsed-args)))
3412 (name (car (cdr (cdr parsed-args))))
3413 (args (cdr (cdr (cdr parsed-args)))))
3414 (insert " -- " category " of " class ": " name)
3415 (while args
3416 (insert " " (upcase (car args)))
3417 (setq args (cdr args)))))
3419 ;; @defmethod: Specialized object-oriented
3420 (put 'defmethod 'texinfo-deffn-formatting-property 'texinfo-format-defmethod)
3421 (put 'defmethodx 'texinfo-deffn-formatting-property 'texinfo-format-defmethod)
3422 (defun texinfo-format-defmethod (parsed-args)
3423 ;; Specialized object oriented entity:
3424 ;; @defmethod class name args...
3425 ;; In Info, `Method on class: name ARGS'
3426 ;; Note: args in upper case; use of `on'
3427 ;; Use cdr of texinfo-defun-type to determine category:
3428 (let ((category (car (cdr texinfo-defun-type)))
3429 (class (car parsed-args))
3430 (name (car (cdr parsed-args)))
3431 (args (cdr (cdr parsed-args))))
3432 (insert " -- " category " on " class ": " name)
3433 (while args
3434 (insert " " (upcase (car args)))
3435 (setq args (cdr args)))))
3437 ;; @defivar: Specialized object-oriented
3438 (put 'defivar 'texinfo-deffn-formatting-property 'texinfo-format-defivar)
3439 (put 'defivarx 'texinfo-deffn-formatting-property 'texinfo-format-defivar)
3440 (defun texinfo-format-defivar (parsed-args)
3441 ;; Specialized object oriented entity:
3442 ;; @defivar class name
3443 ;; In Info, `Instance variable of class: name'
3444 ;; Note: args in upper case; use of `of'
3445 ;; Use cdr of texinfo-defun-type to determine category:
3446 (let ((category (car (cdr texinfo-defun-type)))
3447 (class (car parsed-args))
3448 (name (car (cdr parsed-args)))
3449 (args (cdr (cdr parsed-args))))
3450 (insert " -- " category " of " class ": " name)
3451 (while args
3452 (insert " " (upcase (car args)))
3453 (setq args (cdr args)))))
3456 ;;; Indexing for definitions
3458 ;; An index entry has three parts: the `entry proper', the node name, and the
3459 ;; line number. Depending on the which command is used, the entry is
3460 ;; formatted differently:
3462 ;; @defun,
3463 ;; @defmac,
3464 ;; @defspec,
3465 ;; @defvar,
3466 ;; @defopt all use their 1st argument as the entry-proper
3468 ;; @deffn,
3469 ;; @defvr,
3470 ;; @deftp
3471 ;; @deftypefun
3472 ;; @deftypevar all use their 2nd argument as the entry-proper
3474 ;; @deftypefn,
3475 ;; @deftypevr both use their 3rd argument as the entry-proper
3477 ;; @defmethod uses its 2nd and 1st arguments as an entry-proper
3478 ;; formatted: NAME on CLASS
3480 ;; @defop uses its 3rd and 2nd arguments as an entry-proper
3481 ;; formatted: NAME on CLASS
3483 ;; @defivar uses its 2nd and 1st arguments as an entry-proper
3484 ;; formatted: NAME of CLASS
3486 ;; @defcv uses its 3rd and 2nd argument as an entry-proper
3487 ;; formatted: NAME of CLASS
3489 (put 'defun 'texinfo-defun-indexing-property 'texinfo-index-defun)
3490 (put 'defunx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3491 (put 'defmac 'texinfo-defun-indexing-property 'texinfo-index-defun)
3492 (put 'defmacx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3493 (put 'defspec 'texinfo-defun-indexing-property 'texinfo-index-defun)
3494 (put 'defspecx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3495 (put 'defvar 'texinfo-defun-indexing-property 'texinfo-index-defun)
3496 (put 'defvarx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3497 (put 'defopt 'texinfo-defun-indexing-property 'texinfo-index-defun)
3498 (put 'defoptx 'texinfo-defun-indexing-property 'texinfo-index-defun)
3499 (defun texinfo-index-defun (parsed-args)
3500 ;; use 1st parsed-arg as entry-proper
3501 ;; `index-list' will be texinfo-findex or the like
3502 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3503 (set index-list
3504 (cons
3505 ;; Three elements: entry-proper, node-name, line-number
3506 (list
3507 (car parsed-args)
3508 texinfo-last-node
3509 ;; Region formatting may not provide last node position.
3510 (if texinfo-last-node-pos
3511 (1+ (count-lines texinfo-last-node-pos (point)))
3513 (symbol-value index-list)))))
3515 (put 'deffn 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3516 (put 'deffnx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3517 (put 'defvr 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3518 (put 'defvrx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3519 (put 'deftp 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3520 (put 'deftpx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3521 (put 'deftypefun 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3522 (put 'deftypefunx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3523 (put 'deftypevar 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3524 (put 'deftypevarx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
3525 (defun texinfo-index-deffn (parsed-args)
3526 ;; use 2nd parsed-arg as entry-proper
3527 ;; `index-list' will be texinfo-findex or the like
3528 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3529 (set index-list
3530 (cons
3531 ;; Three elements: entry-proper, node-name, line-number
3532 (list
3533 (car (cdr parsed-args))
3534 texinfo-last-node
3535 ;; Region formatting may not provide last node position.
3536 (if texinfo-last-node-pos
3537 (1+ (count-lines texinfo-last-node-pos (point)))
3539 (symbol-value index-list)))))
3541 (put 'deftypefn 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
3542 (put 'deftypefnx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
3543 (put 'deftypevr 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
3544 (put 'deftypevrx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
3545 (defun texinfo-index-deftypefn (parsed-args)
3546 ;; use 3rd parsed-arg as entry-proper
3547 ;; `index-list' will be texinfo-findex or the like
3548 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3549 (set index-list
3550 (cons
3551 ;; Three elements: entry-proper, node-name, line-number
3552 (list
3553 (car (cdr (cdr parsed-args)))
3554 texinfo-last-node
3555 ;; Region formatting may not provide last node position.
3556 (if texinfo-last-node-pos
3557 (1+ (count-lines texinfo-last-node-pos (point)))
3559 (symbol-value index-list)))))
3561 (put 'defmethod 'texinfo-defun-indexing-property 'texinfo-index-defmethod)
3562 (put 'defmethodx 'texinfo-defun-indexing-property 'texinfo-index-defmethod)
3563 (defun texinfo-index-defmethod (parsed-args)
3564 ;; use 2nd on 1st parsed-arg as entry-proper
3565 ;; `index-list' will be texinfo-findex or the like
3566 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3567 (set index-list
3568 (cons
3569 ;; Three elements: entry-proper, node-name, line-number
3570 (list
3571 (format "%s on %s"
3572 (car (cdr parsed-args))
3573 (car parsed-args))
3574 texinfo-last-node
3575 ;; Region formatting may not provide last node position.
3576 (if texinfo-last-node-pos
3577 (1+ (count-lines texinfo-last-node-pos (point)))
3579 (symbol-value index-list)))))
3581 (put 'defop 'texinfo-defun-indexing-property 'texinfo-index-defop)
3582 (put 'defopx 'texinfo-defun-indexing-property 'texinfo-index-defop)
3583 (defun texinfo-index-defop (parsed-args)
3584 ;; use 3rd on 2nd parsed-arg as entry-proper
3585 ;; `index-list' will be texinfo-findex or the like
3586 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3587 (set index-list
3588 (cons
3589 ;; Three elements: entry-proper, node-name, line-number
3590 (list
3591 (format "%s on %s"
3592 (car (cdr (cdr parsed-args)))
3593 (car (cdr parsed-args)))
3594 texinfo-last-node
3595 ;; Region formatting may not provide last node position.
3596 (if texinfo-last-node-pos
3597 (1+ (count-lines texinfo-last-node-pos (point)))
3599 (symbol-value index-list)))))
3601 (put 'defivar 'texinfo-defun-indexing-property 'texinfo-index-defivar)
3602 (put 'defivarx 'texinfo-defun-indexing-property 'texinfo-index-defivar)
3603 (defun texinfo-index-defivar (parsed-args)
3604 ;; use 2nd of 1st parsed-arg as entry-proper
3605 ;; `index-list' will be texinfo-findex or the like
3606 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3607 (set index-list
3608 (cons
3609 ;; Three elements: entry-proper, node-name, line-number
3610 (list
3611 (format "%s of %s"
3612 (car (cdr parsed-args))
3613 (car parsed-args))
3614 texinfo-last-node
3615 ;; Region formatting may not provide last node position.
3616 (if texinfo-last-node-pos
3617 (1+ (count-lines texinfo-last-node-pos (point)))
3619 (symbol-value index-list)))))
3621 (put 'defcv 'texinfo-defun-indexing-property 'texinfo-index-defcv)
3622 (put 'defcvx 'texinfo-defun-indexing-property 'texinfo-index-defcv)
3623 (defun texinfo-index-defcv (parsed-args)
3624 ;; use 3rd of 2nd parsed-arg as entry-proper
3625 ;; `index-list' will be texinfo-findex or the like
3626 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
3627 (set index-list
3628 (cons
3629 ;; Three elements: entry-proper, node-name, line-number
3630 (list
3631 (format "%s of %s"
3632 (car (cdr (cdr parsed-args)))
3633 (car (cdr parsed-args)))
3634 texinfo-last-node
3635 ;; Region formatting may not provide last node position.
3636 (if texinfo-last-node-pos
3637 (1+ (count-lines texinfo-last-node-pos (point)))
3639 (symbol-value index-list)))))
3642 ;;; Properties for definitions
3644 ;; Each definition command has six properties:
3646 ;; 1. texinfo-deffn-formatting-property to format definition line
3647 ;; 2. texinfo-defun-indexing-property to create index entry
3648 ;; 3. texinfo-format formatting command
3649 ;; 4. texinfo-end end formatting command
3650 ;; 5. texinfo-defun-type type of deffn to format
3651 ;; 6. texinfo-defun-index type of index to use
3653 ;; The `x' forms of each definition command are used for the second
3654 ;; and subsequent header lines.
3656 ;; The texinfo-deffn-formatting-property and texinfo-defun-indexing-property
3657 ;; are listed just before the appropriate formatting and indexing commands.
3659 (put 'deffn 'texinfo-format 'texinfo-format-defun)
3660 (put 'deffnx 'texinfo-format 'texinfo-format-defunx)
3661 (put 'deffn 'texinfo-end 'texinfo-end-defun)
3662 (put 'deffn 'texinfo-defun-type '('deffn-type nil))
3663 (put 'deffnx 'texinfo-defun-type '('deffn-type nil))
3664 (put 'deffn 'texinfo-defun-index 'texinfo-findex)
3665 (put 'deffnx 'texinfo-defun-index 'texinfo-findex)
3667 (put 'defun 'texinfo-format 'texinfo-format-defun)
3668 (put 'defunx 'texinfo-format 'texinfo-format-defunx)
3669 (put 'defun 'texinfo-end 'texinfo-end-defun)
3670 (put 'defun 'texinfo-defun-type '('defun-type "Function"))
3671 (put 'defunx 'texinfo-defun-type '('defun-type "Function"))
3672 (put 'defun 'texinfo-defun-index 'texinfo-findex)
3673 (put 'defunx 'texinfo-defun-index 'texinfo-findex)
3675 (put 'defmac 'texinfo-format 'texinfo-format-defun)
3676 (put 'defmacx 'texinfo-format 'texinfo-format-defunx)
3677 (put 'defmac 'texinfo-end 'texinfo-end-defun)
3678 (put 'defmac 'texinfo-defun-type '('defun-type "Macro"))
3679 (put 'defmacx 'texinfo-defun-type '('defun-type "Macro"))
3680 (put 'defmac 'texinfo-defun-index 'texinfo-findex)
3681 (put 'defmacx 'texinfo-defun-index 'texinfo-findex)
3683 (put 'defspec 'texinfo-format 'texinfo-format-defun)
3684 (put 'defspecx 'texinfo-format 'texinfo-format-defunx)
3685 (put 'defspec 'texinfo-end 'texinfo-end-defun)
3686 (put 'defspec 'texinfo-defun-type '('defun-type "Special form"))
3687 (put 'defspecx 'texinfo-defun-type '('defun-type "Special form"))
3688 (put 'defspec 'texinfo-defun-index 'texinfo-findex)
3689 (put 'defspecx 'texinfo-defun-index 'texinfo-findex)
3691 (put 'defvr 'texinfo-format 'texinfo-format-defun)
3692 (put 'defvrx 'texinfo-format 'texinfo-format-defunx)
3693 (put 'defvr 'texinfo-end 'texinfo-end-defun)
3694 (put 'defvr 'texinfo-defun-type '('deffn-type nil))
3695 (put 'defvrx 'texinfo-defun-type '('deffn-type nil))
3696 (put 'defvr 'texinfo-defun-index 'texinfo-vindex)
3697 (put 'defvrx 'texinfo-defun-index 'texinfo-vindex)
3699 (put 'defvar 'texinfo-format 'texinfo-format-defun)
3700 (put 'defvarx 'texinfo-format 'texinfo-format-defunx)
3701 (put 'defvar 'texinfo-end 'texinfo-end-defun)
3702 (put 'defvar 'texinfo-defun-type '('defun-type "Variable"))
3703 (put 'defvarx 'texinfo-defun-type '('defun-type "Variable"))
3704 (put 'defvar 'texinfo-defun-index 'texinfo-vindex)
3705 (put 'defvarx 'texinfo-defun-index 'texinfo-vindex)
3707 (put 'defconst 'texinfo-format 'texinfo-format-defun)
3708 (put 'defconstx 'texinfo-format 'texinfo-format-defunx)
3709 (put 'defconst 'texinfo-end 'texinfo-end-defun)
3710 (put 'defconst 'texinfo-defun-type '('defun-type "Constant"))
3711 (put 'defconstx 'texinfo-defun-type '('defun-type "Constant"))
3712 (put 'defconst 'texinfo-defun-index 'texinfo-vindex)
3713 (put 'defconstx 'texinfo-defun-index 'texinfo-vindex)
3715 (put 'defcmd 'texinfo-format 'texinfo-format-defun)
3716 (put 'defcmdx 'texinfo-format 'texinfo-format-defunx)
3717 (put 'defcmd 'texinfo-end 'texinfo-end-defun)
3718 (put 'defcmd 'texinfo-defun-type '('defun-type "Command"))
3719 (put 'defcmdx 'texinfo-defun-type '('defun-type "Command"))
3720 (put 'defcmd 'texinfo-defun-index 'texinfo-findex)
3721 (put 'defcmdx 'texinfo-defun-index 'texinfo-findex)
3723 (put 'defopt 'texinfo-format 'texinfo-format-defun)
3724 (put 'defoptx 'texinfo-format 'texinfo-format-defunx)
3725 (put 'defopt 'texinfo-end 'texinfo-end-defun)
3726 (put 'defopt 'texinfo-defun-type '('defun-type "User Option"))
3727 (put 'defoptx 'texinfo-defun-type '('defun-type "User Option"))
3728 (put 'defopt 'texinfo-defun-index 'texinfo-vindex)
3729 (put 'defoptx 'texinfo-defun-index 'texinfo-vindex)
3731 (put 'deftp 'texinfo-format 'texinfo-format-defun)
3732 (put 'deftpx 'texinfo-format 'texinfo-format-defunx)
3733 (put 'deftp 'texinfo-end 'texinfo-end-defun)
3734 (put 'deftp 'texinfo-defun-type '('deftp-type nil))
3735 (put 'deftpx 'texinfo-defun-type '('deftp-type nil))
3736 (put 'deftp 'texinfo-defun-index 'texinfo-tindex)
3737 (put 'deftpx 'texinfo-defun-index 'texinfo-tindex)
3739 ;;; Object-oriented stuff is a little hairier.
3741 (put 'defop 'texinfo-format 'texinfo-format-defun)
3742 (put 'defopx 'texinfo-format 'texinfo-format-defunx)
3743 (put 'defop 'texinfo-end 'texinfo-end-defun)
3744 (put 'defop 'texinfo-defun-type '('defop-type nil))
3745 (put 'defopx 'texinfo-defun-type '('defop-type nil))
3746 (put 'defop 'texinfo-defun-index 'texinfo-findex)
3747 (put 'defopx 'texinfo-defun-index 'texinfo-findex)
3749 (put 'defmethod 'texinfo-format 'texinfo-format-defun)
3750 (put 'defmethodx 'texinfo-format 'texinfo-format-defunx)
3751 (put 'defmethod 'texinfo-end 'texinfo-end-defun)
3752 (put 'defmethod 'texinfo-defun-type '('defmethod-type "Method"))
3753 (put 'defmethodx 'texinfo-defun-type '('defmethod-type "Method"))
3754 (put 'defmethod 'texinfo-defun-index 'texinfo-findex)
3755 (put 'defmethodx 'texinfo-defun-index 'texinfo-findex)
3757 (put 'defcv 'texinfo-format 'texinfo-format-defun)
3758 (put 'defcvx 'texinfo-format 'texinfo-format-defunx)
3759 (put 'defcv 'texinfo-end 'texinfo-end-defun)
3760 (put 'defcv 'texinfo-defun-type '('defop-type nil))
3761 (put 'defcvx 'texinfo-defun-type '('defop-type nil))
3762 (put 'defcv 'texinfo-defun-index 'texinfo-vindex)
3763 (put 'defcvx 'texinfo-defun-index 'texinfo-vindex)
3765 (put 'defivar 'texinfo-format 'texinfo-format-defun)
3766 (put 'defivarx 'texinfo-format 'texinfo-format-defunx)
3767 (put 'defivar 'texinfo-end 'texinfo-end-defun)
3768 (put 'defivar 'texinfo-defun-type '('defmethod-type "Instance variable"))
3769 (put 'defivarx 'texinfo-defun-type '('defmethod-type "Instance variable"))
3770 (put 'defivar 'texinfo-defun-index 'texinfo-vindex)
3771 (put 'defivarx 'texinfo-defun-index 'texinfo-vindex)
3773 ;;; Typed functions and variables
3775 (put 'deftypefn 'texinfo-format 'texinfo-format-defun)
3776 (put 'deftypefnx 'texinfo-format 'texinfo-format-defunx)
3777 (put 'deftypefn 'texinfo-end 'texinfo-end-defun)
3778 (put 'deftypefn 'texinfo-defun-type '('deftypefn-type nil))
3779 (put 'deftypefnx 'texinfo-defun-type '('deftypefn-type nil))
3780 (put 'deftypefn 'texinfo-defun-index 'texinfo-findex)
3781 (put 'deftypefnx 'texinfo-defun-index 'texinfo-findex)
3783 (put 'deftypefun 'texinfo-format 'texinfo-format-defun)
3784 (put 'deftypefunx 'texinfo-format 'texinfo-format-defunx)
3785 (put 'deftypefun 'texinfo-end 'texinfo-end-defun)
3786 (put 'deftypefun 'texinfo-defun-type '('deftypefun-type "Function"))
3787 (put 'deftypefunx 'texinfo-defun-type '('deftypefun-type "Function"))
3788 (put 'deftypefun 'texinfo-defun-index 'texinfo-findex)
3789 (put 'deftypefunx 'texinfo-defun-index 'texinfo-findex)
3791 (put 'deftypevr 'texinfo-format 'texinfo-format-defun)
3792 (put 'deftypevrx 'texinfo-format 'texinfo-format-defunx)
3793 (put 'deftypevr 'texinfo-end 'texinfo-end-defun)
3794 (put 'deftypevr 'texinfo-defun-type '('deftypefn-type nil))
3795 (put 'deftypevrx 'texinfo-defun-type '('deftypefn-type nil))
3796 (put 'deftypevr 'texinfo-defun-index 'texinfo-vindex)
3797 (put 'deftypevrx 'texinfo-defun-index 'texinfo-vindex)
3799 (put 'deftypevar 'texinfo-format 'texinfo-format-defun)
3800 (put 'deftypevarx 'texinfo-format 'texinfo-format-defunx)
3801 (put 'deftypevar 'texinfo-end 'texinfo-end-defun)
3802 (put 'deftypevar 'texinfo-defun-type '('deftypevar-type "Variable"))
3803 (put 'deftypevarx 'texinfo-defun-type '('deftypevar-type "Variable"))
3804 (put 'deftypevar 'texinfo-defun-index 'texinfo-vindex)
3805 (put 'deftypevarx 'texinfo-defun-index 'texinfo-vindex)
3808 ;;; @set, @clear, @ifset, @ifclear
3810 ;; If a flag is set with @set FLAG, then text between @ifset and @end
3811 ;; ifset is formatted normally, but if the flag is is cleared with
3812 ;; @clear FLAG, then the text is not formatted; it is ignored.
3814 ;; If a flag is cleared with @clear FLAG, then text between @ifclear
3815 ;; and @end ifclear is formatted normally, but if the flag is is set with
3816 ;; @set FLAG, then the text is not formatted; it is ignored. @ifclear
3817 ;; is the opposite of @ifset.
3819 ;; If a flag is set to a string with @set FLAG,
3820 ;; replace @value{FLAG} with the string.
3821 ;; If a flag with a value is cleared,
3822 ;; @value{FLAG} is invalid,
3823 ;; as if there had never been any @set FLAG previously.
3825 (put 'clear 'texinfo-format 'texinfo-clear)
3826 (defun texinfo-clear ()
3827 "Clear the value of the flag."
3828 (let* ((arg (texinfo-parse-arg-discard))
3829 (flag (car (read-from-string arg)))
3830 (value (substring arg (cdr (read-from-string arg)))))
3831 (put flag 'texinfo-whether-setp 'flag-cleared)
3832 (put flag 'texinfo-set-value "")))
3834 (put 'set 'texinfo-format 'texinfo-set)
3835 (defun texinfo-set ()
3836 "Set the value of the flag, optionally to a string.
3837 The command `@set foo This is a string.'
3838 sets flag foo to the value: `This is a string.'
3839 The command `@value{foo}' expands to the value."
3840 (let* ((arg (texinfo-parse-arg-discard))
3841 (flag (car (read-from-string arg)))
3842 (value (substring arg (cdr (read-from-string arg)))))
3843 (if (string-match "^[ \t]+" value)
3844 (setq value (substring value (match-end 0))))
3845 (put flag 'texinfo-whether-setp 'flag-set)
3846 (put flag 'texinfo-set-value value)))
3848 (put 'value 'texinfo-format 'texinfo-value)
3849 (defun texinfo-value ()
3850 "Insert the string to which the flag is set.
3851 The command `@set foo This is a string.'
3852 sets flag foo to the value: `This is a string.'
3853 The command `@value{foo}' expands to the value."
3854 (let ((arg (texinfo-parse-arg-discard)))
3855 (cond ((and
3856 (eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3857 'flag-set)
3858 (get (car (read-from-string arg)) 'texinfo-set-value))
3859 (insert (get (car (read-from-string arg)) 'texinfo-set-value)))
3860 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3861 'flag-cleared)
3862 (insert (format "{No value for \"%s\"}" arg)))
3863 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) nil)
3864 (insert (format "{No value for \"%s\"}" arg))))))
3866 (put 'ifset 'texinfo-end 'texinfo-discard-command)
3867 (put 'ifset 'texinfo-format 'texinfo-if-set)
3868 (defun texinfo-if-set ()
3869 "If set, continue formatting; else do not format region up to @end ifset"
3870 (let ((arg (texinfo-parse-arg-discard)))
3871 (cond
3872 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3873 'flag-set)
3874 ;; Format the text (i.e., do not remove it); do nothing here.
3876 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3877 'flag-cleared)
3878 ;; Clear region (i.e., cause the text to be ignored).
3879 (delete-region texinfo-command-start
3880 (progn (re-search-forward "@end ifset[ \t]*\n")
3881 (point))))
3882 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3883 nil)
3884 ;; In this case flag is neither set nor cleared.
3885 ;; Act as if set, i.e. do nothing.
3886 ()))))
3888 (put 'ifclear 'texinfo-end 'texinfo-discard-command)
3889 (put 'ifclear 'texinfo-format 'texinfo-if-clear)
3890 (defun texinfo-if-clear ()
3891 "If clear, continue formatting; if set, do not format up to @end ifset"
3892 (let ((arg (texinfo-parse-arg-discard)))
3893 (cond
3894 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3895 'flag-set)
3896 ;; Clear region (i.e., cause the text to be ignored).
3897 (delete-region texinfo-command-start
3898 (progn (re-search-forward "@end ifclear[ \t]*\n")
3899 (point))))
3900 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3901 'flag-cleared)
3902 ;; Format the text (i.e., do not remove it); do nothing here.
3904 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
3905 nil)
3906 ;; In this case flag is neither set nor cleared.
3907 ;; Act as if clear, i.e. do nothing.
3908 ()))))
3910 ;;; @ifeq
3912 (put 'ifeq 'texinfo-format 'texinfo-format-ifeq)
3913 (defun texinfo-format-ifeq ()
3914 "If ARG1 and ARG2 caselessly string compare to same string, perform COMMAND.
3915 Otherwise produces no output.
3917 Thus:
3918 @ifeq{ arg1 , arg1 , @code{foo}} bar
3920 ==> `foo' bar.
3922 @ifeq{ arg1 , arg2 , @code{foo}} bar
3924 ==> bar
3926 Note that the Texinfo command and its arguments must be arguments to
3927 the @ifeq command."
3928 ;; compare-buffer-substrings does not exist in version 18; don't use
3929 (goto-char texinfo-command-end)
3930 (let* ((case-fold-search t)
3931 (stop (save-excursion (forward-sexp 1) (point)))
3932 start end
3933 ;; @ifeq{arg1, arg2, @command{optional-args}}
3934 (arg1
3935 (progn
3936 (forward-char 1)
3937 (skip-chars-forward " ")
3938 (setq start (point))
3939 (search-forward "," stop t)
3940 (skip-chars-backward ", ")
3941 (buffer-substring start (point))))
3942 (arg2
3943 (progn
3944 (search-forward "," stop t)
3945 (skip-chars-forward " ")
3946 (setq start (point))
3947 (search-forward "," stop t)
3948 (skip-chars-backward ", ")
3949 (buffer-substring start (point))))
3950 (texinfo-command
3951 (progn
3952 (search-forward "," stop t)
3953 (skip-chars-forward " ")
3954 (setq start (point))
3955 (goto-char (1- stop))
3956 (skip-chars-backward " ")
3957 (buffer-substring start (point)))))
3958 (delete-region texinfo-command-start stop)
3959 (if (equal arg1 arg2)
3960 (insert texinfo-command))
3961 (goto-char texinfo-command-start)))
3964 ;;; Process included files: `@include' command
3966 ;; Updated 19 October 1990
3967 ;; In the original version, include files were ignored by Info but
3968 ;; incorporated in to the printed manual. To make references to the
3969 ;; included file, the Texinfo source file has to refer to the included
3970 ;; files using the `(filename)nodename' format for referring to other
3971 ;; Info files. Also, the included files had to be formatted on their
3972 ;; own. It was just like they were another file.
3974 ;; Currently, include files are inserted into the buffer that is
3975 ;; formatted for Info. If large, the resulting info file is split and
3976 ;; tagified. For current include files to work, the master menu must
3977 ;; refer to all the nodes, and the highest level nodes in the include
3978 ;; files must have the correct next, prev, and up pointers.
3980 ;; The included file may have an @setfilename and even an @settitle,
3981 ;; but not an `\input texinfo' line.
3983 ;; Updated 24 March 1993
3984 ;; In order for @raisesections and @lowersections to work, included
3985 ;; files must be inserted into the buffer holding the outer file
3986 ;; before other Info formatting takes place. So @include is no longer
3987 ;; is treated like other @-commands.
3988 (put 'include 'texinfo-format 'texinfo-format-noop)
3990 ;; Original definition:
3991 ;; (defun texinfo-format-include ()
3992 ;; (let ((filename (texinfo-parse-arg-discard))
3993 ;; (default-directory input-directory)
3994 ;; subindex)
3995 ;; (setq subindex
3996 ;; (save-excursion
3997 ;; (progn (find-file
3998 ;; (cond ((file-readable-p (concat filename ".texinfo"))
3999 ;; (concat filename ".texinfo"))
4000 ;; ((file-readable-p (concat filename ".texi"))
4001 ;; (concat filename ".texi"))
4002 ;; ((file-readable-p (concat filename ".tex"))
4003 ;; (concat filename ".tex"))
4004 ;; ((file-readable-p filename)
4005 ;; filename)
4006 ;; (t (error "@include'd file %s not found"
4007 ;; filename))))
4008 ;; (texinfo-format-buffer-1))))
4009 ;; (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex))
4010 ;; (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex))
4011 ;; (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex))
4012 ;; (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex))
4013 ;; (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex))
4014 ;; (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex))))
4016 ;;(defun texinfo-subindex (indexvar file content)
4017 ;; (set indexvar (cons (list 'recurse file content)
4018 ;; (symbol-value indexvar))))
4020 ;; Second definition:
4021 ;; (put 'include 'texinfo-format 'texinfo-format-include)
4022 ;; (defun texinfo-format-include ()
4023 ;; (let ((filename (concat input-directory
4024 ;; (texinfo-parse-arg-discard)))
4025 ;; (default-directory input-directory))
4026 ;; (message "Reading: %s" filename)
4027 ;; (save-excursion
4028 ;; (save-restriction
4029 ;; (narrow-to-region
4030 ;; (point)
4031 ;; (+ (point) (car (cdr (insert-file-contents filename)))))
4032 ;; (goto-char (point-min))
4033 ;; (texinfo-append-refill)
4034 ;; (texinfo-format-convert (point-min) (point-max))))
4035 ;; (setq last-input-buffer input-buffer) ; to bypass setfilename
4036 ;; ))
4039 ;;; Numerous commands do nothing in Info
4040 ;; These commands are defined in texinfo.tex for printed output.
4043 ;;; various noops, such as @b{foo}, that take arguments in braces
4045 (put 'b 'texinfo-format 'texinfo-format-noop)
4046 (put 'i 'texinfo-format 'texinfo-format-noop)
4047 (put 'r 'texinfo-format 'texinfo-format-noop)
4048 (put 't 'texinfo-format 'texinfo-format-noop)
4049 (put 'w 'texinfo-format 'texinfo-format-noop)
4050 (put 'asis 'texinfo-format 'texinfo-format-noop)
4051 (put 'dmn 'texinfo-format 'texinfo-format-noop)
4052 (put 'math 'texinfo-format 'texinfo-format-noop)
4053 (put 'titlefont 'texinfo-format 'texinfo-format-noop)
4054 (defun texinfo-format-noop ()
4055 (insert (texinfo-parse-arg-discard))
4056 (goto-char texinfo-command-start))
4058 ;; @hyphenation command discards an argument within braces
4059 (put 'hyphenation 'texinfo-format 'texinfo-discard-command-and-arg)
4060 (defun texinfo-discard-command-and-arg ()
4061 "Discard both @-command and its argument in braces."
4062 (goto-char texinfo-command-end)
4063 (forward-list 1)
4064 (setq texinfo-command-end (point))
4065 (delete-region texinfo-command-start texinfo-command-end))
4068 ;;; Do nothing commands, such as @smallbook, that have no args and no braces
4069 ;; These must appear on a line of their own
4071 (put 'bye 'texinfo-format 'texinfo-discard-line)
4072 (put 'smallbook 'texinfo-format 'texinfo-discard-line)
4073 (put 'finalout 'texinfo-format 'texinfo-discard-line)
4074 (put 'overfullrule 'texinfo-format 'texinfo-discard-line)
4075 (put 'smallbreak 'texinfo-format 'texinfo-discard-line)
4076 (put 'medbreak 'texinfo-format 'texinfo-discard-line)
4077 (put 'bigbreak 'texinfo-format 'texinfo-discard-line)
4080 ;;; These noop commands discard the rest of the line.
4082 (put 'c 'texinfo-format 'texinfo-discard-line-with-args)
4083 (put 'comment 'texinfo-format 'texinfo-discard-line-with-args)
4084 (put 'contents 'texinfo-format 'texinfo-discard-line-with-args)
4085 (put 'group 'texinfo-end 'texinfo-discard-line-with-args)
4086 (put 'group 'texinfo-format 'texinfo-discard-line-with-args)
4087 (put 'headings 'texinfo-format 'texinfo-discard-line-with-args)
4088 (put 'setchapterstyle 'texinfo-format 'texinfo-discard-line-with-args)
4089 (put 'hsize 'texinfo-format 'texinfo-discard-line-with-args)
4090 (put 'itemindent 'texinfo-format 'texinfo-discard-line-with-args)
4091 (put 'lispnarrowing 'texinfo-format 'texinfo-discard-line-with-args)
4092 (put 'need 'texinfo-format 'texinfo-discard-line-with-args)
4093 (put 'nopara 'texinfo-format 'texinfo-discard-line-with-args)
4095 ;; @novalidate suppresses cross-reference checking and auxiliary file
4096 ;; creation with TeX. The Info-validate command checks that every
4097 ;; node pointer points to an existing node. Since this Info command
4098 ;; is not invoked automatically, the @novalidate command is irrelevant
4099 ;; and not supported by texinfmt.el
4100 (put 'novalidate 'texinfo-format 'texinfo-discard-line-with-args)
4102 (put 'page 'texinfo-format 'texinfo-discard-line-with-args)
4103 (put 'pagesizes 'texinfo-format 'texinfo-discard-line-with-args)
4104 (put 'parindent 'texinfo-format 'texinfo-discard-line-with-args)
4105 (put 'setchapternewpage 'texinfo-format 'texinfo-discard-line-with-args)
4106 (put 'setq 'texinfo-format 'texinfo-discard-line-with-args)
4108 (put 'setcontentsaftertitlepage
4109 'texinfo-format 'texinfo-discard-line-with-args)
4110 (put 'setshortcontentsaftertitlepage
4111 'texinfo-format 'texinfo-discard-line-with-args)
4113 (put 'settitle 'texinfo-format 'texinfo-discard-line-with-args)
4114 (put 'setx 'texinfo-format 'texinfo-discard-line-with-args)
4115 (put 'shortcontents 'texinfo-format 'texinfo-discard-line-with-args)
4116 (put 'shorttitlepage 'texinfo-format 'texinfo-discard-line-with-args)
4117 (put 'summarycontents 'texinfo-format 'texinfo-discard-line-with-args)
4118 (put 'input 'texinfo-format 'texinfo-discard-line-with-args)
4121 ;;; Some commands cannot be handled
4123 (defun texinfo-unsupported ()
4124 (error "%s is not handled by texinfo"
4125 (buffer-substring texinfo-command-start texinfo-command-end)))
4127 ;;; Batch formatting
4129 (defun batch-texinfo-format ()
4130 "Runs texinfo-format-buffer on the files remaining on the command line.
4131 Must be used only with -batch, and kills emacs on completion.
4132 Each file will be processed even if an error occurred previously.
4133 For example, invoke
4134 \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"."
4135 (if (not noninteractive)
4136 (error "batch-texinfo-format may only be used -batch"))
4137 (let ((version-control t)
4138 (auto-save-default nil)
4139 (find-file-run-dired nil)
4140 (kept-old-versions 259259)
4141 (kept-new-versions 259259))
4142 (let ((error 0)
4143 file
4144 (files ()))
4145 (while command-line-args-left
4146 (setq file (expand-file-name (car command-line-args-left)))
4147 (cond ((not (file-exists-p file))
4148 (message ">> %s does not exist!" file)
4149 (setq error 1
4150 command-line-args-left (cdr command-line-args-left)))
4151 ((file-directory-p file)
4152 (setq command-line-args-left
4153 (nconc (directory-files file)
4154 (cdr command-line-args-left))))
4156 (setq files (cons file files)
4157 command-line-args-left (cdr command-line-args-left)))))
4158 (while files
4159 (setq file (car files)
4160 files (cdr files))
4161 (condition-case err
4162 (progn
4163 (if buffer-file-name (kill-buffer (current-buffer)))
4164 (find-file file)
4165 (buffer-disable-undo (current-buffer))
4166 (set-buffer-modified-p nil)
4167 (texinfo-mode)
4168 (message "texinfo formatting %s..." file)
4169 (texinfo-format-buffer nil)
4170 (if (buffer-modified-p)
4171 (progn (message "Saving modified %s" (buffer-file-name))
4172 (save-buffer))))
4173 (error
4174 (message ">> Error: %s" (prin1-to-string err))
4175 (message ">> point at")
4176 (let ((s (buffer-substring (point)
4177 (min (+ (point) 100)
4178 (point-max))))
4179 (tem 0))
4180 (while (setq tem (string-match "\n+" s tem))
4181 (setq s (concat (substring s 0 (match-beginning 0))
4182 "\n>> "
4183 (substring s (match-end 0)))
4184 tem (1+ tem)))
4185 (message ">> %s" s))
4186 (setq error 1))))
4187 (kill-emacs error))))
4190 ;;; Place `provide' at end of file.
4191 (provide 'texinfmt)
4193 ;;; texinfmt.el ends here