aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-06-25 06:41:54 +0000
committerRichard M. Stallman1993-06-25 06:41:54 +0000
commitc6cc04e999a65194fa9a1f6f4bfde6c0f91c2240 (patch)
tree176ba046adb8afc6370693b18c3bc1b5fd568369
parent712a169400ab322d776afdac446c3cce3ee3bfea (diff)
downloademacs-c6cc04e999a65194fa9a1f6f4bfde6c0f91c2240.tar.gz
emacs-c6cc04e999a65194fa9a1f6f4bfde6c0f91c2240.zip
Set up autoloads for files `makeinfo' and `texnfo-upd'.
(texinfo-delete-from-print-queue-command): New var. (texinfo-tex-trailer): New var. (texinfo-tex-region): Use that. (texinfo-tex-buffer): Rewritten; use the actual source file. Binding is now C-c C-t C-b. (texinfo-texindex): Turned back on. (texinfo-quit-job): New command, with binding. (texinfo-delete-from-print-queue): Likewise. (texinfo-show-structure): Indent each line according to depth. Require texnfo-upd. (texinfo-section-types-regexp): Var deleted. (texinfo-insert-@-with-arg): New function. (texinfo-insert-@var, etc.): Use that. (texinfo-insert-@end): New command, now on C-c C-c e. (texinfo-insert-@end-example): Deleted. (texinfo-insert-@table): New command, on C-c C-c t. (texinfo-start-menu-description): New command, on C-c C-c C-d. (texinfo-mode): No longer set tex-trailer. Make the @node for the top node start a page. Use shorter values for tex-end-of-header and tex-start-of-header. (texinfo-mode-map): Add bindings for makeinfo-buffer, etc. Delete bindings for texinfo-format-buffer/region. (texinfo-define-common-keys): New function.
-rw-r--r--lisp/textmodes/texinfo.el669
1 files changed, 483 insertions, 186 deletions
diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el
index 1a4ab68a41f..47f9d0e76e8 100644
--- a/lisp/textmodes/texinfo.el
+++ b/lisp/textmodes/texinfo.el
@@ -1,12 +1,11 @@
1;;; texinfo.el --- major mode for editing Texinfo files. 1;;;; texinfo.el--major mode for editing Texinfo files.
2;; Copyright (C) 1985, '88, '89,
3;; '90, '91, '92, '93 Free Software Foundation, Inc.
2 4
3;; Copyright (C) 1985, 1988, 1989, 1990, 1993 Free Software Foundation, Inc. 5;;; Author: Robert J. Chassell
6;;; Maintainer: FSF
4 7
5;; Author: Bob Chassell <bob@gnu.ai.mit.edu> 8;;; This file is part of GNU Emacs.
6;; Version: 2.00
7;; Keywords: maint, tex, doc, wp
8
9;; This file is part of GNU Emacs.
10 9
11;; GNU Emacs is free software; you can redistribute it and/or modify 10;; 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 11;; it under the terms of the GNU General Public License as published by
@@ -22,13 +21,165 @@
22;; along with GNU Emacs; see the file COPYING. If not, write to 21;; along with GNU Emacs; see the file COPYING. If not, write to
23;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 22;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 23
24
25;;; Autoloads:
26
27(autoload 'makeinfo-region
28 "makeinfo"
29 "Make Info file from region of current Texinfo file, and switch to it.
30
31This command does not offer the `next-error' feature since it would
32apply to a temporary file, not the original; use the `makeinfo-buffer'
33command to gain use of `next-error'."
34 t nil)
35
36(autoload 'makeinfo-buffer
37 "makeinfo"
38 "Make Info file from current buffer.
39
40Use the \\[next-error] command to move to the next error
41\(if there are errors\)."
42 t nil)
43
44(autoload 'kill-compilation
45 "compile"
46 "Kill the process made by the \\[compile] command."
47 t nil)
48
49(autoload 'makeinfo-recenter-compilation-buffer
50 "makeinfo"
51 "Redisplay `*compilation*' buffer so most recent output can be seen.
52The last line of the buffer is displayed on
53line LINE of the window, or centered if LINE is nil."
54 t nil)
55
56(autoload 'texinfo-make-menu
57 "texnfo-upd"
58 "Without any prefix argument, make or update a menu.
59Make the menu for the section enclosing the node found following point.
60
61Non-nil argument (prefix, if interactive) means make or update menus
62for nodes within or part of the marked region.
63
64Whenever a menu exists, and is being updated, the descriptions that
65are associated with node names in the pre-existing menu are
66incorporated into the new menu. Otherwise, the nodes' section titles
67are inserted as descriptions."
68 t nil)
69
70(autoload 'texinfo-all-menus-update
71 "texnfo-upd"
72 "Update every regular menu in a Texinfo file.
73Remove pre-existing master menu, if there is one.
74
75If called with a non-nil argument, this function first updates all the
76nodes in the buffer before updating the menus."
77 t nil)
78
79(autoload 'texinfo-master-menu
80 "texnfo-upd"
81 "Make a master menu for a whole Texinfo file.
82Non-nil argument (prefix, if interactive) means first update all
83existing nodes and menus. Remove pre-existing master menu, if there is one.
84
85This function creates a master menu that follows the top node. The
86master menu includes every entry from all the other menus. It
87replaces any existing ordinary menu that follows the top node.
88
89If called with a non-nil argument, this function first updates all the
90menus in the buffer (incorporating descriptions from pre-existing
91menus) before it constructs the master menu.
92
93The function removes the detailed part of an already existing master
94menu. This action depends on the pre-exisitng master menu using the
95standard `texinfo-master-menu-header'.
96
97The master menu has the following format, which is adapted from the
98recommendation in the Texinfo Manual:
99
100 * The first part contains the major nodes in the Texinfo file: the
101 nodes for the chapters, chapter-like sections, and the major
102 appendices. This includes the indices, so long as they are in
103 chapter-like sections, such as unnumbered sections.
104
105 * The second and subsequent parts contain a listing of the other,
106 lower level menus, in order. This way, an inquirer can go
107 directly to a particular node if he or she is searching for
108 specific information.
109
110Each of the menus in the detailed node listing is introduced by the
111title of the section containing the menu."
112 t nil)
113
114(autoload 'texinfo-indent-menu-description
115 "texnfo-upd"
116 "Indent every description in menu following point to COLUMN.
117Non-nil argument (prefix, if interactive) means indent every
118description in every menu in the region. Does not indent second and
119subsequent lines of a multi-line description."
120 t nil)
121
122(autoload 'texinfo-insert-node-lines
123 "texnfo-upd"
124 "Insert missing `@node' lines in region of Texinfo file.
125Non-nil argument (prefix, if interactive) means also to insert the
126section titles as node names; and also to insert the section titles as
127node names in pre-existing @node lines that lack names."
128 t nil)
129
130(autoload 'texinfo-start-menu-description
131 "texnfo-upd"
132 "In this menu entry, insert the node's section title as a description.
133Position point at beginning of description ready for editing.
134Do not insert a title if the line contains an existing description.
135
136You will need to edit the inserted text since a useful description
137complements the node name rather than repeats it as a title does."
138 t nil)
139
140(autoload 'texinfo-multiple-files-update
141 "texnfo-upd"
142 "Update first node pointers in each file included in OUTER-FILE;
143create or update main menu in the outer file that refers to such nodes.
144This does not create or update menus or pointers within the included files.
145
146With optional MAKE-MASTER-MENU argument (prefix arg, if interactive),
147insert a master menu in OUTER-FILE. This does not create or update
148menus or pointers within the included files.
149
150With optional UPDATE-EVERYTHING argument (numeric prefix arg, if
151interactive), update all the menus and all the `Next', `Previous', and
152`Up' pointers of all the files included in OUTER-FILE before inserting
153a master menu in OUTER-FILE.
154
155The command also updates the `Top' level node pointers of OUTER-FILE.
156
157Notes:
158
159 * this command does NOT save any files--you must save the
160 outer file and any modified, included files.
161
162 * except for the `Top' node, this command does NOT handle any
163 pre-existing nodes in the outer file; hence, indices must be
164 enclosed in an included file.
165
166Requirements:
167
168 * each of the included files must contain exactly one highest
169 hierarchical level node,
170 * this highest node must be the first node in the included file,
171 * each highest hierarchical level node must be of the same type.
172
173Thus, normally, each included file contains one, and only one,
174chapter."
175 t nil)
176
177
25;;; Code: 178;;; Code:
26 179
27;;; Don't you dare insert any `require' calls at top level in this file--rms. 180;;; Don't you dare insert any `require' calls at top level in this file--rms.
28 181
29(defvar texinfo-chapter-level-regexp 182;;; Syntax table
30 "chapter\\|unnumbered \\|appendix \\|majorheading\\|chapheading"
31 "Regular expression matching just the Texinfo chapter level headings.")
32 183
33(defvar texinfo-mode-syntax-table nil) 184(defvar texinfo-mode-syntax-table nil)
34 185
@@ -45,24 +196,45 @@
45 (modify-syntax-entry ?} "){" texinfo-mode-syntax-table) 196 (modify-syntax-entry ?} "){" texinfo-mode-syntax-table)
46 (modify-syntax-entry ?\' "w" texinfo-mode-syntax-table)) 197 (modify-syntax-entry ?\' "w" texinfo-mode-syntax-table))
47 198
199
200;;; Keybindings
48(defvar texinfo-mode-map nil) 201(defvar texinfo-mode-map nil)
49 202
203;;; Keys common both to Texinfo mode and to TeX shell.
204
205(defun texinfo-define-common-keys (keymap)
206 "Define the keys both in Texinfo mode and in the texinfo-tex-shell."
207 (define-key keymap "\C-c\C-t\C-k" 'tex-kill-job)
208 (define-key keymap "\C-c\C-t\C-x" 'texinfo-quit-job)
209 (define-key keymap "\C-c\C-t\C-l" 'tex-recenter-output-buffer)
210 (define-key keymap "\C-c\C-t\C-d" 'texinfo-delete-from-print-queue)
211 (define-key keymap "\C-c\C-t\C-q" 'tex-show-print-queue)
212 (define-key keymap "\C-c\C-t\C-p" 'texinfo-tex-print)
213 (define-key keymap "\C-c\C-t\C-i" 'texinfo-texindex)
214
215 (define-key keymap "\C-c\C-t\C-r" 'texinfo-tex-region)
216 (define-key keymap "\C-c\C-t\C-b" 'texinfo-tex-buffer))
217
50;; Mode documentation displays commands in reverse order 218;; Mode documentation displays commands in reverse order
51;; from how they are listed in the texinfo-mode-map. 219;; from how they are listed in the texinfo-mode-map.
220
52(if texinfo-mode-map 221(if texinfo-mode-map
53 nil 222 nil
54 (setq texinfo-mode-map (make-sparse-keymap)) 223 (setq texinfo-mode-map (make-sparse-keymap))
55 224
56 (define-key texinfo-mode-map "\C-c\C-t\C-k" 'tex-kill-job) 225 ;; bindings for `texnfo-tex.el'
57 (define-key texinfo-mode-map "\C-c\C-t\C-l" 'tex-recenter-output-buffer) 226 (texinfo-define-common-keys texinfo-mode-map)
58 (define-key texinfo-mode-map "\C-c\C-t\C-q" 'tex-show-print-queue) 227
59 (define-key texinfo-mode-map "\C-c\C-t\C-p" 'texinfo-tex-print) 228 ;; bindings for `makeinfo.el'
60;; (define-key texinfo-mode-map "\C-c\C-t\C-i" 'texinfo-texindex) 229 (define-key texinfo-mode-map "\C-c\C-m\C-k" 'kill-compilation)
61 (define-key texinfo-mode-map "\C-c\C-t\C-t" 'texinfo-tex-buffer) 230 (define-key texinfo-mode-map "\C-c\C-m\C-l"
62 (define-key texinfo-mode-map "\C-c\C-t\C-r" 'texinfo-tex-region) 231 'makeinfo-recenter-compilation-buffer)
232 (define-key texinfo-mode-map "\C-c\C-m\C-r" 'makeinfo-region)
233 (define-key texinfo-mode-map "\C-c\C-m\C-b" 'makeinfo-buffer)
234
235 ;; bindings for updating nodes and menus
63 236
64 (define-key texinfo-mode-map "\C-c\C-i\C-r" 'texinfo-format-region) 237 (define-key texinfo-mode-map "\C-c\C-um" 'texinfo-master-menu)
65 (define-key texinfo-mode-map "\C-c\C-i\C-b" 'texinfo-format-buffer)
66 238
67 (define-key texinfo-mode-map "\C-c\C-u\C-m" 'texinfo-make-menu) 239 (define-key texinfo-mode-map "\C-c\C-u\C-m" 'texinfo-make-menu)
68 (define-key texinfo-mode-map "\C-c\C-u\C-n" 'texinfo-update-node) 240 (define-key texinfo-mode-map "\C-c\C-u\C-n" 'texinfo-update-node)
@@ -71,107 +243,34 @@
71 243
72 (define-key texinfo-mode-map "\C-c\C-s" 'texinfo-show-structure) 244 (define-key texinfo-mode-map "\C-c\C-s" 'texinfo-show-structure)
73 245
74;;; (define-key texinfo-mode-map "\"" 'texinfo-insert-quote) 246 (define-key texinfo-mode-map "\C-c}" 'up-list)
75 (define-key texinfo-mode-map "\C-c}" 'up-list) 247 (define-key texinfo-mode-map "\C-c]" 'up-list)
76 (define-key texinfo-mode-map "\C-c{" 'texinfo-insert-braces) 248 (define-key texinfo-mode-map "\C-c{" 'texinfo-insert-braces)
249
250 ;; bindings for inserting strings
251
252 (define-key texinfo-mode-map "\C-c\C-c\C-d" 'texinfo-start-menu-description)
77 253
78 (define-key texinfo-mode-map "\C-c\C-cv" 'texinfo-insert-@var) 254 (define-key texinfo-mode-map "\C-c\C-cv" 'texinfo-insert-@var)
255 (define-key texinfo-mode-map "\C-c\C-ct" 'texinfo-insert-@table)
79 (define-key texinfo-mode-map "\C-c\C-cs" 'texinfo-insert-@samp) 256 (define-key texinfo-mode-map "\C-c\C-cs" 'texinfo-insert-@samp)
80 (define-key texinfo-mode-map "\C-c\C-co" 'texinfo-insert-@noindent) 257 (define-key texinfo-mode-map "\C-c\C-co" 'texinfo-insert-@noindent)
81 (define-key texinfo-mode-map "\C-c\C-cn" 'texinfo-insert-@node) 258 (define-key texinfo-mode-map "\C-c\C-cn" 'texinfo-insert-@node)
82 (define-key texinfo-mode-map "\C-c\C-ck" 'texinfo-insert-@kbd) 259 (define-key texinfo-mode-map "\C-c\C-ck" 'texinfo-insert-@kbd)
83 (define-key texinfo-mode-map "\C-c\C-ci" 'texinfo-insert-@item) 260 (define-key texinfo-mode-map "\C-c\C-ci" 'texinfo-insert-@item)
261 (define-key texinfo-mode-map "\C-c\C-cf" 'texinfo-insert-@file)
84 (define-key texinfo-mode-map "\C-c\C-cx" 'texinfo-insert-@example) 262 (define-key texinfo-mode-map "\C-c\C-cx" 'texinfo-insert-@example)
85 (define-key texinfo-mode-map "\C-c\C-ce" 'texinfo-insert-@end-example) 263 (define-key texinfo-mode-map "\C-c\C-ce" 'texinfo-insert-@end)
86 (define-key texinfo-mode-map "\C-c\C-cd" 'texinfo-insert-@dfn) 264 (define-key texinfo-mode-map "\C-c\C-cd" 'texinfo-insert-@dfn)
87 (define-key texinfo-mode-map "\C-c\C-cc" 'texinfo-insert-@code)) 265 (define-key texinfo-mode-map "\C-c\C-cc" 'texinfo-insert-@code))
88 266
89;;; I turned this off because it is inconvenient. 267
90;;; The real " character is used often in texinfo files. --rms. 268;;; Texinfo mode
91;;;(defun texinfo-insert-quote (arg)
92;;; "Insert the appropriate quote marks for TeX.
93;;;Inserts the value of `tex-open-quote' (normally ``) or `tex-close-quote'
94;;;\(normally '') depending on the context. With prefix argument, always
95;;;inserts \" characters."
96;;; (interactive "*P")
97;;; (if arg
98;;; (self-insert-command (prefix-numeric-value arg))
99;;; (insert
100;;; (cond ((or (bobp)
101;;; (save-excursion
102;;; (forward-char -1)
103;;; (looking-at "\\s(\\|\\s \\|\\s>")))
104;;; tex-open-quote)
105;;; ((= (preceding-char) ?\\)
106;;; ?\")
107;;; (t
108;;; tex-close-quote)))))
109
110(defun texinfo-insert-@var ()
111 "Insert the string @var in a texinfo buffer."
112 (interactive)
113 (insert "@var{}")
114 (backward-char))
115
116(defun texinfo-insert-@samp ()
117 "Insert the string @samp in a texinfo buffer."
118 (interactive)
119 (insert "@samp{}")
120 (backward-char))
121
122(defun texinfo-insert-@noindent ()
123 "Insert the string @noindent in a texinfo buffer."
124 (interactive)
125 (insert "@noindent\n"))
126
127(defun texinfo-insert-@node ()
128 "Insert the string @node in a texinfo buffer,
129along with a comment indicating the arguments to @node."
130 (interactive)
131 (insert "@node \n@comment node-name, next, previous, up")
132 (forward-line -1)
133 (forward-char 6))
134
135(defun texinfo-insert-@kbd ()
136 "Insert the string @kbd in a texinfo buffer."
137 (interactive)
138 (insert "@kbd{}")
139 (backward-char))
140
141(defun texinfo-insert-@item ()
142 "Insert the string @item in a texinfo buffer."
143 (interactive)
144 (insert "@item")
145 (newline))
146
147(defun texinfo-insert-@example ()
148 "Insert the string @example in a texinfo buffer."
149 (interactive)
150 (insert "@example\n"))
151
152(defun texinfo-insert-@end-example ()
153 "Insert the string @end example in a texinfo buffer."
154 (interactive)
155 (insert "@end example\n"))
156
157(defun texinfo-insert-@dfn ()
158 "Insert the string @dfn in a texinfo buffer."
159 (interactive)
160 (insert "@dfn{}")
161 (backward-char))
162
163(defun texinfo-insert-@code ()
164 "Insert the string @code in a texinfo buffer."
165 (interactive)
166 (insert "@code{}")
167 (backward-char))
168 269
169(defun texinfo-insert-braces () 270(defvar texinfo-chapter-level-regexp
170 "Make a pair of braces and be poised to type inside of them. 271 "chapter\\|unnumbered \\|appendix \\|majorheading\\|chapheading"
171Use \\[up-list] to move forward out of the braces." 272 "Regular expression matching Texinfo chapter-level headings.
172 (interactive) 273This does not match `@node' and does not match the `@top' command.")
173 (insert "{}")
174 (backward-char))
175 274
176;;;###autoload 275;;;###autoload
177(defun texinfo-mode () 276(defun texinfo-mode ()
@@ -181,15 +280,14 @@ Use \\[up-list] to move forward out of the braces."
181\\{texinfo-mode-map} 280\\{texinfo-mode-map}
182 281
183 These are files that are used as input for TeX to make printed manuals 282 These are files that are used as input for TeX to make printed manuals
184and also to be turned into Info files by \\[texinfo-format-buffer] or 283and also to be turned into Info files with \\[makeinfo-buffer] or
185`makeinfo'. These files must be written in a very restricted and 284the `makeinfo' program. These files must be written in a very restricted and
186modified version of TeX input format. 285modified version of TeX input format.
187 286
188 Editing commands are like text-mode except that the syntax table is 287 Editing commands are like text-mode except that the syntax table is
189set up so expression commands skip Texinfo bracket groups. To see 288set up so expression commands skip Texinfo bracket groups. To see
190what the Info version of a region of the Texinfo file will look like, 289what the Info version of a region of the Texinfo file will look like,
191use \\[texinfo-format-region]. This command runs Info on the current region 290use \\[makeinfo-region], which runs `makeinfo' on the current region.
192of the Texinfo file and formats it properly.
193 291
194 You can show the structure of a Texinfo file with \\[texinfo-show-structure]. 292 You can show the structure of a Texinfo file with \\[texinfo-show-structure].
195This command shows the structure of a Texinfo file by listing the 293This command shows the structure of a Texinfo file by listing the
@@ -247,10 +345,16 @@ value of texinfo-mode-hook."
247 (setq major-mode 'texinfo-mode) 345 (setq major-mode 'texinfo-mode)
248 (use-local-map texinfo-mode-map) 346 (use-local-map texinfo-mode-map)
249 (set-syntax-table texinfo-mode-syntax-table) 347 (set-syntax-table texinfo-mode-syntax-table)
348 (make-local-variable 'page-delimiter)
349 (setq page-delimiter
350 (concat
351 "^@node [ \t]*[Tt]op\\|^@\\("
352 texinfo-chapter-level-regexp
353 "\\)"))
250 (make-local-variable 'require-final-newline) 354 (make-local-variable 'require-final-newline)
251 (setq require-final-newline t) 355 (setq require-final-newline t)
252 (make-local-variable 'page-delimiter) 356 (make-local-variable 'indent-tabs-mode)
253 (setq page-delimiter texinfo-chapter-level-regexp) 357 (setq indent-tabs-mode nil)
254 (make-local-variable 'paragraph-separate) 358 (make-local-variable 'paragraph-separate)
255 (setq paragraph-separate (concat "^\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-separate)) 359 (setq paragraph-separate (concat "^\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-separate))
256 (make-local-variable 'paragraph-start) 360 (make-local-variable 'paragraph-start)
@@ -263,21 +367,147 @@ value of texinfo-mode-hook."
263 (setq comment-start-skip "@c +") 367 (setq comment-start-skip "@c +")
264 (make-local-variable 'words-include-escapes) 368 (make-local-variable 'words-include-escapes)
265 (setq words-include-escapes t) 369 (setq words-include-escapes t)
266 (make-local-variable 'tex-start-of-header) 370 (make-local-variable 'texinfo-start-of-header)
267 (setq tex-start-of-header "%**start of header") 371 (setq tex-start-of-header "%**start")
268 (make-local-variable 'tex-end-of-header) 372 (make-local-variable 'texinfo-end-of-header)
269 (setq tex-end-of-header "%**end of header") 373 (setq tex-end-of-header "%**end")
270 (make-local-variable 'tex-trailer)
271 (setq tex-trailer "@bye\n")
272 (run-hooks 'text-mode-hook 'texinfo-mode-hook)) 374 (run-hooks 'text-mode-hook 'texinfo-mode-hook))
273 375
274 376
275;;; Texinfo file structure 377;;; Insert string commands
378
379(defconst texinfo-environment-regexp
380 "^@\\(f?table\\|enumerate\\|itemize\\|ifinfo\\|iftex\\|example\\|quotation\\|lisp\\|smallexample\\|smalllisp\\|display\\|format\\|flushleft\\|flushright\\|ignore\\|group\\|tex\\|end\\)"
381 "Regexp for environment-like TexInfo list commands.
382Subexpression 1 is what goes into the corresponding `@end' statement.")
383
384;; The following texinfo-insert-@end command not only inserts a SPC
385;; after the @end, but tries to find out what belongs there. It is
386;; not very smart: it does not understand nested lists.
387
388(defun texinfo-insert-@end ()
389 "Insert the matching `@end' for the last Texinfo command that needs one."
390 (interactive)
391 (let ((depth 1) string)
392 (save-excursion
393 (while (and (> depth 0)
394 (re-search-backward texinfo-environment-regexp nil t)
395 (if (looking-at "@end")
396 (setq depth (1+ depth))
397 (setq depth (1- depth)))))
398 (looking-at texinfo-environment-regexp)
399 (setq string
400 (buffer-substring (match-beginning 1)
401 (match-end 1))))
402 (insert "@end ")
403 (if string (insert string "\n"))))
404
405;; The following insert commands accept a prefix arg N, which is the
406;; number of words (actually s-exprs) that should be surrounded by
407;; braces. Thus you can first paste a variable name into a .texinfo
408;; buffer, then say C-u 1 C-c C-c v at the beginning of the just
409;; pasted variable name to put @var{...} *around* the variable name.
410;; Operate on previous word or words with negative arg.
411
412;; These commands use texinfo-insert-@-with-arg
413(defun texinfo-insert-@-with-arg (string &optional arg)
414 (if arg
415 (progn
416 (setq arg (prefix-numeric-value arg))
417 (if (< arg 0)
418 (progn
419 (skip-chars-backward " \t\n\r\f")
420 (save-excursion
421 (forward-sexp arg)
422 (insert "@" string "{"))
423 (insert "}"))
424 (skip-chars-forward " \t\n\r\f")
425 (insert "@" string "{")
426 (forward-sexp arg)
427 (insert "}")))
428 (insert "@" string "{}")
429 (backward-char)))
430
431(defun texinfo-insert-braces ()
432 "Make a pair of braces and be poised to type inside of them.
433Use \\[up-list] to move forward out of the braces."
434 (interactive)
435 (insert "{}")
436 (backward-char))
437
438(defun texinfo-insert-@code (&optional arg)
439 "Insert a `@code{...}' command in a Texinfo buffer.
440A numeric argument says how many words the braces should surround.
441The default is not to surround any existing words with the braces."
442 (interactive "P")
443 (texinfo-insert-@-with-arg "code" arg))
444
445(defun texinfo-insert-@dfn (&optional arg)
446 "Insert a `@dfn{...}' command in a Texinfo buffer.
447A numeric argument says how many words the braces should surround.
448The default is not to surround any existing words with the braces."
449 (interactive "P")
450 (texinfo-insert-@-with-arg "dfn" arg))
276 451
277;; This is also defined in `texnfo-upd.el'. 452(defun texinfo-insert-@example ()
278(defvar texinfo-section-types-regexp 453 "Insert the string `@example' in a Texinfo buffer."
279 "^@\\(chapter \\|sect\\|sub\\|unnum\\|major\\|chapheading \\|heading \\|appendix\\)" 454 (interactive)
280 "Regexp matching chapter, section, other headings (but not the top node).") 455 (insert "@example\n"))
456
457(defun texinfo-insert-@file (&optional arg)
458 "Insert a `@file{...}' command in a Texinfo buffer.
459A numeric argument says how many words the braces should surround.
460The default is not to surround any existing words with the braces."
461 (interactive "P")
462 (texinfo-insert-@-with-arg "file" arg))
463
464(defun texinfo-insert-@item ()
465 "Insert the string `@item' in a Texinfo buffer."
466 (interactive)
467 (insert "@item")
468 (newline))
469
470(defun texinfo-insert-@kbd (&optional arg)
471 "Insert a `@kbd{...}' command in a Texinfo buffer.
472A numeric argument says how many words the braces should surround.
473The default is not to surround any existing words with the braces."
474 (interactive "P")
475 (texinfo-insert-@-with-arg "kbd" arg))
476
477(defun texinfo-insert-@node ()
478 "Insert the string `@node' in a Texinfo buffer.
479This also inserts on the following line a comment indicating
480the order of arguments to @node."
481 (interactive)
482 (insert "@node \n@comment node-name, next, previous, up")
483 (forward-line -1)
484 (forward-char 6))
485
486(defun texinfo-insert-@noindent ()
487 "Insert the string `@noindent' in a Texinfo buffer."
488 (interactive)
489 (insert "@noindent\n"))
490
491(defun texinfo-insert-@samp (&optional arg)
492 "Insert a `@samp{...}' command in a Texinfo buffer.
493A numeric argument says how many words the braces should surround.
494The default is not to surround any existing words with the braces."
495 (interactive "P")
496 (texinfo-insert-@-with-arg "samp" arg))
497
498(defun texinfo-insert-@table (&optional arg)
499 "Insert the string `@table' in a Texinfo buffer."
500 (interactive "P")
501 (insert "@table "))
502
503(defun texinfo-insert-@var (&optional arg)
504 "Insert a `@var{}' command in a Texinfo buffer.
505A numeric argument says how many words the braces should surround.
506The default is not to surround any existing words with the braces."
507 (interactive "P")
508 (texinfo-insert-@-with-arg "var" arg))
509
510;;; Texinfo file structure
281 511
282(defun texinfo-show-structure (&optional nodes-too) 512(defun texinfo-show-structure (&optional nodes-too)
283 "Show the structure of a Texinfo file. 513 "Show the structure of a Texinfo file.
@@ -289,12 +519,12 @@ with @-sign commands for @chapter, @section, and the like, and list
289@node lines. 519@node lines.
290 520
291Lines with structuring commands beginning in them are displayed in 521Lines with structuring commands beginning in them are displayed in
292another window called the *Occur* window. In that window, you can 522another buffer named `*Occur*'. In that buffer, you can move point to
293position the cursor over one of the lines and use 523one of those lines and then use \\<occur-mode-map>\\[occur-mode-goto-occurrence],
294\\[occur-mode-goto-occurrence], 524to jump to the corresponding spot in the Texinfo source file."
295to jump to the corresponding spot in the Texinfo file."
296 525
297 (interactive "P") 526 (interactive "P")
527 (require 'texnfo-upd)
298 (save-excursion 528 (save-excursion
299 (goto-char (point-min)) 529 (goto-char (point-min))
300 (if nodes-too 530 (if nodes-too
@@ -302,56 +532,72 @@ to jump to the corresponding spot in the Texinfo file."
302 (occur texinfo-section-types-regexp))) 532 (occur texinfo-section-types-regexp)))
303 (pop-to-buffer "*Occur*") 533 (pop-to-buffer "*Occur*")
304 (goto-char (point-min)) 534 (goto-char (point-min))
305 (flush-lines "-----")) 535 (flush-lines "-----")
306 536 ;; Now format the "*Occur*" buffer to show the structure.
307 537 ;; Thanks to ceder@signum.se (Per Cederqvist)
308;;; texinfo mode tex and hardcopy printing commands. 538 (goto-char (point-max))
309 539 (let ((margin 5))
310;; These commands are for running tex on a region of a texinfo file in 540 (while (re-search-backward "^ *[0-9]*:" nil 0)
311;; GNU Emacs, or on the whole buffer, and for printing the resulting 541 (re-search-forward ":")
312;; .dvi file. The three commands are: 542 (setq margin
313 543 (cond
314; texinfo-tex-region to run tex on the current region. 544 ((looking-at (concat "@" texinfo-chapter-level-regexp)) 5)
315; texinfo-tex-buffer to run tex on the current buffer. 545 ;; ((looking-at "@chapter ") 5)
316; texinfo-tex-print to print the .dvi file made by tex 546 ;; ((looking-at "@unnumbered ") 5)
317 547 ;; ((looking-at "@appendix ") 5)
318;;; Other useful functions 548 ;; ((looking-at "@majorheading ") 5)
319 549 ;; ((looking-at "@chapheading ") 5)
320; These functions are provided by `tex-mode.el' but are bound to keys 550
321; in texinfo mode. 551 ((looking-at (concat "@" texinfo-section-level-regexp)) 9)
322 552 ;; ((looking-at "@section ") 9)
323; tex-kill-job to kill the currently running tex job 553 ;; ((looking-at "@unnumberedsec ") 9)
324; tex-recenter-output-buffer to redisplay tex job output buffer 554 ;; ((looking-at "@appendixsec ") 9)
325; tex-show-print-queue to show the print queue 555 ;; ((looking-at "@heading ") 9)
326 556
327; Various variables are provided by `tex-mode.el' 557 ((looking-at (concat "@" texinfo-subsection-level-regexp)) 13)
328 558 ;; ((looking-at "@subsection ") 13)
329; tex mode variable Default Value 559 ;; ((looking-at "@unnumberedsubsec ") 13)
330 560 ;; ((looking-at "@appendixsubsec ") 13)
331; tex-dvi-print-command "lpr -d" 561 ;; ((looking-at "@subheading ") 13)
332; tex-directory "/tmp/" 562
333; tex-show-queue-command "lpq" 563 ((looking-at (concat "@" texinfo-subsubsection-level-regexp)) 17)
334; tex-shell-cd-command "cd" 564 ;; ((looking-at "@subsubsection ") 17)
335; tex-zap-file nil (created as needed) 565 ;; ((looking-at "@unnumberedsubsubsec ") 17)
336 566 ;; ((looking-at "@appendixsubsubsec ") 17)
567 ;; ((looking-at "@subsubheading ") 17)
568 (t margin)))
569 (indent-to-column margin)
570 (beginning-of-line))))
337 571
338;;; The tex and print function definitions: 572;;; The tex and print function definitions:
339 573
340(defvar texinfo-tex-command "texi2dvi" 574(defvar texinfo-tex-command "texi2dvi"
341 "*Command used by texinfo-tex-region to run tex on a region.") 575 "*Command used by `texinfo-tex-region' to run TeX on a region.")
342 576
343;;(defvar texinfo-texindex-command "texindex" 577(defvar texinfo-texindex-command "texindex"
344;; "*Command used by texinfo-texindex to sort unsorted index files.") 578 "*Command used by `texinfo-texindex' to sort unsorted index files.")
579
580(defvar texinfo-delete-from-print-queue-command "lprm"
581 "*Command string used to delete a job from the line printer queue.
582Command is used by \\[texinfo-delete-from-print-queue] based on
583number provided by a previous \\[tex-show-print-queue]
584command.")
585
586(defvar texinfo-tex-trailer "@bye"
587 "String appended after a region sent to TeX by `texinfo-tex-region'.")
345 588
346(defun texinfo-tex-region (beg end) 589(defun texinfo-tex-region (beg end)
347 "Run tex on the current region. 590 "Run TeX on the current region.
348A temporary file (`tex-zap-file') is written in directory `tex-directory', and 591This works by writing a temporary file (`tex-zap-file') in the directory
349tex is run in that directory. The first line of the file is copied to the 592that is the value of `tex-directory', then running TeX on that file.
593
594The first line of the buffer is copied to the
350temporary file; and if the buffer has a header, it is written to the 595temporary file; and if the buffer has a header, it is written to the
351temporary file before the region itself. The buffer's header is all lines 596temporary file before the region itself. The buffer's header is all lines
352between the strings defined by `tex-start-of-header' and `tex-end-of-header' 597between the strings defined by `tex-start-of-header' and `tex-end-of-header'
353inclusive. The header must start in the first 100 lines. The value of 598inclusive. The header must start in the first 100 lines.
354tex-trailer is appended to the temporary file after the region." 599
600The value of `texinfo-tex-trailer' is appended to the temporary file after the region."
355 (interactive "r") 601 (interactive "r")
356 (require 'tex-mode) 602 (require 'tex-mode)
357 (if (get-buffer "*tex-shell*") 603 (if (get-buffer "*tex-shell*")
@@ -401,14 +647,19 @@ tex-trailer is appended to the temporary file after the region."
401 ;; We have to create a special buffer in which to insert 647 ;; We have to create a special buffer in which to insert
402 ;; the tex-trailer first because there is no function with 648 ;; the tex-trailer first because there is no function with
403 ;; which to append a literal string directly to a file. 649 ;; which to append a literal string directly to a file.
404 (let ((local-tex-trailer tex-trailer)) 650 (let ((local-tex-trailer texinfo-tex-trailer))
405 (set-buffer temp-buffer) 651 (set-buffer temp-buffer)
406 (erase-buffer) 652 (erase-buffer)
407 ;; make sure trailer isn't hidden by a comment 653 ;; make sure trailer isn't hidden by a comment
408 (insert-string "\n") 654 (insert-string "\n")
409 (if local-tex-trailer (insert-string local-tex-trailer)) 655 (if local-tex-trailer (insert-string local-tex-trailer))
410 (tex-set-buffer-directory temp-buffer zap-directory) 656 (tex-set-buffer-directory temp-buffer zap-directory)
411 (write-region (point-min) (point-max) tex-out-file t nil)))) 657 (write-region (point-min) (point-max) tex-out-file t nil))
658
659;;; The following is sufficient in Emacs 19.
660;;; (write-region (concat "\n" texinfo-tex-trailer) nil
661;;; tex-out-file t nil)
662 ))
412 663
413 (tex-set-buffer-directory "*tex-shell*" zap-directory) 664 (tex-set-buffer-directory "*tex-shell*" zap-directory)
414 (send-string "tex-shell" (concat tex-shell-cd-command " " 665 (send-string "tex-shell" (concat tex-shell-cd-command " "
@@ -418,24 +669,44 @@ tex-trailer is appended to the temporary file after the region."
418 (tex-recenter-output-buffer 0)) 669 (tex-recenter-output-buffer 0))
419 670
420(defun texinfo-tex-buffer () 671(defun texinfo-tex-buffer ()
421 "Run tex on current buffer. 672 "Run TeX on visited file, once or twice, to make a correct `.dvi' file."
422See \\[texinfo-tex-region] for more information." 673 (interactive)
674
675 ;; Make sure TeX shell is running.
676 (if (get-buffer "*tex-shell*")
677 (quit-process (get-process "tex-shell") t)
678 (tex-start-shell))
679
680 (cond ((null buffer-file-name)
681 (error "Buffer not visiting any file!"))
682 ((buffer-modified-p)
683 (error "Buffer has been modified since last saved!")))
684
685 (setq tex-zap-file buffer-file-name)
686
687 (send-string "tex-shell"
688 (concat tex-shell-cd-command
689 " " (file-name-directory tex-zap-file) "\n"))
690
691 (send-string "tex-shell"
692 (concat texinfo-tex-command " " tex-zap-file "\n"))
693
694 (tex-recenter-output-buffer 0))
695
696(defun texinfo-texindex ()
697 "Run `texindex' on unsorted index files.
698The index files are made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer].
699This runs the shell command defined by `texinfo-texindex-command'."
423 (interactive) 700 (interactive)
424 (texinfo-tex-region (point-min) (point-max))) 701 (require 'tex-mode)
425 702 (send-string "tex-shell"
426;;(defun texinfo-texindex () 703 (concat texinfo-texindex-command
427;; "Run texindex on unsorted index files. 704 " " tex-zap-file ".??" "\n"))
428;;The index files are made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. 705 (tex-recenter-output-buffer nil))
429;;Runs the shell command defined by `texinfo-texindex-command'."
430;; (interactive)
431;; (send-string "tex-shell"
432;; (concat texinfo-texindex-command
433;; " " tex-zap-file ".??" "\n"))
434;; (tex-recenter-output-buffer nil))
435 706
436(defun texinfo-tex-print () 707(defun texinfo-tex-print ()
437 "Print .dvi file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. 708 "Print `.dvi' file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer].
438Runs the shell command defined by `tex-dvi-print-command'." 709This runs the shell command defined by `tex-dvi-print-command'."
439 (interactive) 710 (interactive)
440 (require 'tex-mode) 711 (require 'tex-mode)
441 (send-string "tex-shell" 712 (send-string "tex-shell"
@@ -443,6 +714,32 @@ Runs the shell command defined by `tex-dvi-print-command'."
443 " " tex-zap-file ".dvi" "\n")) 714 " " tex-zap-file ".dvi" "\n"))
444 (tex-recenter-output-buffer nil)) 715 (tex-recenter-output-buffer nil))
445 716
717(defun texinfo-quit-job ()
718 "Quit currently running TeX job, by sending an `x' to it."
719 (interactive)
720 (if (not (get-process "tex-shell"))
721 (error "No TeX shell running"))
722 (save-excursion
723 (set-buffer (get-buffer "*tex-shell*"))
724 (goto-char (point-max))
725 (insert "x")
726 (shell-send-input)))
727
728(defun texinfo-delete-from-print-queue (job-number)
729 "Delete job from the line printer spooling queue.
730You are prompted for the job number (use a number shown by a previous
731\\[texinfo-show-tex-print-queue] command)."
732 (interactive "nPrinter job number for deletion: ")
733 (if (tex-shell-running)
734 (tex-kill-job)
735 (tex-start-shell))
736 (send-string "tex-shell"
737 (concat
738 texinfo-delete-from-print-queue-command
739 " "
740 job-number"\n"))
741 (tex-recenter-output-buffer nil))
742
446(provide 'texinfo) 743(provide 'texinfo)
447 744
448;;; texinfo.el ends here 745;;; texinfo.el ends here