annotate lisp/textmodes/texinfmt.el @ 221:ce8e0192266e

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Mon, 01 Apr 1991 21:16:55 +0000
parents 70bc47d3c6c9
children 1e0bc00dca7a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
189
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1 ;;;; texinfmt.el
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
2 ;;;; Convert Texinfo files to Info files.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
3
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
4 ;;;; Version 2.00 14 Dec 1990
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
5
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
6 ;; Copyright (C) 1985, 1986, 1988, 1990 Free Software Foundation, Inc.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
7
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
9
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 1, or (at your option)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
13 ;; any later version.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
14
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
19
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
23
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
24 ;; Updated May 1990 to correspond, more or less, to version 2.8 of
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
25 ;; texinfo.tex. NOTE: texinfmt.el is being phased out; it is being
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
26 ;; replaced by makeinfo.c, which is faster and provides better error
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
27 ;; checking.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
28 ;; Robert J. Chassell, bob@ai.mit.edu
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
29
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
30 (defvar texinfo-format-syntax-table nil)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
31
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
32 (defvar texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
33 (defvar texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
34 (defvar texinfo-cindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
35 (defvar texinfo-pindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
36 (defvar texinfo-tindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
37 (defvar texinfo-kindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
38 (defvar texinfo-last-node)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
39 (defvar texinfo-node-names)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
40
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
41 (if texinfo-format-syntax-table
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
42 nil
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
43 (setq texinfo-format-syntax-table (make-syntax-table))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
44 (modify-syntax-entry ?\" " " texinfo-format-syntax-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
45 (modify-syntax-entry ?\\ " " texinfo-format-syntax-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
46 (modify-syntax-entry ?@ "\\" texinfo-format-syntax-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
47 (modify-syntax-entry ?\^q "\\" texinfo-format-syntax-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
48 (modify-syntax-entry ?\[ "." texinfo-format-syntax-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
49 (modify-syntax-entry ?\] "." texinfo-format-syntax-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
50 (modify-syntax-entry ?\( "." texinfo-format-syntax-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
51 (modify-syntax-entry ?\) "." texinfo-format-syntax-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
52 (modify-syntax-entry ?{ "(}" texinfo-format-syntax-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
53 (modify-syntax-entry ?} "){" texinfo-format-syntax-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
54 (modify-syntax-entry ?\' "." texinfo-format-syntax-table))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
55
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
56 (defun texinfo-format-buffer (&optional notagify)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
57 "Process the current buffer as texinfo code, into an Info file.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
58 The Info file output is generated in a buffer visiting the Info file
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
59 names specified in the @setfilename command.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
60
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
61 Non-nil argument (prefix, if interactive) means don't make tag table
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
62 and don't split the file if large. You can use Info-tagify and
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
63 Info-split to do these manually."
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
64 (interactive "P")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
65 (let ((lastmessage "Formatting Info file..."))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
66 (message lastmessage)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
67 (texinfo-format-buffer-1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
68 (if notagify
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
69 nil
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
70 (if (> (buffer-size) 30000)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
71 (progn
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
72 (message (setq lastmessage "Making tags table for Info file..."))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
73 (Info-tagify)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
74 (if (> (buffer-size) 100000)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
75 (progn
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
76 (message (setq lastmessage "Splitting Info file..."))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
77 (Info-split))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
78 (message (concat lastmessage
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
79 (if (interactive-p) "done. Now save it." "done.")))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
80
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
81
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
82 (defun texinfo-format-buffer-1 ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
83 (let (texinfo-format-filename
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
84 texinfo-example-start
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
85 texinfo-command-start
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
86 texinfo-command-end
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
87 texinfo-command-name
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
88 texinfo-last-node
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
89 texinfo-vindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
90 texinfo-findex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
91 texinfo-cindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
92 texinfo-pindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
93 texinfo-tindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
94 texinfo-kindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
95 texinfo-stack
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
96 texinfo-node-names
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
97 (texinfo-footnote-number 0)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
98 last-input-buffer
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
99 outfile
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
100 (fill-column fill-column)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
101 (input-buffer (current-buffer))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
102 (input-directory default-directory))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
103 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
104 (goto-char (point-min))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
105 (search-forward "@setfilename")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
106 (setq texinfo-command-end (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
107 (setq outfile (texinfo-parse-line-arg)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
108 (find-file outfile)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
109 (texinfo-mode)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
110 (set-syntax-table texinfo-format-syntax-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
111 (erase-buffer)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
112 (insert-buffer-substring input-buffer)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
113 (goto-char (point-min))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
114 (search-forward "@setfilename")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
115 (beginning-of-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
116 (delete-region (point-min) (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
117 ;; Remove @bye at end of file, if it is there.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
118 (goto-char (point-max))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
119 (if (search-backward "@bye" nil t)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
120 (delete-region (point) (point-max)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
121 ;; Make sure buffer ends in a newline.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
122 (or (= (preceding-char) ?\n)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
123 (insert "\n"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
124 ;; Scan the whole buffer, converting to Info format.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
125 (texinfo-format-scan)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
126 ;; Return data for indices.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
127 (goto-char (point-min))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
128 (list outfile
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
129 texinfo-vindex texinfo-findex texinfo-cindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
130 texinfo-pindex texinfo-tindex texinfo-kindex)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
131
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
132 (defvar texinfo-region-buffer-name "*Info Region*"
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
133 "*Name of the temporary buffer used by \\[texinfo-format-region].")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
134
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
135 (defun texinfo-format-region (region-beginning region-ending)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
136 "Convert the current region of the Texinfo file to Info format.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
137 This lets you see what that part of the file will look like in Info.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
138 The command is bound to \\[texinfo-format-region]. The text that is
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
139 converted to Info is stored in a temporary buffer."
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
140 (interactive "r")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
141 (message "Converting region to Info format...")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
142 (let (texinfo-command-start
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
143 texinfo-command-end
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
144 texinfo-command-name
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
145 texinfo-vindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
146 texinfo-findex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
147 texinfo-cindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
148 texinfo-pindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
149 texinfo-tindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
150 texinfo-kindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
151 texinfo-stack
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
152 texinfo-format-filename
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
153 texinfo-example-start
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
154 texinfo-last-node
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
155 texinfo-node-names
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
156 (texinfo-footnote-number 0)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
157 last-input-buffer
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
158 (fill-column fill-column)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
159 (input-buffer (current-buffer))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
160 (input-directory default-directory)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
161 filename-beginning
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
162 filename-ending)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
163
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
164 ;;; Find a buffer to use.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
165
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
166 (switch-to-buffer (get-buffer-create texinfo-region-buffer-name))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
167
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
168 ;; Insert the region into the buffer.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
169 (erase-buffer)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
170
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
171 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
172 (set-buffer input-buffer)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
173 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
174 (save-restriction
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
175 (widen)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
176 (goto-char (point-min))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
177 ;; Initialize the buffer with the filename
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
178 ;; or else explain that a filename is needed.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
179 (or (search-forward "@setfilename"
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
180 (save-excursion (forward-line 100) (point)) t)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
181 (error "The texinfo file needs a line saying: @setfilename <name>"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
182 (beginning-of-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
183 (setq filename-beginning (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
184 (forward-line 1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
185 (setq filename-ending (point)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
186
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
187 ;; Insert the @setfilename line into the buffer.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
188 (insert-buffer-substring input-buffer
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
189 (min filename-beginning region-beginning)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
190 filename-ending)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
191
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
192 ;; Insert the region into the buffer.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
193 (insert-buffer-substring input-buffer
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
194 (max region-beginning filename-ending)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
195 region-ending)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
196
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
197 (texinfo-mode)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
198
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
199 ;; Install a syntax table useful for scanning command operands.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
200 (set-syntax-table texinfo-format-syntax-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
201
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
202 ;; If the region includes the effective end of the data,
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
203 ;; discard everything after that.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
204 (goto-char (point-max))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
205 (if (re-search-backward "^@bye" nil t)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
206 (delete-region (point) (point-max)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
207 ;; Make sure buffer ends in a newline.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
208 (or (= (preceding-char) ?\n)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
209 (insert "\n"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
210
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
211 ;; Now convert for real.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
212 (goto-char (point-min))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
213 (texinfo-format-scan)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
214 (goto-char (point-min)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
215
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
216 (message "Done."))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
217
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
218
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
219 ;; Perform those texinfo-to-info conversions that apply to the whole input
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
220 ;; uniformly.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
221 (defun texinfo-format-scan ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
222 ;; Convert left and right quotes to typewriter font quotes.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
223 (goto-char (point-min))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
224 (while (search-forward "``" nil t)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
225 (replace-match "\""))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
226 (goto-char (point-min))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
227 (while (search-forward "''" nil t)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
228 (replace-match "\""))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
229 ;; Scan for @-commands.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
230 (goto-char (point-min))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
231 (while (search-forward "@" nil t)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
232 (if (looking-at "[@{}'` *]")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
233 ;; Handle a few special @-followed-by-one-char commands.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
234 (if (= (following-char) ?*)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
235 (progn
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
236 ;; remove command
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
237 (delete-region (1- (point)) (1+ (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
238 ;; insert return if not at end of line;
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
239 ;; else line is already broken.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
240 (if (not (= (following-char) ?\n))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
241 (insert ?\n)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
242 ;; The other characters are simply quoted. Delete the @.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
243 (delete-char -1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
244 (forward-char 1))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
245 ;; @ is followed by a command-word; find the end of the word.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
246 (setq texinfo-command-start (1- (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
247 (if (= (char-syntax (following-char)) ?w)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
248 (forward-word 1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
249 (forward-char 1))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
250 (setq texinfo-command-end (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
251 ;; Call the handler for this command.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
252 (setq texinfo-command-name
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
253 (intern (buffer-substring (1+ texinfo-command-start)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
254 texinfo-command-end)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
255 (let ((cmd (get texinfo-command-name 'texinfo-format)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
256 (if cmd (funcall cmd)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
257 (texinfo-unsupported)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
258 (cond (texinfo-stack
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
259 (goto-char (nth 2 (car texinfo-stack)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
260 (error "Unterminated @%s" (car (car texinfo-stack))))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
261
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
262 (put 'begin 'texinfo-format 'texinfo-format-begin)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
263 (defun texinfo-format-begin ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
264 (texinfo-format-begin-end 'texinfo-format))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
265
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
266 (put 'end 'texinfo-format 'texinfo-format-end)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
267 (defun texinfo-format-end ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
268 (texinfo-format-begin-end 'texinfo-end))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
269
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
270 (defun texinfo-format-begin-end (prop)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
271 (setq texinfo-command-name (intern (texinfo-parse-line-arg)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
272 (setq cmd (get texinfo-command-name prop))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
273 (if cmd (funcall cmd)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
274 (texinfo-unsupported)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
275
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
276 (defun texinfo-parse-line-arg ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
277 (goto-char texinfo-command-end)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
278 (let ((start (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
279 (cond ((looking-at " ")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
280 (skip-chars-forward " ")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
281 (setq start (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
282 (end-of-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
283 (skip-chars-backward " ")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
284 (setq texinfo-command-end (1+ (point))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
285 ((looking-at "{")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
286 (setq start (1+ (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
287 (forward-list 1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
288 (setq texinfo-command-end (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
289 (forward-char -1))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
290 (t
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
291 (error "Invalid texinfo command arg format")))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
292 (prog1 (buffer-substring start (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
293 (if (eolp) (forward-char 1)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
294
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
295 (defun texinfo-parse-expanded-arg ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
296 (goto-char texinfo-command-end)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
297 (let ((start (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
298 marker)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
299 (cond ((looking-at " ")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
300 (skip-chars-forward " ")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
301 (setq start (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
302 (end-of-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
303 (setq texinfo-command-end (1+ (point))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
304 ((looking-at "{")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
305 (setq start (1+ (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
306 (forward-list 1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
307 (setq texinfo-command-end (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
308 (forward-char -1))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
309 (t
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
310 (error "Invalid texinfo command arg format")))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
311 (setq marker (move-marker (make-marker) texinfo-command-end))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
312 (texinfo-format-expand-region start (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
313 (setq texinfo-command-end (marker-position marker))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
314 (move-marker marker nil)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
315 (prog1 (buffer-substring start (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
316 (if (eolp) (forward-char 1)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
317
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
318 (defun texinfo-format-expand-region (start end)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
319 (save-restriction
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
320 (narrow-to-region start end)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
321 (let (texinfo-command-start
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
322 texinfo-command-end
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
323 texinfo-command-name
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
324 texinfo-stack)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
325 (texinfo-format-scan))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
326 (goto-char (point-max))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
327
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
328 (defun texinfo-parse-arg-discard ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
329 (prog1 (texinfo-parse-line-arg)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
330 (texinfo-discard-command)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
331
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
332 (defun texinfo-discard-command ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
333 (delete-region texinfo-command-start texinfo-command-end))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
334
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
335 (defun texinfo-optional-braces-discard ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
336 "Discard braces following command, if any."
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
337 (goto-char texinfo-command-end)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
338 (let ((start (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
339 (cond ((looking-at "[ \t]*\n")) ; do nothing
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
340 ((looking-at "{") ; remove braces, if any
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
341 (forward-list 1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
342 (setq texinfo-command-end (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
343 (t
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
344 (error
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
345 "Invalid `texinfo-optional-braces-discard' format \(need braces?\)")))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
346 (delete-region texinfo-command-start texinfo-command-end)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
347
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
348 (defun texinfo-format-parse-line-args ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
349 (let ((start (1- (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
350 next beg end
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
351 args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
352 (skip-chars-forward " ")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
353 (while (not (eolp))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
354 (setq beg (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
355 (re-search-forward "[\n,]")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
356 (setq next (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
357 (if (bolp) (setq next (1- next)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
358 (forward-char -1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
359 (skip-chars-backward " ")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
360 (setq end (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
361 (setq args (cons (if (> end beg) (buffer-substring beg end))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
362 args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
363 (goto-char next)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
364 (skip-chars-forward " "))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
365 (if (eolp) (forward-char 1))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
366 (setq texinfo-command-end (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
367 (nreverse args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
368
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
369 (defun texinfo-format-parse-args ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
370 (let ((start (1- (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
371 next beg end
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
372 args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
373 (search-forward "{")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
374 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
375 (texinfo-format-expand-region
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
376 (point)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
377 (save-excursion (up-list 1) (1- (point)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
378 (while (/= (preceding-char) ?\})
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
379 (skip-chars-forward " \t\n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
380 (setq beg (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
381 (re-search-forward "[},]")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
382 (setq next (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
383 (forward-char -1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
384 (skip-chars-backward " \t\n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
385 (setq end (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
386 (cond ((< beg end)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
387 (goto-char beg)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
388 (while (search-forward "\n" end t)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
389 (replace-match " "))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
390 (setq args (cons (if (> end beg) (buffer-substring beg end))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
391 args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
392 (goto-char next))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
393 (if (eolp) (forward-char 1))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
394 (setq texinfo-command-end (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
395 (nreverse args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
396
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
397 (defun texinfo-format-parse-defun-args ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
398 (goto-char texinfo-command-end)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
399 (let ((start (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
400 (end-of-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
401 (setq texinfo-command-end (1+ (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
402 (let ((marker (move-marker (make-marker) texinfo-command-end)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
403 (texinfo-format-expand-region start (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
404 (setq texinfo-command-end (marker-position marker))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
405 (move-marker marker nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
406 (goto-char start)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
407 (let ((args '())
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
408 beg end)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
409 (skip-chars-forward " ")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
410 (while (not (eolp))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
411 (cond ((looking-at "{")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
412 (setq beg (1+ (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
413 (forward-list 1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
414 (setq end (1- (point))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
415 (t
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
416 (setq beg (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
417 (re-search-forward "[\n ]")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
418 (forward-char -1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
419 (setq end (point))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
420 (setq args (cons (buffer-substring beg end) args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
421 (skip-chars-forward " "))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
422 (forward-char 1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
423 (nreverse args))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
424
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
425
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
426 ; 19 October 1990
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
427 ; @setfilename modifed to work with include files; see @include
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
428 ; (defun texinfo-format-setfilename ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
429 ; (let ((arg (texinfo-parse-arg-discard)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
430 ; (setq texinfo-format-filename
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
431 ; (file-name-nondirectory (expand-file-name arg)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
432 ; (insert "Info file: "
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
433 ; texinfo-format-filename ", -*-Text-*-\n"
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
434 ; "produced by texinfo-format-buffer\nfrom "
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
435 ; (if (buffer-file-name input-buffer)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
436 ; (concat "file: "
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
437 ; (file-name-sans-versions
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
438 ; (file-name-nondirectory
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
439 ; (buffer-file-name input-buffer))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
440 ; (concat "buffer " (buffer-name input-buffer)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
441 ; "\n\n")))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
442
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
443 (put 'setfilename 'texinfo-format 'texinfo-format-setfilename)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
444 (defun texinfo-format-setfilename ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
445 (let ((arg (texinfo-parse-arg-discard)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
446 (if (eq input-buffer last-input-buffer)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
447 nil ; only use first setfilename in buffer
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
448 (message "Formatting Info file: %s" arg)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
449 (setq texinfo-format-filename
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
450 (file-name-nondirectory (expand-file-name arg)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
451 (insert "Info file: "
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
452 texinfo-format-filename ", -*-Text-*-\n"
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
453 "produced by texinfo-format-buffer\nfrom "
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
454 (if (buffer-file-name input-buffer)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
455 (concat "file: "
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
456 (file-name-sans-versions
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
457 (file-name-nondirectory
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
458 (buffer-file-name input-buffer))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
459 (concat "buffer " (buffer-name input-buffer)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
460 "\n\n"))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
461
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
462 (put 'node 'texinfo-format 'texinfo-format-node)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
463 (defun texinfo-format-node ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
464 (let* ((args (texinfo-format-parse-line-args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
465 (name (nth 0 args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
466 (next (nth 1 args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
467 (prev (nth 2 args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
468 (up (nth 3 args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
469 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
470 (setq texinfo-last-node name)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
471 (let ((tem (downcase name)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
472 (if (assoc tem texinfo-node-names)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
473 (error "Duplicate node name: %s" name)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
474 (setq texinfo-node-names (cons (list tem) texinfo-node-names))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
475 (setq texinfo-footnote-number 0)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
476 (or (bolp)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
477 (insert ?\n))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
478 (insert "\^_\nFile: " texinfo-format-filename
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
479 " Node: " name)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
480 (if prev
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
481 (insert ", Prev: " prev))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
482 (if up
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
483 (insert ", Up: " up))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
484 (if next
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
485 (insert ", Next: " next))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
486 (insert ?\n)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
487
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
488 (put 'menu 'texinfo-format 'texinfo-format-menu)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
489 (defun texinfo-format-menu ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
490 (texinfo-discard-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
491 (insert "* Menu:\n\n"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
492
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
493 (put 'menu 'texinfo-end 'texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
494 (defun texinfo-discard-line ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
495 (goto-char texinfo-command-end)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
496 (skip-chars-forward " \t")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
497 (or (eolp)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
498 (error "Extraneous text at end of command line."))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
499 (goto-char texinfo-command-start)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
500 (or (bolp)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
501 (error "Extraneous text at beginning of command line."))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
502 (delete-region (point) (progn (forward-line 1) (point))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
503
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
504 ; @xref {NODE, FNAME, NAME, FILE, DOCUMENT}
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
505 ; -> *Note FNAME: (FILE)NODE
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
506 ; If FILE is missing,
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
507 ; *Note FNAME: NODE
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
508 ; If FNAME is empty and NAME is present
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
509 ; *Note NAME: Node
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
510 ; If both NAME and FNAME are missing
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
511 ; *Note NODE::
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
512 ; texinfo ignores the DOCUMENT argument.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
513 ; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
514 ; If FILE is specified, (FILE)NODE is used for xrefs.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
515 ; If fifth argument DOCUMENT is specified, produces
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
516 ; See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
517 ; of DOCUMENT
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
518
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
519 ; @ref a reference that does not put `See' or `see' in
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
520 ; the hardcopy and is the same as @xref in Info
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
521 (put 'ref 'texinfo-format 'texinfo-format-xref)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
522
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
523 (put 'xref 'texinfo-format 'texinfo-format-xref)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
524 (defun texinfo-format-xref ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
525 (let ((args (texinfo-format-parse-args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
526 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
527 (insert "*Note ")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
528 (let ((fname (or (nth 1 args) (nth 2 args))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
529 (if (null (or fname (nth 3 args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
530 (insert (car args) "::")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
531 (insert (or fname (car args)) ": ")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
532 (if (nth 3 args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
533 (insert "(" (nth 3 args) ")"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
534 (insert (car args))))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
535
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
536 (put 'pxref 'texinfo-format 'texinfo-format-pxref)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
537 (defun texinfo-format-pxref ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
538 (texinfo-format-xref)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
539 (or (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
540 (forward-char -2)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
541 (looking-at "::"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
542 (insert ".")))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
543
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
544 ;@inforef{NODE, FNAME, FILE}
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
545 ;Like @xref{NODE, FNAME,,FILE} in texinfo.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
546 ;In Tex, generates "See Info file FILE, node NODE"
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
547 (put 'inforef 'texinfo-format 'texinfo-format-inforef)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
548 (defun texinfo-format-inforef ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
549 (let ((args (texinfo-format-parse-args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
550 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
551 (if (nth 1 args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
552 (insert "*Note " (nth 1 args) ": (" (nth 2 args) ")" (car args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
553 (insert "*Note " "(" (nth 2 args) ")" (car args) "::"))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
554
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
555 (put 'chapheading 'texinfo-format 'texinfo-format-chapter)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
556 (put 'ichapter 'texinfo-format 'texinfo-format-chapter)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
557 (put 'chapter 'texinfo-format 'texinfo-format-chapter)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
558 (put 'iappendix 'texinfo-format 'texinfo-format-chapter)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
559 (put 'appendix 'texinfo-format 'texinfo-format-chapter)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
560 (put 'iunnumbered 'texinfo-format 'texinfo-format-chapter)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
561 (put 'unnumbered 'texinfo-format 'texinfo-format-chapter)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
562 (defun texinfo-format-chapter ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
563 (texinfo-format-chapter-1 ?*))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
564
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
565 (put 'heading 'texinfo-format 'texinfo-format-section)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
566 (put 'isection 'texinfo-format 'texinfo-format-section)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
567 (put 'section 'texinfo-format 'texinfo-format-section)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
568 (put 'iappendixsection 'texinfo-format 'texinfo-format-section)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
569 (put 'appendixsection 'texinfo-format 'texinfo-format-section)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
570 (put 'iappendixsec 'texinfo-format 'texinfo-format-section)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
571 (put 'appendixsec 'texinfo-format 'texinfo-format-section)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
572 (put 'iunnumberedsec 'texinfo-format 'texinfo-format-section)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
573 (put 'unnumberedsec 'texinfo-format 'texinfo-format-section)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
574 (defun texinfo-format-section ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
575 (texinfo-format-chapter-1 ?=))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
576
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
577 (put 'subheading 'texinfo-format 'texinfo-format-subsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
578 (put 'isubsection 'texinfo-format 'texinfo-format-subsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
579 (put 'subsection 'texinfo-format 'texinfo-format-subsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
580 (put 'iappendixsubsec 'texinfo-format 'texinfo-format-subsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
581 (put 'appendixsubsec 'texinfo-format 'texinfo-format-subsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
582 (put 'iunnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
583 (put 'unnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
584 (defun texinfo-format-subsection ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
585 (texinfo-format-chapter-1 ?-))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
586
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
587 (put 'subsubheading 'texinfo-format 'texinfo-format-subsubsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
588 (put 'isubsubsection 'texinfo-format 'texinfo-format-subsubsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
589 (put 'subsubsection 'texinfo-format 'texinfo-format-subsubsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
590 (put 'iappendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
591 (put 'appendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
592 (put 'iunnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
593 (put 'unnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
594 (defun texinfo-format-subsubsection ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
595 (texinfo-format-chapter-1 ?.))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
596
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
597 (defun texinfo-format-chapter-1 (belowchar)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
598 (let ((arg (texinfo-parse-arg-discard)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
599 (message "Formatting: %s ... " arg) ; So we can see where we are.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
600 (insert ?\n arg ?\n "@SectionPAD " belowchar ?\n)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
601 (forward-line -2)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
602
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
603 (put 'SectionPAD 'texinfo-format 'texinfo-format-sectionpad)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
604 (defun texinfo-format-sectionpad ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
605 (let ((str (texinfo-parse-arg-discard)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
606 (forward-char -1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
607 (let ((column (current-column)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
608 (forward-char 1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
609 (while (> column 0)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
610 (insert str)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
611 (setq column (1- column))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
612 (insert ?\n)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
613
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
614 (put '\. 'texinfo-format 'texinfo-format-\.)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
615 (defun texinfo-format-\. ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
616 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
617 (insert "."))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
618
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
619 (put '\: 'texinfo-format 'texinfo-format-\:)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
620 (defun texinfo-format-\: ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
621 (texinfo-discard-command))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
622
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
623 (put 'center 'texinfo-format 'texinfo-format-center)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
624 (defun texinfo-format-center ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
625 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
626 (let ((indent-tabs-mode nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
627 (center-line)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
628
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
629 (put 'sp 'texinfo-format 'texinfo-format-sp)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
630 (defun texinfo-format-sp ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
631 (let* ((arg (texinfo-parse-arg-discard))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
632 (num (read arg)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
633 (insert-char ?\n num)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
634
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
635 (put 'br 'texinfo-format 'texinfo-format-paragraph-break)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
636 (defun texinfo-format-paragraph-break ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
637 "Force a paragraph break.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
638 If used within a line, follow `@br' with braces."
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
639 (texinfo-optional-braces-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
640 ;; insert one return if at end of line;
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
641 ;; else insert two returns, to generate a blank line.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
642 (if (= (following-char) ?\n)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
643 (insert ?\n)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
644 (insert-char ?\n 2)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
645
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
646
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
647 ;;; @footnote
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
648
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
649 ; In Texinfo, footnotes are created with the `@footnote' command.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
650 ; This command is followed immediately by a left brace, then by the text of
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
651 ; the footnote, and then by a terminating right brace. The
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
652 ; template for a footnote is:
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
653 ;
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
654 ; @footnote{TEXT}
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
655 ;
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
656 ; Info has two footnote styles:
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
657 ;
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
658 ; `End Node'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
659 ; In the "End Node" style, all the footnotes for a single node
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
660 ; are placed at the end of that node. The footnotes are
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
661 ; separated from the rest of the node by a line of dashes with
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
662 ; the word `Footnotes' within it.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
663 ;
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
664 ; `Make Node'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
665 ; In the "Make Node" style, all the footnotes for a single node are
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
666 ; placed in an automatically constructed node of their own.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
667
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
668 (put 'footnote 'texinfo-format 'texinfo-format-footnote)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
669
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
670 (defvar texinfo-footnote-style 'MN "\
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
671 *Footnote style, either EN for end node or MN for make node.")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
672
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
673 (defvar texinfo-footnote-number)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
674
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
675 (defun texinfo-format-footnote ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
676 "Format a footnote in either `end node' or `make node' style.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
677 The texinfo-footnote-style variable controls which style is used."
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
678 (setq texinfo-footnote-number (1+ texinfo-footnote-number))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
679 (cond ((eq texinfo-footnote-style 'EN) (texinfo-format-end-node))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
680 ((eq texinfo-footnote-style 'MN) (texinfo-format-make-node))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
681
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
682 (defun texinfo-format-make-node ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
683 "Format footnote in `MN', Make Node, style with notes in own node.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
684 The node is constructed automatically."
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
685 (let* (start
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
686 (arg (texinfo-parse-expanded-arg))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
687 (node-name-beginning
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
688 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
689 (re-search-backward
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
690 "^File: \\w+\\(\\w\\|\\s_\\|\\.\\)*[ \t]+Node:")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
691 (match-end 0)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
692 (node-name
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
693 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
694 (buffer-substring
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
695 (progn (goto-char node-name-beginning) ; skip over node command
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
696 (skip-chars-forward " \t") ; and over spaces
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
697 (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
698 (if (search-forward
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
699 ","
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
700 (save-excursion (end-of-line) (point)) t) ; bound search
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
701 (1- (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
702 (end-of-line) (point))))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
703 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
704 (insert (format "(%d) (*note %s-Footnotes::)"
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
705 texinfo-footnote-number node-name))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
706 (fill-paragraph nil)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
707 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
708 (if (re-search-forward "^@node" nil 'move)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
709 (forward-line -1))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
710
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
711 ;; two cases: for the first footnote, we must insert a node header;
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
712 ;; for the second and subsequent footnotes, we need only insert
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
713 ;; the text of the footnote.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
714
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
715 (if (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
716 (re-search-backward
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
717 (concat node-name "-Footnotes, Up: ")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
718 node-name-beginning
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
719 t))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
720 (progn ; already at least one footnote
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
721 (setq start (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
722 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
723 (fill-region start (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
724 ;; else not yet a footnote
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
725 (insert "\n\^_\nFile: " texinfo-format-filename
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
726 " Node: " node-name "-Footnotes, Up: " node-name "\n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
727 (setq start (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
728 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
729 (fill-region start (point))))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
730
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
731 (defun texinfo-format-end-node ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
732 "Format footnote in `EN', End Node, style with notes at end of node."
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
733 (let (start
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
734 (arg (texinfo-parse-expanded-arg)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
735 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
736 (insert (format "(%d) " texinfo-footnote-number))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
737 (fill-paragraph nil)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
738 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
739 (if (search-forward "\n--------- Footnotes ---------\n" nil t)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
740 (progn ; already have footnote, put new one before end of node
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
741 (if (re-search-forward "^@node" nil 'move)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
742 (forward-line -1))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
743 (setq start (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
744 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
745 (fill-region start (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
746 ;; else no prior footnote
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
747 (if (re-search-forward "^@node" nil 'move)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
748 (forward-line -1))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
749 (insert "\n--------- Footnotes ---------\n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
750 (setq start (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
751 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
752 (fill-region start (point))))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
753
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
754
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
755 ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
756 ;; @enumerate pushes (enumerate 0 STARTPOS).
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
757 ;; @item dispatches to the texinfo-item prop of the first elt of the list.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
758 ;; For itemize, this puts in and rescans the COMMANDS.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
759 ;; For enumerate, this increments the number and puts it in.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
760 ;; In either case, it puts a Backspace at the front of the line
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
761 ;; which marks it not to be indented later.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
762 ;; All other lines get indented by 5 when the @end is reached.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
763
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
764 (defun texinfo-push-stack (check arg)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
765 (setq texinfo-stack
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
766 (cons (list check arg texinfo-command-start)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
767 texinfo-stack)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
768
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
769 (defun texinfo-pop-stack (check)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
770 (if (null texinfo-stack)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
771 (error "Unmatched @end %s" check))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
772 (if (not (eq (car (car texinfo-stack)) check))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
773 (error "@end %s matches @%s"
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
774 check (car (car texinfo-stack))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
775 (prog1 (cdr (car texinfo-stack))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
776 (setq texinfo-stack (cdr texinfo-stack))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
777
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
778 (put 'itemize 'texinfo-format 'texinfo-itemize)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
779 (defun texinfo-itemize ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
780 (texinfo-push-stack 'itemize (texinfo-parse-arg-discard))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
781 (setq fill-column (- fill-column 5)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
782
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
783 (put 'itemize 'texinfo-end 'texinfo-end-itemize)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
784 (defun texinfo-end-itemize ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
785 (setq fill-column (+ fill-column 5))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
786 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
787 (let ((stacktop
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
788 (texinfo-pop-stack 'itemize)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
789 (texinfo-do-itemize (nth 1 stacktop))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
790
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
791 (put 'enumerate 'texinfo-format 'texinfo-enumerate)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
792 (defun texinfo-enumerate ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
793 (texinfo-push-stack 'enumerate 0)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
794 (setq fill-column (- fill-column 5))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
795 (texinfo-discard-line))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
796
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
797 (put 'enumerate 'texinfo-end 'texinfo-end-enumerate)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
798 (defun texinfo-end-enumerate ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
799 (setq fill-column (+ fill-column 5))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
800 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
801 (let ((stacktop
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
802 (texinfo-pop-stack 'enumerate)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
803 (texinfo-do-itemize (nth 1 stacktop))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
804
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
805 (put 'table 'texinfo-format 'texinfo-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
806 (defun texinfo-table ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
807 (texinfo-push-stack 'table (texinfo-parse-arg-discard))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
808 (setq fill-column (- fill-column 5)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
809
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
810 (put 'ftable 'texinfo-format 'texinfo-ftable)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
811 (defun texinfo-ftable ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
812 (texinfo-push-stack 'table "@code")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
813 (setq fill-column (- fill-column 5))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
814 (texinfo-discard-line))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
815
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
816 (put 'description 'texinfo-format 'texinfo-description)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
817 (defun texinfo-description ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
818 (texinfo-push-stack 'table "@asis")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
819 (setq fill-column (- fill-column 5))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
820 (texinfo-discard-line))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
821
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
822 (put 'table 'texinfo-end 'texinfo-end-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
823 (put 'ftable 'texinfo-end 'texinfo-end-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
824 (put 'description 'texinfo-end 'texinfo-end-table)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
825 (defun texinfo-end-table ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
826 (setq fill-column (+ fill-column 5))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
827 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
828 (let ((stacktop
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
829 (texinfo-pop-stack 'table)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
830 (texinfo-do-itemize (nth 1 stacktop))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
831
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
832 ;; At the @end, indent all the lines within the construct
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
833 ;; except those marked with backspace. FROM says where
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
834 ;; construct started.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
835 (defun texinfo-do-itemize (from)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
836 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
837 (while (progn (forward-line -1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
838 (>= (point) from))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
839 (if (= (following-char) ?\b)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
840 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
841 (delete-char 1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
842 (end-of-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
843 (delete-char 6))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
844 (if (not (looking-at "[ \t]*$"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
845 (save-excursion (insert " ")))))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
846
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
847 (put 'item 'texinfo-format 'texinfo-item)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
848 (put 'itemx 'texinfo-format 'texinfo-item)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
849 (defun texinfo-item ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
850 (funcall (get (car (car texinfo-stack)) 'texinfo-item)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
851
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
852 (put 'itemize 'texinfo-item 'texinfo-itemize-item)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
853 (defun texinfo-itemize-item ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
854 (texinfo-discard-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
855 (insert "\b " (nth 1 (car texinfo-stack)) " \n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
856 (forward-line -1))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
857
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
858 (put 'enumerate 'texinfo-item 'texinfo-enumerate-item)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
859 (defun texinfo-enumerate-item ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
860 (texinfo-discard-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
861 (let ((next (1+ (car (cdr (car texinfo-stack))))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
862 (setcar (cdr (car texinfo-stack)) next)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
863 (insert ?\b (format "%3d. " next) ?\n))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
864 (forward-line -1))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
865
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
866 (put 'table 'texinfo-item 'texinfo-table-item)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
867 (defun texinfo-table-item ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
868 (let ((arg (texinfo-parse-arg-discard))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
869 (itemfont (car (cdr (car texinfo-stack)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
870 (insert ?\b itemfont ?\{ arg "}\n \n"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
871 (forward-line -2))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
872
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
873
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
874 ; @ftable
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
875
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
876 ; The `@ftable' command is like the `@table' command but it also
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
877 ; inserts each item in the first column into the function index.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
878
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
879 (put 'ftable 'texinfo-format 'texinfo-ftable)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
880
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
881 ; The following function presumes that the first column of the table
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
882 ; should be in `@code' font; but the texinfo.tex source does not
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
883 ; presume this.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
884 ; (defun texinfo-ftable ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
885 ; (texinfo-push-stack 'ftable "@code")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
886 ; (setq fill-column (- fill-column 5))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
887 ; (texinfo-discard-line))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
888
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
889 (defun texinfo-ftable ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
890 (texinfo-push-stack 'ftable (texinfo-parse-arg-discard))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
891 (setq fill-column (- fill-column 5)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
892
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
893 (put 'ftable 'texinfo-item 'texinfo-ftable-item)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
894 (defun texinfo-ftable-item ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
895 (let ((item (texinfo-parse-arg-discard))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
896 (itemfont (car (cdr (car texinfo-stack))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
897 (indexvar 'texinfo-findex))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
898 (insert ?\b itemfont ?\{ item "}\n \n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
899 (set indexvar
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
900 (cons
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
901 (list item texinfo-last-node)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
902 (symbol-value indexvar)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
903 (forward-line -2)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
904
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
905 (put 'ftable 'texinfo-end 'texinfo-end-ftable)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
906 (defun texinfo-end-ftable ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
907 (setq fill-column (+ fill-column 5))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
908 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
909 (let ((stacktop
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
910 (texinfo-pop-stack 'ftable)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
911 (texinfo-do-itemize (nth 1 stacktop))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
912
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
913
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
914 (put 'ifinfo 'texinfo-format 'texinfo-discard-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
915 (put 'ifinfo 'texinfo-end 'texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
916
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
917 (put 'iftex 'texinfo-format 'texinfo-format-iftex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
918 (defun texinfo-format-iftex ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
919 (delete-region texinfo-command-start
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
920 (progn (re-search-forward "@end iftex\n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
921 (point))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
922
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
923 (put 'tex 'texinfo-format 'texinfo-format-tex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
924 (defun texinfo-format-tex ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
925 (delete-region texinfo-command-start
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
926 (progn (re-search-forward "@end tex\n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
927 (point))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
928
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
929 (put 'titlepage 'texinfo-format 'texinfo-format-titlepage)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
930 (defun texinfo-format-titlepage ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
931 (delete-region texinfo-command-start
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
932 (progn (search-forward "@end titlepage\n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
933 (point))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
934
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
935 (put 'endtitlepage 'texinfo-format 'texinfo-discard-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
936
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
937 ; @titlespec an alternative titling command; ignored by Info
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
938
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
939 (put 'titlespec 'texinfo-format 'texinfo-format-titlespec)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
940 (defun texinfo-format-titlespec ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
941 (delete-region texinfo-command-start
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
942 (progn (search-forward "@end titlespec\n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
943 (point))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
944
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
945 (put 'endtitlespec 'texinfo-format 'texinfo-discard-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
946
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
947 ; @today{}
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
948
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
949 (put 'today 'texinfo-format 'texinfo-format-today)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
950
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
951 ; Produces Day Month Year style of output. eg `1 Jan 1900'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
952 ; The `@today{}' command requires a pair of braces, like `@dots{}'.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
953 (defun texinfo-format-today ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
954 (texinfo-parse-arg-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
955 (insert (format "%s %s %s"
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
956 (substring (current-time-string) 8 10)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
957 (substring (current-time-string) 4 7)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
958 (substring (current-time-string) -4))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
959
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
960
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
961 (put 'ignore 'texinfo-format 'texinfo-format-ignore)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
962 (defun texinfo-format-ignore ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
963 (delete-region texinfo-command-start
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
964 (progn (search-forward "@end ignore\n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
965 (point))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
966
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
967 (put 'endignore 'texinfo-format 'texinfo-discard-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
968
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
969 (put 'var 'texinfo-format 'texinfo-format-var)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
970 ; @sc a small caps font for TeX; formatted as `var' in Info
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
971 (put 'sc 'texinfo-format 'texinfo-format-var)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
972 (defun texinfo-format-var ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
973 (insert (upcase (texinfo-parse-arg-discard)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
974 (goto-char texinfo-command-start))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
975
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
976 ; various noops
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
977
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
978 (put 'asis 'texinfo-format 'texinfo-format-noop)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
979 (put 'b 'texinfo-format 'texinfo-format-noop)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
980 (put 't 'texinfo-format 'texinfo-format-noop)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
981 (put 'i 'texinfo-format 'texinfo-format-noop)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
982 (put 'r 'texinfo-format 'texinfo-format-noop)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
983 (put 'titlefont 'texinfo-format 'texinfo-format-noop)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
984 (put 'key 'texinfo-format 'texinfo-format-noop)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
985 (put 'w 'texinfo-format 'texinfo-format-noop)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
986 (defun texinfo-format-noop ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
987 (insert (texinfo-parse-arg-discard))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
988 (goto-char texinfo-command-start))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
989
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
990 (put 'code 'texinfo-format 'texinfo-format-code)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
991 (put 'samp 'texinfo-format 'texinfo-format-code)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
992 (put 'file 'texinfo-format 'texinfo-format-code)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
993 (put 'kbd 'texinfo-format 'texinfo-format-code)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
994 (put 'cite 'texinfo-format 'texinfo-format-code)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
995 (defun texinfo-format-code ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
996 (insert "`" (texinfo-parse-arg-discard) "'")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
997 (goto-char texinfo-command-start))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
998
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
999 (put 'emph 'texinfo-format 'texinfo-format-emph)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1000 (put 'strong 'texinfo-format 'texinfo-format-emph)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1001 (defun texinfo-format-emph ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1002 (insert "*" (texinfo-parse-arg-discard) "*")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1003 (goto-char texinfo-command-start))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1004
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1005 (put 'defn 'texinfo-format 'texinfo-format-defn)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1006 (put 'dfn 'texinfo-format 'texinfo-format-defn)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1007 (defun texinfo-format-defn ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1008 (insert "\"" (texinfo-parse-arg-discard) "\"")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1009 (goto-char texinfo-command-start))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1010
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1011 (put 'bullet 'texinfo-format 'texinfo-format-bullet)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1012 (defun texinfo-format-bullet ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1013 "Insert an asterisk.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1014 If used within a line, follow `@bullet' with braces."
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1015 (texinfo-optional-braces-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1016 (insert "*"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1017
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1018 (put 'smallexample 'texinfo-format 'texinfo-format-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1019 (put 'smalllisp 'texinfo-format 'texinfo-format-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1020 (put 'example 'texinfo-format 'texinfo-format-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1021 (put 'quotation 'texinfo-format 'texinfo-format-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1022 (put 'lisp 'texinfo-format 'texinfo-format-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1023 (put 'display 'texinfo-format 'texinfo-format-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1024 (put 'format 'texinfo-format 'texinfo-format-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1025 (put 'flushleft 'texinfo-format 'texinfo-format-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1026 (defun texinfo-format-example ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1027 (texinfo-push-stack 'example nil)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1028 (setq fill-column (- fill-column 5))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1029 (texinfo-discard-line))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1030
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1031 (put 'smallexample 'texinfo-end 'texinfo-end-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1032 (put 'example 'texinfo-end 'texinfo-end-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1033 (put 'quotation 'texinfo-end 'texinfo-end-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1034 (put 'lisp 'texinfo-end 'texinfo-end-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1035 (put 'display 'texinfo-end 'texinfo-end-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1036 (put 'format 'texinfo-end 'texinfo-end-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1037 (put 'flushleft 'texinfo-end 'texinfo-end-example)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1038 (defun texinfo-end-example ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1039 (setq fill-column (+ fill-column 5))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1040 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1041 (let ((stacktop
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1042 (texinfo-pop-stack 'example)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1043 (texinfo-do-itemize (nth 1 stacktop))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1044
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1045 (put 'exdent 'texinfo-format 'texinfo-format-exdent)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1046 (defun texinfo-format-exdent ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1047 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1048 (delete-region (point)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1049 (progn
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1050 (skip-chars-forward " ")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1051 (point)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1052 (insert ?\b)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1053 ;; Cancel out the deletion that texinfo-do-itemize
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1054 ;; is going to do at the end of this line.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1055 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1056 (end-of-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1057 (insert "\n ")))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1058
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1059
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1060 ;; @flushright ... @end flushright
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1061
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1062 ; The @flushright command right justifies every line but leaves the
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1063 ; left end ragged.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1064
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1065 (put 'flushright 'texinfo-format 'texinfo-format-flushright)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1066 (defun texinfo-format-flushright ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1067 (texinfo-push-stack 'flushright nil)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1068 (texinfo-discard-line))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1069
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1070 (put 'flushright 'texinfo-end 'texinfo-end-flushright)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1071 (defun texinfo-end-flushright ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1072 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1073
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1074 (let ((stacktop
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1075 (texinfo-pop-stack 'flushright)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1076
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1077 (texinfo-do-flushright (nth 1 stacktop))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1078
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1079 (defun texinfo-do-flushright (from)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1080 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1081 (while (progn (forward-line -1)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1082 (>= (point) from))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1083
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1084 (beginning-of-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1085 (insert
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1086 (make-string
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1087 (- fill-column
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1088 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1089 (end-of-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1090 (current-column)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1091 ? )))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1092
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1093
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1094 (put 'ctrl 'texinfo-format 'texinfo-format-ctrl)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1095 (defun texinfo-format-ctrl ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1096 (let ((str (texinfo-parse-arg-discard)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1097 (insert (logand 31 (aref str 0)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1098
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1099 (put 'TeX 'texinfo-format 'texinfo-format-TeX)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1100 (defun texinfo-format-TeX ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1101 (texinfo-parse-arg-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1102 (insert "TeX"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1103
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1104 (put 'copyright 'texinfo-format 'texinfo-format-copyright)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1105 (defun texinfo-format-copyright ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1106 (texinfo-parse-arg-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1107 (insert "(C)"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1108
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1109 (put 'minus 'texinfo-format 'texinfo-format-minus)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1110 (defun texinfo-format-minus ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1111 "Insert a minus sign.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1112 If used within a line, follow `@minus' with braces."
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1113 (texinfo-optional-braces-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1114 (insert "-"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1115
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1116 (put 'dots 'texinfo-format 'texinfo-format-dots)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1117 (defun texinfo-format-dots ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1118 (texinfo-parse-arg-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1119 (insert "..."))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1120
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1121 (put 'refill 'texinfo-format 'texinfo-format-refill)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1122 (defun texinfo-format-refill ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1123 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1124 (fill-paragraph nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1125
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1126
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1127 ;;; Index generation
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1128
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1129 (put 'vindex 'texinfo-format 'texinfo-format-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1130 (defun texinfo-format-vindex ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1131 (texinfo-index 'texinfo-vindex))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1132
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1133 (put 'cindex 'texinfo-format 'texinfo-format-cindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1134 (defun texinfo-format-cindex ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1135 (texinfo-index 'texinfo-cindex))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1136
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1137 (put 'findex 'texinfo-format 'texinfo-format-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1138 (defun texinfo-format-findex ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1139 (texinfo-index 'texinfo-findex))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1140
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1141 (put 'pindex 'texinfo-format 'texinfo-format-pindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1142 (defun texinfo-format-pindex ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1143 (texinfo-index 'texinfo-pindex))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1144
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1145 (put 'tindex 'texinfo-format 'texinfo-format-tindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1146 (defun texinfo-format-tindex ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1147 (texinfo-index 'texinfo-tindex))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1148
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1149 (put 'kindex 'texinfo-format 'texinfo-format-kindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1150 (defun texinfo-format-kindex ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1151 (texinfo-index 'texinfo-kindex))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1152
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1153 (defun texinfo-index (indexvar)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1154 (let ((arg (texinfo-parse-expanded-arg)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1155 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1156 (set indexvar
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1157 (cons (list arg texinfo-last-node)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1158 (symbol-value indexvar)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1159
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1160 (defconst texinfo-indexvar-alist
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1161 '(("cp" . texinfo-cindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1162 ("fn" . texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1163 ("vr" . texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1164 ("tp" . texinfo-tindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1165 ("pg" . texinfo-pindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1166 ("ky" . texinfo-kindex)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1167
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1168
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1169 ;;; @defindex @defcodeindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1170 (put 'defindex 'texinfo-format 'texinfo-format-defindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1171 (put 'defcodeindex 'texinfo-format 'texinfo-format-defindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1172
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1173 (defun texinfo-format-defindex ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1174 (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1175 (indexing-command (intern (concat index-name "index")))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1176 (index-formatting-command ; eg: `texinfo-format-aaindex'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1177 (intern (concat "texinfo-format-" index-name "index")))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1178 (index-alist-name ; eg: `texinfo-aaindex'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1179 (intern (concat "texinfo-" index-name "index"))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1180
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1181 (set index-alist-name nil)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1182
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1183 (put indexing-command ; eg, aaindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1184 'texinfo-format
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1185 index-formatting-command) ; eg, texinfo-format-aaindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1186
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1187 ;; eg: "aa" . texinfo-aaindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1188 (or (assoc index-name texinfo-indexvar-alist)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1189 (setq texinfo-indexvar-alist
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1190 (cons
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1191 (cons index-name
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1192 index-alist-name)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1193 texinfo-indexvar-alist)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1194
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1195 (fset index-formatting-command
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1196 (list 'lambda 'nil
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1197 (list 'texinfo-index
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1198 (list 'quote index-alist-name))))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1199
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1200
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1201 ;;; @synindex @syncodeindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1202
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1203 (put 'synindex 'texinfo-format 'texinfo-format-synindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1204 (put 'syncodeindex 'texinfo-format 'texinfo-format-synindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1205
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1206 (defun texinfo-format-synindex ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1207 (let* ((args (texinfo-parse-arg-discard))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1208 (second (cdr (read-from-string args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1209 (joiner (symbol-name (car (read-from-string args))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1210 (joined (symbol-name (car (read-from-string args second)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1211
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1212 (if (assoc joiner texinfo-short-index-cmds-alist)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1213 (put
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1214 (cdr (assoc joiner texinfo-short-index-cmds-alist))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1215 'texinfo-format
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1216 (or (cdr (assoc joined texinfo-short-index-format-cmds-alist))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1217 (intern (concat "texinfo-format-" joined "index"))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1218 (put
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1219 (intern (concat joiner "index"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1220 'texinfo-format
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1221 (or (cdr(assoc joined texinfo-short-index-format-cmds-alist))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1222 (intern (concat "texinfo-format-" joined "index")))))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1223
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1224 (defconst texinfo-short-index-cmds-alist
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1225 '(("cp" . cindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1226 ("fn" . findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1227 ("vr" . vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1228 ("tp" . tindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1229 ("pg" . pindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1230 ("ky" . kindex)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1231
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1232 (defconst texinfo-short-index-format-cmds-alist
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1233 '(("cp" . texinfo-format-cindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1234 ("fn" . texinfo-format-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1235 ("vr" . texinfo-format-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1236 ("tp" . texinfo-format-tindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1237 ("pg" . texinfo-format-pindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1238 ("ky" . texinfo-format-kindex)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1239
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1240
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1241 ;;; @printindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1242
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1243 (put 'printindex 'texinfo-format 'texinfo-format-printindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1244
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1245 (defun texinfo-format-printindex ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1246 (let ((indexelts (symbol-value
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1247 (cdr (assoc (texinfo-parse-arg-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1248 texinfo-indexvar-alist))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1249 opoint)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1250 (insert "\n* Menu:\n\n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1251 (setq opoint (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1252 (texinfo-print-index nil indexelts)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1253
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1254 (if (eq system-type 'vax-vms)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1255 (texinfo-sort-region opoint (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1256 (shell-command-on-region opoint (point) "sort -fd" 1))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1257
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1258 (defun texinfo-print-index (file indexelts)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1259 (while indexelts
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1260 (if (stringp (car (car indexelts)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1261 (insert "* " (car (car indexelts))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1262 ": " (if file (concat "(" file ")") "")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1263 (nth 1 (car indexelts)) ".\n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1264 ;; index entries from @include'd file
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1265 (texinfo-print-index (nth 1 (car indexelts))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1266 (nth 2 (car indexelts))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1267 (setq indexelts (cdr indexelts))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1268
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1269
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1270 ;;; NOTATIONS: @equiv, @error, etc
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1271
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1272 ;; @equiv to show that two expressions are equivalent
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1273 ;; @error to show an error message
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1274 ;; @expansion to show what a macro expands to
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1275 ;; @point to show the location of point in an example
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1276 ;; @print to show what an evaluated expression prints
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1277 ;; @result to indicate the value returned by an expression
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1278
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1279 (put 'equiv 'texinfo-format 'texinfo-format-equiv)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1280 (defun texinfo-format-equiv ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1281 (texinfo-parse-arg-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1282 (insert "=="))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1283
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1284 (put 'error 'texinfo-format 'texinfo-format-error)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1285 (defun texinfo-format-error ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1286 (texinfo-parse-arg-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1287 (insert "error-->"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1288
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1289 (put 'expansion 'texinfo-format 'texinfo-format-expansion)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1290 (defun texinfo-format-expansion ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1291 (texinfo-parse-arg-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1292 (insert "==>"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1293
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1294 (put 'point 'texinfo-format 'texinfo-format-point)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1295 (defun texinfo-format-point ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1296 (texinfo-parse-arg-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1297 (insert "-!-"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1298
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1299 (put 'print 'texinfo-format 'texinfo-format-print)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1300 (defun texinfo-format-print ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1301 (texinfo-parse-arg-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1302 (insert "-|"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1303
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1304 (put 'result 'texinfo-format 'texinfo-format-result)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1305 (defun texinfo-format-result ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1306 (texinfo-parse-arg-discard)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1307 (insert "=>"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1308
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1309
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1310 ;;;; Description formatting: @deffn, @defun, etc
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1311
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1312 (defun texinfo-format-defun ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1313 (texinfo-push-stack 'defun nil)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1314 (setq fill-column (- fill-column 5))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1315 (texinfo-format-defun-1 t))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1316
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1317 (defun texinfo-format-defunx ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1318 (texinfo-format-defun-1 nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1319
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1320 (defun texinfo-format-defun-1 (first-p)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1321 (let ((args (texinfo-format-parse-defun-args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1322 (command-type (get texinfo-command-name 'texinfo-defun-type))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1323 (class "")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1324 (name "")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1325 (classification "")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1326 (data-type ""))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1327 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1328
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1329 (cond
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1330 ;; Generalized object oriented entity: `category class name [args...]'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1331 ;; In Info, `Category on class: name ARG'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1332 ((eq (eval (car command-type)) 'defop-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1333 (setq category (car args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1334 (setq class (car (cdr args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1335 (setq name (car args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1336 (setq args (cdr (cdr args))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1337
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1338 ;; Specialized object oriented entity: @defmethod, @defivar
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1339 ;; "Instance Variable" `class name [args...]'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1340 ;; In Info, `Instance variable of class: name'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1341 ((eq (eval (car command-type)) 'defmethod-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1342 (setq category (car (cdr command-type)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1343 (setq class (car args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1344 (setq name (car args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1345 (setq args (cdr args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1346
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1347 ;; Generalized function-like or variable-like entity:
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1348 ;; `category name [args...]'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1349 ;; In Info, `Category: name ARGS'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1350 ((or (eq (eval (car command-type)) 'deffn-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1351 (eq (eval (car command-type)) 'deftp-type))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1352 (setq category (car args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1353 (setq args (cdr args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1354 (setq name (car args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1355
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1356 ;; Specialized function-like or variable-like entity:
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1357 ;; "Macro" `name [args...]'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1358 ;; In Info, `Macro: Name ARGS'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1359 ((eq (eval (car command-type)) 'defun-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1360 (setq category (car (cdr command-type)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1361 (setq name (car args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1362
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1363 ;; Generalized typed-function-like or typed-variable-like entity:
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1364 ;; `Classification data-type name [args...]'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1365 ;; In Info, `Classification: data-type name ARGS'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1366 ((or (eq (eval (car command-type)) 'deftypefn-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1367 (eq (eval (car command-type)) 'deftypevr-type))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1368 (setq classification (car args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1369 (setq data-type (car (cdr args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1370 (setq name (car (cdr (cdr args))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1371 (setq args (cdr (cdr (cdr args)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1372
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1373 ;; Specialized typed-function-like or typed-variable-like entity:
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1374 ;; `data-type name [args...]'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1375 ;; In Info, `Function: data-type name ARGS'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1376 ;; or, `Variable: data-type name'
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1377 ((or (eq (eval (car command-type)) 'deftypefun-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1378 (eq (eval (car command-type)) 'deftypevar-type))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1379 (setq classification (car (cdr command-type)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1380 (setq data-type (car args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1381 (setq name (car (cdr args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1382 (setq args (cdr (cdr args)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1383
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1384 ;; Delete extra newline inserted after previous header line.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1385 (if (not first-p)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1386 (delete-char -1))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1387
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1388 (let ((formatter (get texinfo-command-name 'texinfo-defun-format-type)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1389 (cond
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1390 ;; if typed function or variable
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1391 ((eq formatter 'texinfo-format-deftypefn-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1392 (insert "* " classification ": " data-type " " name)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1393 (let ((args args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1394 (while args
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1395 (insert " " (car args))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1396 (setq args (cdr args)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1397 (t
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1398 ;; and if object oriented, set category
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1399 (if (or (eq formatter 'texinfo-format-defop-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1400 (eq formatter 'texinfo-format-defcv-type))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1401 (setq category (funcall formatter category class)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1402 (insert "* " category ": " name)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1403 (let ((args (cdr args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1404 (while args
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1405 (insert " "
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1406 (if (or (= ?& (aref (car args) 0))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1407 (eq (eval (car command-type)) 'deftp-type))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1408 (car args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1409 (upcase (car args))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1410 (setq args (cdr args)))))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1411
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1412 ;; Insert extra newline so that paragraph filling does not mess
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1413 ;; with header line.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1414 (insert "\n\n")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1415 (rplaca (cdr (cdr (car texinfo-stack))) (point))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1416
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1417 (let ((indexvar (get texinfo-command-name 'texinfo-defun-index))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1418 (index-formatter
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1419 (get texinfo-command-name 'texinfo-defun-format-index)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1420 (set indexvar
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1421 (cons (list
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1422 (cond
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1423 ;; if object oriented
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1424 ((or (eq index-formatter 'texinfo-format-defop-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1425 (eq index-formatter 'texinfo-format-defcv-index))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1426 (funcall index-formatter name class))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1427 ((eq index-formatter 'texinfo-format-deftypefn-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1428 (funcall index-formatter name data-type))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1429 (t (car args)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1430 texinfo-last-node)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1431 (symbol-value indexvar))))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1432
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1433 (defun texinfo-end-defun ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1434 (setq fill-column (+ fill-column 5))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1435 (texinfo-discard-command)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1436 (let ((start (nth 1 (texinfo-pop-stack 'defun))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1437 (texinfo-do-itemize start)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1438 ;; Delete extra newline inserted after header.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1439 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1440 (goto-char start)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1441 (delete-char -1))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1442
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1443 (defun texinfo-format-defop-type (category class)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1444 (format "%s on %s" category class))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1445
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1446 (defun texinfo-format-defop-index (name class)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1447 (format "%s on %s" name class))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1448
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1449 (defun texinfo-format-defcv-type (category class)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1450 (format "%s of %s" category class))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1451
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1452 (defun texinfo-format-defcv-index (name class)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1453 (format "%s of %s" name class))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1454
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1455 (put 'deffn 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1456 (put 'deffnx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1457 (put 'deffn 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1458 (put 'deffn 'texinfo-defun-type '('deffn-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1459 (put 'deffnx 'texinfo-defun-type '('deffn-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1460 (put 'deffn 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1461 (put 'deffnx 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1462
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1463 (put 'defun 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1464 (put 'defunx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1465 (put 'defun 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1466 (put 'defun 'texinfo-defun-type '('defun-type "Function"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1467 (put 'defunx 'texinfo-defun-type '('defun-type "Function"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1468 (put 'defun 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1469 (put 'defunx 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1470
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1471 (put 'defmac 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1472 (put 'defmacx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1473 (put 'defmac 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1474 (put 'defmac 'texinfo-defun-type '('defun-type "Macro"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1475 (put 'defmacx 'texinfo-defun-type '('defun-type "Macro"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1476 (put 'defmac 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1477 (put 'defmacx 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1478
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1479 (put 'defspec 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1480 (put 'defspecx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1481 (put 'defspec 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1482 (put 'defspec 'texinfo-defun-type '('defun-type "Special form"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1483 (put 'defspecx 'texinfo-defun-type '('defun-type "Special form"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1484 (put 'defspec 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1485 (put 'defspecx 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1486
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1487 (put 'defvr 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1488 (put 'defvrx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1489 (put 'defvr 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1490 (put 'defvr 'texinfo-defun-type '('deffn-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1491 (put 'defvrx 'texinfo-defun-type '('deffn-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1492 (put 'defvr 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1493 (put 'defvrx 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1494
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1495 (put 'defvar 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1496 (put 'defvarx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1497 (put 'defvar 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1498 (put 'defvar 'texinfo-defun-type '('defun-type "Variable"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1499 (put 'defvarx 'texinfo-defun-type '('defun-type "Variable"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1500 (put 'defvar 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1501 (put 'defvarx 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1502
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1503 (put 'defconst 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1504 (put 'defconstx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1505 (put 'defconst 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1506 (put 'defconst 'texinfo-defun-type '('defun-type "Constant"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1507 (put 'defconstx 'texinfo-defun-type '('defun-type "Constant"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1508 (put 'defconst 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1509 (put 'defconstx 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1510
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1511 (put 'defcmd 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1512 (put 'defcmdx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1513 (put 'defcmd 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1514 (put 'defcmd 'texinfo-defun-type '('defun-type "Command"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1515 (put 'defcmdx 'texinfo-defun-type '('defun-type "Command"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1516 (put 'defcmd 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1517 (put 'defcmdx 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1518
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1519 (put 'defopt 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1520 (put 'defoptx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1521 (put 'defopt 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1522 (put 'defopt 'texinfo-defun-type '('defun-type "User Option"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1523 (put 'defoptx 'texinfo-defun-type '('defun-type "User Option"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1524 (put 'defopt 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1525 (put 'defoptx 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1526
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1527 (put 'deftp 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1528 (put 'deftpx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1529 (put 'deftp 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1530 (put 'deftp 'texinfo-defun-type '('deftp-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1531 (put 'deftpx 'texinfo-defun-type '('deftp-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1532 (put 'deftp 'texinfo-defun-index 'texinfo-tindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1533 (put 'deftpx 'texinfo-defun-index 'texinfo-tindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1534
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1535 ;;; Object-oriented stuff is a little hairier.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1536
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1537 (put 'defop 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1538 (put 'defopx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1539 (put 'defop 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1540 (put 'defop 'texinfo-defun-type '('defop-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1541 (put 'defopx 'texinfo-defun-type '('defop-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1542 (put 'defop 'texinfo-defun-format-type 'texinfo-format-defop-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1543 (put 'defopx 'texinfo-defun-format-type 'texinfo-format-defop-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1544 (put 'defop 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1545 (put 'defopx 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1546 (put 'defop 'texinfo-defun-format-index 'texinfo-format-defop-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1547 (put 'defopx 'texinfo-defun-format-index 'texinfo-format-defop-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1548
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1549 (put 'defmethod 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1550 (put 'defmethodx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1551 (put 'defmethod 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1552 (put 'defmethod 'texinfo-defun-type '('defmethod-type "Operation"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1553 (put 'defmethodx 'texinfo-defun-type '('defmethod-type "Operation"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1554 (put 'defmethod 'texinfo-defun-format-type 'texinfo-format-defop-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1555 (put 'defmethodx 'texinfo-defun-format-type 'texinfo-format-defop-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1556 (put 'defmethod 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1557 (put 'defmethodx 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1558 (put 'defmethod 'texinfo-defun-format-index 'texinfo-format-defop-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1559 (put 'defmethodx 'texinfo-defun-format-index 'texinfo-format-defop-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1560
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1561 (put 'defcv 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1562 (put 'defcvx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1563 (put 'defcv 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1564 (put 'defcv 'texinfo-defun-type '('defop-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1565 (put 'defcvx 'texinfo-defun-type '('defop-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1566 (put 'defcv 'texinfo-defun-format-type 'texinfo-format-defcv-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1567 (put 'defcvx 'texinfo-defun-format-type 'texinfo-format-defcv-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1568 (put 'defcv 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1569 (put 'defcvx 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1570 (put 'defcv 'texinfo-defun-format-index 'texinfo-format-defcv-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1571 (put 'defcvx 'texinfo-defun-format-index 'texinfo-format-defcv-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1572
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1573 (put 'defivar 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1574 (put 'defivarx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1575 (put 'defivar 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1576 (put 'defivar 'texinfo-defun-type '('defmethod-type "Instance variable"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1577 (put 'defivarx 'texinfo-defun-type '('defmethod-type "Instance variable"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1578 (put 'defivar 'texinfo-defun-format-type 'texinfo-format-defcv-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1579 (put 'defivarx 'texinfo-defun-format-type 'texinfo-format-defcv-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1580 (put 'defivar 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1581 (put 'defivarx 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1582 (put 'defivar 'texinfo-defun-format-index 'texinfo-format-defcv-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1583 (put 'defivarx 'texinfo-defun-format-index 'texinfo-format-defcv-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1584
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1585 ;;; Typed functions and variables
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1586
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1587 (defun texinfo-format-deftypefn-type (classification data-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1588 (format "%s" classification data-type))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1589
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1590 (defun texinfo-format-deftypefn-index (name data-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1591 (format "%s of type %s" name data-type))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1592
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1593
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1594 (put 'deftypefn 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1595 (put 'deftypefnx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1596 (put 'deftypefn 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1597 (put 'deftypefn 'texinfo-defun-type '('deftypefn-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1598 (put 'deftypefnx 'texinfo-defun-type '('deftypefn-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1599 (put 'deftypefn 'texinfo-defun-format-type 'texinfo-format-deftypefn-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1600 (put 'deftypefnx 'texinfo-defun-format-type 'texinfo-format-deftypefn-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1601 (put 'deftypefn 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1602 (put 'deftypefnx 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1603 (put 'deftypefn 'texinfo-defun-format-index 'texinfo-format-deftypefn-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1604 (put 'deftypefnx 'texinfo-defun-format-index 'texinfo-format-deftypefn-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1605
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1606 (put 'deftypefun 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1607 (put 'deftypefunx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1608 (put 'deftypefun 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1609 (put 'deftypefun 'texinfo-defun-type '('deftypefun-type "Function"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1610 (put 'deftypefunx 'texinfo-defun-type '('deftypefun-type "Function"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1611 (put 'deftypefun 'texinfo-defun-format-type 'texinfo-format-deftypefn-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1612 (put 'deftypefunx 'texinfo-defun-format-type 'texinfo-format-deftypefn-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1613 (put 'deftypefun 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1614 (put 'deftypefunx 'texinfo-defun-index 'texinfo-findex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1615 (put 'deftypefun 'texinfo-defun-format-index 'texinfo-format-deftypefn-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1616 (put 'deftypefunx 'texinfo-defun-format-index 'texinfo-format-deftypefn-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1617
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1618 (put 'deftypevr 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1619 (put 'deftypevrx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1620 (put 'deftypevr 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1621 (put 'deftypevr 'texinfo-defun-type '('deftypefn-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1622 (put 'deftypevrx 'texinfo-defun-type '('deftypefn-type nil))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1623 (put 'deftypevr 'texinfo-defun-format-type 'texinfo-format-deftypefn-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1624 (put 'deftypevrx 'texinfo-defun-format-type 'texinfo-format-deftypefn-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1625 (put 'deftypevr 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1626 (put 'deftypevrx 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1627 (put 'deftypevr 'texinfo-defun-format-index 'texinfo-format-deftypefn-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1628 (put 'deftypevrx 'texinfo-defun-format-index 'texinfo-format-deftypefn-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1629
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1630 (put 'deftypevar 'texinfo-format 'texinfo-format-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1631 (put 'deftypevarx 'texinfo-format 'texinfo-format-defunx)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1632 (put 'deftypevar 'texinfo-end 'texinfo-end-defun)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1633 (put 'deftypevar 'texinfo-defun-type '('deftypevar-type "Variable"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1634 (put 'deftypevarx 'texinfo-defun-type '('deftypevar-type "Variable"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1635 (put 'deftypevar 'texinfo-defun-format-type 'texinfo-format-deftypefn-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1636 (put 'deftypevarx 'texinfo-defun-format-type 'texinfo-format-deftypefn-type)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1637 (put 'deftypevar 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1638 (put 'deftypevarx 'texinfo-defun-index 'texinfo-vindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1639 (put 'deftypevar 'texinfo-defun-format-index 'texinfo-format-deftypefn-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1640 (put 'deftypevarx 'texinfo-defun-format-index 'texinfo-format-deftypefn-index)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1641
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1642
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1643 ;; process included files: `@include' command
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1644
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1645 ;; Updated 19 October 1990
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1646 ;; In the original version, include files were ignored by Info but
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1647 ;; incorporated in to the printed manual. To make references to the
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1648 ;; included file, the Texinfo source file has to refer to the included
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1649 ;; files using the `(filename)nodename' format for refering to other
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1650 ;; Info files. Also, the included files had to be formatted on their
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1651 ;; own. It was just like they were another file.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1652
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1653 ;; Currently, include files are inserted into the buffer that is
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1654 ;; formatted for Info. If large, the resulting info file is split and
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1655 ;; tagified. For current include files to work, the master menu must
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1656 ;; refer to all the nodes, and the highest level nodes in the include
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1657 ;; files must have the correct next, prev, and up pointers.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1658
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1659 ;; The included file may have an @setfilename and even an @settitle,
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1660 ;; but not an /input texinfo
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1661
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1662 ; Original definition:
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1663 ; (defun texinfo-format-include ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1664 ; (let ((filename (texinfo-parse-arg-discard))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1665 ; (default-directory input-directory)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1666 ; subindex)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1667 ; (setq subindex
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1668 ; (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1669 ; (progn (find-file
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1670 ; (cond ((file-readable-p (concat filename ".texinfo"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1671 ; (concat filename ".texinfo"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1672 ; ((file-readable-p (concat filename ".texi"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1673 ; (concat filename ".texi"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1674 ; ((file-readable-p (concat filename ".tex"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1675 ; (concat filename ".tex"))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1676 ; ((file-readable-p filename)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1677 ; filename)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1678 ; (t (error "@include'd file %s not found"
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1679 ; filename))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1680 ; (texinfo-format-buffer-1))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1681 ; (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1682 ; (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1683 ; (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1684 ; (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1685 ; (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1686 ; (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1687
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1688 (defun texinfo-subindex (indexvar file content)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1689 (set indexvar (cons (list 'recurse file content)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1690 (symbol-value indexvar))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1691
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1692 (put 'include 'texinfo-format 'texinfo-format-include)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1693 (defun texinfo-format-include ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1694 (let ((filename (concat input-directory
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1695 (texinfo-parse-arg-discard)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1696 (default-directory input-directory))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1697 (message "Reading: %s" filename)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1698 (save-excursion
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1699 (insert-file-contents filename)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1700 (setq last-input-buffer input-buffer) ; to bypass setfilename
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1701 )
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1702
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1703
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1704
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1705 ;; Lots of bolio constructs do nothing in texinfo.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1706
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1707 (put 'page 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1708 (put 'c 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1709 (put 'comment 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1710 (put 'setchapternewpage 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1711 (put 'contents 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1712 (put 'summarycontents 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1713 (put 'shortcontents 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1714 (put 'nopara 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1715 (put 'noindent 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1716 (put 'setx 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1717 (put 'setq 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1718 (put 'settitle 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1719 (put 'hsize 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1720 (put 'parindent 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1721 (put 'lispnarrowing 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1722 (put 'itemindent 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1723 (put 'headings 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1724 (put 'group 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1725 (put 'group 'texinfo-end 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1726 (put 'need 'texinfo-format 'texinfo-discard-line-with-args)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1727 (put 'bye 'texinfo-format 'texinfo-discard-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1728 (put 'smallbook 'texinfo-format 'texinfo-discard-line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1729
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1730 (defun texinfo-discard-line-with-args ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1731 (goto-char texinfo-command-start)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1732 (delete-region (point) (progn (forward-line 1) (point))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1733
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1734 ;; Sort an index which is in the current buffer between START and END.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1735 ;; Used on VMS, where the `sort' utility is not available.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1736 (defun texinfo-sort-region (start end)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1737 (require 'sort)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1738 (save-restriction
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1739 (narrow-to-region start end)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1740 (sort-subr nil 'forward-line 'end-of-line 'texinfo-sort-startkeyfun)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1741
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1742 ;; Subroutine for sorting an index.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1743 ;; At start of a line, return a string to sort the line under.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1744 (defun texinfo-sort-startkeyfun ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1745 (let ((line
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1746 (buffer-substring (point) (save-excursion (end-of-line) (point)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1747 ;; Canonicalize whitespace and eliminate funny chars.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1748 (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1749 (setq line (concat (substring line 0 (match-beginning 0))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1750 " "
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1751 (substring line (match-end 0) (length line)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1752 line))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1753
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1754 ;; Some cannot be handled
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1755
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1756 (defun texinfo-unsupported ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1757 (error "%s is not handled by texinfo"
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1758 (buffer-substring texinfo-command-start texinfo-command-end)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1759
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1760 (defun batch-texinfo-format ()
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1761 "Runs texinfo-format-buffer on the files remaining on the command line.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1762 Must be used only with -batch, and kills emacs on completion.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1763 Each file will be processed even if an error occurred previously.
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1764 For example, invoke
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1765 \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"."
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1766 (if (not noninteractive)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1767 (error "batch-texinfo-format may only be used -batch."))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1768 (let ((version-control t)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1769 (auto-save-default nil)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1770 (find-file-run-dired nil)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1771 (kept-old-versions 259259)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1772 (kept-new-versions 259259))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1773 (let ((error 0)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1774 file
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1775 (files ()))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1776 (while command-line-args-left
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1777 (setq file (expand-file-name (car command-line-args-left)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1778 (cond ((not (file-exists-p file))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1779 (message ">> %s does not exist!" file)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1780 (setq error 1
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1781 command-line-args-left (cdr command-line-args-left)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1782 ((file-directory-p file)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1783 (setq command-line-args-left
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1784 (nconc (directory-files file)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1785 (cdr command-line-args-left))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1786 (t
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1787 (setq files (cons file files)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1788 command-line-args-left (cdr command-line-args-left)))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1789 (while files
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1790 (setq file (car files)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1791 files (cdr files))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1792 (condition-case err
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1793 (progn
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1794 (if buffer-file-name (kill-buffer (current-buffer)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1795 (find-file file)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1796 (buffer-disable-undo (current-buffer))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1797 (set-buffer-modified-p nil)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1798 (texinfo-mode)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1799 (message "texinfo formatting %s..." file)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1800 (texinfo-format-buffer nil)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1801 (if (buffer-modified-p)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1802 (progn (message "Saving modified %s" (buffer-file-name))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1803 (save-buffer))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1804 (error
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1805 (message ">> Error: %s" (prin1-to-string err))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1806 (message ">> point at")
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1807 (let ((s (buffer-substring (point)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1808 (min (+ (point) 100)
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1809 (point-max))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1810 (tem 0))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1811 (while (setq tem (string-match "\n+" s tem))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1812 (setq s (concat (substring s 0 (match-beginning 0))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1813 "\n>> "
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1814 (substring s (match-end 0)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1815 tem (1+ tem)))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1816 (message ">> %s" s))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1817 (setq error 1))))
70bc47d3c6c9 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1818 (kill-emacs error))))