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