]> code.delx.au - gnu-emacs-elpa/blob - packages/auctex/tex-info.el
Update AUCTeX ELPA package to the new 11.87 release.
[gnu-emacs-elpa] / packages / auctex / tex-info.el
1 ;;; tex-info.el --- Support for editing Texinfo source.
2
3 ;; Copyright (C) 1993, 1994, 1997, 2000, 2001, 2004, 2005, 2006, 2011
4 ;; Free Software Foundation, Inc.
5
6 ;; Maintainer: auctex-devel@gnu.org
7 ;; Keywords: tex
8
9 ;; This file is part of AUCTeX.
10
11 ;; AUCTeX is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; any later version.
15
16 ;; AUCTeX is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with AUCTeX; see the file COPYING. If not, write to the Free
23 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 ;; 02110-1301, USA.
25
26 ;;; Code:
27
28 (require 'tex)
29
30 (require 'texinfo)
31 ;; Make sure the Texinfo mode of AUCTeX is still used after loading
32 ;; texinfo.el. (This is only an issue on Emacs 21.)
33 (when (and (boundp 'TeX-modes)
34 (memq 'texinfo-mode TeX-modes))
35 (defalias 'texinfo-mode 'TeX-texinfo-mode))
36
37 ;;; Environments:
38
39 (defvar Texinfo-environment-list
40 '(("cartouche") ("command") ("copying") ("defcv") ("deffn") ("defivar")
41 ("defmac") ("defmethod") ("defop") ("defopt") ("defspec")
42 ("deftp") ("deftypefn") ("deftypefun") ("deftypevar") ("deftypevr")
43 ("defun") ("defvar") ("defvr") ("description") ("detailmenu")
44 ("direntry") ("display") ("documentdescription") ("enumerate")
45 ("example") ("flushleft") ("flushright") ("format") ("ftable")
46 ("group") ("ifclear") ("ifdocbook") ("ifhtml") ("ifinfo")
47 ("ifnotdocbook") ("ifnothtml") ("ifnotinfo") ("ifnotplaintext")
48 ("ifnottex") ("ifnotxml") ("ifplaintext") ("ifset") ("iftex")
49 ("ifxml") ("ignore") ("itemize") ("lisp") ("macro") ("menu")
50 ("multitable") ("quotation") ("smalldisplay") ("smallexample")
51 ("smallformat") ("smalllisp") ("table") ("tex") ("titlepage")
52 ("verbatim") ("vtable"))
53 "Alist of Texinfo environments.")
54
55 (defconst texinfo-environment-regexp
56 ;; Overwrite version from `texinfo.el'.
57 (concat "^@\\("
58 (mapconcat 'car Texinfo-environment-list "\\|")
59 "\\|end\\)\\>")
60 "Regexp for environment-like Texinfo list commands.
61 Subexpression 1 is what goes into the corresponding `@end' statement.")
62
63 (defun Texinfo-environment (env &optional arg)
64 "Make Texinfo environment ENV.
65 With optional ARG, modify current environment."
66 ;; XXX: This could be enhanced to act like `LaTeX-environment',
67 ;; i.e. suggest a default environment and have its own history.
68 (interactive (list (completing-read "Environment: "
69 Texinfo-environment-list)
70 current-prefix-arg))
71 (if arg
72 (Texinfo-modify-environment env)
73 (Texinfo-insert-environment env)))
74
75 (defun Texinfo-insert-environment (env)
76 "Insert Texinfo environment ENV."
77 (if (and (TeX-active-mark)
78 (not (eq (mark) (point))))
79 (progn
80 (when (< (mark) (point))
81 (exchange-point-and-mark))
82 (unless (TeX-looking-at-backward "^[ \t]*")
83 (newline))
84 (insert "@" env)
85 (newline)
86 (goto-char (mark))
87 (unless (TeX-looking-at-backward "^[ \t]*")
88 (newline))
89 (insert "@end " env)
90 (save-excursion (newline))
91 (end-of-line 0))
92 (insert "@" env "\n\n@end " env "\n")
93 (if (null (cdr-safe (assoc "defcv" Texinfo-environment-list)))
94 (forward-line -2))))
95
96 (defun Texinfo-modify-environment (env)
97 "Change current environment to environment ENV."
98 (save-excursion
99 (Texinfo-find-env-end)
100 (re-search-backward (concat (regexp-quote TeX-esc) "end \\([a-zA-Z]*\\)")
101 (line-beginning-position))
102 (replace-match env t t nil 1)
103 (beginning-of-line)
104 (Texinfo-find-env-start)
105 (re-search-forward (concat (regexp-quote TeX-esc) "\\([a-zA-Z]*\\)")
106 (line-end-position))
107 (replace-match env t t nil 1)))
108
109 (defun Texinfo-find-env-end ()
110 "Move point to the end of the current environment."
111 (interactive)
112 (let* ((envs (mapcar 'car Texinfo-environment-list))
113 (regexp (concat "^[ \t]*" (regexp-quote TeX-esc) "\\(end \\)*"
114 (regexp-opt envs t) "\\b"))
115 (orig-pos (point))
116 (level 1)
117 case-fold-search)
118 (save-restriction
119 (save-excursion
120 (save-excursion
121 (beginning-of-line)
122 ;; Stop if point is inside of an @end <env> command, but not
123 ;; if it is behind it.
124 (when (and (looking-at regexp)
125 (match-string 1)
126 (> (match-end 0) orig-pos))
127 (setq level 0)))
128 (while (and (> level 0) (re-search-forward regexp nil t))
129 (if (match-string 1)
130 (setq level (1- level))
131 (setq level (1+ level)))))
132 (if (= level 0)
133 (goto-char (match-end 0))
134 (error "Can't locate end of current environment")))))
135
136 (defun Texinfo-find-env-start ()
137 "Move point to the start of the current environment."
138 (interactive)
139 (let* ((envs (mapcar 'car Texinfo-environment-list))
140 (regexp (concat "^[ \t]*\\(" (regexp-quote TeX-esc) "\\)\\(end \\)*"
141 (regexp-opt envs t) "\\b"))
142 (level 1)
143 (orig-pos (point))
144 case-fold-search)
145 (save-restriction
146 (save-excursion
147 (save-excursion
148 (beginning-of-line)
149 ;; Stop if point is inside of an @<env> command, but not if
150 ;; it is before it.
151 (when (and (looking-at regexp)
152 (not (match-string 2))
153 (< (match-beginning 1) orig-pos))
154 (setq level 0)))
155 (while (and (> level 0) (re-search-backward regexp nil t))
156 (if (match-string 2)
157 (setq level (1+ level))
158 (setq level (1- level)))))
159 (if (= level 0)
160 (goto-char (match-beginning 0))
161 (error "Can't locate start of current environment")))))
162
163 (defun Texinfo-mark-environment (&optional count)
164 "Set mark to end of current environment and point to the matching begin.
165 If prefix argument COUNT is given, mark the respective number of
166 enclosing environments. The command will not work properly if
167 there are unbalanced begin-end pairs in comments and verbatim
168 environments."
169 ;; TODO:
170 ;; This is identical to the LaTeX counterpart but for the find begin/end
171 ;; functions. So some day the implemenation should be factorized.
172 (interactive "p")
173 (setq count (if count (abs count) 1))
174 (let ((cur (point)) beg end)
175 ;; Only change point and mark after beginning and end were found.
176 ;; Point should not end up in the middle of nowhere if the search fails.
177 (save-excursion
178 (dotimes (c count)
179 (Texinfo-find-env-end))
180 (setq end (line-beginning-position 2))
181 (goto-char cur)
182 (dotimes (c count)
183 (Texinfo-find-env-start)
184 (unless (= (1+ c) count)
185 (beginning-of-line 0)))
186 (setq beg (point)))
187 (set-mark end)
188 (goto-char beg)
189 (TeX-activate-region)))
190
191 (defun Texinfo-mark-section (&optional no-subsection)
192 "Mark current section, with inclusion of any containing node.
193
194 The current section is detected as starting by any of the
195 structuring commands matched by regexp in variable
196 `outline-regexp' which in turn is a regexp matching any element
197 of variable `texinfo-section-list'.
198
199 If optional argument NO-SUBSECTION is set to any integer or is a
200 non nil empty argument (i.e. `C-u \\[Texinfo-mark-section]'),
201 then mark the current section with exclusion of any subsections.
202
203 Otherwise, any included subsections are also marked along with
204 current section.
205
206 Note that when current section is starting immediatley after a
207 node commande, then the node command is also marked as part as
208 the section."
209 (interactive "P")
210 (let (beg end is-beg-section is-end-section
211 (section-re (concat "^\\s-*" outline-regexp)))
212 (if (and (consp no-subsection) (eq (car no-subsection) 4))
213 ;; section with exclusion of any subsection
214 (setq beg (save-excursion
215 (unless (looking-at section-re)
216 (end-of-line))
217 (re-search-backward section-re nil t))
218 is-beg-section t
219 end (save-excursion
220 (beginning-of-line)
221 (when
222 (re-search-forward (concat section-re
223 "\\|^\\s-*@bye\\_>" ) nil t)
224 (save-match-data
225 (beginning-of-line)
226 (point))))
227 is-end-section (match-string 1))
228 ;; full section without exclusion of any subsection
229 (let (section-command-level)
230 (setq beg
231 (save-excursion
232 (end-of-line)
233 (re-search-backward section-re nil t)))
234 (when beg
235 (setq is-beg-section t
236 section-command-level
237 (cadr (assoc (match-string 1) texinfo-section-list))
238 end
239 (save-excursion
240 (beginning-of-line)
241 (while
242 (and (re-search-forward
243 (concat section-re "\\|^\\s-*@bye\\_>" ) nil t)
244 (or (null (setq is-end-section (match-string 1)))
245 (> (cadr (assoc is-end-section
246 texinfo-section-list))
247 section-command-level))))
248 (when (match-string 0)
249 (beginning-of-line)
250 (point))))))); (if ...)
251 (when (and beg end)
252 ;; now take also enclosing node of beg and end
253 (dolist
254 (boundary '(beg end))
255 (when (symbol-value (intern (concat "is-" (symbol-name boundary)
256 "-section")))
257 (save-excursion
258 (goto-char (symbol-value boundary))
259 (while
260 (and
261 (null (bobp))
262 (progn
263 (beginning-of-line 0)
264 (looking-at "^\\s-*\\($\\|@\\(c\\|comment\\)\\_>\\)"))))
265 (when (looking-at "^\\s-*@node\\_>")
266 (set boundary (point))))))
267
268 (set-mark end)
269 (goto-char beg)
270 (TeX-activate-region) )))
271
272 (defun Texinfo-mark-node ()
273 "Mark the current node. \
274 This is the node in which the pointer is. It is starting at
275 previous beginning of keyword `@node' and ending at next
276 beginning of keyword `@node' or `@bye'."
277 (interactive)
278 (let ((beg (save-excursion
279 (unless (looking-at "^\\s-*@\\(?:node\\)\\_>")
280 (end-of-line))
281 (re-search-backward "^\\s-*@\\(?:node\\)\\_>" nil t )))
282 (end (save-excursion
283 (beginning-of-line)
284 (and (re-search-forward "^\\s-*@\\(?:node\\|bye\\)\\_>" nil t )
285 (progn (beginning-of-line) (point))))))
286
287 (when (and beg end)
288 (set-mark end)
289 (goto-char beg)
290 (TeX-activate-region) )))
291
292 (defun Texinfo-insert-node ()
293 "Insert a Texinfo node in the current buffer.
294 That means, insert the string `@node' and prompt for current,
295 next, previous and upper node. If there is an active region, use
296 this for the current node and inhibit the prompt for it. Insert
297 a comment on the following line indicating the order of arguments
298 for @node."
299 (interactive)
300 (let ((active-mark (and (TeX-active-mark) (not (eq (mark) (point)))))
301 nodes node-name next-node previous-node up-node)
302 ;; Build list of nodes in current buffer.
303 ;; (What about using `imenu--index-alist'?)
304 ;; FIXME: Support multi-file documents.
305 (save-excursion
306 (goto-char (point-min))
307 (while (re-search-forward "^@node\\b" nil t)
308 (skip-chars-forward " \t")
309 (add-to-list 'nodes
310 (list (buffer-substring-no-properties
311 (point) (progn (skip-chars-forward "^,")
312 (point)))))))
313 (unless active-mark
314 (setq node-name (read-string "Node name: ")))
315 ;; FIXME: What if key binding for `minibuffer-complete' was changed?
316 ;; `substitute-command-keys' doesn't return the correct value.
317 (setq next-node (completing-read "Next node (TAB completes): " nodes))
318 (setq previous-node
319 (completing-read "Previous node (TAB completes): " nodes))
320 (setq up-node (completing-read "Upper node (TAB completes): " nodes))
321 (when (and active-mark
322 (< (mark) (point)))
323 (exchange-point-and-mark))
324 (insert "@node ")
325 (if active-mark
326 (goto-char (mark))
327 (insert node-name))
328 (insert ", " next-node ", " previous-node ", " up-node
329 "\n@comment node-name, next, previous, up\n")
330 ;; Position point at first empty field.
331 (unless (and (or (> (length node-name) 0) active-mark)
332 (> (length next-node) 0)
333 (> (length previous-node) 0)
334 (> (length up-node) 0))
335 (forward-line -2)
336 (forward-char 6)
337 (catch 'break
338 (if (or (> (length node-name) 0) active-mark)
339 (progn (skip-chars-forward "^,") (forward-char 2))
340 (throw 'break nil))
341 (dolist (node (list next-node previous-node up-node))
342 (if (> (length node) 0)
343 (progn (skip-chars-forward "^,") (forward-char 2))
344 (throw 'break nil)))))))
345
346 ;; Silence the byte-compiler from warnings for variables and functions declared
347 ;; in reftex.
348 (eval-when-compile
349 (defvar reftex-section-levels-all)
350 (defvar reftex-level-indent)
351 (defvar reftex-label-menu-flags)
352 (defvar reftex-tables-dirty)
353
354 (when (fboundp 'declare-function)
355 (declare-function reftex-match-string "reftex" (n))
356 (declare-function reftex-section-number "reftex-parse" (&optional level star))
357 (declare-function reftex-nicify-text "reftex" (text))
358 (declare-function reftex-ensure-compiled-variables "reftex" ())))
359
360 (defun Texinfo-reftex-section-info (file)
361 ;; Return a section entry for the current match.
362 ;; Carefull: This function expects the match-data to be still in place!
363 (let* ((marker (set-marker (make-marker) (1- (match-beginning 3))))
364 (macro (reftex-match-string 3))
365 (level-exp (cdr (assoc macro reftex-section-levels-all)))
366 (level (if (symbolp level-exp)
367 (save-match-data (funcall level-exp))
368 level-exp))
369 (unnumbered (< level 0))
370 (level (abs level))
371 (section-number (reftex-section-number level unnumbered))
372 (text1 (save-match-data
373 (save-excursion
374 (buffer-substring-no-properties (point) (progn (end-of-line) (point))))))
375 (literal (buffer-substring-no-properties
376 (1- (match-beginning 3))
377 (min (point-max) (+ (match-end 0) (length text1) 1))))
378 ;; Literal can be too short since text1 too short. No big problem.
379 (text (reftex-nicify-text text1)))
380
381 ;; Add section number and indentation
382 (setq text
383 (concat
384 (make-string (* reftex-level-indent level) ?\ )
385 (if (nth 1 reftex-label-menu-flags) ; section number flag
386 (concat section-number " "))
387 text))
388 (list 'toc "toc" text file marker level section-number
389 literal (marker-position marker))))
390
391 (defun Texinfo-reftex-hook ()
392 "Hook function to plug Texinfo into RefTeX."
393 ;; force recompilation of variables
394 (when (string= TeX-base-mode-name "Texinfo")
395 (dolist (v `((reftex-section-pre-regexp . "@")
396 ; section post-regexp must contain exactly one group
397 (reftex-section-post-regexp . "\\([ \t]+\\)")
398 (reftex-section-info-function . Texinfo-reftex-section-info)
399 (reftex-section-levels
400 . ,(mapcar
401 (lambda (x)
402 (if (string-match "\\(\\`unnumbered\\)\\|\\(heading\\'\\)\\|\\(\\`top\\'\\)"
403 (car x))
404 (cons (car x) (- (cadr x)))
405 (cons (car x) (cadr x))))
406 texinfo-section-list))))
407 (set (make-local-variable (car v) ) (cdr v)))
408 (setq reftex-tables-dirty t)
409 (reftex-ensure-compiled-variables)))
410
411 ;;; Keymap:
412
413 (defvar Texinfo-mode-map
414 (let ((map (make-sparse-keymap)))
415 (set-keymap-parent map TeX-mode-map)
416
417 ;; From texinfo.el
418 ;; bindings for updating nodes and menus
419 (define-key map "\C-c\C-um" 'texinfo-master-menu)
420 (define-key map "\C-c\C-u\C-m" 'texinfo-make-menu)
421 (define-key map "\C-c\C-u\C-n" 'texinfo-update-node)
422 (define-key map "\C-c\C-u\C-e" 'texinfo-every-node-update)
423 (define-key map "\C-c\C-u\C-a" 'texinfo-all-menus-update)
424
425 ;; Simulating LaTeX-mode
426 (define-key map "\C-c\C-e" 'Texinfo-environment)
427 (define-key map "\C-c." 'Texinfo-mark-environment)
428 (define-key map "\C-c*" 'Texinfo-mark-section)
429 (define-key map "\M-\C-h" 'Texinfo-mark-node)
430 (define-key map "\C-c\n" 'texinfo-insert-@item)
431 (or (key-binding "\e\r")
432 (define-key map "\e\r" 'texinfo-insert-@item)) ;*** Alias
433 (define-key map "\C-c\C-s" 'Texinfo-insert-node)
434 (define-key map "\C-c]" 'texinfo-insert-@end)
435 map)
436 "Keymap for Texinfo mode.")
437
438 (easy-menu-define Texinfo-command-menu
439 Texinfo-mode-map
440 "Menu used in Texinfo mode for external commands."
441 (TeX-mode-specific-command-menu 'texinfo-mode))
442
443 (easy-menu-define Texinfo-mode-menu
444 Texinfo-mode-map
445 "Menu used in Texinfo mode."
446 (TeX-menu-with-help
447 `("Texinfo"
448 ["Node ..." texinfo-insert-@node
449 :help "Insert a node"]
450 ["Macro ..." TeX-insert-macro
451 :help "Insert a macro and possibly arguments"]
452 ["Complete Macro" TeX-complete-symbol
453 :help "Complete the current macro"]
454 ["Environment ..." Texinfo-insert-environment
455 :help "Insert an environment"]
456 ["Item" texinfo-insert-@item
457 :help "Insert an @item"]
458 "-"
459 ("Insert Font"
460 ["Emphasize" (TeX-font nil ?\C-e) :keys "C-c C-f C-e"]
461 ["Bold" (TeX-font nil ?\C-b) :keys "C-c C-f C-b"]
462 ["Typewriter" (TeX-font nil ?\C-t) :keys "C-c C-f C-t"]
463 ["Small Caps" (TeX-font nil ?\C-c) :keys "C-c C-f C-c"]
464 ["Italic" (TeX-font nil ?\C-i) :keys "C-c C-f C-i"]
465 ["Sample" (TeX-font nil ?\C-s) :keys "C-c C-f C-s"]
466 ["Roman" (TeX-font nil ?\C-r) :keys "C-c C-f C-r"])
467 ("Replace Font"
468 ["Emphasize" (TeX-font t ?\C-e) :keys "C-u C-c C-f C-e"]
469 ["Bold" (TeX-font t ?\C-b) :keys "C-u C-c C-f C-b"]
470 ["Typewriter" (TeX-font t ?\C-t) :keys "C-u C-c C-f C-t"]
471 ["Small Caps" (TeX-font t ?\C-c) :keys "C-u C-c C-f C-c"]
472 ["Italic" (TeX-font t ?\C-i) :keys "C-u C-c C-f C-i"]
473 ["Sample" (TeX-font t ?\C-s) :keys "C-u C-c C-f C-s"]
474 ["Roman" (TeX-font t ?\C-r) :keys "C-u C-c C-f C-r"])
475 ["Delete Font" (TeX-font t ?\C-d) :keys "C-c C-f C-d"]
476 "-"
477 ["Create Master Menu" texinfo-master-menu
478 :help "Make a master menu for the whole Texinfo file"]
479 ["Create Menu" texinfo-make-menu
480 :help "Make or update the menu for the current section"]
481 ["Update Node" texinfo-update-node
482 :help "Update the current node"]
483 ["Update Every Node" texinfo-every-node-update
484 :help "Update every node in the current file"]
485 ["Update All Menus" texinfo-all-menus-update
486 :help "Update every menu in the current file"]
487 "-"
488 ("Commenting"
489 ["Comment or Uncomment Region"
490 TeX-comment-or-uncomment-region
491 :help "Comment or uncomment the currently selected region"]
492 ["Comment or Uncomment Paragraph"
493 TeX-comment-or-uncomment-paragraph
494 :help "Comment or uncomment the current paragraph"])
495 ,TeX-fold-menu
496 "-"
497 . ,TeX-common-menu-entries)))
498
499 (defvar Texinfo-font-list
500 '((?\C-b "@b{" "}")
501 (?\C-c "@sc{" "}")
502 (?\C-e "@emph{" "}")
503 (?\C-i "@i{" "}")
504 (?\C-r "@r{" "}")
505 (?\C-s "@samp{" "}")
506 (?\C-t "@t{" "}")
507 (?s "@strong{" "}")
508 (?\C-f "@file{" "}")
509 (?d "@dfn{" "}")
510 (?\C-v "@var{" "}")
511 (?k "@key{" "}")
512 (?\C-k "@kbd{" "}")
513 (?c "@code{" "}")
514 (?C "@cite{" "}")
515 (?\C-d "" "" t))
516 "Font commands used in Texinfo mode. See `TeX-font-list'.")
517
518 ;;; Mode:
519
520 ;;;###autoload
521 (defalias 'Texinfo-mode 'texinfo-mode)
522
523 ;;;###autoload
524 (defun TeX-texinfo-mode ()
525 "Major mode in AUCTeX for editing Texinfo files.
526
527 Special commands:
528 \\{Texinfo-mode-map}
529
530 Entering Texinfo mode calls the value of `text-mode-hook' and then the
531 value of `Texinfo-mode-hook'."
532 (interactive)
533 (kill-all-local-variables)
534 (setq TeX-mode-p t)
535 ;; Mostly stolen from texinfo.el
536 (setq TeX-base-mode-name "Texinfo")
537 (setq major-mode 'texinfo-mode)
538 (use-local-map Texinfo-mode-map)
539 (set-syntax-table texinfo-mode-syntax-table)
540 (make-local-variable 'page-delimiter)
541 (setq page-delimiter
542 (concat
543 "^@node [ \t]*[Tt]op\\|^@\\("
544 texinfo-chapter-level-regexp
545 "\\)"))
546 (make-local-variable 'require-final-newline)
547 (setq require-final-newline t)
548 (make-local-variable 'indent-tabs-mode)
549 (setq indent-tabs-mode nil)
550 (make-local-variable 'paragraph-separate)
551 (setq paragraph-separate
552 (concat "\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-separate))
553 (make-local-variable 'paragraph-start)
554 (setq paragraph-start
555 (concat "\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-start))
556 (make-local-variable 'fill-column)
557 (setq fill-column 72)
558 (make-local-variable 'comment-start)
559 (setq comment-start "@c ")
560 (make-local-variable 'comment-start-skip)
561 (setq comment-start-skip "@c +\\|@comment +")
562 (set (make-local-variable 'comment-use-syntax) nil)
563 (make-local-variable 'words-include-escapes)
564 (setq words-include-escapes t)
565 (if (not (boundp 'texinfo-imenu-generic-expression))
566 ;; This was introduced in 19.30.
567 ()
568 (make-local-variable 'imenu-generic-expression)
569 (setq imenu-generic-expression texinfo-imenu-generic-expression))
570 (make-local-variable 'font-lock-defaults)
571 (setq font-lock-defaults
572 ;; COMPATIBILITY for Emacs 20
573 (if (boundp 'texinfo-font-lock-syntactic-keywords)
574 '(texinfo-font-lock-keywords
575 nil nil nil backward-paragraph
576 (font-lock-syntactic-keywords
577 . texinfo-font-lock-syntactic-keywords))
578 '(texinfo-font-lock-keywords t)))
579 (if (not (boundp 'texinfo-section-list))
580 ;; This was included in 19.31.
581 ()
582 (make-local-variable 'outline-regexp)
583 (setq outline-regexp
584 (concat "@\\("
585 (mapconcat 'car texinfo-section-list "\\>\\|")
586 "\\>\\)"))
587 (make-local-variable 'outline-level)
588 (setq outline-level 'texinfo-outline-level))
589
590 ;; Mostly AUCTeX stuff
591 (easy-menu-add Texinfo-mode-menu Texinfo-mode-map)
592 (easy-menu-add Texinfo-command-menu Texinfo-mode-map)
593 (make-local-variable 'TeX-command-current)
594 (setq TeX-command-current 'TeX-command-master)
595
596 (setq TeX-default-extension "texi")
597 (make-local-variable 'TeX-esc)
598 (setq TeX-esc "@")
599
600 (make-local-variable 'TeX-auto-regexp-list)
601 (setq TeX-auto-regexp-list 'TeX-auto-empty-regexp-list)
602 (make-local-variable 'TeX-auto-update)
603 (setq TeX-auto-update t)
604
605 (setq TeX-command-default "TeX")
606 (setq TeX-header-end "%*end")
607 (setq TeX-trailer-start (regexp-quote (concat TeX-esc "bye")))
608
609 (make-local-variable 'TeX-complete-list)
610 (setq TeX-complete-list
611 (list (list "@\\([a-zA-Z]*\\)" 1 'TeX-symbol-list nil)
612 (list "" TeX-complete-word)))
613
614 (make-local-variable 'TeX-font-list)
615 (setq TeX-font-list Texinfo-font-list)
616 (make-local-variable 'TeX-font-replace-function)
617 (setq TeX-font-replace-function 'TeX-font-replace-macro)
618
619 (add-hook 'find-file-hooks (lambda ()
620 (unless (file-exists-p (buffer-file-name))
621 (TeX-master-file nil nil t))) nil t)
622
623 (TeX-add-symbols
624 '("appendix" (TeX-arg-literal " ") (TeX-arg-free "Title"))
625 '("appendixsec" (TeX-arg-literal " ") (TeX-arg-free "Title"))
626 '("appendixsection" (TeX-arg-literal " ") (TeX-arg-free "Title"))
627 '("appendixsubsec" (TeX-arg-literal " ") (TeX-arg-free "Title"))
628 '("appendixsubsubsec" (TeX-arg-literal " ") (TeX-arg-free "Title"))
629 '("asis")
630 '("author" (TeX-arg-literal " ") (TeX-arg-free "Author"))
631 '("b" "Text")
632 '("bullet")
633 '("bye")
634 '("c" (TeX-arg-literal " ") (TeX-arg-free "Comment"))
635 '("center" (TeX-arg-literal " ") (TeX-arg-free "Line of text"))
636 '("chapheading" (TeX-arg-literal " ") (TeX-arg-free "Title"))
637 '("chapter" (TeX-arg-literal " ") (TeX-arg-free "Title"))
638 '("cindex" (TeX-arg-literal " ") (TeX-arg-free "Entry"))
639 '("cite" "Reference")
640 '("clear" (TeX-arg-literal " ") (TeX-arg-free "Flag"))
641 '("code" "Sample code")
642 '("command" "Command")
643 '("comment" (TeX-arg-literal " ") (TeX-arg-free "Comment"))
644 '("contents")
645 '("copyright" nil)
646 '("defcodeindex" (TeX-arg-literal " ") (TeX-arg-free "Index name"))
647 '("defindex" (TeX-arg-literal " ") (TeX-arg-free "Index name"))
648 '("dfn" "Term")
649 '("dmn" "Dimension")
650 '("dots" nil)
651 '("emph" "Text")
652 '("email" "Email address")
653 '("equiv" nil)
654 '("error")
655 '("evenfooting" Texinfo-lrc-argument-hook)
656 '("evenheading" Texinfo-lrc-argument-hook)
657 '("everyfooting" Texinfo-lrc-argument-hook)
658 '("everyheading" Texinfo-lrc-argument-hook)
659 '("exdent" (TeX-arg-literal " ") (TeX-arg-free "Line of text"))
660 '("expansion" nil)
661 '("file" "Filename")
662 '("finalout")
663 '("findex" (TeX-arg-literal " ") (TeX-arg-free "Entry"))
664 '("footnote" "Text of footnote")
665 '("footnotestyle" (TeX-arg-literal " ") (TeX-arg-free "Style"))
666 '("group")
667 '("heading" (TeX-arg-literal " ") (TeX-arg-free "Title"))
668 ;; XXX: Would be nice with completion.
669 '("headings" (TeX-arg-literal " ") (TeX-arg-free "On off single double"))
670 '("i" "Text")
671 '("ignore")
672 '("include" (TeX-arg-literal " ") (TeX-arg-free "Filename"))
673 '("inforef" "Node name" "Info file name")
674 '("item")
675 '("itemx")
676 '("kbd" "Keyboard characters")
677 '("key" "Key name")
678 '("kindex" (TeX-arg-literal " ") (TeX-arg-free "Entry"))
679 '("lowersections" 0)
680 '("majorheading" (TeX-arg-literal " ") (TeX-arg-free "Title"))
681 '("menu")
682 '("minus")
683 '("need" "N")
684 '("node" (TeX-arg-literal " ") (TeX-arg-free "Name")
685 (TeX-arg-literal ", ") (TeX-arg-free "Next")
686 (TeX-arg-literal ", ") (TeX-arg-free "Previous")
687 (TeX-arg-literal ", ") (TeX-arg-free "Up"))
688 '("noindent")
689 '("oddfooting" Texinfo-lrc-argument-hook)
690 '("oddheading" Texinfo-lrc-argument-hook)
691 '("page")
692 '("paragraphindent" (TeX-arg-literal " ") (TeX-arg-free "Indent"))
693 '("pindex" "Entry")
694 '("point" nil)
695 '("print")
696 '("printindex" (TeX-arg-literal " ") (TeX-arg-free "Index name"))
697 '("pxref" "Node name")
698 '("r" "Text")
699 '("raisesections" 0)
700 '("ref" "Node name")
701 '("refill")
702 '("result")
703 '("samp" "Text")
704 '("sc" "Text")
705 '("section" (TeX-arg-literal " ") (TeX-arg-free "Title"))
706 '("set" (TeX-arg-literal " ") (TeX-arg-free "Flag"))
707 ;; XXX: Would be nice with completion.
708 '("setchapternewpage" (TeX-arg-literal " ") (TeX-arg-free "On off odd"))
709 '("setfilename" (TeX-arg-literal " ") (TeX-arg-free "Info file name"))
710 '("settitle" (TeX-arg-literal " ") (TeX-arg-free "Title"))
711 '("shortcontents")
712 '("smallbook")
713 '("sp" "N")
714 '("strong" "Text")
715 '("subheading" (TeX-arg-literal " ") (TeX-arg-free "Title"))
716 '("subsection" (TeX-arg-literal " ") (TeX-arg-free "Title"))
717 '("subsubheading" (TeX-arg-literal " ") (TeX-arg-free "Title"))
718 '("subsubsection" (TeX-arg-literal " ") (TeX-arg-free "Title"))
719 '("subtitle" (TeX-arg-literal " ") (TeX-arg-free "Title"))
720 '("summarycontents")
721 '("syncodeindex" (TeX-arg-literal " ") (TeX-arg-free "From index")
722 (TeX-arg-literal " ") (TeX-arg-free "Into index"))
723 '("synindex" (TeX-arg-literal " ") (TeX-arg-free "From index")
724 (TeX-arg-literal " ") (TeX-arg-free "Into index"))
725 '("t" "Text")
726 '("TeX" nil)
727 '("thischapter")
728 '("thischaptername")
729 '("thisfile")
730 '("thispage")
731 '("tindex" (TeX-arg-literal " ") (TeX-arg-free "Entry"))
732 '("title" (TeX-arg-literal " ") (TeX-arg-free "Title"))
733 '("titlefont" "Text")
734 '("titlepage")
735 '("today" nil)
736 '("top" (TeX-arg-literal " ") (TeX-arg-free "Title"))
737 '("unnumbered" (TeX-arg-literal " ") (TeX-arg-free "Title"))
738 '("unnumberedsec" (TeX-arg-literal " ") (TeX-arg-free "Title"))
739 '("unnumberedsubsec" (TeX-arg-literal " ") (TeX-arg-free "Title"))
740 '("unnumberedsubsubsec" (TeX-arg-literal " ") (TeX-arg-free "Title"))
741 '("value" "Flag")
742 '("var" "Metasyntactic variable")
743 '("vindex" (TeX-arg-literal " ") (TeX-arg-free "Entry"))
744 '("vskip" (TeX-arg-literal " ") (TeX-arg-free "Amount"))
745 '("w" "Text")
746 '("xref" "Node name"))
747
748 ;; RefTeX plugging
749 (add-hook 'reftex-mode-hook 'Texinfo-reftex-hook)
750 (if (and (boundp 'reftex-mode) reftex-mode)
751 (Texinfo-reftex-hook))
752
753 (TeX-run-mode-hooks 'text-mode-hook 'Texinfo-mode-hook)
754 (TeX-set-mode-name))
755
756 (defcustom Texinfo-clean-intermediate-suffixes nil
757 "List of regexps matching suffixes of files to be deleted.
758 The regexps will be anchored at the end of the file name to be matched,
759 i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
760 :type '(repeat regexp)
761 :group 'TeX-command)
762
763 (defcustom Texinfo-clean-output-suffixes
764 ;; See `man texi2html' for the HTML stuff.
765 '("\\.info\\(-[0-9]+\\)?" "\\.dvi" "\\.pdf" "\\.ps" "\\.html"
766 "_toc\\.html" "_fot\\.html" "_abt\\.html" "_[0-9]+\\.html" "_l2h_img.+")
767 "List of regexps matching suffixes of files to be deleted.
768 The regexps will be anchored at the end of the file name to be matched,
769 i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
770 :type '(repeat regexp)
771 :group 'TeX-command)
772
773 (provide 'tex-info)
774
775 ;;; tex-info.el ends here