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