2
|
1 ;;; texinfmt.el --- format Texinfo files into Info files.
|
|
2
|
|
3 ;; Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993 Free Software
|
|
4 ;; Foundation, Inc.
|
0
|
5
|
|
6 ;; Maintainer: Robert J. Chassell <bug-texinfo@prep.ai.mit.edu>
|
|
7
|
2
|
8 ;; This file is part of XEmacs.
|
0
|
9
|
2
|
10 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
11 ;; under the terms of the GNU General Public License as published by
|
0
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
13 ;; any later version.
|
|
14
|
2
|
15 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
18 ;; General Public License for more details.
|
0
|
19
|
|
20 ;; You should have received a copy of the GNU General Public License
|
2
|
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
23 ;; 02111-1307, USA.
|
0
|
24
|
2
|
25 ;;; Synched up with: FSF 19.34.
|
0
|
26
|
|
27 ;;; Code:
|
|
28
|
|
29 ;;; Emacs lisp functions to convert Texinfo files to Info files.
|
|
30
|
|
31 (defvar texinfmt-version "2.34 of 7 June 1995")
|
|
32
|
|
33 ;;; Variable definitions
|
|
34
|
|
35 (require 'texinfo) ; So `texinfo-footnote-style' is defined.
|
|
36 (require 'texnfo-upd) ; So `texinfo-section-types-regexp' is defined.
|
|
37
|
|
38 (defvar texinfo-format-syntax-table nil)
|
|
39
|
|
40 (defvar texinfo-vindex)
|
|
41 (defvar texinfo-findex)
|
|
42 (defvar texinfo-cindex)
|
|
43 (defvar texinfo-pindex)
|
|
44 (defvar texinfo-tindex)
|
|
45 (defvar texinfo-kindex)
|
|
46 (defvar texinfo-last-node)
|
|
47 (defvar texinfo-node-names)
|
|
48 (defvar texinfo-enclosure-list)
|
|
49 (defvar texinfo-alias-list)
|
|
50
|
|
51 (defvar texinfo-command-start)
|
|
52 (defvar texinfo-command-end)
|
|
53 (defvar texinfo-command-name)
|
|
54 (defvar texinfo-defun-type)
|
|
55 (defvar texinfo-last-node-pos)
|
|
56 (defvar texinfo-stack)
|
|
57 (defvar texinfo-short-index-cmds-alist)
|
|
58 (defvar texinfo-short-index-format-cmds-alist)
|
|
59 (defvar texinfo-format-filename)
|
|
60 (defvar texinfo-footnote-number)
|
|
61 (defvar texinfo-start-of-header)
|
|
62 (defvar texinfo-end-of-header)
|
|
63 (defvar texinfo-raisesections-alist)
|
|
64 (defvar texinfo-lowersections-alist)
|
|
65
|
|
66 ;;; Syntax table
|
|
67
|
|
68 (if texinfo-format-syntax-table
|
|
69 nil
|
|
70 (setq texinfo-format-syntax-table (make-syntax-table))
|
|
71 (modify-syntax-entry ?\" " " texinfo-format-syntax-table)
|
|
72 (modify-syntax-entry ?\\ " " texinfo-format-syntax-table)
|
|
73 (modify-syntax-entry ?@ "\\" texinfo-format-syntax-table)
|
|
74 (modify-syntax-entry ?\^q "\\" texinfo-format-syntax-table)
|
|
75 (modify-syntax-entry ?\[ "." texinfo-format-syntax-table)
|
|
76 (modify-syntax-entry ?\] "." texinfo-format-syntax-table)
|
|
77 (modify-syntax-entry ?\( "." texinfo-format-syntax-table)
|
|
78 (modify-syntax-entry ?\) "." texinfo-format-syntax-table)
|
|
79 (modify-syntax-entry ?{ "(}" texinfo-format-syntax-table)
|
|
80 (modify-syntax-entry ?} "){" texinfo-format-syntax-table)
|
|
81 (modify-syntax-entry ?\' "." texinfo-format-syntax-table))
|
|
82
|
|
83
|
|
84 ;;; Top level buffer and region formatting functions
|
|
85
|
|
86 ;;;###autoload
|
|
87 (defun texinfo-format-buffer (&optional notagify)
|
|
88 "Process the current buffer as texinfo code, into an Info file.
|
|
89 The Info file output is generated in a buffer visiting the Info file
|
|
90 names specified in the @setfilename command.
|
|
91
|
|
92 Non-nil argument (prefix, if interactive) means don't make tag table
|
|
93 and don't split the file if large. You can use Info-tagify and
|
|
94 Info-split to do these manually."
|
|
95 (interactive "P")
|
|
96 (let ((lastmessage "Formatting Info file..."))
|
|
97 (message lastmessage)
|
|
98 (texinfo-format-buffer-1)
|
|
99 (if notagify
|
|
100 nil
|
|
101 (if (> (buffer-size) 30000)
|
|
102 (progn
|
|
103 (message (setq lastmessage "Making tags table for Info file..."))
|
|
104 (Info-tagify)))
|
|
105 (if (> (buffer-size) 100000)
|
|
106 (progn
|
|
107 (message (setq lastmessage "Splitting Info file..."))
|
|
108 (Info-split))))
|
|
109 (message (concat lastmessage
|
|
110 (if (interactive-p) "done. Now save it." "done.")))))
|
|
111
|
|
112 (defvar texinfo-region-buffer-name "*Info Region*"
|
|
113 "*Name of the temporary buffer used by \\[texinfo-format-region].")
|
|
114
|
|
115 ;;;###autoload
|
|
116 (defun texinfo-format-region (region-beginning region-end)
|
|
117 "Convert the current region of the Texinfo file to Info format.
|
|
118 This lets you see what that part of the file will look like in Info.
|
|
119 The command is bound to \\[texinfo-format-region]. The text that is
|
|
120 converted to Info is stored in a temporary buffer."
|
|
121 (interactive "r")
|
|
122 (message "Converting region to Info format...")
|
|
123 (let (texinfo-command-start
|
|
124 texinfo-command-end
|
|
125 texinfo-command-name
|
|
126 texinfo-vindex
|
|
127 texinfo-findex
|
|
128 texinfo-cindex
|
|
129 texinfo-pindex
|
|
130 texinfo-tindex
|
|
131 texinfo-kindex
|
|
132 texinfo-stack
|
|
133 (texinfo-format-filename "")
|
|
134 texinfo-example-start
|
|
135 texinfo-last-node-pos
|
|
136 texinfo-last-node
|
|
137 texinfo-node-names
|
|
138 (texinfo-footnote-number 0)
|
|
139 last-input-buffer
|
|
140 (fill-column-for-info fill-column)
|
|
141 (input-buffer (current-buffer))
|
|
142 (input-directory default-directory)
|
|
143 (header-text "")
|
|
144 (header-beginning 1)
|
|
145 (header-end 1))
|
|
146
|
|
147 ;;; Copy lines between beginning and end of header lines,
|
|
148 ;;; if any, or else copy the `@setfilename' line, if any.
|
|
149 (save-excursion
|
|
150 (save-restriction
|
|
151 (widen)
|
|
152 (goto-char (point-min))
|
|
153 (let ((search-end (save-excursion (forward-line 100) (point))))
|
|
154 (if (or
|
|
155 ;; Either copy header text.
|
|
156 (and
|
|
157 (prog1
|
|
158 (search-forward tex-start-of-header search-end t)
|
|
159 (forward-line 1)
|
|
160 ;; Mark beginning of header.
|
|
161 (setq header-beginning (point)))
|
|
162 (prog1
|
|
163 (search-forward tex-end-of-header nil t)
|
|
164 (beginning-of-line)
|
|
165 ;; Mark end of header
|
|
166 (setq header-end (point))))
|
|
167 ;; Or copy @filename line.
|
|
168 (prog2
|
|
169 (goto-char (point-min))
|
|
170 (search-forward "@setfilename" search-end t)
|
|
171 (beginning-of-line)
|
|
172 (setq header-beginning (point))
|
|
173 (forward-line 1)
|
|
174 (setq header-end (point))))
|
|
175
|
|
176 ;; Copy header
|
|
177 (setq header-text
|
|
178 (buffer-substring
|
|
179 (min header-beginning region-beginning)
|
|
180 header-end))))))
|
|
181
|
|
182 ;;; Find a buffer to use.
|
|
183 (switch-to-buffer (get-buffer-create texinfo-region-buffer-name))
|
|
184 (erase-buffer)
|
|
185 ;; Insert the header into the buffer.
|
|
186 (insert header-text)
|
|
187 ;; Insert the region into the buffer.
|
|
188 (insert-buffer-substring
|
|
189 input-buffer
|
|
190 (max region-beginning header-end)
|
|
191 region-end)
|
|
192 ;; Make sure region ends in a newline.
|
|
193 (or (= (preceding-char) ?\n)
|
|
194 (insert "\n"))
|
|
195
|
|
196 (goto-char (point-min))
|
|
197 (texinfo-mode)
|
|
198 (message "Converting region to Info format...")
|
|
199 (setq fill-column fill-column-for-info)
|
|
200 ;; Install a syntax table useful for scanning command operands.
|
|
201 (set-syntax-table texinfo-format-syntax-table)
|
|
202
|
|
203 ;; Insert @include files so `texinfo-raise-lower-sections' can
|
|
204 ;; work on them without losing track of multiple
|
|
205 ;; @raise/@lowersections commands.
|
|
206 (while (re-search-forward "^@include" nil t)
|
|
207 (setq texinfo-command-end (point))
|
|
208 (let ((filename (concat input-directory
|
|
209 (texinfo-parse-line-arg))))
|
|
210 (re-search-backward "^@include")
|
|
211 (delete-region (point) (save-excursion (forward-line 1) (point)))
|
|
212 (message "Reading included file: %s" filename)
|
|
213 (save-excursion
|
|
214 (save-restriction
|
|
215 (narrow-to-region
|
|
216 (point)
|
|
217 (+ (point) (car (cdr (insert-file-contents filename)))))
|
|
218 (goto-char (point-min))
|
|
219 ;; Remove `@setfilename' line from included file, if any,
|
|
220 ;; so @setfilename command not duplicated.
|
|
221 (if (re-search-forward
|
|
222 "^@setfilename" (save-excursion (forward-line 100) (point)) t)
|
|
223 (progn
|
|
224 (beginning-of-line)
|
|
225 (delete-region
|
|
226 (point) (save-excursion (forward-line 1) (point)))))))))
|
|
227
|
|
228 ;; Raise or lower level of each section, if necessary.
|
|
229 (goto-char (point-min))
|
|
230 (texinfo-raise-lower-sections)
|
|
231 ;; Append @refill to appropriate paragraphs for filling.
|
|
232 (goto-char (point-min))
|
|
233 (texinfo-append-refill)
|
|
234 ;; If the region includes the effective end of the data,
|
|
235 ;; discard everything after that.
|
|
236 (goto-char (point-max))
|
|
237 (if (re-search-backward "^@bye" nil t)
|
|
238 (delete-region (point) (point-max)))
|
|
239 ;; Make sure buffer ends in a newline.
|
|
240 (or (= (preceding-char) ?\n)
|
|
241 (insert "\n"))
|
|
242 ;; Don't use a previous value of texinfo-enclosure-list.
|
|
243 (setq texinfo-enclosure-list nil)
|
|
244 (setq texinfo-alias-list nil)
|
|
245
|
|
246 (goto-char (point-min))
|
|
247 (if (looking-at "\\\\input[ \t]+texinfo")
|
|
248 (delete-region (point) (save-excursion (forward-line 1) (point))))
|
|
249
|
|
250 ;; Insert Info region title text.
|
|
251 (goto-char (point-min))
|
|
252 (if (search-forward
|
|
253 "@setfilename" (save-excursion (forward-line 100) (point)) t)
|
|
254 (progn
|
|
255 (setq texinfo-command-end (point))
|
|
256 (beginning-of-line)
|
|
257 (setq texinfo-command-start (point))
|
|
258 (let ((arg (texinfo-parse-arg-discard)))
|
|
259 (insert " "
|
|
260 texinfo-region-buffer-name
|
|
261 " buffer for: `")
|
|
262 (insert (file-name-nondirectory (expand-file-name arg)))
|
|
263 (insert "', -*-Text-*-\n")))
|
|
264 ;; Else no `@setfilename' line
|
|
265 (insert " "
|
|
266 texinfo-region-buffer-name
|
|
267 " buffer -*-Text-*-\n"))
|
|
268 (insert "produced by `texinfo-format-region'\n"
|
|
269 "from a region in: "
|
|
270 (if (buffer-file-name input-buffer)
|
|
271 (concat "`"
|
|
272 (file-name-sans-versions
|
|
273 (file-name-nondirectory
|
|
274 (buffer-file-name input-buffer)))
|
|
275 "'")
|
|
276 (concat "buffer `" (buffer-name input-buffer) "'"))
|
|
277 "\nusing `texinfmt.el' version "
|
|
278 texinfmt-version
|
|
279 ".\n\n")
|
|
280
|
|
281 ;; Now convert for real.
|
|
282 (goto-char (point-min))
|
|
283 (texinfo-format-scan)
|
|
284 (goto-char (point-min))
|
|
285
|
|
286 (message "Done.")))
|
|
287
|
|
288
|
|
289 ;;; Primary internal formatting function for the whole buffer.
|
|
290
|
|
291 (defun texinfo-format-buffer-1 ()
|
|
292 (let (texinfo-format-filename
|
|
293 texinfo-example-start
|
|
294 texinfo-command-start
|
|
295 texinfo-command-end
|
|
296 texinfo-command-name
|
|
297 texinfo-last-node
|
|
298 texinfo-last-node-pos
|
|
299 texinfo-vindex
|
|
300 texinfo-findex
|
|
301 texinfo-cindex
|
|
302 texinfo-pindex
|
|
303 texinfo-tindex
|
|
304 texinfo-kindex
|
|
305 texinfo-stack
|
|
306 texinfo-node-names
|
|
307 (texinfo-footnote-number 0)
|
|
308 last-input-buffer
|
|
309 outfile
|
|
310 (fill-column-for-info fill-column)
|
|
311 (input-buffer (current-buffer))
|
|
312 (input-directory default-directory))
|
|
313 (setq texinfo-enclosure-list nil)
|
|
314 (setq texinfo-alias-list nil)
|
|
315 (save-excursion
|
|
316 (goto-char (point-min))
|
|
317 (or (search-forward "@setfilename" nil t)
|
|
318 (error "Texinfo file needs an `@setfilename FILENAME' line."))
|
|
319 (setq texinfo-command-end (point))
|
|
320 (setq outfile (texinfo-parse-line-arg)))
|
|
321 (find-file outfile)
|
|
322 (texinfo-mode)
|
|
323 (setq fill-column fill-column-for-info)
|
|
324 (set-syntax-table texinfo-format-syntax-table)
|
|
325 (erase-buffer)
|
|
326 (insert-buffer-substring input-buffer)
|
|
327 (message "Converting %s to Info format..." (buffer-name input-buffer))
|
|
328
|
|
329 ;; Insert @include files so `texinfo-raise-lower-sections' can
|
|
330 ;; work on them without losing track of multiple
|
|
331 ;; @raise/@lowersections commands.
|
|
332 (goto-char (point-min))
|
|
333 (while (re-search-forward "^@include" nil t)
|
|
334 (setq texinfo-command-end (point))
|
|
335 (let ((filename (concat input-directory
|
|
336 (texinfo-parse-line-arg))))
|
|
337 (re-search-backward "^@include")
|
|
338 (delete-region (point) (save-excursion (forward-line 1) (point)))
|
|
339 (message "Reading included file: %s" filename)
|
|
340 (save-excursion
|
|
341 (save-restriction
|
|
342 (narrow-to-region
|
|
343 (point)
|
|
344 (+ (point) (car (cdr (insert-file-contents filename)))))
|
|
345 (goto-char (point-min))
|
|
346 ;; Remove `@setfilename' line from included file, if any,
|
|
347 ;; so @setfilename command not duplicated.
|
|
348 (if (re-search-forward
|
|
349 "^@setfilename"
|
|
350 (save-excursion (forward-line 100) (point)) t)
|
|
351 (progn
|
|
352 (beginning-of-line)
|
|
353 (delete-region
|
|
354 (point) (save-excursion (forward-line 1) (point)))))))))
|
|
355 ;; Raise or lower level of each section, if necessary.
|
|
356 (goto-char (point-min))
|
|
357 (texinfo-raise-lower-sections)
|
|
358 ;; Append @refill to appropriate paragraphs
|
|
359 (goto-char (point-min))
|
|
360 (texinfo-append-refill)
|
|
361 (goto-char (point-min))
|
|
362 (search-forward "@setfilename")
|
|
363 (beginning-of-line)
|
|
364 (delete-region (point-min) (point))
|
|
365 ;; Remove @bye at end of file, if it is there.
|
|
366 (goto-char (point-max))
|
|
367 (if (search-backward "@bye" nil t)
|
|
368 (delete-region (point) (point-max)))
|
|
369 ;; Make sure buffer ends in a newline.
|
|
370 (or (= (preceding-char) ?\n)
|
|
371 (insert "\n"))
|
|
372 ;; Scan the whole buffer, converting to Info format.
|
|
373 (texinfo-format-scan)
|
|
374 ;; Return data for indices.
|
|
375 (goto-char (point-min))
|
|
376 (list outfile
|
|
377 texinfo-vindex texinfo-findex texinfo-cindex
|
|
378 texinfo-pindex texinfo-tindex texinfo-kindex)))
|
|
379
|
|
380
|
|
381 ;;; Perform non-@-command file conversions: quotes and hyphens
|
|
382
|
|
383 (defun texinfo-format-convert (min max)
|
|
384 ;; Convert left and right quotes to typewriter font quotes.
|
|
385 (goto-char min)
|
|
386 (while (search-forward "``" max t)
|
|
387 (replace-match "\""))
|
|
388 (goto-char min)
|
|
389 (while (search-forward "''" max t)
|
|
390 (replace-match "\""))
|
|
391 ;; Convert three hyphens in a row to two.
|
|
392 (goto-char min)
|
|
393 (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t)
|
|
394 (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning
|
|
395 2)))))
|
|
396
|
|
397
|
|
398 ;;; Handle paragraph filling
|
|
399
|
|
400 (defvar texinfo-no-refill-regexp
|
|
401 "^@\\(example\\|smallexample\\|lisp\\|smalllisp\\|display\\|format\\|flushleft\\|flushright\\|menu\\|titlepage\\|iftex\\|ifhtml\\|tex\\|html\\)"
|
|
402 "Regexp specifying environments in which paragraphs are not filled.")
|
|
403
|
|
404 (defvar texinfo-part-of-para-regexp
|
|
405 "^@\\(b{\\|bullet{\\|cite{\\|code{\\|emph{\\|equiv{\\|error{\\|expansion{\\|file{\\|i{\\|inforef{\\|kbd{\\|key{\\|lisp{\\|minus{\\|point{\\|print{\\|pxref{\\|r{\\|ref{\\|result{\\|samp{\\|sc{\\|t{\\|TeX{\\|today{\\|var{\\|w{\\|xref{\\)"
|
|
406 "Regexp specifying @-commands found within paragraphs.")
|
|
407
|
|
408 (defun texinfo-append-refill ()
|
|
409 "Append @refill at end of each paragraph that should be filled.
|
|
410 Do not append @refill to paragraphs within @example and similar environments.
|
|
411 Do not append @refill to paragraphs containing @w{TEXT} or @*."
|
|
412
|
|
413 ;; It is necessary to append @refill before other processing because
|
|
414 ;; the other processing removes information that tells Texinfo
|
|
415 ;; whether the text should or should not be filled.
|
|
416
|
|
417 (while (< (point) (point-max))
|
|
418 (let ((refill-blank-lines "^[ \t\n]*$")
|
|
419 (case-fold-search nil)) ; Don't confuse @TeX and @tex....
|
|
420 (beginning-of-line)
|
|
421 ;; 1. Skip over blank lines;
|
|
422 ;; skip over lines beginning with @-commands,
|
|
423 ;; but do not skip over lines
|
|
424 ;; that are no-refill environments such as @example or
|
|
425 ;; that begin with within-paragraph @-commands such as @code.
|
|
426 (while (and (looking-at (concat "^@\\|^\\\\\\|" refill-blank-lines))
|
|
427 (not (looking-at
|
|
428 (concat
|
|
429 "\\("
|
|
430 texinfo-no-refill-regexp
|
|
431 "\\|"
|
|
432 texinfo-part-of-para-regexp
|
|
433 "\\)")))
|
|
434 (< (point) (point-max)))
|
|
435 (forward-line 1))
|
|
436 ;; 2. Skip over @example and similar no-refill environments.
|
|
437 (if (looking-at texinfo-no-refill-regexp)
|
|
438 (let ((environment
|
|
439 (buffer-substring (match-beginning 1) (match-end 1))))
|
|
440 (progn (re-search-forward (concat "^@end " environment) nil t)
|
|
441 (forward-line 1)))
|
|
442 ;; 3. Do not refill a paragraph containing @w or @*
|
|
443 (if (or
|
|
444 (>= (point) (point-max))
|
|
445 (re-search-forward
|
|
446 "@w{\\|@\\*" (save-excursion (forward-paragraph) (point)) t))
|
|
447 ;; Go to end of paragraph and do nothing.
|
|
448 (forward-paragraph)
|
|
449 ;; 4. Else go to end of paragraph and insert @refill
|
|
450 (forward-paragraph)
|
|
451 (forward-line -1)
|
|
452 (end-of-line)
|
|
453 (delete-region
|
|
454 (point)
|
|
455 (save-excursion (skip-chars-backward " \t") (point)))
|
|
456 ;; `looking-at-backward' not available in v. 18.57
|
|
457 ;; (if (not (looking-at-backward "@refill\\|@bye")) ;)
|
|
458 (if (not (re-search-backward
|
|
459 "@refill\\|@bye"
|
|
460 (save-excursion (beginning-of-line) (point))
|
|
461 t))
|
|
462 (insert "@refill"))
|
|
463 (forward-line 1))))))
|
|
464
|
|
465
|
|
466 ;;; Handle `@raisesections' and `@lowersections' commands
|
|
467
|
|
468 ;; These commands change the hierarchical level of chapter structuring
|
|
469 ;; commands.
|
|
470 ;;
|
|
471 ;; @raisesections changes @subsection to @section,
|
|
472 ;; @section to @chapter,
|
|
473 ;; etc.
|
|
474 ;;
|
|
475 ;; @lowersections changes @chapter to @section
|
|
476 ;; @subsection to @subsubsection,
|
|
477 ;; etc.
|
|
478 ;;
|
|
479 ;; An @raisesections/@lowersections command changes only those
|
|
480 ;; structuring commands that follow the @raisesections/@lowersections
|
|
481 ;; command.
|
|
482 ;;
|
|
483 ;; Repeated @raisesections/@lowersections continue to raise or lower
|
|
484 ;; the heading level.
|
|
485 ;;
|
|
486 ;; An @lowersections command cancels an @raisesections command, and
|
|
487 ;; vice versa.
|
|
488 ;;
|
|
489 ;; You cannot raise or lower "beyond" chapters or subsubsections, but
|
|
490 ;; trying to do so does not elicit an error---you just get more
|
|
491 ;; headings that mean the same thing as you keep raising or lowering
|
|
492 ;; (for example, after a single @raisesections, both @chapter and
|
|
493 ;; @section produce chapter headings).
|
|
494
|
|
495 (defun texinfo-raise-lower-sections ()
|
|
496 "Raise or lower the hierarchical level of chapters, sections, etc.
|
|
497
|
|
498 This function acts according to `@raisesections' and `@lowersections'
|
|
499 commands in the Texinfo file.
|
|
500
|
|
501 For example, an `@lowersections' command is useful if you wish to
|
|
502 include what is written as an outer or standalone Texinfo file in
|
|
503 another Texinfo file as an inner, included file. The `@lowersections'
|
|
504 command changes chapters to sections, sections to subsections and so
|
|
505 on.
|
|
506
|
|
507 @raisesections changes @subsection to @section,
|
|
508 @section to @chapter,
|
|
509 @heading to @chapheading,
|
|
510 etc.
|
|
511
|
|
512 @lowersections changes @chapter to @section,
|
|
513 @subsection to @subsubsection,
|
|
514 @heading to @subheading,
|
|
515 etc.
|
|
516
|
|
517 An `@raisesections' or `@lowersections' command changes only those
|
|
518 structuring commands that follow the `@raisesections' or
|
|
519 `@lowersections' command.
|
|
520
|
|
521 An `@lowersections' command cancels an `@raisesections' command, and
|
|
522 vice versa.
|
|
523
|
|
524 Repeated use of the commands continue to raise or lower the hierarchical
|
|
525 level a step at a time.
|
|
526
|
|
527 An attempt to raise above `chapters' reproduces chapter commands; an
|
|
528 attempt to lower below subsubsections reproduces subsubsection
|
|
529 commands."
|
|
530
|
|
531 ;; `texinfo-section-types-regexp' is defined in `texnfo-upd.el';
|
|
532 ;; it is a regexp matching chapter, section, other headings
|
|
533 ;; (but not the top node).
|
|
534
|
|
535 (let (type (level 0))
|
|
536 (while
|
|
537 (re-search-forward
|
|
538 (concat
|
|
539 "\\(\\(^@\\(raise\\|lower\\)sections\\)\\|\\("
|
|
540 texinfo-section-types-regexp
|
|
541 "\\)\\)")
|
|
542 nil t)
|
|
543 (beginning-of-line)
|
|
544 (save-excursion (setq type (read (current-buffer))))
|
|
545 (cond
|
|
546
|
|
547 ;; 1. Increment level
|
|
548 ((eq type '@raisesections)
|
|
549 (setq level (1+ level))
|
|
550 (delete-region
|
|
551 (point) (save-excursion (forward-line 1) (point))))
|
|
552
|
|
553 ;; 2. Decrement level
|
|
554 ((eq type '@lowersections)
|
|
555 (setq level (1- level))
|
|
556 (delete-region
|
|
557 (point) (save-excursion (forward-line 1) (point))))
|
|
558
|
|
559 ;; Now handle structuring commands
|
|
560 ((cond
|
|
561
|
|
562 ;; 3. Raise level when positive
|
|
563 ((> level 0)
|
|
564 (let ((count level)
|
|
565 (new-level type))
|
|
566 (while (> count 0)
|
|
567 (setq new-level
|
|
568 (cdr (assq new-level texinfo-raisesections-alist)))
|
|
569 (setq count (1- count)))
|
|
570 (kill-word 1)
|
|
571 (insert (symbol-name new-level))))
|
|
572
|
|
573 ;; 4. Do nothing except move point when level is zero
|
|
574 ((= level 0) (forward-line 1))
|
|
575
|
|
576 ;; 5. Lower level when positive
|
|
577 ((< level 0)
|
|
578 (let ((count level)
|
|
579 (new-level type))
|
|
580 (while (< count 0)
|
|
581 (setq new-level
|
|
582 (cdr (assq new-level texinfo-lowersections-alist)))
|
|
583 (setq count (1+ count)))
|
|
584 (kill-word 1)
|
|
585 (insert (symbol-name new-level))))))))))
|
|
586
|
|
587 (defvar texinfo-raisesections-alist
|
|
588 '((@chapter . @chapter) ; Cannot go higher
|
|
589 (@unnumbered . @unnumbered)
|
|
590
|
|
591 (@majorheading . @majorheading)
|
|
592 (@chapheading . @chapheading)
|
|
593 (@appendix . @appendix)
|
|
594
|
|
595 (@section . @chapter)
|
|
596 (@unnumberedsec . @unnumbered)
|
|
597 (@heading . @chapheading)
|
|
598 (@appendixsec . @appendix)
|
|
599
|
|
600 (@subsection . @section)
|
|
601 (@unnumberedsubsec . @unnumberedsec)
|
|
602 (@subheading . @heading)
|
|
603 (@appendixsubsec . @appendixsec)
|
|
604
|
|
605 (@subsubsection . @subsection)
|
|
606 (@unnumberedsubsubsec . @unnumberedsubsec)
|
|
607 (@subsubheading . @subheading)
|
|
608 (@appendixsubsubsec . @appendixsubsec))
|
|
609 "*An alist of next higher levels for chapters, sections. etc.
|
|
610 For example, section to chapter, subsection to section.
|
|
611 Used by `texinfo-raise-lower-sections'.
|
|
612 The keys specify types of section; the values correspond to the next
|
|
613 higher types.")
|
|
614
|
|
615 (defvar texinfo-lowersections-alist
|
|
616 '((@chapter . @section)
|
|
617 (@unnumbered . @unnumberedsec)
|
|
618 (@majorheading . @heading)
|
|
619 (@chapheading . @heading)
|
|
620 (@appendix . @appendixsec)
|
|
621
|
|
622 (@section . @subsection)
|
|
623 (@unnumberedsec . @unnumberedsubsec)
|
|
624 (@heading . @subheading)
|
|
625 (@appendixsec . @appendixsubsec)
|
|
626
|
|
627 (@subsection . @subsubsection)
|
|
628 (@unnumberedsubsec . @unnumberedsubsubsec)
|
|
629 (@subheading . @subsubheading)
|
|
630 (@appendixsubsec . @appendixsubsubsec)
|
|
631
|
|
632 (@subsubsection . @subsubsection) ; Cannot go lower.
|
|
633 (@unnumberedsubsubsec . @unnumberedsubsubsec)
|
|
634 (@subsubheading . @subsubheading)
|
|
635 (@appendixsubsubsec . @appendixsubsubsec))
|
|
636 "*An alist of next lower levels for chapters, sections. etc.
|
|
637 For example, chapter to section, section to subsection.
|
|
638 Used by `texinfo-raise-lower-sections'.
|
|
639 The keys specify types of section; the values correspond to the next
|
|
640 lower types.")
|
|
641
|
|
642
|
|
643 ;;; Perform those texinfo-to-info conversions that apply to the whole input
|
|
644 ;;; uniformly.
|
|
645
|
|
646 (defun texinfo-format-scan ()
|
|
647 (texinfo-format-convert (point-min) (point-max))
|
|
648 ;; Scan for @-commands.
|
|
649 (goto-char (point-min))
|
|
650 (while (search-forward "@" nil t)
|
|
651 (if (looking-at "[@{}^'` *\"?!]")
|
|
652 ;; Handle a few special @-followed-by-one-char commands.
|
|
653 (if (= (following-char) ?*)
|
|
654 (progn
|
|
655 ;; remove command
|
|
656 (delete-region (1- (point)) (1+ (point)))
|
|
657 ;; insert return if not at end of line;
|
|
658 ;; else line is already broken.
|
|
659 (if (not (= (following-char) ?\n))
|
|
660 (insert ?\n)))
|
|
661 ;; The other characters are simply quoted. Delete the @.
|
|
662 (delete-char -1)
|
|
663 (forward-char 1))
|
|
664 ;; @ is followed by a command-word; find the end of the word.
|
|
665 (setq texinfo-command-start (1- (point)))
|
|
666 (if (= (char-syntax (following-char)) ?w)
|
|
667 (forward-word 1)
|
|
668 (forward-char 1))
|
|
669 (setq texinfo-command-end (point))
|
|
670 ;; Handle let aliasing
|
|
671 (setq texinfo-command-name
|
|
672 (let (trial
|
|
673 (cmdname
|
|
674 (buffer-substring
|
|
675 (1+ texinfo-command-start) texinfo-command-end)))
|
|
676 (while (setq trial (assoc cmdname texinfo-alias-list))
|
|
677 (setq cmdname (cdr trial)))
|
|
678 (intern cmdname)))
|
|
679 ;; Call the handler for this command.
|
|
680 (let ((enclosure-type
|
|
681 (assoc
|
|
682 (symbol-name texinfo-command-name)
|
|
683 texinfo-enclosure-list)))
|
|
684 (if enclosure-type
|
|
685 (progn
|
|
686 (insert
|
|
687 (car (car (cdr enclosure-type)))
|
|
688 (texinfo-parse-arg-discard)
|
|
689 (car (cdr (car (cdr enclosure-type)))))
|
|
690 (goto-char texinfo-command-start))
|
|
691 (let ((cmd (get texinfo-command-name 'texinfo-format)))
|
|
692 (if cmd (funcall cmd) (texinfo-unsupported)))))))
|
|
693
|
|
694 (cond (texinfo-stack
|
|
695 (goto-char (nth 2 (car texinfo-stack)))
|
|
696 (error "Unterminated @%s" (car (car texinfo-stack))))))
|
|
697
|
|
698 (put 'begin 'texinfo-format 'texinfo-format-begin)
|
|
699 (defun texinfo-format-begin ()
|
|
700 (texinfo-format-begin-end 'texinfo-format))
|
|
701
|
|
702 (put 'end 'texinfo-format 'texinfo-format-end)
|
|
703 (defun texinfo-format-end ()
|
|
704 (texinfo-format-begin-end 'texinfo-end))
|
|
705
|
|
706 (defun texinfo-format-begin-end (prop)
|
|
707 (setq texinfo-command-name (intern (texinfo-parse-line-arg)))
|
|
708 (let ((cmd (get texinfo-command-name prop)))
|
|
709 (if cmd (funcall cmd)
|
|
710 (texinfo-unsupported))))
|
|
711
|
|
712 ;;; Parsing functions
|
|
713
|
|
714 (defun texinfo-parse-line-arg ()
|
|
715 (goto-char texinfo-command-end)
|
|
716 (let ((start (point)))
|
|
717 (cond ((looking-at " ")
|
|
718 (skip-chars-forward " ")
|
|
719 (setq start (point))
|
|
720 (end-of-line)
|
|
721 (skip-chars-backward " ")
|
|
722 (delete-region (point) (progn (end-of-line) (point)))
|
|
723 (setq texinfo-command-end (1+ (point))))
|
|
724 ((looking-at "{")
|
|
725 (setq start (1+ (point)))
|
|
726 (forward-list 1)
|
|
727 (setq texinfo-command-end (point))
|
|
728 (forward-char -1))
|
|
729 (t
|
|
730 (error "Invalid texinfo command arg format")))
|
|
731 (prog1 (buffer-substring start (point))
|
|
732 (if (eolp) (forward-char 1)))))
|
|
733
|
|
734 (defun texinfo-parse-expanded-arg ()
|
|
735 (goto-char texinfo-command-end)
|
|
736 (let ((start (point))
|
|
737 marker)
|
|
738 (cond ((looking-at " ")
|
|
739 (skip-chars-forward " ")
|
|
740 (setq start (point))
|
|
741 (end-of-line)
|
|
742 (setq texinfo-command-end (1+ (point))))
|
|
743 ((looking-at "{")
|
|
744 (setq start (1+ (point)))
|
|
745 (forward-list 1)
|
|
746 (setq texinfo-command-end (point))
|
|
747 (forward-char -1))
|
|
748 (t
|
|
749 (error "Invalid texinfo command arg format")))
|
|
750 (setq marker (move-marker (make-marker) texinfo-command-end))
|
|
751 (texinfo-format-expand-region start (point))
|
|
752 (setq texinfo-command-end (marker-position marker))
|
|
753 (move-marker marker nil)
|
|
754 (prog1 (buffer-substring start (point))
|
|
755 (if (eolp) (forward-char 1)))))
|
|
756
|
|
757 (defun texinfo-format-expand-region (start end)
|
|
758 (save-restriction
|
|
759 (narrow-to-region start end)
|
|
760 (let (texinfo-command-start
|
|
761 texinfo-command-end
|
|
762 texinfo-command-name
|
|
763 texinfo-stack)
|
|
764 (texinfo-format-scan))
|
|
765 (goto-char (point-max))))
|
|
766
|
|
767 (defun texinfo-parse-arg-discard ()
|
|
768 (prog1 (texinfo-parse-line-arg)
|
|
769 (texinfo-discard-command)))
|
|
770
|
|
771 (defun texinfo-discard-command ()
|
|
772 (delete-region texinfo-command-start texinfo-command-end))
|
|
773
|
|
774 (defun texinfo-optional-braces-discard ()
|
|
775 "Discard braces following command, if any."
|
|
776 (goto-char texinfo-command-end)
|
|
777 (let ((start (point)))
|
|
778 (cond ((looking-at "[ \t]*\n")) ; do nothing
|
|
779 ((looking-at "{") ; remove braces, if any
|
|
780 (forward-list 1)
|
|
781 (setq texinfo-command-end (point)))
|
|
782 (t
|
|
783 (error
|
|
784 "Invalid `texinfo-optional-braces-discard' format \(need braces?\)")))
|
|
785 (delete-region texinfo-command-start texinfo-command-end)))
|
|
786
|
|
787 (defun texinfo-format-parse-line-args ()
|
|
788 (let ((start (1- (point)))
|
|
789 next beg end
|
|
790 args)
|
|
791 (skip-chars-forward " ")
|
|
792 (while (not (eolp))
|
|
793 (setq beg (point))
|
|
794 (re-search-forward "[\n,]")
|
|
795 (setq next (point))
|
|
796 (if (bolp) (setq next (1- next)))
|
|
797 (forward-char -1)
|
|
798 (skip-chars-backward " ")
|
|
799 (setq end (point))
|
|
800 (setq args (cons (if (> end beg) (buffer-substring beg end))
|
|
801 args))
|
|
802 (goto-char next)
|
|
803 (skip-chars-forward " "))
|
|
804 (if (eolp) (forward-char 1))
|
|
805 (setq texinfo-command-end (point))
|
|
806 (nreverse args)))
|
|
807
|
|
808 (defun texinfo-format-parse-args ()
|
|
809 (let ((start (1- (point)))
|
|
810 next beg end
|
|
811 args)
|
|
812 (search-forward "{")
|
|
813 (save-excursion
|
|
814 (texinfo-format-expand-region
|
|
815 (point)
|
|
816 (save-excursion (up-list 1) (1- (point)))))
|
|
817 ;; The following does not handle cross references of the form:
|
|
818 ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the
|
|
819 ;; re-search-forward finds the first right brace after the second
|
|
820 ;; comma.
|
|
821 (while (/= (preceding-char) ?\})
|
|
822 (skip-chars-forward " \t\n")
|
|
823 (setq beg (point))
|
|
824 (re-search-forward "[},]")
|
|
825 (setq next (point))
|
|
826 (forward-char -1)
|
|
827 (skip-chars-backward " \t\n")
|
|
828 (setq end (point))
|
|
829 (cond ((< beg end)
|
|
830 (goto-char beg)
|
|
831 (while (search-forward "\n" end t)
|
|
832 (replace-match " "))))
|
|
833 (setq args (cons (if (> end beg) (buffer-substring beg end))
|
|
834 args))
|
|
835 (goto-char next))
|
|
836 (if (eolp) (forward-char 1))
|
|
837 (setq texinfo-command-end (point))
|
|
838 (nreverse args)))
|
|
839
|
|
840 (defun texinfo-format-parse-defun-args ()
|
|
841 (goto-char texinfo-command-end)
|
|
842 (let ((start (point)))
|
|
843 (end-of-line)
|
|
844 (setq texinfo-command-end (1+ (point)))
|
|
845 (let ((marker (move-marker (make-marker) texinfo-command-end)))
|
|
846 (texinfo-format-expand-region start (point))
|
|
847 (setq texinfo-command-end (marker-position marker))
|
|
848 (move-marker marker nil))
|
|
849 (goto-char start)
|
|
850 (let ((args '())
|
|
851 beg end)
|
|
852 (skip-chars-forward " ")
|
|
853 (while (not (eolp))
|
|
854 (cond ((looking-at "{")
|
|
855 (setq beg (1+ (point)))
|
|
856 (forward-list 1)
|
|
857 (setq end (1- (point))))
|
|
858 (t
|
|
859 (setq beg (point))
|
|
860 (re-search-forward "[\n ]")
|
|
861 (forward-char -1)
|
|
862 (setq end (point))))
|
|
863 (setq args (cons (buffer-substring beg end) args))
|
|
864 (skip-chars-forward " "))
|
|
865 (forward-char 1)
|
|
866 (nreverse args))))
|
|
867
|
|
868 (defun texinfo-discard-line ()
|
|
869 (goto-char texinfo-command-end)
|
|
870 (skip-chars-forward " \t")
|
|
871 (or (eolp)
|
|
872 (error "Extraneous text at end of command line."))
|
|
873 (goto-char texinfo-command-start)
|
|
874 (or (bolp)
|
|
875 (error "Extraneous text at beginning of command line."))
|
|
876 (delete-region (point) (progn (forward-line 1) (point))))
|
|
877
|
|
878 (defun texinfo-discard-line-with-args ()
|
|
879 (goto-char texinfo-command-start)
|
|
880 (delete-region (point) (progn (forward-line 1) (point))))
|
|
881
|
|
882
|
|
883 ;;; @setfilename
|
|
884
|
|
885 ;; Only `texinfo-format-buffer' handles @setfilename with this
|
|
886 ;; definition; `texinfo-format-region' handles @setfilename, if any,
|
|
887 ;; specially.
|
|
888 (put 'setfilename 'texinfo-format 'texinfo-format-setfilename)
|
|
889 (defun texinfo-format-setfilename ()
|
|
890 (let ((arg (texinfo-parse-arg-discard)))
|
|
891 (message "Formatting Info file: %s" arg)
|
|
892 (setq texinfo-format-filename
|
|
893 (file-name-nondirectory (expand-file-name arg)))
|
|
894 (insert "Info file: "
|
|
895 texinfo-format-filename ", -*-Text-*-\n"
|
|
896 "produced by `texinfo-format-buffer'\n"
|
|
897 "from file"
|
|
898 (if (buffer-file-name input-buffer)
|
|
899 (concat " `"
|
|
900 (file-name-sans-versions
|
|
901 (file-name-nondirectory
|
|
902 (buffer-file-name input-buffer)))
|
|
903 "'")
|
|
904 (concat "buffer `" (buffer-name input-buffer) "'"))
|
|
905 "\nusing `texinfmt.el' version "
|
|
906 texinfmt-version
|
|
907 ".\n\n")))
|
|
908
|
|
909 ;;; @node, @menu
|
|
910
|
|
911 (put 'node 'texinfo-format 'texinfo-format-node)
|
|
912 (put 'nwnode 'texinfo-format 'texinfo-format-node)
|
|
913 (defun texinfo-format-node ()
|
|
914 (let* ((args (texinfo-format-parse-line-args))
|
|
915 (name (nth 0 args))
|
|
916 (next (nth 1 args))
|
|
917 (prev (nth 2 args))
|
|
918 (up (nth 3 args)))
|
|
919 (texinfo-discard-command)
|
|
920 (setq texinfo-last-node name)
|
|
921 (let ((tem (downcase name)))
|
|
922 (if (assoc tem texinfo-node-names)
|
|
923 (error "Duplicate node name: %s" name)
|
|
924 (setq texinfo-node-names (cons (list tem) texinfo-node-names))))
|
|
925 (setq texinfo-footnote-number 0)
|
|
926 ;; insert "\n\^_" unconditionally since this is what info is looking for
|
|
927 (insert "\n\^_\nFile: " texinfo-format-filename
|
|
928 ", Node: " name)
|
|
929 (if next
|
|
930 (insert ", Next: " next))
|
|
931 (if prev
|
|
932 (insert ", Prev: " prev))
|
|
933 (if up
|
|
934 (insert ", Up: " up))
|
|
935 (insert ?\n)
|
|
936 (setq texinfo-last-node-pos (point))))
|
|
937
|
|
938 (put 'menu 'texinfo-format 'texinfo-format-menu)
|
|
939 (defun texinfo-format-menu ()
|
|
940 (texinfo-discard-line)
|
|
941 (insert "* Menu:\n\n"))
|
|
942
|
|
943 (put 'menu 'texinfo-end 'texinfo-discard-command)
|
|
944
|
|
945
|
|
946 ;;; Cross references
|
|
947
|
|
948 ; @xref {NODE, FNAME, NAME, FILE, DOCUMENT}
|
|
949 ; -> *Note FNAME: (FILE)NODE
|
|
950 ; If FILE is missing,
|
|
951 ; *Note FNAME: NODE
|
|
952 ; If FNAME is empty and NAME is present
|
|
953 ; *Note NAME: Node
|
|
954 ; If both NAME and FNAME are missing
|
|
955 ; *Note NODE::
|
|
956 ; texinfo ignores the DOCUMENT argument.
|
|
957 ; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
|
|
958 ; If FILE is specified, (FILE)NODE is used for xrefs.
|
|
959 ; If fifth argument DOCUMENT is specified, produces
|
|
960 ; See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
|
|
961 ; of DOCUMENT
|
|
962
|
|
963 ; @ref a reference that does not put `See' or `see' in
|
|
964 ; the hardcopy and is the same as @xref in Info
|
|
965 (put 'ref 'texinfo-format 'texinfo-format-xref)
|
|
966
|
|
967 (put 'xref 'texinfo-format 'texinfo-format-xref)
|
|
968 (defun texinfo-format-xref ()
|
|
969 (let ((args (texinfo-format-parse-args)))
|
|
970 (texinfo-discard-command)
|
|
971 (insert "*Note ")
|
|
972 (let ((fname (or (nth 1 args) (nth 2 args))))
|
|
973 (if (null (or fname (nth 3 args)))
|
|
974 (insert (car args) "::")
|
|
975 (insert (or fname (car args)) ": ")
|
|
976 (if (nth 3 args)
|
|
977 (insert "(" (nth 3 args) ")"))
|
|
978 (insert (car args))))))
|
|
979
|
|
980 (put 'pxref 'texinfo-format 'texinfo-format-pxref)
|
|
981 (defun texinfo-format-pxref ()
|
|
982 (texinfo-format-xref)
|
|
983 (or (save-excursion
|
|
984 (forward-char -2)
|
|
985 (looking-at "::"))
|
|
986 (insert ".")))
|
|
987
|
|
988 ;@inforef{NODE, FNAME, FILE}
|
|
989 ;Like @xref{NODE, FNAME,,FILE} in texinfo.
|
|
990 ;In Tex, generates "See Info file FILE, node NODE"
|
|
991 (put 'inforef 'texinfo-format 'texinfo-format-inforef)
|
|
992 (defun texinfo-format-inforef ()
|
|
993 (let ((args (texinfo-format-parse-args)))
|
|
994 (texinfo-discard-command)
|
|
995 (if (nth 1 args)
|
|
996 (insert "*Note " (nth 1 args) ": (" (nth 2 args) ")" (car args))
|
|
997 (insert "*Note " "(" (nth 2 args) ")" (car args) "::"))))
|
|
998
|
|
999
|
|
1000 ;;; Section headings
|
|
1001
|
|
1002 (put 'majorheading 'texinfo-format 'texinfo-format-chapter)
|
|
1003 (put 'chapheading 'texinfo-format 'texinfo-format-chapter)
|
|
1004 (put 'ichapter 'texinfo-format 'texinfo-format-chapter)
|
|
1005 (put 'chapter 'texinfo-format 'texinfo-format-chapter)
|
|
1006 (put 'iappendix 'texinfo-format 'texinfo-format-chapter)
|
|
1007 (put 'appendix 'texinfo-format 'texinfo-format-chapter)
|
|
1008 (put 'iunnumbered 'texinfo-format 'texinfo-format-chapter)
|
|
1009 (put 'top 'texinfo-format 'texinfo-format-chapter)
|
|
1010 (put 'unnumbered 'texinfo-format 'texinfo-format-chapter)
|
|
1011 (defun texinfo-format-chapter ()
|
|
1012 (texinfo-format-chapter-1 ?*))
|
|
1013
|
|
1014 (put 'heading 'texinfo-format 'texinfo-format-section)
|
|
1015 (put 'isection 'texinfo-format 'texinfo-format-section)
|
|
1016 (put 'section 'texinfo-format 'texinfo-format-section)
|
|
1017 (put 'iappendixsection 'texinfo-format 'texinfo-format-section)
|
|
1018 (put 'appendixsection 'texinfo-format 'texinfo-format-section)
|
|
1019 (put 'iappendixsec 'texinfo-format 'texinfo-format-section)
|
|
1020 (put 'appendixsec 'texinfo-format 'texinfo-format-section)
|
|
1021 (put 'iunnumberedsec 'texinfo-format 'texinfo-format-section)
|
|
1022 (put 'unnumberedsec 'texinfo-format 'texinfo-format-section)
|
|
1023 (defun texinfo-format-section ()
|
|
1024 (texinfo-format-chapter-1 ?=))
|
|
1025
|
|
1026 (put 'subheading 'texinfo-format 'texinfo-format-subsection)
|
|
1027 (put 'isubsection 'texinfo-format 'texinfo-format-subsection)
|
|
1028 (put 'subsection 'texinfo-format 'texinfo-format-subsection)
|
|
1029 (put 'iappendixsubsec 'texinfo-format 'texinfo-format-subsection)
|
|
1030 (put 'appendixsubsec 'texinfo-format 'texinfo-format-subsection)
|
|
1031 (put 'iunnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
|
|
1032 (put 'unnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
|
|
1033 (defun texinfo-format-subsection ()
|
|
1034 (texinfo-format-chapter-1 ?-))
|
|
1035
|
|
1036 (put 'subsubheading 'texinfo-format 'texinfo-format-subsubsection)
|
|
1037 (put 'isubsubsection 'texinfo-format 'texinfo-format-subsubsection)
|
|
1038 (put 'subsubsection 'texinfo-format 'texinfo-format-subsubsection)
|
|
1039 (put 'iappendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
|
|
1040 (put 'appendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
|
|
1041 (put 'iunnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
|
|
1042 (put 'unnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
|
|
1043 (defun texinfo-format-subsubsection ()
|
|
1044 (texinfo-format-chapter-1 ?.))
|
|
1045
|
|
1046 (defun texinfo-format-chapter-1 (belowchar)
|
|
1047 (let ((arg (texinfo-parse-arg-discard)))
|
|
1048 (message "Formatting: %s ... " arg) ; So we can see where we are.
|
|
1049 (insert ?\n arg ?\n "@SectionPAD " belowchar ?\n)
|
|
1050 (forward-line -2)))
|
|
1051
|
|
1052 (put 'SectionPAD 'texinfo-format 'texinfo-format-sectionpad)
|
|
1053 (defun texinfo-format-sectionpad ()
|
|
1054 (let ((str (texinfo-parse-arg-discard)))
|
|
1055 (forward-char -1)
|
|
1056 (let ((column (current-column)))
|
|
1057 (forward-char 1)
|
|
1058 (while (> column 0)
|
|
1059 (insert str)
|
|
1060 (setq column (1- column))))
|
|
1061 (insert ?\n)))
|
|
1062
|
|
1063
|
|
1064 ;;; Space controlling commands: @. and @:, and the soft hyphen.
|
|
1065
|
|
1066 (put '\. 'texinfo-format 'texinfo-format-\.)
|
|
1067 (defun texinfo-format-\. ()
|
|
1068 (texinfo-discard-command)
|
|
1069 (insert "."))
|
|
1070
|
|
1071 (put '\: 'texinfo-format 'texinfo-format-\:)
|
|
1072 (defun texinfo-format-\: ()
|
|
1073 (texinfo-discard-command))
|
|
1074
|
|
1075 (put '\- 'texinfo-format 'texinfo-format-soft-hyphen)
|
|
1076 (defun texinfo-format-soft-hyphen ()
|
|
1077 (texinfo-discard-command))
|
|
1078
|
|
1079
|
|
1080 ;;; @center, @sp, and @br
|
|
1081
|
|
1082 (put 'center 'texinfo-format 'texinfo-format-center)
|
|
1083 (defun texinfo-format-center ()
|
|
1084 (let ((arg (texinfo-parse-expanded-arg)))
|
|
1085 (texinfo-discard-command)
|
|
1086 (insert arg)
|
|
1087 (insert ?\n)
|
|
1088 (save-restriction
|
|
1089 (goto-char (1- (point)))
|
|
1090 (let ((indent-tabs-mode nil))
|
|
1091 (center-line)))))
|
|
1092
|
|
1093 (put 'sp 'texinfo-format 'texinfo-format-sp)
|
|
1094 (defun texinfo-format-sp ()
|
|
1095 (let* ((arg (texinfo-parse-arg-discard))
|
|
1096 (num (read arg)))
|
|
1097 (insert-char ?\n num)))
|
|
1098
|
|
1099 (put 'br 'texinfo-format 'texinfo-format-paragraph-break)
|
|
1100 (defun texinfo-format-paragraph-break ()
|
|
1101 "Force a paragraph break.
|
|
1102 If used within a line, follow `@br' with braces."
|
|
1103 (texinfo-optional-braces-discard)
|
|
1104 ;; insert one return if at end of line;
|
|
1105 ;; else insert two returns, to generate a blank line.
|
|
1106 (if (= (following-char) ?\n)
|
|
1107 (insert ?\n)
|
|
1108 (insert-char ?\n 2)))
|
|
1109
|
|
1110
|
|
1111 ;;; @footnote and @footnotestyle
|
|
1112
|
|
1113 ; In Texinfo, footnotes are created with the `@footnote' command.
|
|
1114 ; This command is followed immediately by a left brace, then by the text of
|
|
1115 ; the footnote, and then by a terminating right brace. The
|
|
1116 ; template for a footnote is:
|
|
1117 ;
|
|
1118 ; @footnote{TEXT}
|
|
1119 ;
|
|
1120 ; Info has two footnote styles:
|
|
1121 ;
|
|
1122 ; * In the End of node style, all the footnotes for a single node
|
|
1123 ; are placed at the end of that node. The footnotes are
|
|
1124 ; separated from the rest of the node by a line of dashes with
|
|
1125 ; the word `Footnotes' within it.
|
|
1126 ;
|
|
1127 ; * In the Separate node style, all the footnotes for a single node
|
|
1128 ; are placed in an automatically constructed node of their own.
|
|
1129
|
|
1130 ; Footnote style is specified by the @footnotestyle command, either
|
|
1131 ; @footnotestyle separate
|
|
1132 ; or
|
|
1133 ; @footnotestyle end
|
|
1134 ;
|
|
1135 ; The default is separate
|
|
1136
|
|
1137 (defvar texinfo-footnote-style "separate"
|
|
1138 "Footnote style, either separate or end.")
|
|
1139
|
|
1140 (put 'footnotestyle 'texinfo-format 'texinfo-footnotestyle)
|
|
1141 (defun texinfo-footnotestyle ()
|
|
1142 "Specify whether footnotes are at end of node or in separate nodes.
|
|
1143 Argument is either end or separate."
|
|
1144 (setq texinfo-footnote-style (texinfo-parse-arg-discard)))
|
|
1145
|
|
1146 (defvar texinfo-footnote-number)
|
|
1147
|
|
1148 (put 'footnote 'texinfo-format 'texinfo-format-footnote)
|
|
1149 (defun texinfo-format-footnote ()
|
|
1150 "Format a footnote in either end of node or separate node style.
|
|
1151 The texinfo-footnote-style variable controls which style is used."
|
|
1152 (setq texinfo-footnote-number (1+ texinfo-footnote-number))
|
|
1153 (cond ((string= texinfo-footnote-style "end")
|
|
1154 (texinfo-format-end-node))
|
|
1155 ((string= texinfo-footnote-style "separate")
|
|
1156 (texinfo-format-separate-node))))
|
|
1157
|
|
1158 (defun texinfo-format-separate-node ()
|
|
1159 "Format footnote in Separate node style, with notes in own node.
|
|
1160 The node is constructed automatically."
|
|
1161 (let* (start
|
|
1162 (arg (texinfo-parse-line-arg))
|
|
1163 (node-name-beginning
|
|
1164 (save-excursion
|
|
1165 (re-search-backward
|
|
1166 "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:")
|
|
1167 (match-end 0)))
|
|
1168 (node-name
|
|
1169 (save-excursion
|
|
1170 (buffer-substring
|
|
1171 (progn (goto-char node-name-beginning) ; skip over node command
|
|
1172 (skip-chars-forward " \t") ; and over spaces
|
|
1173 (point))
|
|
1174 (if (search-forward
|
|
1175 ","
|
|
1176 (save-excursion (end-of-line) (point)) t) ; bound search
|
|
1177 (1- (point))
|
|
1178 (end-of-line) (point))))))
|
|
1179 (texinfo-discard-command) ; remove or insert whitespace, as needed
|
|
1180 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
|
|
1181 (point))
|
|
1182 (insert (format " (%d) (*Note %s-Footnotes::)"
|
|
1183 texinfo-footnote-number node-name))
|
|
1184 (fill-paragraph nil)
|
|
1185 (save-excursion
|
|
1186 (if (re-search-forward "^@node" nil 'move)
|
|
1187 (forward-line -1))
|
|
1188
|
|
1189 ;; two cases: for the first footnote, we must insert a node header;
|
|
1190 ;; for the second and subsequent footnotes, we need only insert
|
|
1191 ;; the text of the footnote.
|
|
1192
|
|
1193 (if (save-excursion
|
|
1194 (re-search-backward
|
|
1195 (concat node-name "-Footnotes, Up: ")
|
|
1196 node-name-beginning
|
|
1197 t))
|
|
1198 (progn ; already at least one footnote
|
|
1199 (setq start (point))
|
|
1200 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
|
|
1201 (fill-region start (point)))
|
|
1202 ;; else not yet a footnote
|
|
1203 (insert "\n\^_\nFile: " texinfo-format-filename
|
|
1204 " Node: " node-name "-Footnotes, Up: " node-name "\n")
|
|
1205 (setq start (point))
|
|
1206 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
|
|
1207 (fill-region start (point))))))
|
|
1208
|
|
1209 (defun texinfo-format-end-node ()
|
|
1210 "Format footnote in the End of node style, with notes at end of node."
|
|
1211 (let (start
|
|
1212 (arg (texinfo-parse-line-arg)))
|
|
1213 (texinfo-discard-command) ; remove or insert whitespace, as needed
|
|
1214 (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
|
|
1215 (point))
|
|
1216 (insert (format " (%d) " texinfo-footnote-number))
|
|
1217 (fill-paragraph nil)
|
|
1218 (save-excursion
|
|
1219 (if (search-forward "\n--------- Footnotes ---------\n" nil t)
|
|
1220 (progn ; already have footnote, put new one before end of node
|
|
1221 (if (re-search-forward "^@node" nil 'move)
|
|
1222 (forward-line -1))
|
|
1223 (setq start (point))
|
|
1224 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))
|
|
1225 (fill-region start (point)))
|
|
1226 ;; else no prior footnote
|
|
1227 (if (re-search-forward "^@node" nil 'move)
|
|
1228 (forward-line -1))
|
|
1229 (insert "\n--------- Footnotes ---------\n")
|
|
1230 (setq start (point))
|
|
1231 (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))))))
|
|
1232
|
|
1233
|
|
1234 ;;; @itemize, @enumerate, and similar commands
|
|
1235
|
|
1236 ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.
|
|
1237 ;; @enumerate pushes (enumerate 0 STARTPOS).
|
|
1238 ;; @item dispatches to the texinfo-item prop of the first elt of the list.
|
|
1239 ;; For itemize, this puts in and rescans the COMMANDS.
|
|
1240 ;; For enumerate, this increments the number and puts it in.
|
|
1241 ;; In either case, it puts a Backspace at the front of the line
|
|
1242 ;; which marks it not to be indented later.
|
|
1243 ;; All other lines get indented by 5 when the @end is reached.
|
|
1244
|
|
1245 (defvar texinfo-stack-depth 0
|
|
1246 "Count of number of unpopped texinfo-push-stack calls.
|
|
1247 Used by @refill indenting command to avoid indenting within lists, etc.")
|
|
1248
|
|
1249 (defun texinfo-push-stack (check arg)
|
|
1250 (setq texinfo-stack-depth (1+ texinfo-stack-depth))
|
|
1251 (setq texinfo-stack
|
|
1252 (cons (list check arg texinfo-command-start)
|
|
1253 texinfo-stack)))
|
|
1254
|
|
1255 (defun texinfo-pop-stack (check)
|
|
1256 (setq texinfo-stack-depth (1- texinfo-stack-depth))
|
|
1257 (if (null texinfo-stack)
|
|
1258 (error "Unmatched @end %s" check))
|
|
1259 (if (not (eq (car (car texinfo-stack)) check))
|
|
1260 (error "@end %s matches @%s"
|
|
1261 check (car (car texinfo-stack))))
|
|
1262 (prog1 (cdr (car texinfo-stack))
|
|
1263 (setq texinfo-stack (cdr texinfo-stack))))
|
|
1264
|
|
1265 (put 'itemize 'texinfo-format 'texinfo-itemize)
|
|
1266 (defun texinfo-itemize ()
|
|
1267 (texinfo-push-stack
|
|
1268 'itemize
|
|
1269 (progn (skip-chars-forward " \t")
|
|
1270 (if (eolp)
|
|
1271 "@bullet"
|
|
1272 (texinfo-parse-line-arg))))
|
|
1273 (texinfo-discard-line-with-args)
|
|
1274 (setq fill-column (- fill-column 5)))
|
|
1275
|
|
1276 (put 'itemize 'texinfo-end 'texinfo-end-itemize)
|
|
1277 (defun texinfo-end-itemize ()
|
|
1278 (setq fill-column (+ fill-column 5))
|
|
1279 (texinfo-discard-command)
|
|
1280 (let ((stacktop
|
|
1281 (texinfo-pop-stack 'itemize)))
|
|
1282 (texinfo-do-itemize (nth 1 stacktop))))
|
|
1283
|
|
1284 (put 'enumerate 'texinfo-format 'texinfo-enumerate)
|
|
1285 (defun texinfo-enumerate ()
|
|
1286 (texinfo-push-stack
|
|
1287 'enumerate
|
|
1288 (progn (skip-chars-forward " \t")
|
|
1289 (if (eolp)
|
|
1290 1
|
|
1291 (read (current-buffer)))))
|
|
1292 (if (and (symbolp (car (cdr (car texinfo-stack))))
|
|
1293 (> 1 (length (symbol-name (car (cdr (car texinfo-stack)))))))
|
|
1294 (error
|
|
1295 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." ))
|
|
1296 (texinfo-discard-line-with-args)
|
|
1297 (setq fill-column (- fill-column 5)))
|
|
1298
|
|
1299 (put 'enumerate 'texinfo-end 'texinfo-end-enumerate)
|
|
1300 (defun texinfo-end-enumerate ()
|
|
1301 (setq fill-column (+ fill-column 5))
|
|
1302 (texinfo-discard-command)
|
|
1303 (let ((stacktop
|
|
1304 (texinfo-pop-stack 'enumerate)))
|
|
1305 (texinfo-do-itemize (nth 1 stacktop))))
|
|
1306
|
|
1307 ;; @alphaenumerate never became a standard part of Texinfo
|
|
1308 (put 'alphaenumerate 'texinfo-format 'texinfo-alphaenumerate)
|
|
1309 (defun texinfo-alphaenumerate ()
|
|
1310 (texinfo-push-stack 'alphaenumerate (1- ?a))
|
|
1311 (setq fill-column (- fill-column 5))
|
|
1312 (texinfo-discard-line))
|
|
1313
|
|
1314 (put 'alphaenumerate 'texinfo-end 'texinfo-end-alphaenumerate)
|
|
1315 (defun texinfo-end-alphaenumerate ()
|
|
1316 (setq fill-column (+ fill-column 5))
|
|
1317 (texinfo-discard-command)
|
|
1318 (let ((stacktop
|
|
1319 (texinfo-pop-stack 'alphaenumerate)))
|
|
1320 (texinfo-do-itemize (nth 1 stacktop))))
|
|
1321
|
|
1322 ;; @capsenumerate never became a standard part of Texinfo
|
|
1323 (put 'capsenumerate 'texinfo-format 'texinfo-capsenumerate)
|
|
1324 (defun texinfo-capsenumerate ()
|
|
1325 (texinfo-push-stack 'capsenumerate (1- ?A))
|
|
1326 (setq fill-column (- fill-column 5))
|
|
1327 (texinfo-discard-line))
|
|
1328
|
|
1329 (put 'capsenumerate 'texinfo-end 'texinfo-end-capsenumerate)
|
|
1330 (defun texinfo-end-capsenumerate ()
|
|
1331 (setq fill-column (+ fill-column 5))
|
|
1332 (texinfo-discard-command)
|
|
1333 (let ((stacktop
|
|
1334 (texinfo-pop-stack 'capsenumerate)))
|
|
1335 (texinfo-do-itemize (nth 1 stacktop))))
|
|
1336
|
|
1337 ;; At the @end, indent all the lines within the construct
|
|
1338 ;; except those marked with backspace. FROM says where
|
|
1339 ;; construct started.
|
|
1340 (defun texinfo-do-itemize (from)
|
|
1341 (save-excursion
|
|
1342 (while (progn (forward-line -1)
|
|
1343 (>= (point) from))
|
|
1344 (if (= (following-char) ?\b)
|
|
1345 (save-excursion
|
|
1346 (delete-char 1)
|
|
1347 (end-of-line)
|
|
1348 (delete-char 6))
|
|
1349 (if (not (looking-at "[ \t]*$"))
|
|
1350 (save-excursion (insert " ")))))))
|
|
1351
|
|
1352 (put 'item 'texinfo-format 'texinfo-item)
|
|
1353 (put 'itemx 'texinfo-format 'texinfo-item)
|
|
1354 (defun texinfo-item ()
|
|
1355 (funcall (get (car (car texinfo-stack)) 'texinfo-item)))
|
|
1356
|
|
1357 (put 'itemize 'texinfo-item 'texinfo-itemize-item)
|
|
1358 (defun texinfo-itemize-item ()
|
|
1359 ;; (texinfo-discard-line) ; Did not handle text on same line as @item.
|
|
1360 (delete-region (1+ (point)) (save-excursion (beginning-of-line) (point)))
|
|
1361 (if (looking-at "[ \t]*[^ \t\n]+")
|
|
1362 ;; Text on same line as @item command.
|
|
1363 (insert "\b " (nth 1 (car texinfo-stack)) " \n")
|
|
1364 ;; Else text on next line.
|
|
1365 (insert "\b " (nth 1 (car texinfo-stack)) " "))
|
|
1366 (forward-line -1))
|
|
1367
|
|
1368 (put 'enumerate 'texinfo-item 'texinfo-enumerate-item)
|
|
1369 (defun texinfo-enumerate-item ()
|
|
1370 (texinfo-discard-line)
|
|
1371 (let (enumerating-symbol)
|
|
1372 (cond ((integerp (car (cdr (car texinfo-stack))))
|
|
1373 (setq enumerating-symbol (car (cdr (car texinfo-stack))))
|
|
1374 (insert ?\b (format "%3d. " enumerating-symbol) ?\n)
|
|
1375 (setcar (cdr (car texinfo-stack)) (1+ enumerating-symbol)))
|
|
1376 ((symbolp (car (cdr (car texinfo-stack))))
|
|
1377 (setq enumerating-symbol
|
|
1378 (symbol-name (car (cdr (car texinfo-stack)))))
|
|
1379 (if (or (equal ?\[ (string-to-char enumerating-symbol))
|
|
1380 (equal ?\{ (string-to-char enumerating-symbol)))
|
|
1381 (error
|
|
1382 "Too many items in enumerated list; alphabet ends at Z."))
|
|
1383 (insert ?\b (format "%3s. " enumerating-symbol) ?\n)
|
|
1384 (setcar (cdr (car texinfo-stack))
|
|
1385 (make-symbol
|
|
1386 (char-to-string
|
|
1387 (1+
|
|
1388 (string-to-char enumerating-symbol))))))
|
|
1389 (t
|
|
1390 (error
|
|
1391 "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." )))
|
|
1392 (forward-line -1)))
|
|
1393
|
|
1394 (put 'alphaenumerate 'texinfo-item 'texinfo-alphaenumerate-item)
|
|
1395 (defun texinfo-alphaenumerate-item ()
|
|
1396 (texinfo-discard-line)
|
|
1397 (let ((next (1+ (car (cdr (car texinfo-stack))))))
|
|
1398 (if (> next ?z)
|
|
1399 (error "More than 26 items in @alphaenumerate; get a bigger alphabet."))
|
|
1400 (setcar (cdr (car texinfo-stack)) next)
|
|
1401 (insert "\b " next ". \n"))
|
|
1402 (forward-line -1))
|
|
1403
|
|
1404 (put 'capsenumerate 'texinfo-item 'texinfo-capsenumerate-item)
|
|
1405 (defun texinfo-capsenumerate-item ()
|
|
1406 (texinfo-discard-line)
|
|
1407 (let ((next (1+ (car (cdr (car texinfo-stack))))))
|
|
1408 (if (> next ?Z)
|
|
1409 (error "More than 26 items in @capsenumerate; get a bigger alphabet."))
|
|
1410 (setcar (cdr (car texinfo-stack)) next)
|
|
1411 (insert "\b " next ". \n"))
|
|
1412 (forward-line -1))
|
|
1413
|
|
1414
|
|
1415 ;;; @table
|
|
1416
|
|
1417 ; The `@table' command produces two-column tables.
|
|
1418
|
|
1419 (put 'table 'texinfo-format 'texinfo-table)
|
|
1420 (defun texinfo-table ()
|
|
1421 (texinfo-push-stack
|
|
1422 'table
|
|
1423 (progn (skip-chars-forward " \t")
|
|
1424 (if (eolp)
|
|
1425 "@asis"
|
|
1426 (texinfo-parse-line-arg))))
|
|
1427 (texinfo-discard-line-with-args)
|
|
1428 (setq fill-column (- fill-column 5)))
|
|
1429
|
|
1430 (put 'table 'texinfo-item 'texinfo-table-item)
|
|
1431 (defun texinfo-table-item ()
|
|
1432 (let ((arg (texinfo-parse-arg-discard))
|
|
1433 (itemfont (car (cdr (car texinfo-stack)))))
|
|
1434 (insert ?\b itemfont ?\{ arg "}\n \n"))
|
|
1435 (forward-line -2))
|
|
1436
|
|
1437 (put 'table 'texinfo-end 'texinfo-end-table)
|
|
1438 (defun texinfo-end-table ()
|
|
1439 (setq fill-column (+ fill-column 5))
|
|
1440 (texinfo-discard-command)
|
|
1441 (let ((stacktop
|
|
1442 (texinfo-pop-stack 'table)))
|
|
1443 (texinfo-do-itemize (nth 1 stacktop))))
|
|
1444
|
|
1445 ;; @description appears to be an undocumented variant on @table that
|
|
1446 ;; does not require an arg. It fails in texinfo.tex 2.58 and is not
|
|
1447 ;; part of makeinfo.c The command appears to be a relic of the past.
|
|
1448 (put 'description 'texinfo-end 'texinfo-end-table)
|
|
1449 (put 'description 'texinfo-format 'texinfo-description)
|
|
1450 (defun texinfo-description ()
|
|
1451 (texinfo-push-stack 'table "@asis")
|
|
1452 (setq fill-column (- fill-column 5))
|
|
1453 (texinfo-discard-line))
|
|
1454
|
|
1455
|
|
1456 ;;; @ftable, @vtable
|
|
1457
|
|
1458 ; The `@ftable' and `@vtable' commands are like the `@table' command
|
|
1459 ; but they also insert each entry in the first column of the table
|
|
1460 ; into the function or variable index.
|
|
1461
|
|
1462 ;; Handle the @ftable and @vtable commands:
|
|
1463
|
|
1464 (put 'ftable 'texinfo-format 'texinfo-ftable)
|
|
1465 (put 'vtable 'texinfo-format 'texinfo-vtable)
|
|
1466
|
|
1467 (defun texinfo-ftable () (texinfo-indextable 'ftable))
|
|
1468 (defun texinfo-vtable () (texinfo-indextable 'vtable))
|
|
1469
|
|
1470 (defun texinfo-indextable (table-type)
|
|
1471 (texinfo-push-stack table-type (texinfo-parse-arg-discard))
|
|
1472 (setq fill-column (- fill-column 5)))
|
|
1473
|
|
1474 ;; Handle the @item commands within ftable and vtable:
|
|
1475
|
|
1476 (put 'ftable 'texinfo-item 'texinfo-ftable-item)
|
|
1477 (put 'vtable 'texinfo-item 'texinfo-vtable-item)
|
|
1478
|
|
1479 (defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex))
|
|
1480 (defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex))
|
|
1481
|
|
1482 (defun texinfo-indextable-item (index-type)
|
|
1483 (let ((item (texinfo-parse-arg-discard))
|
|
1484 (itemfont (car (cdr (car texinfo-stack))))
|
|
1485 (indexvar index-type))
|
|
1486 (insert ?\b itemfont ?\{ item "}\n \n")
|
|
1487 (set indexvar
|
|
1488 (cons
|
|
1489 (list item texinfo-last-node)
|
|
1490 (symbol-value indexvar)))
|
|
1491 (forward-line -2)))
|
|
1492
|
|
1493 ;; Handle @end ftable, @end vtable
|
|
1494
|
|
1495 (put 'ftable 'texinfo-end 'texinfo-end-ftable)
|
|
1496 (put 'vtable 'texinfo-end 'texinfo-end-vtable)
|
|
1497
|
|
1498 (defun texinfo-end-ftable () (texinfo-end-indextable 'ftable))
|
|
1499 (defun texinfo-end-vtable () (texinfo-end-indextable 'vtable))
|
|
1500
|
|
1501 (defun texinfo-end-indextable (table-type)
|
|
1502 (setq fill-column (+ fill-column 5))
|
|
1503 (texinfo-discard-command)
|
|
1504 (let ((stacktop
|
|
1505 (texinfo-pop-stack table-type)))
|
|
1506 (texinfo-do-itemize (nth 1 stacktop))))
|
|
1507
|
|
1508
|
|
1509 ;;; @ifinfo, @iftex, @tex, @ifhtml, @html
|
|
1510
|
|
1511 (put 'ifinfo 'texinfo-format 'texinfo-discard-line)
|
|
1512 (put 'ifinfo 'texinfo-end 'texinfo-discard-command)
|
|
1513
|
|
1514 (put 'iftex 'texinfo-format 'texinfo-format-iftex)
|
|
1515 (defun texinfo-format-iftex ()
|
|
1516 (delete-region texinfo-command-start
|
|
1517 (progn (re-search-forward "@end iftex[ \t]*\n")
|
|
1518 (point))))
|
|
1519
|
|
1520 (put 'ifhtml 'texinfo-format 'texinfo-format-ifhtml)
|
|
1521 (defun texinfo-format-ifhtml ()
|
|
1522 (delete-region texinfo-command-start
|
|
1523 (progn (re-search-forward "@end ifhtml[ \t]*\n")
|
|
1524 (point))))
|
|
1525
|
|
1526 (put 'tex 'texinfo-format 'texinfo-format-tex)
|
|
1527 (defun texinfo-format-tex ()
|
|
1528 (delete-region texinfo-command-start
|
|
1529 (progn (re-search-forward "@end tex[ \t]*\n")
|
|
1530 (point))))
|
|
1531
|
|
1532 (put 'html 'texinfo-format 'texinfo-format-html)
|
|
1533 (defun texinfo-format-html ()
|
|
1534 (delete-region texinfo-command-start
|
|
1535 (progn (re-search-forward "@end html[ \t]*\n")
|
|
1536 (point))))
|
|
1537
|
|
1538
|
|
1539 ;;; @titlepage
|
|
1540
|
|
1541 (put 'titlepage 'texinfo-format 'texinfo-format-titlepage)
|
|
1542 (defun texinfo-format-titlepage ()
|
|
1543 (delete-region texinfo-command-start
|
|
1544 (progn (re-search-forward "@end titlepage[ \t]*\n")
|
|
1545 (point))))
|
|
1546
|
|
1547 (put 'endtitlepage 'texinfo-format 'texinfo-discard-line)
|
|
1548
|
|
1549 ; @titlespec an alternative titling command; ignored by Info
|
|
1550
|
|
1551 (put 'titlespec 'texinfo-format 'texinfo-format-titlespec)
|
|
1552 (defun texinfo-format-titlespec ()
|
|
1553 (delete-region texinfo-command-start
|
|
1554 (progn (re-search-forward "@end titlespec[ \t]*\n")
|
|
1555 (point))))
|
|
1556
|
|
1557 (put 'endtitlespec 'texinfo-format 'texinfo-discard-line)
|
|
1558
|
|
1559
|
|
1560 ;;; @today
|
|
1561
|
|
1562 (put 'today 'texinfo-format 'texinfo-format-today)
|
|
1563
|
|
1564 ; Produces Day Month Year style of output. eg `1 Jan 1900'
|
|
1565 ; The `@today{}' command requires a pair of braces, like `@dots{}'.
|
|
1566 (defun texinfo-format-today ()
|
|
1567 (texinfo-parse-arg-discard)
|
2
|
1568 (insert (format-time-string "%e %b %Y")))
|
0
|
1569
|
|
1570
|
|
1571 ;;; @ignore
|
|
1572
|
|
1573 (put 'ignore 'texinfo-format 'texinfo-format-ignore)
|
|
1574 (defun texinfo-format-ignore ()
|
|
1575 (delete-region texinfo-command-start
|
|
1576 (progn (re-search-forward "@end ignore[ \t]*\n")
|
|
1577 (point))))
|
|
1578
|
|
1579 (put 'endignore 'texinfo-format 'texinfo-discard-line)
|
|
1580
|
|
1581
|
|
1582 ;;; Define the Info enclosure command: @definfoenclose
|
|
1583
|
|
1584 ; A `@definfoenclose' command may be used to define a highlighting
|
|
1585 ; command for Info, but not for TeX. A command defined using
|
|
1586 ; `@definfoenclose' marks text by enclosing it in strings that precede
|
|
1587 ; and follow the text.
|
|
1588 ;
|
|
1589 ; Presumably, if you define a command with `@definfoenclose` for Info,
|
|
1590 ; you will also define the same command in the TeX definitions file,
|
|
1591 ; `texinfo.tex' in a manner appropriate for typesetting.
|
|
1592 ;
|
|
1593 ; Write a `@definfoenclose' command on a line and follow it with three
|
|
1594 ; arguments separated by commas (commas are used as separators in an
|
|
1595 ; `@node' line in the same way). The first argument to
|
|
1596 ; `@definfoenclose' is the @-command name \(without the `@'\); the
|
|
1597 ; second argument is the Info start delimiter string; and the third
|
|
1598 ; argument is the Info end delimiter string. The latter two arguments
|
|
1599 ; enclose the highlighted text in the Info file. A delimiter string
|
|
1600 ; may contain spaces. Neither the start nor end delimiter is
|
|
1601 ; required. However, if you do not provide a start delimiter, you
|
|
1602 ; must follow the command name with two commas in a row; otherwise,
|
|
1603 ; the Info formatting commands will misinterpret the end delimiter
|
|
1604 ; string as a start delimiter string.
|
|
1605 ;
|
|
1606 ; If you do a @definfoenclose{} on the name of a pre-defined macro (such
|
|
1607 ; as @emph{}, @strong{}, @tt{}, or @i{}) the enclosure definition will
|
|
1608 ; override the built-in definition.
|
|
1609 ;
|
|
1610 ; An enclosure command defined this way takes one argument in braces.
|
|
1611 ;
|
|
1612 ; For example, you can write:
|
|
1613 ;
|
|
1614 ; @ifinfo
|
|
1615 ; @definfoenclose phoo, //, \\
|
|
1616 ; @end ifinfo
|
|
1617 ;
|
|
1618 ; near the beginning of a Texinfo file at the beginning of the lines
|
|
1619 ; to define `@phoo' as an Info formatting command that inserts `//'
|
|
1620 ; before and `\\' after the argument to `@phoo'. You can then write
|
|
1621 ; `@phoo{bar}' wherever you want `//bar\\' highlighted in Info.
|
|
1622 ;
|
|
1623 ; Also, for TeX formatting, you could write
|
|
1624 ;
|
|
1625 ; @iftex
|
|
1626 ; @global@let@phoo=@i
|
|
1627 ; @end iftex
|
|
1628 ;
|
|
1629 ; to define `@phoo' as a command that causes TeX to typeset
|
|
1630 ; the argument to `@phoo' in italics.
|
|
1631 ;
|
|
1632 ; Note that each definition applies to its own formatter: one for TeX,
|
|
1633 ; the other for texinfo-format-buffer or texinfo-format-region.
|
|
1634 ;
|
|
1635 ; Here is another example: write
|
|
1636 ;
|
|
1637 ; @definfoenclose headword, , :
|
|
1638 ;
|
|
1639 ; near the beginning of the file, to define `@headword' as an Info
|
|
1640 ; formatting command that inserts nothing before and a colon after the
|
|
1641 ; argument to `@headword'.
|
|
1642
|
|
1643 (put 'definfoenclose 'texinfo-format 'texinfo-define-info-enclosure)
|
|
1644 (defun texinfo-define-info-enclosure ()
|
|
1645 (let* ((args (texinfo-format-parse-line-args))
|
|
1646 (command-name (nth 0 args))
|
|
1647 (beginning-delimiter (or (nth 1 args) ""))
|
|
1648 (end-delimiter (or (nth 2 args) "")))
|
|
1649 (texinfo-discard-command)
|
|
1650 (setq texinfo-enclosure-list
|
|
1651 (cons
|
|
1652 (list command-name
|
|
1653 (list
|
|
1654 beginning-delimiter
|
|
1655 end-delimiter))
|
|
1656 texinfo-enclosure-list))))
|
|
1657
|
|
1658
|
|
1659 ;;; @var, @code and the like
|
|
1660
|
|
1661 (put 'var 'texinfo-format 'texinfo-format-var)
|
|
1662 ; @sc a small caps font for TeX; formatted as `var' in Info
|
|
1663 (put 'sc 'texinfo-format 'texinfo-format-var)
|
|
1664 (defun texinfo-format-var ()
|
|
1665 (insert (upcase (texinfo-parse-arg-discard)))
|
|
1666 (goto-char texinfo-command-start))
|
|
1667
|
|
1668 ; various noops
|
|
1669
|
|
1670 (put 'b 'texinfo-format 'texinfo-format-noop)
|
|
1671 (put 'i 'texinfo-format 'texinfo-format-noop)
|
|
1672 (put 'r 'texinfo-format 'texinfo-format-noop)
|
|
1673 (put 't 'texinfo-format 'texinfo-format-noop)
|
|
1674 (put 'w 'texinfo-format 'texinfo-format-noop)
|
|
1675 (put 'asis 'texinfo-format 'texinfo-format-noop)
|
|
1676 (put 'dmn 'texinfo-format 'texinfo-format-noop)
|
|
1677 (put 'key 'texinfo-format 'texinfo-format-noop)
|
|
1678 (put 'math 'texinfo-format 'texinfo-format-noop)
|
|
1679 (put 'titlefont 'texinfo-format 'texinfo-format-noop)
|
|
1680 (defun texinfo-format-noop ()
|
|
1681 (insert (texinfo-parse-arg-discard))
|
|
1682 (goto-char texinfo-command-start))
|
|
1683
|
|
1684 (put 'cite 'texinfo-format 'texinfo-format-code)
|
|
1685 (put 'code 'texinfo-format 'texinfo-format-code)
|
|
1686 (put 'file 'texinfo-format 'texinfo-format-code)
|
|
1687 (put 'kbd 'texinfo-format 'texinfo-format-code)
|
|
1688 (put 'samp 'texinfo-format 'texinfo-format-code)
|
|
1689 (defun texinfo-format-code ()
|
|
1690 (insert "`" (texinfo-parse-arg-discard) "'")
|
|
1691 (goto-char texinfo-command-start))
|
|
1692
|
|
1693 (put 'emph 'texinfo-format 'texinfo-format-emph)
|
|
1694 (put 'strong 'texinfo-format 'texinfo-format-emph)
|
|
1695 (defun texinfo-format-emph ()
|
|
1696 (insert "*" (texinfo-parse-arg-discard) "*")
|
|
1697 (goto-char texinfo-command-start))
|
|
1698
|
|
1699 (put 'dfn 'texinfo-format 'texinfo-format-defn)
|
|
1700 (put 'defn 'texinfo-format 'texinfo-format-defn)
|
|
1701 (defun texinfo-format-defn ()
|
|
1702 (insert "\"" (texinfo-parse-arg-discard) "\"")
|
|
1703 (goto-char texinfo-command-start))
|
|
1704
|
|
1705 (put 'bullet 'texinfo-format 'texinfo-format-bullet)
|
|
1706 (defun texinfo-format-bullet ()
|
|
1707 "Insert an asterisk.
|
|
1708 If used within a line, follow `@bullet' with braces."
|
|
1709 (texinfo-optional-braces-discard)
|
|
1710 (insert "*"))
|
|
1711
|
|
1712
|
|
1713 ;;; @example, @lisp, @quotation, @display, @smalllisp, @smallexample
|
|
1714
|
|
1715 (put 'display 'texinfo-format 'texinfo-format-example)
|
|
1716 (put 'example 'texinfo-format 'texinfo-format-example)
|
|
1717 (put 'lisp 'texinfo-format 'texinfo-format-example)
|
|
1718 (put 'quotation 'texinfo-format 'texinfo-format-example)
|
|
1719 (put 'smallexample 'texinfo-format 'texinfo-format-example)
|
|
1720 (put 'smalllisp 'texinfo-format 'texinfo-format-example)
|
|
1721 (defun texinfo-format-example ()
|
|
1722 (texinfo-push-stack 'example nil)
|
|
1723 (setq fill-column (- fill-column 5))
|
|
1724 (texinfo-discard-line))
|
|
1725
|
|
1726 (put 'example 'texinfo-end 'texinfo-end-example)
|
|
1727 (put 'display 'texinfo-end 'texinfo-end-example)
|
|
1728 (put 'lisp 'texinfo-end 'texinfo-end-example)
|
|
1729 (put 'quotation 'texinfo-end 'texinfo-end-example)
|
|
1730 (put 'smallexample 'texinfo-end 'texinfo-end-example)
|
|
1731 (put 'smalllisp 'texinfo-end 'texinfo-end-example)
|
|
1732 (defun texinfo-end-example ()
|
|
1733 (setq fill-column (+ fill-column 5))
|
|
1734 (texinfo-discard-command)
|
|
1735 (let ((stacktop
|
|
1736 (texinfo-pop-stack 'example)))
|
|
1737 (texinfo-do-itemize (nth 1 stacktop))))
|
|
1738
|
|
1739 (put 'exdent 'texinfo-format 'texinfo-format-exdent)
|
|
1740 (defun texinfo-format-exdent ()
|
|
1741 (texinfo-discard-command)
|
|
1742 (delete-region (point)
|
|
1743 (progn
|
|
1744 (skip-chars-forward " ")
|
|
1745 (point)))
|
|
1746 (insert ?\b)
|
|
1747 ;; Cancel out the deletion that texinfo-do-itemize
|
|
1748 ;; is going to do at the end of this line.
|
|
1749 (save-excursion
|
|
1750 (end-of-line)
|
|
1751 (insert "\n ")))
|
|
1752
|
|
1753
|
|
1754 ;;; @cartouche
|
|
1755
|
|
1756 ; The @cartouche command is a noop in Info; in a printed manual,
|
|
1757 ; it makes a box with rounded corners.
|
|
1758
|
|
1759 (put 'cartouche 'texinfo-format 'texinfo-discard-line)
|
|
1760 (put 'cartouche 'texinfo-end 'texinfo-discard-command)
|
|
1761
|
|
1762
|
|
1763 ;;; @flushleft and @format
|
|
1764
|
|
1765 ; The @flushleft command left justifies every line but leaves the
|
|
1766 ; right end ragged. As far as Info is concerned, @flushleft is a
|
|
1767 ; `do-nothing' command
|
|
1768
|
|
1769 ; The @format command is similar to @example except that it does not
|
|
1770 ; indent; this means that in Info, @format is similar to @flushleft.
|
|
1771
|
|
1772 (put 'format 'texinfo-format 'texinfo-format-flushleft)
|
|
1773 (put 'flushleft 'texinfo-format 'texinfo-format-flushleft)
|
|
1774 (defun texinfo-format-flushleft ()
|
|
1775 (texinfo-discard-line))
|
|
1776
|
|
1777 (put 'format 'texinfo-end 'texinfo-end-flushleft)
|
|
1778 (put 'flushleft 'texinfo-end 'texinfo-end-flushleft)
|
|
1779 (defun texinfo-end-flushleft ()
|
|
1780 (texinfo-discard-command))
|
|
1781
|
|
1782
|
|
1783 ;;; @flushright
|
|
1784
|
|
1785 ; The @flushright command right justifies every line but leaves the
|
|
1786 ; left end ragged. Spaces and tabs at the right ends of lines are
|
|
1787 ; removed so that visible text lines up on the right side.
|
|
1788
|
|
1789 (put 'flushright 'texinfo-format 'texinfo-format-flushright)
|
|
1790 (defun texinfo-format-flushright ()
|
|
1791 (texinfo-push-stack 'flushright nil)
|
|
1792 (texinfo-discard-line))
|
|
1793
|
|
1794 (put 'flushright 'texinfo-end 'texinfo-end-flushright)
|
|
1795 (defun texinfo-end-flushright ()
|
|
1796 (texinfo-discard-command)
|
|
1797
|
|
1798 (let ((stacktop
|
|
1799 (texinfo-pop-stack 'flushright)))
|
|
1800
|
|
1801 (texinfo-do-flushright (nth 1 stacktop))))
|
|
1802
|
|
1803 (defun texinfo-do-flushright (from)
|
|
1804 (save-excursion
|
|
1805 (while (progn (forward-line -1)
|
|
1806 (>= (point) from))
|
|
1807
|
|
1808 (beginning-of-line)
|
|
1809 (insert
|
|
1810 (make-string
|
|
1811 (- fill-column
|
|
1812 (save-excursion
|
|
1813 (end-of-line)
|
|
1814 (skip-chars-backward " \t")
|
|
1815 (delete-region (point) (progn (end-of-line) (point)))
|
|
1816 (current-column)))
|
|
1817 ? )))))
|
|
1818
|
|
1819
|
|
1820 ;;; @ctrl, @TeX, @copyright, @minus, @dots
|
|
1821
|
|
1822 (put 'ctrl 'texinfo-format 'texinfo-format-ctrl)
|
|
1823 (defun texinfo-format-ctrl ()
|
|
1824 (let ((str (texinfo-parse-arg-discard)))
|
|
1825 (insert (logand 31 (aref str 0)))))
|
|
1826
|
|
1827 (put 'TeX 'texinfo-format 'texinfo-format-TeX)
|
|
1828 (defun texinfo-format-TeX ()
|
|
1829 (texinfo-parse-arg-discard)
|
|
1830 (insert "TeX"))
|
|
1831
|
|
1832 (put 'copyright 'texinfo-format 'texinfo-format-copyright)
|
|
1833 (defun texinfo-format-copyright ()
|
|
1834 (texinfo-parse-arg-discard)
|
|
1835 (insert "(C)"))
|
|
1836
|
|
1837 (put 'minus 'texinfo-format 'texinfo-format-minus)
|
|
1838 (defun texinfo-format-minus ()
|
|
1839 "Insert a minus sign.
|
|
1840 If used within a line, follow `@minus' with braces."
|
|
1841 (texinfo-optional-braces-discard)
|
|
1842 (insert "-"))
|
|
1843
|
|
1844 (put 'dots 'texinfo-format 'texinfo-format-dots)
|
|
1845 (defun texinfo-format-dots ()
|
|
1846 (texinfo-parse-arg-discard)
|
|
1847 (insert "..."))
|
|
1848
|
|
1849 (put 'enddots 'texinfo-format 'texinfo-format-enddots)
|
|
1850 (defun texinfo-format-enddots ()
|
|
1851 (texinfo-parse-arg-discard)
|
|
1852 (insert "...."))
|
|
1853
|
|
1854
|
|
1855 ;;; Refilling and indenting: @refill, @paragraphindent, @noindent
|
|
1856
|
|
1857 ;;; Indent only those paragraphs that are refilled as a result of an
|
|
1858 ;;; @refill command.
|
|
1859
|
|
1860 ; * If the value is `asis', do not change the existing indentation at
|
|
1861 ; the starts of paragraphs.
|
|
1862
|
|
1863 ; * If the value zero, delete any existing indentation.
|
|
1864
|
|
1865 ; * If the value is greater than zero, indent each paragraph by that
|
|
1866 ; number of spaces.
|
|
1867
|
|
1868 ;;; But do not refill paragraphs with an @refill command that are
|
|
1869 ;;; preceded by @noindent or are part of a table, list, or deffn.
|
|
1870
|
|
1871 (defvar texinfo-paragraph-indent "asis"
|
|
1872 "Number of spaces for @refill to indent a paragraph; else to leave as is.")
|
|
1873
|
|
1874 (put 'paragraphindent 'texinfo-format 'texinfo-paragraphindent)
|
|
1875
|
|
1876 (defun texinfo-paragraphindent ()
|
|
1877 "Specify the number of spaces for @refill to indent a paragraph.
|
|
1878 Default is to leave the number of spaces as is."
|
|
1879 (let ((arg (texinfo-parse-arg-discard)))
|
|
1880 (if (string= "asis" arg)
|
|
1881 (setq texinfo-paragraph-indent "asis")
|
|
1882 (setq texinfo-paragraph-indent (string-to-int arg)))))
|
|
1883
|
|
1884 (put 'refill 'texinfo-format 'texinfo-format-refill)
|
|
1885 (defun texinfo-format-refill ()
|
|
1886 "Refill paragraph. Also, indent first line as set by @paragraphindent.
|
|
1887 Default is to leave paragraph indentation as is."
|
|
1888 (texinfo-discard-command)
|
|
1889 (forward-paragraph -1)
|
|
1890 (if (looking-at "[ \t\n]*$") (forward-line 1))
|
|
1891 ;; Do not indent if an entry in a list, table, or deffn,
|
|
1892 ;; or if paragraph is preceded by @noindent.
|
|
1893 ;; Otherwise, indent
|
|
1894 (cond
|
|
1895 ;; delete a @noindent line and do not indent paragraph
|
|
1896 ((save-excursion (forward-line -1)
|
|
1897 (looking-at "^@noindent"))
|
|
1898 (forward-line -1)
|
|
1899 (delete-region (point) (progn (forward-line 1) (point))))
|
|
1900 ;; do nothing if "asis"
|
|
1901 ((equal texinfo-paragraph-indent "asis"))
|
|
1902 ;; do no indenting in list, etc.
|
|
1903 ((> texinfo-stack-depth 0))
|
|
1904 ;; otherwise delete existing whitespace and indent
|
|
1905 (t
|
|
1906 (delete-region (point) (progn (skip-chars-forward " \t") (point)))
|
|
1907 (insert (make-string texinfo-paragraph-indent ? ))))
|
|
1908 (forward-paragraph 1)
|
|
1909 (forward-line -1)
|
|
1910 (end-of-line)
|
|
1911 ;; Do not fill a section title line with asterisks, hyphens, etc. that
|
|
1912 ;; are used to underline it. This could occur if the line following
|
|
1913 ;; the underlining is not an index entry and has text within it.
|
|
1914 ;; XEmacs change: the standard 3.6 paragraph separators cause
|
|
1915 ;; texinfmt to fail on vm.texi so we continue to use the older version.
|
|
1916 (let* ((previous-paragraph-separate paragraph-separate)
|
|
1917 (paragraph-separate (concat paragraph-separate "\\|^[=*---.]+"))
|
|
1918 (previous-paragraph-start paragraph-start)
|
|
1919 (paragraph-start (concat paragraph-start "\\|^[=*---.]+")))
|
|
1920 (unwind-protect
|
|
1921 (fill-paragraph nil)
|
|
1922 (setq paragraph-separate previous-paragraph-separate)
|
|
1923 (setq paragraph-start previous-paragraph-start))))
|
|
1924
|
|
1925 (put 'noindent 'texinfo-format 'texinfo-noindent)
|
|
1926 (defun texinfo-noindent ()
|
|
1927 (save-excursion
|
|
1928 (forward-paragraph 1)
|
|
1929 (if (search-backward "@refill"
|
|
1930 (save-excursion (forward-line -1) (point)) t)
|
|
1931 () ; leave @noindent command so @refill command knows not to indent
|
|
1932 ;; else
|
|
1933 (texinfo-discard-line))))
|
|
1934
|
|
1935
|
|
1936 ;;; Index generation
|
|
1937
|
|
1938 (put 'vindex 'texinfo-format 'texinfo-format-vindex)
|
|
1939 (defun texinfo-format-vindex ()
|
|
1940 (texinfo-index 'texinfo-vindex))
|
|
1941
|
|
1942 (put 'cindex 'texinfo-format 'texinfo-format-cindex)
|
|
1943 (defun texinfo-format-cindex ()
|
|
1944 (texinfo-index 'texinfo-cindex))
|
|
1945
|
|
1946 (put 'findex 'texinfo-format 'texinfo-format-findex)
|
|
1947 (defun texinfo-format-findex ()
|
|
1948 (texinfo-index 'texinfo-findex))
|
|
1949
|
|
1950 (put 'pindex 'texinfo-format 'texinfo-format-pindex)
|
|
1951 (defun texinfo-format-pindex ()
|
|
1952 (texinfo-index 'texinfo-pindex))
|
|
1953
|
|
1954 (put 'tindex 'texinfo-format 'texinfo-format-tindex)
|
|
1955 (defun texinfo-format-tindex ()
|
|
1956 (texinfo-index 'texinfo-tindex))
|
|
1957
|
|
1958 (put 'kindex 'texinfo-format 'texinfo-format-kindex)
|
|
1959 (defun texinfo-format-kindex ()
|
|
1960 (texinfo-index 'texinfo-kindex))
|
|
1961
|
|
1962 (defun texinfo-index (indexvar)
|
|
1963 (let ((arg (texinfo-parse-expanded-arg)))
|
|
1964 (texinfo-discard-command)
|
|
1965 (set indexvar
|
|
1966 (cons (list arg
|
|
1967 texinfo-last-node
|
|
1968 ;; Region formatting may not provide last node position.
|
|
1969 (if texinfo-last-node-pos
|
|
1970 (1+ (count-lines texinfo-last-node-pos (point)))
|
|
1971 1))
|
|
1972 (symbol-value indexvar)))))
|
|
1973
|
|
1974 (defconst texinfo-indexvar-alist
|
|
1975 '(("cp" . texinfo-cindex)
|
|
1976 ("fn" . texinfo-findex)
|
|
1977 ("vr" . texinfo-vindex)
|
|
1978 ("tp" . texinfo-tindex)
|
|
1979 ("pg" . texinfo-pindex)
|
|
1980 ("ky" . texinfo-kindex)))
|
|
1981
|
|
1982
|
|
1983 ;;; @defindex @defcodeindex
|
|
1984 (put 'defindex 'texinfo-format 'texinfo-format-defindex)
|
|
1985 (put 'defcodeindex 'texinfo-format 'texinfo-format-defindex)
|
|
1986
|
|
1987 (defun texinfo-format-defindex ()
|
|
1988 (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa'
|
|
1989 (indexing-command (intern (concat index-name "index")))
|
|
1990 (index-formatting-command ; eg: `texinfo-format-aaindex'
|
|
1991 (intern (concat "texinfo-format-" index-name "index")))
|
|
1992 (index-alist-name ; eg: `texinfo-aaindex'
|
|
1993 (intern (concat "texinfo-" index-name "index"))))
|
|
1994
|
|
1995 (set index-alist-name nil)
|
|
1996
|
|
1997 (put indexing-command ; eg, aaindex
|
|
1998 'texinfo-format
|
|
1999 index-formatting-command) ; eg, texinfo-format-aaindex
|
|
2000
|
|
2001 ;; eg: "aa" . texinfo-aaindex
|
|
2002 (or (assoc index-name texinfo-indexvar-alist)
|
|
2003 (setq texinfo-indexvar-alist
|
|
2004 (cons
|
|
2005 (cons index-name
|
|
2006 index-alist-name)
|
|
2007 texinfo-indexvar-alist)))
|
|
2008
|
|
2009 (fset index-formatting-command
|
|
2010 (list 'lambda 'nil
|
|
2011 (list 'texinfo-index
|
|
2012 (list 'quote index-alist-name))))))
|
|
2013
|
|
2014
|
|
2015 ;;; @synindex @syncodeindex
|
|
2016
|
|
2017 (put 'synindex 'texinfo-format 'texinfo-format-synindex)
|
|
2018 (put 'syncodeindex 'texinfo-format 'texinfo-format-synindex)
|
|
2019
|
|
2020 (defun texinfo-format-synindex ()
|
|
2021 (let* ((args (texinfo-parse-arg-discard))
|
|
2022 (second (cdr (read-from-string args)))
|
|
2023 (joiner (symbol-name (car (read-from-string args))))
|
|
2024 (joined (symbol-name (car (read-from-string args second)))))
|
|
2025
|
|
2026 (if (assoc joiner texinfo-short-index-cmds-alist)
|
|
2027 (put
|
|
2028 (cdr (assoc joiner texinfo-short-index-cmds-alist))
|
|
2029 'texinfo-format
|
|
2030 (or (cdr (assoc joined texinfo-short-index-format-cmds-alist))
|
|
2031 (intern (concat "texinfo-format-" joined "index"))))
|
|
2032 (put
|
|
2033 (intern (concat joiner "index"))
|
|
2034 'texinfo-format
|
|
2035 (or (cdr(assoc joined texinfo-short-index-format-cmds-alist))
|
|
2036 (intern (concat "texinfo-format-" joined "index")))))))
|
|
2037
|
|
2038 (defconst texinfo-short-index-cmds-alist
|
|
2039 '(("cp" . cindex)
|
|
2040 ("fn" . findex)
|
|
2041 ("vr" . vindex)
|
|
2042 ("tp" . tindex)
|
|
2043 ("pg" . pindex)
|
|
2044 ("ky" . kindex)))
|
|
2045
|
|
2046 (defconst texinfo-short-index-format-cmds-alist
|
|
2047 '(("cp" . texinfo-format-cindex)
|
|
2048 ("fn" . texinfo-format-findex)
|
|
2049 ("vr" . texinfo-format-vindex)
|
|
2050 ("tp" . texinfo-format-tindex)
|
|
2051 ("pg" . texinfo-format-pindex)
|
|
2052 ("ky" . texinfo-format-kindex)))
|
|
2053
|
|
2054
|
|
2055 ;;; Sort and index (for VMS)
|
|
2056
|
|
2057 ;; Sort an index which is in the current buffer between START and END.
|
|
2058 ;; Used on VMS, where the `sort' utility is not available.
|
|
2059 (defun texinfo-sort-region (start end)
|
|
2060 (require 'sort)
|
|
2061 (save-restriction
|
|
2062 (narrow-to-region start end)
|
|
2063 (sort-subr nil 'forward-line 'end-of-line 'texinfo-sort-startkeyfun)))
|
|
2064
|
|
2065 ;; Subroutine for sorting an index.
|
|
2066 ;; At start of a line, return a string to sort the line under.
|
|
2067 (defun texinfo-sort-startkeyfun ()
|
|
2068 (let ((line
|
|
2069 (buffer-substring (point) (save-excursion (end-of-line) (point)))))
|
|
2070 ;; Canonicalize whitespace and eliminate funny chars.
|
|
2071 (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line)
|
|
2072 (setq line (concat (substring line 0 (match-beginning 0))
|
|
2073 " "
|
|
2074 (substring line (match-end 0) (length line)))))
|
|
2075 line))
|
|
2076
|
|
2077
|
|
2078 ;;; @printindex
|
|
2079
|
|
2080 (put 'printindex 'texinfo-format 'texinfo-format-printindex)
|
|
2081
|
|
2082 (defun texinfo-format-printindex ()
|
|
2083 (let ((indexelts (symbol-value
|
|
2084 (cdr (assoc (texinfo-parse-arg-discard)
|
|
2085 texinfo-indexvar-alist))))
|
|
2086 opoint)
|
|
2087 (insert "\n* Menu:\n\n")
|
|
2088 (setq opoint (point))
|
|
2089 (texinfo-print-index nil indexelts)
|
|
2090
|
|
2091 (if (eq system-type 'vax-vms)
|
|
2092 (texinfo-sort-region opoint (point))
|
|
2093 (shell-command-on-region opoint (point) "sort -fd" 1))))
|
|
2094
|
|
2095 (defun texinfo-print-index (file indexelts)
|
|
2096 (while indexelts
|
|
2097 (if (stringp (car (car indexelts)))
|
|
2098 (progn
|
|
2099 (insert "* " (car (car indexelts)) ": " )
|
|
2100 (indent-to 32)
|
|
2101 (insert
|
|
2102 (if file (concat "(" file ")") "")
|
|
2103 (nth 1 (car indexelts)) ".")
|
|
2104 (indent-to 54)
|
|
2105 (insert
|
|
2106 (if (nth 2 (car indexelts))
|
|
2107 (format " %d." (nth 2 (car indexelts)))
|
|
2108 "")
|
|
2109 "\n"))
|
|
2110 ;; index entries from @include'd file
|
|
2111 (texinfo-print-index (nth 1 (car indexelts))
|
|
2112 (nth 2 (car indexelts))))
|
|
2113 (setq indexelts (cdr indexelts))))
|
|
2114
|
|
2115
|
|
2116 ;;; Glyphs: @equiv, @error, etc
|
|
2117
|
|
2118 ;; @equiv to show that two expressions are equivalent
|
|
2119 ;; @error to show an error message
|
|
2120 ;; @expansion to show what a macro expands to
|
|
2121 ;; @point to show the location of point in an example
|
|
2122 ;; @print to show what an evaluated expression prints
|
|
2123 ;; @result to indicate the value returned by an expression
|
|
2124
|
|
2125 (put 'equiv 'texinfo-format 'texinfo-format-equiv)
|
|
2126 (defun texinfo-format-equiv ()
|
|
2127 (texinfo-parse-arg-discard)
|
|
2128 (insert "=="))
|
|
2129
|
|
2130 (put 'error 'texinfo-format 'texinfo-format-error)
|
|
2131 (defun texinfo-format-error ()
|
|
2132 (texinfo-parse-arg-discard)
|
|
2133 (insert "error-->"))
|
|
2134
|
|
2135 (put 'expansion 'texinfo-format 'texinfo-format-expansion)
|
|
2136 (defun texinfo-format-expansion ()
|
|
2137 (texinfo-parse-arg-discard)
|
|
2138 (insert "==>"))
|
|
2139
|
|
2140 (put 'point 'texinfo-format 'texinfo-format-point)
|
|
2141 (defun texinfo-format-point ()
|
|
2142 (texinfo-parse-arg-discard)
|
|
2143 (insert "-!-"))
|
|
2144
|
|
2145 (put 'print 'texinfo-format 'texinfo-format-print)
|
|
2146 (defun texinfo-format-print ()
|
|
2147 (texinfo-parse-arg-discard)
|
|
2148 (insert "-|"))
|
|
2149
|
|
2150 (put 'result 'texinfo-format 'texinfo-format-result)
|
|
2151 (defun texinfo-format-result ()
|
|
2152 (texinfo-parse-arg-discard)
|
|
2153 (insert "=>"))
|
|
2154
|
|
2155
|
|
2156 ;;; Definition formatting: @deffn, @defun, etc
|
|
2157
|
|
2158 ;; What definition formatting produces:
|
|
2159 ;;
|
|
2160 ;; @deffn category name args...
|
|
2161 ;; In Info, `Category: name ARGS'
|
|
2162 ;; In index: name: node. line#.
|
|
2163 ;;
|
|
2164 ;; @defvr category name
|
|
2165 ;; In Info, `Category: name'
|
|
2166 ;; In index: name: node. line#.
|
|
2167 ;;
|
|
2168 ;; @deftp category name attributes...
|
|
2169 ;; `category name attributes...' Note: @deftp args in lower case.
|
|
2170 ;; In index: name: node. line#.
|
|
2171 ;;
|
|
2172 ;; Specialized function-like or variable-like entity:
|
|
2173 ;;
|
|
2174 ;; @defun, @defmac, @defspec, @defvar, @defopt
|
|
2175 ;;
|
|
2176 ;; @defun name args In Info, `Function: name ARGS'
|
|
2177 ;; @defmac name args In Info, `Macro: name ARGS'
|
|
2178 ;; @defvar name In Info, `Variable: name'
|
|
2179 ;; etc.
|
|
2180 ;; In index: name: node. line#.
|
|
2181 ;;
|
|
2182 ;; Generalized typed-function-like or typed-variable-like entity:
|
|
2183 ;; @deftypefn category data-type name args...
|
|
2184 ;; In Info, `Category: data-type name args...'
|
|
2185 ;; @deftypevr category data-type name
|
|
2186 ;; In Info, `Category: data-type name'
|
|
2187 ;; In index: name: node. line#.
|
|
2188 ;;
|
|
2189 ;; Specialized typed-function-like or typed-variable-like entity:
|
|
2190 ;; @deftypefun data-type name args...
|
|
2191 ;; In Info, `Function: data-type name ARGS'
|
|
2192 ;; In index: name: node. line#.
|
|
2193 ;;
|
|
2194 ;; @deftypevar data-type name
|
|
2195 ;; In Info, `Variable: data-type name'
|
|
2196 ;; In index: name: node. line#. but include args after name!?
|
|
2197 ;;
|
|
2198 ;; Generalized object oriented entity:
|
|
2199 ;; @defop category class name args...
|
|
2200 ;; In Info, `Category on class: name ARG'
|
|
2201 ;; In index: name on class: node. line#.
|
|
2202 ;;
|
|
2203 ;; @defcv category class name
|
|
2204 ;; In Info, `Category of class: name'
|
|
2205 ;; In index: name of class: node. line#.
|
|
2206 ;;
|
|
2207 ;; Specialized object oriented entity:
|
|
2208 ;; @defmethod class name args...
|
|
2209 ;; In Info, `Method on class: name ARGS'
|
|
2210 ;; In index: name on class: node. line#.
|
|
2211 ;;
|
|
2212 ;; @defivar class name
|
|
2213 ;; In Info, `Instance variable of class: name'
|
|
2214 ;; In index: name of class: node. line#.
|
|
2215
|
|
2216
|
|
2217 ;;; The definition formatting functions
|
|
2218
|
|
2219 (defun texinfo-format-defun ()
|
|
2220 (texinfo-push-stack 'defun nil)
|
|
2221 (setq fill-column (- fill-column 5))
|
|
2222 (texinfo-format-defun-1 t))
|
|
2223
|
|
2224 (defun texinfo-end-defun ()
|
|
2225 (setq fill-column (+ fill-column 5))
|
|
2226 (texinfo-discard-command)
|
|
2227 (let ((start (nth 1 (texinfo-pop-stack 'defun))))
|
|
2228 (texinfo-do-itemize start)
|
|
2229 ;; Delete extra newline inserted after header.
|
|
2230 (save-excursion
|
|
2231 (goto-char start)
|
|
2232 (delete-char -1))))
|
|
2233
|
|
2234 (defun texinfo-format-defunx ()
|
|
2235 (texinfo-format-defun-1 nil))
|
|
2236
|
|
2237 (defun texinfo-format-defun-1 (first-p)
|
|
2238 (let ((parse-args (texinfo-format-parse-defun-args))
|
|
2239 (texinfo-defun-type (get texinfo-command-name 'texinfo-defun-type)))
|
|
2240 (texinfo-discard-command)
|
|
2241 ;; Delete extra newline inserted after previous header line.
|
|
2242 (if (not first-p)
|
|
2243 (delete-char -1))
|
|
2244 (funcall
|
|
2245 (get texinfo-command-name 'texinfo-deffn-formatting-property) parse-args)
|
|
2246 ;; Insert extra newline so that paragraph filling does not mess
|
|
2247 ;; with header line.
|
|
2248 (insert "\n\n")
|
|
2249 (rplaca (cdr (cdr (car texinfo-stack))) (point))
|
|
2250 (funcall
|
|
2251 (get texinfo-command-name 'texinfo-defun-indexing-property) parse-args)))
|
|
2252
|
|
2253 ;;; Formatting the first line of a definition
|
|
2254
|
|
2255 ;; @deffn, @defvr, @deftp
|
|
2256 (put 'deffn 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
|
|
2257 (put 'deffnx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
|
|
2258 (put 'defvr 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
|
|
2259 (put 'defvrx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
|
|
2260 (put 'deftp 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
|
|
2261 (put 'deftpx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
|
|
2262 (defun texinfo-format-deffn (parsed-args)
|
|
2263 ;; Generalized function-like, variable-like, or generic data-type entity:
|
|
2264 ;; @deffn category name args...
|
|
2265 ;; In Info, `Category: name ARGS'
|
|
2266 ;; @deftp category name attributes...
|
|
2267 ;; `category name attributes...' Note: @deftp args in lower case.
|
|
2268 (let ((category (car parsed-args))
|
|
2269 (name (car (cdr parsed-args)))
|
|
2270 (args (cdr (cdr parsed-args))))
|
|
2271 (insert " -- " category ": " name)
|
|
2272 (while args
|
|
2273 (insert " "
|
|
2274 (if (or (= ?& (aref (car args) 0))
|
|
2275 (eq (eval (car texinfo-defun-type)) 'deftp-type))
|
|
2276 (car args)
|
|
2277 (upcase (car args))))
|
|
2278 (setq args (cdr args)))))
|
|
2279
|
|
2280 ;; @defun, @defmac, @defspec, @defvar, @defopt: Specialized, simple
|
|
2281 (put 'defun 'texinfo-deffn-formatting-property
|
|
2282 'texinfo-format-specialized-defun)
|
|
2283 (put 'defunx 'texinfo-deffn-formatting-property
|
|
2284 'texinfo-format-specialized-defun)
|
|
2285 (put 'defmac 'texinfo-deffn-formatting-property
|
|
2286 'texinfo-format-specialized-defun)
|
|
2287 (put 'defmacx 'texinfo-deffn-formatting-property
|
|
2288 'texinfo-format-specialized-defun)
|
|
2289 (put 'defspec 'texinfo-deffn-formatting-property
|
|
2290 'texinfo-format-specialized-defun)
|
|
2291 (put 'defspecx 'texinfo-deffn-formatting-property
|
|
2292 'texinfo-format-specialized-defun)
|
|
2293 (put 'defvar 'texinfo-deffn-formatting-property
|
|
2294 'texinfo-format-specialized-defun)
|
|
2295 (put 'defvarx 'texinfo-deffn-formatting-property
|
|
2296 'texinfo-format-specialized-defun)
|
|
2297 (put 'defopt 'texinfo-deffn-formatting-property
|
|
2298 'texinfo-format-specialized-defun)
|
|
2299 (put 'defoptx 'texinfo-deffn-formatting-property
|
|
2300 'texinfo-format-specialized-defun)
|
|
2301 (defun texinfo-format-specialized-defun (parsed-args)
|
|
2302 ;; Specialized function-like or variable-like entity:
|
|
2303 ;; @defun name args In Info, `Function: Name ARGS'
|
|
2304 ;; @defmac name args In Info, `Macro: Name ARGS'
|
|
2305 ;; @defvar name In Info, `Variable: Name'
|
|
2306 ;; Use cdr of texinfo-defun-type to determine category:
|
|
2307 (let ((category (car (cdr texinfo-defun-type)))
|
|
2308 (name (car parsed-args))
|
|
2309 (args (cdr parsed-args)))
|
|
2310 (insert " -- " category ": " name)
|
|
2311 (while args
|
|
2312 (insert " "
|
|
2313 (if (= ?& (aref (car args) 0))
|
|
2314 (car args)
|
|
2315 (upcase (car args))))
|
|
2316 (setq args (cdr args)))))
|
|
2317
|
|
2318 ;; @deftypefn, @deftypevr: Generalized typed
|
|
2319 (put 'deftypefn 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
|
|
2320 (put 'deftypefnx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
|
|
2321 (put 'deftypevr 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
|
|
2322 (put 'deftypevrx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
|
|
2323 (defun texinfo-format-deftypefn (parsed-args)
|
|
2324 ;; Generalized typed-function-like or typed-variable-like entity:
|
|
2325 ;; @deftypefn category data-type name args...
|
|
2326 ;; In Info, `Category: data-type name args...'
|
|
2327 ;; @deftypevr category data-type name
|
|
2328 ;; In Info, `Category: data-type name'
|
|
2329 ;; Note: args in lower case, unless modified in command line.
|
|
2330 (let ((category (car parsed-args))
|
|
2331 (data-type (car (cdr parsed-args)))
|
|
2332 (name (car (cdr (cdr parsed-args))))
|
|
2333 (args (cdr (cdr (cdr parsed-args)))))
|
|
2334 (insert " -- " category ": " data-type " " name)
|
|
2335 (while args
|
|
2336 (insert " " (car args))
|
|
2337 (setq args (cdr args)))))
|
|
2338
|
|
2339 ;; @deftypefun, @deftypevar: Specialized typed
|
|
2340 (put 'deftypefun 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun)
|
|
2341 (put 'deftypefunx 'texinfo-deffn-formatting-property
|
|
2342 'texinfo-format-deftypefun)
|
|
2343 (put 'deftypevar 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun)
|
|
2344 (put 'deftypevarx 'texinfo-deffn-formatting-property
|
|
2345 'texinfo-format-deftypefun)
|
|
2346 (defun texinfo-format-deftypefun (parsed-args)
|
|
2347 ;; Specialized typed-function-like or typed-variable-like entity:
|
|
2348 ;; @deftypefun data-type name args...
|
|
2349 ;; In Info, `Function: data-type name ARGS'
|
|
2350 ;; @deftypevar data-type name
|
|
2351 ;; In Info, `Variable: data-type name'
|
|
2352 ;; Note: args in lower case, unless modified in command line.
|
|
2353 ;; Use cdr of texinfo-defun-type to determine category:
|
|
2354 (let ((category (car (cdr texinfo-defun-type)))
|
|
2355 (data-type (car parsed-args))
|
|
2356 (name (car (cdr parsed-args)))
|
|
2357 (args (cdr (cdr parsed-args))))
|
|
2358 (insert " -- " category ": " data-type " " name)
|
|
2359 (while args
|
|
2360 (insert " " (car args))
|
|
2361 (setq args (cdr args)))))
|
|
2362
|
|
2363 ;; @defop: Generalized object-oriented
|
|
2364 (put 'defop 'texinfo-deffn-formatting-property 'texinfo-format-defop)
|
|
2365 (put 'defopx 'texinfo-deffn-formatting-property 'texinfo-format-defop)
|
|
2366 (defun texinfo-format-defop (parsed-args)
|
|
2367 ;; Generalized object oriented entity:
|
|
2368 ;; @defop category class name args...
|
|
2369 ;; In Info, `Category on class: name ARG'
|
|
2370 ;; Note: args in upper case; use of `on'
|
|
2371 (let ((category (car parsed-args))
|
|
2372 (class (car (cdr parsed-args)))
|
|
2373 (name (car (cdr (cdr parsed-args))))
|
|
2374 (args (cdr (cdr (cdr parsed-args)))))
|
|
2375 (insert " -- " category " on " class ": " name)
|
|
2376 (while args
|
|
2377 (insert " " (upcase (car args)))
|
|
2378 (setq args (cdr args)))))
|
|
2379
|
|
2380 ;; @defcv: Generalized object-oriented
|
|
2381 (put 'defcv 'texinfo-deffn-formatting-property 'texinfo-format-defcv)
|
|
2382 (put 'defcvx 'texinfo-deffn-formatting-property 'texinfo-format-defcv)
|
|
2383 (defun texinfo-format-defcv (parsed-args)
|
|
2384 ;; Generalized object oriented entity:
|
|
2385 ;; @defcv category class name
|
|
2386 ;; In Info, `Category of class: name'
|
|
2387 ;; Note: args in upper case; use of `of'
|
|
2388 (let ((category (car parsed-args))
|
|
2389 (class (car (cdr parsed-args)))
|
|
2390 (name (car (cdr (cdr parsed-args))))
|
|
2391 (args (cdr (cdr (cdr parsed-args)))))
|
|
2392 (insert " -- " category " of " class ": " name)
|
|
2393 (while args
|
|
2394 (insert " " (upcase (car args)))
|
|
2395 (setq args (cdr args)))))
|
|
2396
|
|
2397 ;; @defmethod: Specialized object-oriented
|
|
2398 (put 'defmethod 'texinfo-deffn-formatting-property 'texinfo-format-defmethod)
|
|
2399 (put 'defmethodx 'texinfo-deffn-formatting-property 'texinfo-format-defmethod)
|
|
2400 (defun texinfo-format-defmethod (parsed-args)
|
|
2401 ;; Specialized object oriented entity:
|
|
2402 ;; @defmethod class name args...
|
|
2403 ;; In Info, `Method on class: name ARGS'
|
|
2404 ;; Note: args in upper case; use of `on'
|
|
2405 ;; Use cdr of texinfo-defun-type to determine category:
|
|
2406 (let ((category (car (cdr texinfo-defun-type)))
|
|
2407 (class (car parsed-args))
|
|
2408 (name (car (cdr parsed-args)))
|
|
2409 (args (cdr (cdr parsed-args))))
|
|
2410 (insert " -- " category " on " class ": " name)
|
|
2411 (while args
|
|
2412 (insert " " (upcase (car args)))
|
|
2413 (setq args (cdr args)))))
|
|
2414
|
|
2415 ;; @defivar: Specialized object-oriented
|
|
2416 (put 'defivar 'texinfo-deffn-formatting-property 'texinfo-format-defivar)
|
|
2417 (put 'defivarx 'texinfo-deffn-formatting-property 'texinfo-format-defivar)
|
|
2418 (defun texinfo-format-defivar (parsed-args)
|
|
2419 ;; Specialized object oriented entity:
|
|
2420 ;; @defivar class name
|
|
2421 ;; In Info, `Instance variable of class: name'
|
|
2422 ;; Note: args in upper case; use of `of'
|
|
2423 ;; Use cdr of texinfo-defun-type to determine category:
|
|
2424 (let ((category (car (cdr texinfo-defun-type)))
|
|
2425 (class (car parsed-args))
|
|
2426 (name (car (cdr parsed-args)))
|
|
2427 (args (cdr (cdr parsed-args))))
|
|
2428 (insert " -- " category " of " class ": " name)
|
|
2429 (while args
|
|
2430 (insert " " (upcase (car args)))
|
|
2431 (setq args (cdr args)))))
|
|
2432
|
|
2433
|
|
2434 ;;; Indexing for definitions
|
|
2435
|
|
2436 ;; An index entry has three parts: the `entry proper', the node name, and the
|
|
2437 ;; line number. Depending on the which command is used, the entry is
|
|
2438 ;; formatted differently:
|
|
2439 ;;
|
|
2440 ;; @defun,
|
|
2441 ;; @defmac,
|
|
2442 ;; @defspec,
|
|
2443 ;; @defvar,
|
|
2444 ;; @defopt all use their 1st argument as the entry-proper
|
|
2445 ;;
|
|
2446 ;; @deffn,
|
|
2447 ;; @defvr,
|
|
2448 ;; @deftp
|
|
2449 ;; @deftypefun
|
|
2450 ;; @deftypevar all use their 2nd argument as the entry-proper
|
|
2451 ;;
|
|
2452 ;; @deftypefn,
|
|
2453 ;; @deftypevr both use their 3rd argument as the entry-proper
|
|
2454 ;;
|
|
2455 ;; @defmethod uses its 2nd and 1st arguments as an entry-proper
|
|
2456 ;; formatted: NAME on CLASS
|
|
2457
|
|
2458 ;; @defop uses its 3rd and 2nd arguments as an entry-proper
|
|
2459 ;; formatted: NAME on CLASS
|
|
2460 ;;
|
|
2461 ;; @defivar uses its 2nd and 1st arguments as an entry-proper
|
|
2462 ;; formatted: NAME of CLASS
|
|
2463 ;;
|
|
2464 ;; @defcv uses its 3rd and 2nd argument as an entry-proper
|
|
2465 ;; formatted: NAME of CLASS
|
|
2466
|
|
2467 (put 'defun 'texinfo-defun-indexing-property 'texinfo-index-defun)
|
|
2468 (put 'defunx 'texinfo-defun-indexing-property 'texinfo-index-defun)
|
|
2469 (put 'defmac 'texinfo-defun-indexing-property 'texinfo-index-defun)
|
|
2470 (put 'defmacx 'texinfo-defun-indexing-property 'texinfo-index-defun)
|
|
2471 (put 'defspec 'texinfo-defun-indexing-property 'texinfo-index-defun)
|
|
2472 (put 'defspecx 'texinfo-defun-indexing-property 'texinfo-index-defun)
|
|
2473 (put 'defvar 'texinfo-defun-indexing-property 'texinfo-index-defun)
|
|
2474 (put 'defvarx 'texinfo-defun-indexing-property 'texinfo-index-defun)
|
|
2475 (put 'defopt 'texinfo-defun-indexing-property 'texinfo-index-defun)
|
|
2476 (put 'defoptx 'texinfo-defun-indexing-property 'texinfo-index-defun)
|
|
2477 (defun texinfo-index-defun (parsed-args)
|
|
2478 ;; use 1st parsed-arg as entry-proper
|
|
2479 ;; `index-list' will be texinfo-findex or the like
|
|
2480 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
|
|
2481 (set index-list
|
|
2482 (cons
|
|
2483 ;; Three elements: entry-proper, node-name, line-number
|
|
2484 (list
|
|
2485 (car parsed-args)
|
|
2486 texinfo-last-node
|
|
2487 ;; Region formatting may not provide last node position.
|
|
2488 (if texinfo-last-node-pos
|
|
2489 (1+ (count-lines texinfo-last-node-pos (point)))
|
|
2490 1))
|
|
2491 (symbol-value index-list)))))
|
|
2492
|
|
2493 (put 'deffn 'texinfo-defun-indexing-property 'texinfo-index-deffn)
|
|
2494 (put 'deffnx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
|
|
2495 (put 'defvr 'texinfo-defun-indexing-property 'texinfo-index-deffn)
|
|
2496 (put 'defvrx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
|
|
2497 (put 'deftp 'texinfo-defun-indexing-property 'texinfo-index-deffn)
|
|
2498 (put 'deftpx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
|
|
2499 (put 'deftypefun 'texinfo-defun-indexing-property 'texinfo-index-deffn)
|
|
2500 (put 'deftypefunx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
|
|
2501 (put 'deftypevar 'texinfo-defun-indexing-property 'texinfo-index-deffn)
|
|
2502 (put 'deftypevarx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
|
|
2503 (defun texinfo-index-deffn (parsed-args)
|
|
2504 ;; use 2nd parsed-arg as entry-proper
|
|
2505 ;; `index-list' will be texinfo-findex or the like
|
|
2506 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
|
|
2507 (set index-list
|
|
2508 (cons
|
|
2509 ;; Three elements: entry-proper, node-name, line-number
|
|
2510 (list
|
|
2511 (car (cdr parsed-args))
|
|
2512 texinfo-last-node
|
|
2513 ;; Region formatting may not provide last node position.
|
|
2514 (if texinfo-last-node-pos
|
|
2515 (1+ (count-lines texinfo-last-node-pos (point)))
|
|
2516 1))
|
|
2517 (symbol-value index-list)))))
|
|
2518
|
|
2519 (put 'deftypefn 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
|
|
2520 (put 'deftypefnx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
|
|
2521 (put 'deftypevr 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
|
|
2522 (put 'deftypevrx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
|
|
2523 (defun texinfo-index-deftypefn (parsed-args)
|
|
2524 ;; use 3rd parsed-arg as entry-proper
|
|
2525 ;; `index-list' will be texinfo-findex or the like
|
|
2526 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
|
|
2527 (set index-list
|
|
2528 (cons
|
|
2529 ;; Three elements: entry-proper, node-name, line-number
|
|
2530 (list
|
|
2531 (car (cdr (cdr parsed-args)))
|
|
2532 texinfo-last-node
|
|
2533 ;; Region formatting may not provide last node position.
|
|
2534 (if texinfo-last-node-pos
|
|
2535 (1+ (count-lines texinfo-last-node-pos (point)))
|
|
2536 1))
|
|
2537 (symbol-value index-list)))))
|
|
2538
|
|
2539 (put 'defmethod 'texinfo-defun-indexing-property 'texinfo-index-defmethod)
|
|
2540 (put 'defmethodx 'texinfo-defun-indexing-property 'texinfo-index-defmethod)
|
|
2541 (defun texinfo-index-defmethod (parsed-args)
|
|
2542 ;; use 2nd on 1st parsed-arg as entry-proper
|
|
2543 ;; `index-list' will be texinfo-findex or the like
|
|
2544 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
|
|
2545 (set index-list
|
|
2546 (cons
|
|
2547 ;; Three elements: entry-proper, node-name, line-number
|
|
2548 (list
|
|
2549 (format "%s on %s"
|
|
2550 (car (cdr parsed-args))
|
|
2551 (car parsed-args))
|
|
2552 texinfo-last-node
|
|
2553 ;; Region formatting may not provide last node position.
|
|
2554 (if texinfo-last-node-pos
|
|
2555 (1+ (count-lines texinfo-last-node-pos (point)))
|
|
2556 1))
|
|
2557 (symbol-value index-list)))))
|
|
2558
|
|
2559 (put 'defop 'texinfo-defun-indexing-property 'texinfo-index-defop)
|
|
2560 (put 'defopx 'texinfo-defun-indexing-property 'texinfo-index-defop)
|
|
2561 (defun texinfo-index-defop (parsed-args)
|
|
2562 ;; use 3rd on 2nd parsed-arg as entry-proper
|
|
2563 ;; `index-list' will be texinfo-findex or the like
|
|
2564 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
|
|
2565 (set index-list
|
|
2566 (cons
|
|
2567 ;; Three elements: entry-proper, node-name, line-number
|
|
2568 (list
|
|
2569 (format "%s on %s"
|
|
2570 (car (cdr (cdr parsed-args)))
|
|
2571 (car (cdr parsed-args)))
|
|
2572 texinfo-last-node
|
|
2573 ;; Region formatting may not provide last node position.
|
|
2574 (if texinfo-last-node-pos
|
|
2575 (1+ (count-lines texinfo-last-node-pos (point)))
|
|
2576 1))
|
|
2577 (symbol-value index-list)))))
|
|
2578
|
|
2579 (put 'defivar 'texinfo-defun-indexing-property 'texinfo-index-defivar)
|
|
2580 (put 'defivarx 'texinfo-defun-indexing-property 'texinfo-index-defivar)
|
|
2581 (defun texinfo-index-defivar (parsed-args)
|
|
2582 ;; use 2nd of 1st parsed-arg as entry-proper
|
|
2583 ;; `index-list' will be texinfo-findex or the like
|
|
2584 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
|
|
2585 (set index-list
|
|
2586 (cons
|
|
2587 ;; Three elements: entry-proper, node-name, line-number
|
|
2588 (list
|
|
2589 (format "%s of %s"
|
|
2590 (car (cdr parsed-args))
|
|
2591 (car parsed-args))
|
|
2592 texinfo-last-node
|
|
2593 ;; Region formatting may not provide last node position.
|
|
2594 (if texinfo-last-node-pos
|
|
2595 (1+ (count-lines texinfo-last-node-pos (point)))
|
|
2596 1))
|
|
2597 (symbol-value index-list)))))
|
|
2598
|
|
2599 (put 'defcv 'texinfo-defun-indexing-property 'texinfo-index-defcv)
|
|
2600 (put 'defcvx 'texinfo-defun-indexing-property 'texinfo-index-defcv)
|
|
2601 (defun texinfo-index-defcv (parsed-args)
|
|
2602 ;; use 3rd of 2nd parsed-arg as entry-proper
|
|
2603 ;; `index-list' will be texinfo-findex or the like
|
|
2604 (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
|
|
2605 (set index-list
|
|
2606 (cons
|
|
2607 ;; Three elements: entry-proper, node-name, line-number
|
|
2608 (list
|
|
2609 (format "%s of %s"
|
|
2610 (car (cdr (cdr parsed-args)))
|
|
2611 (car (cdr parsed-args)))
|
|
2612 texinfo-last-node
|
|
2613 ;; Region formatting may not provide last node position.
|
|
2614 (if texinfo-last-node-pos
|
|
2615 (1+ (count-lines texinfo-last-node-pos (point)))
|
|
2616 1))
|
|
2617 (symbol-value index-list)))))
|
|
2618
|
|
2619
|
|
2620 ;;; Properties for definitions
|
|
2621
|
|
2622 ;; Each definition command has six properties:
|
|
2623 ;;
|
|
2624 ;; 1. texinfo-deffn-formatting-property to format definition line
|
|
2625 ;; 2. texinfo-defun-indexing-property to create index entry
|
|
2626 ;; 3. texinfo-format formatting command
|
|
2627 ;; 4. texinfo-end end formatting command
|
|
2628 ;; 5. texinfo-defun-type type of deffn to format
|
|
2629 ;; 6. texinfo-defun-index type of index to use
|
|
2630 ;;
|
|
2631 ;; The `x' forms of each definition command are used for the second
|
|
2632 ;; and subsequent header lines.
|
|
2633
|
|
2634 ;; The texinfo-deffn-formatting-property and texinfo-defun-indexing-property
|
|
2635 ;; are listed just before the appropriate formatting and indexing commands.
|
|
2636
|
|
2637 (put 'deffn 'texinfo-format 'texinfo-format-defun)
|
|
2638 (put 'deffnx 'texinfo-format 'texinfo-format-defunx)
|
|
2639 (put 'deffn 'texinfo-end 'texinfo-end-defun)
|
|
2640 (put 'deffn 'texinfo-defun-type '('deffn-type nil))
|
|
2641 (put 'deffnx 'texinfo-defun-type '('deffn-type nil))
|
|
2642 (put 'deffn 'texinfo-defun-index 'texinfo-findex)
|
|
2643 (put 'deffnx 'texinfo-defun-index 'texinfo-findex)
|
|
2644
|
|
2645 (put 'defun 'texinfo-format 'texinfo-format-defun)
|
|
2646 (put 'defunx 'texinfo-format 'texinfo-format-defunx)
|
|
2647 (put 'defun 'texinfo-end 'texinfo-end-defun)
|
|
2648 (put 'defun 'texinfo-defun-type '('defun-type "Function"))
|
|
2649 (put 'defunx 'texinfo-defun-type '('defun-type "Function"))
|
|
2650 (put 'defun 'texinfo-defun-index 'texinfo-findex)
|
|
2651 (put 'defunx 'texinfo-defun-index 'texinfo-findex)
|
|
2652
|
|
2653 (put 'defmac 'texinfo-format 'texinfo-format-defun)
|
|
2654 (put 'defmacx 'texinfo-format 'texinfo-format-defunx)
|
|
2655 (put 'defmac 'texinfo-end 'texinfo-end-defun)
|
|
2656 (put 'defmac 'texinfo-defun-type '('defun-type "Macro"))
|
|
2657 (put 'defmacx 'texinfo-defun-type '('defun-type "Macro"))
|
|
2658 (put 'defmac 'texinfo-defun-index 'texinfo-findex)
|
|
2659 (put 'defmacx 'texinfo-defun-index 'texinfo-findex)
|
|
2660
|
|
2661 (put 'defspec 'texinfo-format 'texinfo-format-defun)
|
|
2662 (put 'defspecx 'texinfo-format 'texinfo-format-defunx)
|
|
2663 (put 'defspec 'texinfo-end 'texinfo-end-defun)
|
|
2664 (put 'defspec 'texinfo-defun-type '('defun-type "Special form"))
|
|
2665 (put 'defspecx 'texinfo-defun-type '('defun-type "Special form"))
|
|
2666 (put 'defspec 'texinfo-defun-index 'texinfo-findex)
|
|
2667 (put 'defspecx 'texinfo-defun-index 'texinfo-findex)
|
|
2668
|
|
2669 (put 'defvr 'texinfo-format 'texinfo-format-defun)
|
|
2670 (put 'defvrx 'texinfo-format 'texinfo-format-defunx)
|
|
2671 (put 'defvr 'texinfo-end 'texinfo-end-defun)
|
|
2672 (put 'defvr 'texinfo-defun-type '('deffn-type nil))
|
|
2673 (put 'defvrx 'texinfo-defun-type '('deffn-type nil))
|
|
2674 (put 'defvr 'texinfo-defun-index 'texinfo-vindex)
|
|
2675 (put 'defvrx 'texinfo-defun-index 'texinfo-vindex)
|
|
2676
|
|
2677 (put 'defvar 'texinfo-format 'texinfo-format-defun)
|
|
2678 (put 'defvarx 'texinfo-format 'texinfo-format-defunx)
|
|
2679 (put 'defvar 'texinfo-end 'texinfo-end-defun)
|
|
2680 (put 'defvar 'texinfo-defun-type '('defun-type "Variable"))
|
|
2681 (put 'defvarx 'texinfo-defun-type '('defun-type "Variable"))
|
|
2682 (put 'defvar 'texinfo-defun-index 'texinfo-vindex)
|
|
2683 (put 'defvarx 'texinfo-defun-index 'texinfo-vindex)
|
|
2684
|
|
2685 (put 'defconst 'texinfo-format 'texinfo-format-defun)
|
|
2686 (put 'defconstx 'texinfo-format 'texinfo-format-defunx)
|
|
2687 (put 'defconst 'texinfo-end 'texinfo-end-defun)
|
|
2688 (put 'defconst 'texinfo-defun-type '('defun-type "Constant"))
|
|
2689 (put 'defconstx 'texinfo-defun-type '('defun-type "Constant"))
|
|
2690 (put 'defconst 'texinfo-defun-index 'texinfo-vindex)
|
|
2691 (put 'defconstx 'texinfo-defun-index 'texinfo-vindex)
|
|
2692
|
|
2693 (put 'defcmd 'texinfo-format 'texinfo-format-defun)
|
|
2694 (put 'defcmdx 'texinfo-format 'texinfo-format-defunx)
|
|
2695 (put 'defcmd 'texinfo-end 'texinfo-end-defun)
|
|
2696 (put 'defcmd 'texinfo-defun-type '('defun-type "Command"))
|
|
2697 (put 'defcmdx 'texinfo-defun-type '('defun-type "Command"))
|
|
2698 (put 'defcmd 'texinfo-defun-index 'texinfo-findex)
|
|
2699 (put 'defcmdx 'texinfo-defun-index 'texinfo-findex)
|
|
2700
|
|
2701 (put 'defopt 'texinfo-format 'texinfo-format-defun)
|
|
2702 (put 'defoptx 'texinfo-format 'texinfo-format-defunx)
|
|
2703 (put 'defopt 'texinfo-end 'texinfo-end-defun)
|
|
2704 (put 'defopt 'texinfo-defun-type '('defun-type "User Option"))
|
|
2705 (put 'defoptx 'texinfo-defun-type '('defun-type "User Option"))
|
|
2706 (put 'defopt 'texinfo-defun-index 'texinfo-vindex)
|
|
2707 (put 'defoptx 'texinfo-defun-index 'texinfo-vindex)
|
|
2708
|
|
2709 (put 'deftp 'texinfo-format 'texinfo-format-defun)
|
|
2710 (put 'deftpx 'texinfo-format 'texinfo-format-defunx)
|
|
2711 (put 'deftp 'texinfo-end 'texinfo-end-defun)
|
|
2712 (put 'deftp 'texinfo-defun-type '('deftp-type nil))
|
|
2713 (put 'deftpx 'texinfo-defun-type '('deftp-type nil))
|
|
2714 (put 'deftp 'texinfo-defun-index 'texinfo-tindex)
|
|
2715 (put 'deftpx 'texinfo-defun-index 'texinfo-tindex)
|
|
2716
|
|
2717 ;;; Object-oriented stuff is a little hairier.
|
|
2718
|
|
2719 (put 'defop 'texinfo-format 'texinfo-format-defun)
|
|
2720 (put 'defopx 'texinfo-format 'texinfo-format-defunx)
|
|
2721 (put 'defop 'texinfo-end 'texinfo-end-defun)
|
|
2722 (put 'defop 'texinfo-defun-type '('defop-type nil))
|
|
2723 (put 'defopx 'texinfo-defun-type '('defop-type nil))
|
|
2724 (put 'defop 'texinfo-defun-index 'texinfo-findex)
|
|
2725 (put 'defopx 'texinfo-defun-index 'texinfo-findex)
|
|
2726
|
|
2727 (put 'defmethod 'texinfo-format 'texinfo-format-defun)
|
|
2728 (put 'defmethodx 'texinfo-format 'texinfo-format-defunx)
|
|
2729 (put 'defmethod 'texinfo-end 'texinfo-end-defun)
|
|
2730 (put 'defmethod 'texinfo-defun-type '('defmethod-type "Method"))
|
|
2731 (put 'defmethodx 'texinfo-defun-type '('defmethod-type "Method"))
|
|
2732 (put 'defmethod 'texinfo-defun-index 'texinfo-findex)
|
|
2733 (put 'defmethodx 'texinfo-defun-index 'texinfo-findex)
|
|
2734
|
|
2735 (put 'defcv 'texinfo-format 'texinfo-format-defun)
|
|
2736 (put 'defcvx 'texinfo-format 'texinfo-format-defunx)
|
|
2737 (put 'defcv 'texinfo-end 'texinfo-end-defun)
|
|
2738 (put 'defcv 'texinfo-defun-type '('defop-type nil))
|
|
2739 (put 'defcvx 'texinfo-defun-type '('defop-type nil))
|
|
2740 (put 'defcv 'texinfo-defun-index 'texinfo-vindex)
|
|
2741 (put 'defcvx 'texinfo-defun-index 'texinfo-vindex)
|
|
2742
|
|
2743 (put 'defivar 'texinfo-format 'texinfo-format-defun)
|
|
2744 (put 'defivarx 'texinfo-format 'texinfo-format-defunx)
|
|
2745 (put 'defivar 'texinfo-end 'texinfo-end-defun)
|
|
2746 (put 'defivar 'texinfo-defun-type '('defmethod-type "Instance variable"))
|
|
2747 (put 'defivarx 'texinfo-defun-type '('defmethod-type "Instance variable"))
|
|
2748 (put 'defivar 'texinfo-defun-index 'texinfo-vindex)
|
|
2749 (put 'defivarx 'texinfo-defun-index 'texinfo-vindex)
|
|
2750
|
|
2751 ;;; Typed functions and variables
|
|
2752
|
|
2753 (put 'deftypefn 'texinfo-format 'texinfo-format-defun)
|
|
2754 (put 'deftypefnx 'texinfo-format 'texinfo-format-defunx)
|
|
2755 (put 'deftypefn 'texinfo-end 'texinfo-end-defun)
|
|
2756 (put 'deftypefn 'texinfo-defun-type '('deftypefn-type nil))
|
|
2757 (put 'deftypefnx 'texinfo-defun-type '('deftypefn-type nil))
|
|
2758 (put 'deftypefn 'texinfo-defun-index 'texinfo-findex)
|
|
2759 (put 'deftypefnx 'texinfo-defun-index 'texinfo-findex)
|
|
2760
|
|
2761 (put 'deftypefun 'texinfo-format 'texinfo-format-defun)
|
|
2762 (put 'deftypefunx 'texinfo-format 'texinfo-format-defunx)
|
|
2763 (put 'deftypefun 'texinfo-end 'texinfo-end-defun)
|
|
2764 (put 'deftypefun 'texinfo-defun-type '('deftypefun-type "Function"))
|
|
2765 (put 'deftypefunx 'texinfo-defun-type '('deftypefun-type "Function"))
|
|
2766 (put 'deftypefun 'texinfo-defun-index 'texinfo-findex)
|
|
2767 (put 'deftypefunx 'texinfo-defun-index 'texinfo-findex)
|
|
2768
|
|
2769 (put 'deftypevr 'texinfo-format 'texinfo-format-defun)
|
|
2770 (put 'deftypevrx 'texinfo-format 'texinfo-format-defunx)
|
|
2771 (put 'deftypevr 'texinfo-end 'texinfo-end-defun)
|
|
2772 (put 'deftypevr 'texinfo-defun-type '('deftypefn-type nil))
|
|
2773 (put 'deftypevrx 'texinfo-defun-type '('deftypefn-type nil))
|
|
2774 (put 'deftypevr 'texinfo-defun-index 'texinfo-vindex)
|
|
2775 (put 'deftypevrx 'texinfo-defun-index 'texinfo-vindex)
|
|
2776
|
|
2777 (put 'deftypevar 'texinfo-format 'texinfo-format-defun)
|
|
2778 (put 'deftypevarx 'texinfo-format 'texinfo-format-defunx)
|
|
2779 (put 'deftypevar 'texinfo-end 'texinfo-end-defun)
|
|
2780 (put 'deftypevar 'texinfo-defun-type '('deftypevar-type "Variable"))
|
|
2781 (put 'deftypevarx 'texinfo-defun-type '('deftypevar-type "Variable"))
|
|
2782 (put 'deftypevar 'texinfo-defun-index 'texinfo-vindex)
|
|
2783 (put 'deftypevarx 'texinfo-defun-index 'texinfo-vindex)
|
|
2784
|
|
2785
|
|
2786 ;;; @set, @clear, @ifset, @ifclear
|
|
2787
|
|
2788 ;; If a flag is set with @set FLAG, then text between @ifset and @end
|
2
|
2789 ;; ifset is formatted normally, but if the flag is cleared with
|
0
|
2790 ;; @clear FLAG, then the text is not formatted; it is ignored.
|
|
2791
|
|
2792 ;; If a flag is cleared with @clear FLAG, then text between @ifclear
|
2
|
2793 ;; and @end ifclear is formatted normally, but if the flag is set with
|
0
|
2794 ;; @set FLAG, then the text is not formatted; it is ignored. @ifclear
|
|
2795 ;; is the opposite of @ifset.
|
|
2796
|
|
2797 ;; If a flag is set to a string with @set FLAG,
|
|
2798 ;; replace @value{FLAG} with the string.
|
|
2799 ;; If a flag with a value is cleared,
|
|
2800 ;; @value{FLAG} is invalid,
|
|
2801 ;; as if there had never been any @set FLAG previously.
|
|
2802
|
|
2803 (put 'clear 'texinfo-format 'texinfo-clear)
|
|
2804 (defun texinfo-clear ()
|
|
2805 "Clear the value of the flag."
|
|
2806 (let* ((arg (texinfo-parse-arg-discard))
|
|
2807 (flag (car (read-from-string arg)))
|
|
2808 (value (substring arg (cdr (read-from-string arg)))))
|
|
2809 (put flag 'texinfo-whether-setp 'flag-cleared)
|
|
2810 (put flag 'texinfo-set-value "")))
|
|
2811
|
|
2812 (put 'set 'texinfo-format 'texinfo-set)
|
|
2813 (defun texinfo-set ()
|
|
2814 "Set the value of the flag, optionally to a string.
|
|
2815 The command `@set foo This is a string.'
|
|
2816 sets flag foo to the value: `This is a string.'
|
|
2817 The command `@value{foo}' expands to the value."
|
|
2818 (let* ((arg (texinfo-parse-arg-discard))
|
|
2819 (flag (car (read-from-string arg)))
|
|
2820 (value (substring arg (cdr (read-from-string arg)))))
|
|
2821 (put flag 'texinfo-whether-setp 'flag-set)
|
|
2822 (put flag 'texinfo-set-value value)))
|
|
2823
|
|
2824 (put 'value 'texinfo-format 'texinfo-value)
|
|
2825 (defun texinfo-value ()
|
|
2826 "Insert the string to which the flag is set.
|
|
2827 The command `@set foo This is a string.'
|
|
2828 sets flag foo to the value: `This is a string.'
|
|
2829 The command `@value{foo}' expands to the value."
|
|
2830 (let ((arg (texinfo-parse-arg-discard)))
|
|
2831 (cond ((and
|
|
2832 (eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
|
|
2833 'flag-set)
|
|
2834 (get (car (read-from-string arg)) 'texinfo-set-value))
|
|
2835 (insert (get (car (read-from-string arg)) 'texinfo-set-value)))
|
|
2836 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
|
|
2837 'flag-cleared)
|
|
2838 (insert (format "{No value for \"%s\"}" arg)))
|
|
2839 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) nil)
|
|
2840 (insert (format "{No value for \"%s\"}" arg))))))
|
|
2841
|
|
2842 (put 'ifset 'texinfo-end 'texinfo-discard-command)
|
|
2843 (put 'ifset 'texinfo-format 'texinfo-if-set)
|
|
2844 (defun texinfo-if-set ()
|
|
2845 "If set, continue formatting; else do not format region up to @end ifset"
|
|
2846 (let ((arg (texinfo-parse-arg-discard)))
|
|
2847 (cond
|
|
2848 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
|
|
2849 'flag-set)
|
|
2850 ;; Format the text (i.e., do not remove it); do nothing here.
|
|
2851 ())
|
|
2852 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
|
|
2853 'flag-cleared)
|
|
2854 ;; Clear region (i.e., cause the text to be ignored).
|
|
2855 (delete-region texinfo-command-start
|
|
2856 (progn (re-search-forward "@end ifset[ \t]*\n")
|
|
2857 (point))))
|
|
2858 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
|
|
2859 nil)
|
|
2860 ;; In this case flag is neither set nor cleared.
|
|
2861 ;; Act as if set, i.e. do nothing.
|
|
2862 ()))))
|
|
2863
|
|
2864 (put 'ifclear 'texinfo-end 'texinfo-discard-command)
|
|
2865 (put 'ifclear 'texinfo-format 'texinfo-if-clear)
|
|
2866 (defun texinfo-if-clear ()
|
|
2867 "If clear, continue formatting; if set, do not format up to @end ifset"
|
|
2868 (let ((arg (texinfo-parse-arg-discard)))
|
|
2869 (cond
|
|
2870 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
|
|
2871 'flag-set)
|
|
2872 ;; Clear region (i.e., cause the text to be ignored).
|
|
2873 (delete-region texinfo-command-start
|
|
2874 (progn (re-search-forward "@end ifclear[ \t]*\n")
|
|
2875 (point))))
|
|
2876 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
|
|
2877 'flag-cleared)
|
|
2878 ;; Format the text (i.e., do not remove it); do nothing here.
|
|
2879 ())
|
|
2880 ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
|
|
2881 nil)
|
|
2882 ;; In this case flag is neither set nor cleared.
|
|
2883 ;; Act as if clear, i.e. do nothing.
|
|
2884 ()))))
|
|
2885
|
|
2886
|
|
2887 ;;; Process included files: `@include' command
|
|
2888
|
|
2889 ;; Updated 19 October 1990
|
|
2890 ;; In the original version, include files were ignored by Info but
|
|
2891 ;; incorporated in to the printed manual. To make references to the
|
|
2892 ;; included file, the Texinfo source file has to refer to the included
|
2
|
2893 ;; files using the `(filename)nodename' format for referring to other
|
0
|
2894 ;; Info files. Also, the included files had to be formatted on their
|
|
2895 ;; own. It was just like they were another file.
|
|
2896
|
|
2897 ;; Currently, include files are inserted into the buffer that is
|
|
2898 ;; formatted for Info. If large, the resulting info file is split and
|
|
2899 ;; tagified. For current include files to work, the master menu must
|
|
2900 ;; refer to all the nodes, and the highest level nodes in the include
|
|
2901 ;; files must have the correct next, prev, and up pointers.
|
|
2902
|
|
2903 ;; The included file may have an @setfilename and even an @settitle,
|
|
2904 ;; but not an `\input texinfo' line.
|
|
2905
|
|
2906 ;; Updated 24 March 1993
|
|
2907 ;; In order for @raisesections and @lowersections to work, included
|
|
2908 ;; files must be inserted into the buffer holding the outer file
|
|
2909 ;; before other Info formatting takes place. So @include is no longer
|
|
2910 ;; is treated like other @-commands.
|
|
2911 (put 'include 'texinfo-format 'texinfo-format-noop)
|
|
2912
|
|
2913 ; Original definition:
|
|
2914 ; (defun texinfo-format-include ()
|
|
2915 ; (let ((filename (texinfo-parse-arg-discard))
|
|
2916 ; (default-directory input-directory)
|
|
2917 ; subindex)
|
|
2918 ; (setq subindex
|
|
2919 ; (save-excursion
|
|
2920 ; (progn (find-file
|
|
2921 ; (cond ((file-readable-p (concat filename ".texinfo"))
|
|
2922 ; (concat filename ".texinfo"))
|
|
2923 ; ((file-readable-p (concat filename ".texi"))
|
|
2924 ; (concat filename ".texi"))
|
|
2925 ; ((file-readable-p (concat filename ".tex"))
|
|
2926 ; (concat filename ".tex"))
|
|
2927 ; ((file-readable-p filename)
|
|
2928 ; filename)
|
|
2929 ; (t (error "@include'd file %s not found"
|
|
2930 ; filename))))
|
|
2931 ; (texinfo-format-buffer-1))))
|
|
2932 ; (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex))
|
|
2933 ; (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex))
|
|
2934 ; (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex))
|
|
2935 ; (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex))
|
|
2936 ; (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex))
|
|
2937 ; (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex))))
|
|
2938 ;
|
|
2939 ;(defun texinfo-subindex (indexvar file content)
|
|
2940 ; (set indexvar (cons (list 'recurse file content)
|
|
2941 ; (symbol-value indexvar))))
|
|
2942
|
|
2943 ; Second definition:
|
|
2944 ; (put 'include 'texinfo-format 'texinfo-format-include)
|
|
2945 ; (defun texinfo-format-include ()
|
|
2946 ; (let ((filename (concat input-directory
|
|
2947 ; (texinfo-parse-arg-discard)))
|
|
2948 ; (default-directory input-directory))
|
|
2949 ; (message "Reading: %s" filename)
|
|
2950 ; (save-excursion
|
|
2951 ; (save-restriction
|
|
2952 ; (narrow-to-region
|
|
2953 ; (point)
|
|
2954 ; (+ (point) (car (cdr (insert-file-contents filename)))))
|
|
2955 ; (goto-char (point-min))
|
|
2956 ; (texinfo-append-refill)
|
|
2957 ; (texinfo-format-convert (point-min) (point-max))))
|
|
2958 ; (setq last-input-buffer input-buffer) ; to bypass setfilename
|
|
2959 ; ))
|
|
2960
|
|
2961
|
|
2962 ;;; Numerous commands do nothing in Texinfo
|
|
2963
|
|
2964 ;; These commands are defined in texinfo.tex for printed output.
|
|
2965
|
|
2966 (put 'bye 'texinfo-format 'texinfo-discard-line)
|
|
2967 (put 'c 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2968 (put 'comment 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2969 (put 'contents 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2970 (put 'finalout 'texinfo-format 'texinfo-discard-line)
|
|
2971 (put 'group 'texinfo-end 'texinfo-discard-line-with-args)
|
|
2972 (put 'group 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2973 (put 'headings 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2974 (put 'hsize 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2975 (put 'itemindent 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2976 (put 'lispnarrowing 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2977 (put 'need 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2978 (put 'nopara 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2979 (put 'page 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2980 (put 'parindent 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2981 (put 'setchapternewpage 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2982 (put 'setq 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2983 (put 'settitle 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2984 (put 'setx 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2985 (put 'shortcontents 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2986 (put 'smallbook 'texinfo-format 'texinfo-discard-line)
|
|
2987 (put 'summarycontents 'texinfo-format 'texinfo-discard-line-with-args)
|
|
2988
|
|
2989
|
|
2990 ;;; Some commands cannot be handled
|
|
2991
|
|
2992 (defun texinfo-unsupported ()
|
|
2993 (error "%s is not handled by texinfo"
|
|
2994 (buffer-substring texinfo-command-start texinfo-command-end)))
|
|
2995
|
|
2996 ;;; Batch formatting
|
|
2997
|
|
2998 ;;;###autoload
|
|
2999 (defun batch-texinfo-format ()
|
|
3000 "Runs texinfo-format-buffer on the files remaining on the command line.
|
|
3001 Must be used only with -batch, and kills emacs on completion.
|
|
3002 Each file will be processed even if an error occurred previously.
|
|
3003 For example, invoke
|
|
3004 \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"."
|
|
3005 (if (not noninteractive)
|
|
3006 (error "batch-texinfo-format may only be used -batch."))
|
|
3007 (let ((version-control t)
|
|
3008 (auto-save-default nil)
|
|
3009 (find-file-run-dired nil)
|
|
3010 (kept-old-versions 259259)
|
|
3011 (kept-new-versions 259259))
|
|
3012 (let ((error 0)
|
|
3013 file
|
|
3014 (files ()))
|
|
3015 (while command-line-args-left
|
|
3016 (setq file (expand-file-name (car command-line-args-left)))
|
|
3017 (cond ((not (file-exists-p file))
|
|
3018 (message ">> %s does not exist!" file)
|
|
3019 (setq error 1
|
|
3020 command-line-args-left (cdr command-line-args-left)))
|
|
3021 ((file-directory-p file)
|
|
3022 (setq command-line-args-left
|
|
3023 (nconc (directory-files file)
|
|
3024 (cdr command-line-args-left))))
|
|
3025 (t
|
|
3026 (setq files (cons file files)
|
|
3027 command-line-args-left (cdr command-line-args-left)))))
|
|
3028 (while files
|
|
3029 (setq file (car files)
|
|
3030 files (cdr files))
|
|
3031 (condition-case err
|
|
3032 (progn
|
|
3033 (if buffer-file-name (kill-buffer (current-buffer)))
|
|
3034 (find-file file)
|
|
3035 (buffer-disable-undo (current-buffer))
|
|
3036 (set-buffer-modified-p nil)
|
|
3037 (texinfo-mode)
|
|
3038 (message "texinfo formatting %s..." file)
|
|
3039 (texinfo-format-buffer nil)
|
|
3040 (if (buffer-modified-p)
|
|
3041 (progn (message "Saving modified %s" (buffer-file-name))
|
|
3042 (save-buffer))))
|
|
3043 (error
|
|
3044 (message ">> Error: %s" (prin1-to-string err))
|
|
3045 (message ">> point at")
|
|
3046 (let ((s (buffer-substring (point)
|
|
3047 (min (+ (point) 100)
|
|
3048 (point-max))))
|
|
3049 (tem 0))
|
|
3050 (while (setq tem (string-match "\n+" s tem))
|
|
3051 (setq s (concat (substring s 0 (match-beginning 0))
|
|
3052 "\n>> "
|
|
3053 (substring s (match-end 0)))
|
|
3054 tem (1+ tem)))
|
|
3055 (message ">> %s" s))
|
|
3056 (setq error 1))))
|
|
3057 (kill-emacs error))))
|
|
3058
|
|
3059
|
|
3060 ;;; Place `provide' at end of file.
|
|
3061 (provide 'texinfmt)
|
|
3062
|
|
3063 ;;; texinfmt.el ends here.
|