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