1 ;;; latexinfo.el - Support for LaTeXinfo files.
3 ;; Copyright (C) 1993 Marc Gemis <makke@wins.uia.ac.be>
5 ;; Author: Marc Gemis <makke@wins.uia.ac.be>
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3, or (at your option)
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program; if not, write to the Free Software
19 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 (defvar TeX-latexinfo-node-regexp
26 '("\\\\node[ \t]+\\([^,\n\r%]+\\)" 1 TeX-auto-label)
27 "Matches LaTeXinfo \\node commands, only current node will be found.
28 We ignore next, previous and up fields.")
30 (defvar LaTeXinfo-mode nil
31 "Non-nil means LaTeXinfo minor mode is active.")
32 (make-variable-buffer-local 'LaTeXinfo-mode)
34 (defvar LaTeXinfo-mode-map nil
35 "Keymap containing LaTeXinfo commands.")
37 (if LaTeXinfo-mode-map
39 (setq LaTeXinfo-mode-map (make-sparse-keymap))
40 (define-key LaTeXinfo-mode-map "\C-c\C-u\C-b" 'latexinfo-format-buffer)
41 (define-key LaTeXinfo-mode-map "\C-c\C-u\C-r" 'latexinfo-format-region)
42 (define-key LaTeXinfo-mode-map "\C-c\C-u\C-s" 'latexinfo-show-structure)
43 (define-key LaTeXinfo-mode-map "\C-c\C-ud" 'makke:latexinfo-delete-structure)
44 (define-key LaTeXinfo-mode-map "\C-c\C-ug" 'latexinfo-goto-node)
45 (define-key LaTeXinfo-mode-map "\C-c\C-ui" 'makke:latexinfo-structure))
47 (or (assq 'LaTeXinfo-mode minor-mode-map-alist)
48 (setq minor-mode-map-alist
49 (cons (cons 'LaTeXinfo-mode LaTeXinfo-mode-map)
50 minor-mode-map-alist)))
52 (defun TeX-arg-latexinfo-index (optional &optional prompt)
53 "Prompt for a LaTeXinfo index type with completion."
55 (completing-read (TeX-argument-prompt optional prompt "Index")
56 '(("cp") ("vr") ("fn") ("tp") ("pg") ("ky"))
60 (defun LaTeX-item-latexinfo-menu ()
61 "Insert a new menu item"
65 (defun latexinfo-goto-node () ; temporarily here, later in latexinfo-upd.el ??
66 "Place pointer on the node given by the user, read node with completion
67 This fails when the user types in the label of something else"
69 (let ((node-name (completing-read "Goto Node: " (LaTeX-label-list))))
70 (goto-char (point-min))
71 (if (re-search-forward
73 TeX-esc "node[ \\t]+" node-name ","
75 TeX-esc "label{" LaTeX-section-label node-name
77 TeX-esc "label{" node-name
81 (error "No such node"))))
85 (TeX-add-style-hook "latexinfo"
89 (require 'latexinfo-structure)
92 (setq LaTeXinfo-mode t)
94 (TeX-auto-add-regexp TeX-latexinfo-node-regexp)
99 (TeX-arg-free TeX-arg-define-label "Node name")
100 (TeX-arg-literal ", ")
101 (TeX-arg-free TeX-arg-ref "Next node")
102 (TeX-arg-literal ", ")
103 (TeX-arg-free TeX-arg-ref "Previous node")
104 (TeX-arg-literal ", ")
105 (TeX-arg-free TeX-arg-ref "Up node"))
106 '("setfilename" TeX-arg-file)
119 (TeX-arg-literal " ")
120 (TeX-arg-free "Comment"))
122 (TeX-arg-literal " ")
123 (TeX-arg-free "Comment"))
129 '("newindex" TeX-arg-latexinfo-index)
139 '("xref" TeX-arg-ref)
140 '("pxref" TeX-arg-ref)
142 (TeX-arg-literal "{")
143 (TeX-arg-free "Name of node")
144 (TeX-arg-literal ", ")
145 (TeX-arg-free "Name for note")
146 (TeX-arg-literal ", ")
147 (TeX-arg-free TeX-arg-file "Info file")
148 (TeX-arg-literal "}")))
150 (LaTeX-add-environments "menu" "tex" "ignore" "ifinfo" "iftex"
151 "example" "same" "display" "format")
153 ; Menu's have a special kind of items
154 (make-local-variable 'LaTeX-item-list)
155 (setq LaTeX-item-list (cons '("menu" . LaTeX-item-latexinfo-menu)
158 (make-local-variable 'TeX-font-list)
160 (list (list ?\C-b (concat TeX-esc "b{") "}")
161 (list ?\C-c (concat TeX-esc "sc{") "}")
162 (list ?\C-e (concat TeX-esc "emph{") "}")
163 (list ?\C-i (concat TeX-esc "i{") "}")
164 (list ?\C-r (concat TeX-esc "r{") "}")
165 (list ?\C-s (concat TeX-esc "samp{") "}")
166 (list ?\C-t (concat TeX-esc "t{") "}")
167 (list ?s (concat TeX-esc "strong{") "}")
168 (list ?\C-f (concat TeX-esc "file{") "}")
169 (list ?\C-d (concat TeX-esc "dfn{") "}")
170 (list ?\C-v (concat TeX-esc "var{") "}")
171 (list ?k (concat TeX-esc "key{") "}")
172 (list ?\C-k (concat TeX-esc "kbd{") "}")
173 (list ?c (concat TeX-esc "code{") "}")
174 (list ?C (concat TeX-esc "cite{") "}")))
176 ;; need the following stuff to let xref and pxref work
177 (make-local-variable 'LaTeX-section-label)
178 (setq LaTeX-section-label "")))
181 ;;; latexinfo.el ends here