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