1 ;;; texinfo.el --- major mode for editing Texinfo files
3 ;; Copyright (C) 1985, 1988, 1989, 1990, 1991, 1992, 1993, 1997
4 ;; Free Software Foundation, Inc.
6 ;; Author: Robert J. Chassell
9 ;; This file is part of GNU Emacs.
11 ;; 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
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
33 (autoload 'makeinfo-region
35 "Make Info file from region of current Texinfo file, and switch to it.
37 This command does not offer the `next-error' feature since it would
38 apply to a temporary file, not the original; use the `makeinfo-buffer'
39 command to gain use of `next-error'."
42 (autoload 'makeinfo-buffer
44 "Make Info file from current buffer.
46 Use the \\[next-error] command to move to the next error
47 \(if there are errors\)."
50 (autoload 'kill-compilation
52 "Kill the process made by the \\[compile] command."
55 (autoload 'makeinfo-recenter-compilation-buffer
57 "Redisplay `*compilation*' buffer so most recent output can be seen.
58 The last line of the buffer is displayed on
59 line LINE of the window, or centered if LINE is nil."
62 (autoload 'texinfo-make-menu
64 "Without any prefix argument, make or update a menu.
65 Make the menu for the section enclosing the node found following point.
67 Non-nil argument (prefix, if interactive) means make or update menus
68 for nodes within or part of the marked region.
70 Whenever a menu exists, and is being updated, the descriptions that
71 are associated with node names in the pre-existing menu are
72 incorporated into the new menu. Otherwise, the nodes' section titles
73 are inserted as descriptions."
76 (autoload 'texinfo-all-menus-update
78 "Update every regular menu in a Texinfo file.
79 Remove pre-existing master menu, if there is one.
81 If called with a non-nil argument, this function first updates all the
82 nodes in the buffer before updating the menus."
85 (autoload 'texinfo-master-menu
87 "Make a master menu for a whole Texinfo file.
88 Non-nil argument (prefix, if interactive) means first update all
89 existing nodes and menus. Remove pre-existing master menu, if there is one.
91 This function creates a master menu that follows the top node. The
92 master menu includes every entry from all the other menus. It
93 replaces any existing ordinary menu that follows the top node.
95 If called with a non-nil argument, this function first updates all the
96 menus in the buffer (incorporating descriptions from pre-existing
97 menus) before it constructs the master menu.
99 The function removes the detailed part of an already existing master
100 menu. This action depends on the pre-existing master menu using the
101 standard `texinfo-master-menu-header'.
103 The master menu has the following format, which is adapted from the
104 recommendation in the Texinfo Manual:
106 * The first part contains the major nodes in the Texinfo file: the
107 nodes for the chapters, chapter-like sections, and the major
108 appendices. This includes the indices, so long as they are in
109 chapter-like sections, such as unnumbered sections.
111 * The second and subsequent parts contain a listing of the other,
112 lower level menus, in order. This way, an inquirer can go
113 directly to a particular node if he or she is searching for
114 specific information.
116 Each of the menus in the detailed node listing is introduced by the
117 title of the section containing the menu."
120 (autoload 'texinfo-indent-menu-description
122 "Indent every description in menu following point to COLUMN.
123 Non-nil argument (prefix, if interactive) means indent every
124 description in every menu in the region. Does not indent second and
125 subsequent lines of a multi-line description."
128 (autoload 'texinfo-insert-node-lines
130 "Insert missing `@node' lines in region of Texinfo file.
131 Non-nil argument (prefix, if interactive) means also to insert the
132 section titles as node names; and also to insert the section titles as
133 node names in pre-existing @node lines that lack names."
136 (autoload 'texinfo-start-menu-description
138 "In this menu entry, insert the node's section title as a description.
139 Position point at beginning of description ready for editing.
140 Do not insert a title if the line contains an existing description.
142 You will need to edit the inserted text since a useful description
143 complements the node name rather than repeats it as a title does."
146 (autoload 'texinfo-multiple-files-update
148 "Update first node pointers in each file included in OUTER-FILE;
149 create or update main menu in the outer file that refers to such nodes.
150 This does not create or update menus or pointers within the included files.
152 With optional MAKE-MASTER-MENU argument (prefix arg, if interactive),
153 insert a master menu in OUTER-FILE. This does not create or update
154 menus or pointers within the included files.
156 With optional UPDATE-EVERYTHING argument (numeric prefix arg, if
157 interactive), update all the menus and all the `Next', `Previous', and
158 `Up' pointers of all the files included in OUTER-FILE before inserting
159 a master menu in OUTER-FILE.
161 The command also updates the `Top' level node pointers of OUTER-FILE.
165 * this command does NOT save any files--you must save the
166 outer file and any modified, included files.
168 * except for the `Top' node, this command does NOT handle any
169 pre-existing nodes in the outer file; hence, indices must be
170 enclosed in an included file.
174 * each of the included files must contain exactly one highest
175 hierarchical level node,
176 * this highest node must be the first node in the included file,
177 * each highest hierarchical level node must be of the same type.
179 Thus, normally, each included file contains one, and only one,
186 ;;; Don't you dare insert any `require' calls at top level in this file--rms.
190 (defvar texinfo-mode-syntax-table nil)
192 (if texinfo-mode-syntax-table
194 (setq texinfo-mode-syntax-table (make-syntax-table))
195 (modify-syntax-entry ?\" " " texinfo-mode-syntax-table)
196 (modify-syntax-entry ?\\ " " texinfo-mode-syntax-table)
197 (modify-syntax-entry ?@ "\\" texinfo-mode-syntax-table)
198 (modify-syntax-entry ?\^q "\\" texinfo-mode-syntax-table)
199 (modify-syntax-entry ?\[ "(]" texinfo-mode-syntax-table)
200 (modify-syntax-entry ?\] ")[" texinfo-mode-syntax-table)
201 (modify-syntax-entry ?{ "(}" texinfo-mode-syntax-table)
202 (modify-syntax-entry ?} "){" texinfo-mode-syntax-table)
203 (modify-syntax-entry ?\' "w" texinfo-mode-syntax-table))
205 ;; Written by Wolfgang Bangerth <zcg51122@rpool1.rus.uni-stuttgart.de>
206 ;; To override this example, set either `imenu-generic-expression'
207 ;; or `imenu-create-index-function'.
208 (defvar texinfo-imenu-generic-expression
209 '((nil "^@node[ \t]+\\([^,\n]*\\)" 1)
210 ("Chapters" "^@chapter[ \t]+\\(.*\\)$" 1))
212 "Imenu generic expression for TexInfo mode. See `imenu-generic-expression'.")
214 (defvar texinfo-font-lock-keywords
215 '(;; All but the first 2 had an OVERRIDE of t.
216 ;; It didn't seem to be any better, and it's slower--simon.
217 ("^\\(@c\\|@comment\\)\\>.*" . font-lock-comment-face) ;comments
218 ;; Robert J. Chassell <bob@gnu.ai.mit.edu> says remove this line.
219 ;("\\$\\([^$]*\\)\\$" 1 font-lock-string-face t)
220 ("@\\([a-zA-Z]+\\|[^ \t\n]\\)" 1 font-lock-keyword-face) ;commands
221 ("^\\*\\(.*\\)[\t ]*$" 1 font-lock-function-name-face t) ;menu items
222 ("@\\(emph\\|strong\\|b\\|i\\){\\([^}]+\\)" 2 font-lock-comment-face)
223 ("@\\(file\\|kbd\\|key\\|url\\|email\\){\\([^}]+\\)" 2 font-lock-string-face)
224 ("@\\(samp\\|code\\|var\\|math\\){\\([^}]+\\)"
225 2 font-lock-variable-name-face)
226 ("@\\(cite\\|xref\\|pxref\\){\\([^}]+\\)" 2 font-lock-reference-face)
227 ("@\\(end\\|itemx?\\) +\\(.+\\)" 2 font-lock-function-name-face keep)
229 "Additional expressions to highlight in TeXinfo mode.")
231 (defvar texinfo-section-list
243 ("unnumberedsubsec" 4)
247 ("unnumberedsubsubsec" 5)
248 ("appendixsubsubsec" 5)
250 "Alist of sectioning commands and their relative level.")
252 (defun texinfo-outline-level ()
253 ;; Calculate level of current texinfo outline heading.
258 (let* ((word (buffer-substring-no-properties
259 (point) (progn (forward-word 1) (point))))
260 (entry (assoc word texinfo-section-list)))
266 (defvar texinfo-mode-map nil)
268 ;;; Keys common both to Texinfo mode and to TeX shell.
270 (defun texinfo-define-common-keys (keymap)
271 "Define the keys both in Texinfo mode and in the texinfo-tex-shell."
272 (define-key keymap "\C-c\C-t\C-k" 'tex-kill-job)
273 (define-key keymap "\C-c\C-t\C-x" 'texinfo-quit-job)
274 (define-key keymap "\C-c\C-t\C-l" 'tex-recenter-output-buffer)
275 (define-key keymap "\C-c\C-t\C-d" 'texinfo-delete-from-print-queue)
276 (define-key keymap "\C-c\C-t\C-q" 'tex-show-print-queue)
277 (define-key keymap "\C-c\C-t\C-p" 'texinfo-tex-print)
278 (define-key keymap "\C-c\C-t\C-v" 'texinfo-tex-view)
279 (define-key keymap "\C-c\C-t\C-i" 'texinfo-texindex)
281 (define-key keymap "\C-c\C-t\C-r" 'texinfo-tex-region)
282 (define-key keymap "\C-c\C-t\C-b" 'texinfo-tex-buffer))
284 ;; Mode documentation displays commands in reverse order
285 ;; from how they are listed in the texinfo-mode-map.
289 (setq texinfo-mode-map (make-sparse-keymap))
291 ;; bindings for `texnfo-tex.el'
292 (texinfo-define-common-keys texinfo-mode-map)
294 ;; bindings for `makeinfo.el'
295 (define-key texinfo-mode-map "\C-c\C-m\C-k" 'kill-compilation)
296 (define-key texinfo-mode-map "\C-c\C-m\C-l"
297 'makeinfo-recenter-compilation-buffer)
298 (define-key texinfo-mode-map "\C-c\C-m\C-r" 'makeinfo-region)
299 (define-key texinfo-mode-map "\C-c\C-m\C-b" 'makeinfo-buffer)
301 ; Bindings for texinfmt.el.
302 (define-key texinfo-mode-map "\C-c\C-e\C-r" 'texinfo-format-region)
303 (define-key texinfo-mode-map "\C-c\C-e\C-b" 'texinfo-format-buffer)
305 ;; bindings for updating nodes and menus
307 (define-key texinfo-mode-map "\C-c\C-um" 'texinfo-master-menu)
309 (define-key texinfo-mode-map "\C-c\C-u\C-m" 'texinfo-make-menu)
310 (define-key texinfo-mode-map "\C-c\C-u\C-n" 'texinfo-update-node)
311 (define-key texinfo-mode-map "\C-c\C-u\C-e" 'texinfo-every-node-update)
312 (define-key texinfo-mode-map "\C-c\C-u\C-a" 'texinfo-all-menus-update)
314 (define-key texinfo-mode-map "\C-c\C-s" 'texinfo-show-structure)
316 (define-key texinfo-mode-map "\C-c}" 'up-list)
317 (define-key texinfo-mode-map "\C-c{" 'texinfo-insert-braces)
319 ;; bindings for inserting strings
321 (define-key texinfo-mode-map "\C-c\C-c\C-d" 'texinfo-start-menu-description)
323 (define-key texinfo-mode-map "\C-c\C-cv" 'texinfo-insert-@var)
324 (define-key texinfo-mode-map "\C-c\C-ct" 'texinfo-insert-@table)
325 (define-key texinfo-mode-map "\C-c\C-cs" 'texinfo-insert-@samp)
326 (define-key texinfo-mode-map "\C-c\C-co" 'texinfo-insert-@noindent)
327 (define-key texinfo-mode-map "\C-c\C-cn" 'texinfo-insert-@node)
328 (define-key texinfo-mode-map "\C-c\C-ck" 'texinfo-insert-@kbd)
329 (define-key texinfo-mode-map "\C-c\C-ci" 'texinfo-insert-@item)
330 (define-key texinfo-mode-map "\C-c\C-cf" 'texinfo-insert-@file)
331 (define-key texinfo-mode-map "\C-c\C-cx" 'texinfo-insert-@example)
332 (define-key texinfo-mode-map "\C-c\C-ce" 'texinfo-insert-@end)
333 (define-key texinfo-mode-map "\C-c\C-cd" 'texinfo-insert-@dfn)
334 (define-key texinfo-mode-map "\C-c\C-cc" 'texinfo-insert-@code))
339 (defvar texinfo-chapter-level-regexp
340 "chapter\\|unnumbered \\|appendix \\|majorheading\\|chapheading"
341 "Regular expression matching Texinfo chapter-level headings.
342 This does not match `@node' and does not match the `@top' command.")
345 (defun texinfo-mode ()
346 "Major mode for editing Texinfo files.
348 It has these extra commands:
351 These are files that are used as input for TeX to make printed manuals
352 and also to be turned into Info files with \\[makeinfo-buffer] or
353 the `makeinfo' program. These files must be written in a very restricted and
354 modified version of TeX input format.
356 Editing commands are like text-mode except that the syntax table is
357 set up so expression commands skip Texinfo bracket groups. To see
358 what the Info version of a region of the Texinfo file will look like,
359 use \\[makeinfo-region], which runs `makeinfo' on the current region.
361 You can show the structure of a Texinfo file with \\[texinfo-show-structure].
362 This command shows the structure of a Texinfo file by listing the
363 lines with the @-sign commands for @chapter, @section, and the like.
364 These lines are displayed in another window called the *Occur* window.
365 In that window, you can position the cursor over one of the lines and
366 use \\[occur-mode-goto-occurrence], to jump to the corresponding spot
369 In addition, Texinfo mode provides commands that insert various
370 frequently used @-sign commands into the buffer. You can use these
371 commands to save keystrokes. And you can insert balanced braces with
372 \\[texinfo-insert-braces] and later use the command \\[up-list] to
373 move forward past the closing brace.
375 Also, Texinfo mode provides functions for automatically creating or
376 updating menus and node pointers. These functions
378 * insert the `Next', `Previous' and `Up' pointers of a node,
379 * insert or update the menu for a section, and
380 * create a master menu for a Texinfo source file.
382 Here are the functions:
384 texinfo-update-node \\[texinfo-update-node]
385 texinfo-every-node-update \\[texinfo-every-node-update]
386 texinfo-sequential-node-update
388 texinfo-make-menu \\[texinfo-make-menu]
389 texinfo-all-menus-update \\[texinfo-all-menus-update]
392 texinfo-indent-menu-description (column &optional region-p)
394 The `texinfo-column-for-description' variable specifies the column to
395 which menu descriptions are indented.
397 Passed an argument (a prefix argument, if interactive), the
398 `texinfo-update-node' and `texinfo-make-menu' functions do their jobs
401 To use the updating commands, you must structure your Texinfo file
402 hierarchically, such that each `@node' line, with the exception of the
403 Top node, is accompanied by some kind of section line, such as an
404 `@chapter' or `@section' line.
406 If the file has a `top' node, it must be called `top' or `Top' and
407 be the first node in the file.
409 Entering Texinfo mode calls the value of text-mode-hook, and then the
410 value of texinfo-mode-hook."
413 (setq mode-name "Texinfo")
414 (setq major-mode 'texinfo-mode)
415 (use-local-map texinfo-mode-map)
416 (set-syntax-table texinfo-mode-syntax-table)
417 (make-local-variable 'page-delimiter)
420 "^@node [ \t]*[Tt]op\\|^@\\("
421 texinfo-chapter-level-regexp
423 (make-local-variable 'require-final-newline)
424 (setq require-final-newline t)
425 (make-local-variable 'indent-tabs-mode)
426 (setq indent-tabs-mode nil)
427 (make-local-variable 'paragraph-separate)
428 (setq paragraph-separate (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-separate))
429 (make-local-variable 'paragraph-start)
430 (setq paragraph-start (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-start))
431 (make-local-variable 'fill-column)
432 (setq fill-column 72)
433 (make-local-variable 'comment-start)
434 (setq comment-start "@c ")
435 (make-local-variable 'comment-start-skip)
436 (setq comment-start-skip "@c +")
437 (make-local-variable 'words-include-escapes)
438 (setq words-include-escapes t)
439 (make-local-variable 'imenu-generic-expression)
440 (setq imenu-generic-expression texinfo-imenu-generic-expression)
441 (make-local-variable 'font-lock-defaults)
442 (setq font-lock-defaults '(texinfo-font-lock-keywords t))
443 (make-local-variable 'outline-regexp)
446 (mapconcat 'car texinfo-section-list "\\>\\|")
448 (make-local-variable 'outline-level)
449 (setq outline-level 'texinfo-outline-level)
450 (make-local-variable 'tex-start-of-header)
451 (setq tex-start-of-header "%\\*\\*start")
452 (make-local-variable 'tex-end-of-header)
453 (setq tex-end-of-header "%\\*\\*end")
454 (make-local-variable 'tex-first-line-header-regexp)
455 (setq tex-first-line-header-regexp "^\\\\input")
456 (make-local-variable 'tex-trailer)
457 (setq tex-trailer "@bye\n")
458 (run-hooks 'text-mode-hook 'texinfo-mode-hook))
461 ;;; Insert string commands
463 (defconst texinfo-environment-regexp
464 "^[ \t]*@\\(f?table\\|enumerate\\|itemize\
465 \\|ifhtml\\|ifinfo\\|iftex\\|ifset\\|ifclear\
466 \\|example\\|quotation\\|lisp\\|smallexample\\|smalllisp\\|display\\|format\
467 \\|flushleft\\|flushright\\|ignore\\|group\\|tex\\|html\\|cartouche\\|menu\
468 \\|titlepage\\|end\\|def[a-z]*[a-wyz]\\>\\)"
469 "Regexp for environment-like Texinfo list commands.
470 Subexpression 1 is what goes into the corresponding `@end' statement.")
472 (defun texinfo-insert-@end ()
473 "Insert the matching `@end' for the last Texinfo command that needs one."
475 (let ((depth 1) string)
477 (while (and (> depth 0)
478 (re-search-backward texinfo-environment-regexp nil t)
479 (if (looking-at "@end")
480 (setq depth (1+ depth))
481 (setq depth (1- depth)))))
482 (looking-at texinfo-environment-regexp)
485 (buffer-substring (match-beginning 1)
488 (if string (insert string "\n"))))
490 ;; The following insert commands accept a prefix arg N, which is the
491 ;; number of words (actually s-exprs) that should be surrounded by
492 ;; braces. Thus you can first paste a variable name into a .texinfo
493 ;; buffer, then say C-u 1 C-c C-c v at the beginning of the just
494 ;; pasted variable name to put @var{...} *around* the variable name.
495 ;; Operate on previous word or words with negative arg.
497 ;; These commands use texinfo-insert-@-with-arg
498 (defun texinfo-insert-@-with-arg (string &optional arg)
501 (setq arg (prefix-numeric-value arg))
504 (skip-chars-backward " \t\n\r\f")
507 (insert "@" string "{"))
509 (skip-chars-forward " \t\n\r\f")
510 (insert "@" string "{")
513 (insert "@" string "{}")
516 (defun texinfo-insert-braces ()
517 "Make a pair of braces and be poised to type inside of them.
518 Use \\[up-list] to move forward out of the braces."
523 (defun texinfo-insert-@code (&optional arg)
524 "Insert a `@code{...}' command in a Texinfo buffer.
525 A numeric argument says how many words the braces should surround.
526 The default is not to surround any existing words with the braces."
528 (texinfo-insert-@-with-arg "code" arg))
530 (defun texinfo-insert-@dfn (&optional arg)
531 "Insert a `@dfn{...}' command in a Texinfo buffer.
532 A numeric argument says how many words the braces should surround.
533 The default is not to surround any existing words with the braces."
535 (texinfo-insert-@-with-arg "dfn" arg))
537 (defun texinfo-insert-@example ()
538 "Insert the string `@example' in a Texinfo buffer."
540 (insert "@example\n"))
542 (defun texinfo-insert-@file (&optional arg)
543 "Insert a `@file{...}' command in a Texinfo buffer.
544 A numeric argument says how many words the braces should surround.
545 The default is not to surround any existing words with the braces."
547 (texinfo-insert-@-with-arg "file" arg))
549 (defun texinfo-insert-@item ()
550 "Insert the string `@item' in a Texinfo buffer."
555 (defun texinfo-insert-@kbd (&optional arg)
556 "Insert a `@kbd{...}' command in a Texinfo buffer.
557 A numeric argument says how many words the braces should surround.
558 The default is not to surround any existing words with the braces."
560 (texinfo-insert-@-with-arg "kbd" arg))
562 (defun texinfo-insert-@node ()
563 "Insert the string `@node' in a Texinfo buffer.
564 This also inserts on the following line a comment indicating
565 the order of arguments to @node."
567 (insert "@node \n@comment node-name, next, previous, up")
571 (defun texinfo-insert-@noindent ()
572 "Insert the string `@noindent' in a Texinfo buffer."
574 (insert "@noindent\n"))
576 (defun texinfo-insert-@samp (&optional arg)
577 "Insert a `@samp{...}' command in a Texinfo buffer.
578 A numeric argument says how many words the braces should surround.
579 The default is not to surround any existing words with the braces."
581 (texinfo-insert-@-with-arg "samp" arg))
583 (defun texinfo-insert-@table (&optional arg)
584 "Insert the string `@table' in a Texinfo buffer."
588 (defun texinfo-insert-@var (&optional arg)
589 "Insert a `@var{}' command in a Texinfo buffer.
590 A numeric argument says how many words the braces should surround.
591 The default is not to surround any existing words with the braces."
593 (texinfo-insert-@-with-arg "var" arg))
595 ;;; Texinfo file structure
597 ;; These are defined in tenfo-upd.el.
598 (defvar texinfo-section-types-regexp)
599 (defvar texinfo-section-level-regexp)
600 (defvar texinfo-subsection-level-regexp)
601 (defvar texinfo-subsubsection-level-regexp)
603 (defun texinfo-show-structure (&optional nodes-too)
604 "Show the structure of a Texinfo file.
605 List the lines in the file that begin with the @-sign commands for
606 @chapter, @section, and the like.
608 With optional argument (prefix if interactive), list both the lines
609 with @-sign commands for @chapter, @section, and the like, and list
612 Lines with structuring commands beginning in them are displayed in
613 another buffer named `*Occur*'. In that buffer, you can move point to
614 one of those lines and then use \\<occur-mode-map>\\[occur-mode-goto-occurrence],
615 to jump to the corresponding spot in the Texinfo source file."
618 (require 'texnfo-upd)
620 (goto-char (point-min))
622 (occur (concat "\\(^@node\\)\\|" texinfo-section-types-regexp))
623 (occur texinfo-section-types-regexp)))
624 (pop-to-buffer "*Occur*")
625 (goto-char (point-min))
626 (flush-lines "-----")
627 ;; Now format the "*Occur*" buffer to show the structure.
628 ;; Thanks to ceder@signum.se (Per Cederqvist)
629 (goto-char (point-max))
631 (while (re-search-backward "^ *[0-9]*:" nil 0)
632 (re-search-forward ":")
636 (concat "@\\(" texinfo-chapter-level-regexp "\\)")) 5)
637 ;; ((looking-at "@chapter ") 5)
638 ;; ((looking-at "@unnumbered ") 5)
639 ;; ((looking-at "@appendix ") 5)
640 ;; ((looking-at "@majorheading ") 5)
641 ;; ((looking-at "@chapheading ") 5)
644 (concat "@\\(" texinfo-section-level-regexp "\\)")) 9)
645 ;; ((looking-at "@section ") 9)
646 ;; ((looking-at "@unnumberedsec ") 9)
647 ;; ((looking-at "@appendixsec ") 9)
648 ;; ((looking-at "@heading ") 9)
651 (concat "@\\(" texinfo-subsection-level-regexp "\\)")) 13)
652 ;; ((looking-at "@subsection ") 13)
653 ;; ((looking-at "@unnumberedsubsec ") 13)
654 ;; ((looking-at "@appendixsubsec ") 13)
655 ;; ((looking-at "@subheading ") 13)
658 (concat "@\\(" texinfo-subsubsection-level-regexp "\\)")) 17)
659 ;; ((looking-at "@subsubsection ") 17)
660 ;; ((looking-at "@unnumberedsubsubsec ") 17)
661 ;; ((looking-at "@appendixsubsubsec ") 17)
662 ;; ((looking-at "@subsubheading ") 17)
664 (indent-to-column margin)
665 (beginning-of-line))))
667 ;;; The tex and print function definitions:
669 (defcustom texinfo-texi2dvi-command "texi2dvi"
670 "*Command used by `texinfo-tex-buffer' to run TeX and texindex on a buffer."
674 (defcustom texinfo-tex-command "tex"
675 "*Command used by `texinfo-tex-region' to run TeX on a region."
679 (defcustom texinfo-texindex-command "texindex"
680 "*Command used by `texinfo-texindex' to sort unsorted index files."
684 (defcustom texinfo-delete-from-print-queue-command "lprm"
685 "*Command string used to delete a job from the line printer queue.
686 Command is used by \\[texinfo-delete-from-print-queue] based on
687 number provided by a previous \\[tex-show-print-queue]
692 (defvar texinfo-tex-trailer "@bye"
693 "String appended after a region sent to TeX by `texinfo-tex-region'.")
695 (defun texinfo-tex-region (beg end)
696 "Run TeX on the current region.
697 This works by writing a temporary file (`tex-zap-file') in the directory
698 that is the value of `tex-directory', then running TeX on that file.
700 The first line of the buffer is copied to the
701 temporary file; and if the buffer has a header, it is written to the
702 temporary file before the region itself. The buffer's header is all lines
703 between the strings defined by `tex-start-of-header' and `tex-end-of-header'
704 inclusive. The header must start in the first 100 lines.
706 The value of `texinfo-tex-trailer' is appended to the temporary file after the region."
709 (let ((tex-command texinfo-tex-command)
710 (tex-trailer "@bye\n"))
711 (tex-region beg end)))
713 (defun texinfo-tex-buffer ()
714 "Run TeX on visited file, once or twice, to make a correct `.dvi' file."
717 (let ((tex-command texinfo-texi2dvi-command))
720 (defun texinfo-texindex ()
721 "Run `texindex' on unsorted index files.
722 The index files are made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer].
723 This runs the shell command defined by `texinfo-texindex-command'."
726 (tex-send-command texinfo-texindex-command (concat tex-zap-file ".??"))
727 (tex-recenter-output-buffer nil))
729 (defun texinfo-tex-print ()
730 "Print `.dvi' file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer].
731 This runs the shell command defined by `tex-dvi-print-command'."
736 (defun texinfo-tex-view ()
737 "View `.dvi' file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer].
738 This runs the shell command defined by `tex-dvi-view-command'."
743 (defun texinfo-quit-job ()
744 "Quit currently running TeX job, by sending an `x' to it."
746 (if (not (get-process "tex-shell"))
747 (error "No TeX shell running"))
748 (tex-send-command "x"))
750 (defun texinfo-delete-from-print-queue (job-number)
751 "Delete job from the line printer spooling queue.
752 You are prompted for the job number (use a number shown by a previous
753 \\[texinfo-show-print-queue] command)."
754 (interactive "nPrinter job number for deletion: ")
756 (if (tex-shell-running)
759 (tex-send-command texinfo-delete-from-print-queue-command job-number)
760 (tex-recenter-output-buffer nil))
764 ;;; texinfo.el ends here