]> code.delx.au - gnu-emacs-elpa/blob - packages/auctex/style/latexinfo.el
Update AUCTeX ELPA package to the new 11.87 release.
[gnu-emacs-elpa] / packages / auctex / style / latexinfo.el
1 ;;; latexinfo.el - Support for LaTeXinfo files.
2
3 ;; Copyright (C) 1993 Marc Gemis <makke@wins.uia.ac.be>
4
5 ;; Author: Marc Gemis <makke@wins.uia.ac.be>
6 ;; Version: $Id: latexinfo.el,v 1.7 2008/02/03 14:53:30 angeli Exp $
7
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
11 ;; any later version.
12 ;;
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17 ;;
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program; if not, write to the Free Software
20 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 ;;; Code:
23
24 ;;; LaTeXinfo mode
25
26 (defvar TeX-latexinfo-node-regexp
27 '("\\\\node[ \t]+\\([^,\n\r%]+\\)" 1 TeX-auto-label)
28 "Matches LaTeXinfo \\node commands, only current node will be found.
29 We ignore next, previous and up fields.")
30
31 (defvar LaTeXinfo-mode nil
32 "Non-nil means LaTeXinfo minor mode is active.")
33 (make-variable-buffer-local 'LaTeXinfo-mode)
34
35 (defvar LaTeXinfo-mode-map nil
36 "Keymap containing LaTeXinfo commands.")
37
38 (if LaTeXinfo-mode-map
39 ()
40 (setq LaTeXinfo-mode-map (make-sparse-keymap))
41 (define-key LaTeXinfo-mode-map "\C-c\C-u\C-b" 'latexinfo-format-buffer)
42 (define-key LaTeXinfo-mode-map "\C-c\C-u\C-r" 'latexinfo-format-region)
43 (define-key LaTeXinfo-mode-map "\C-c\C-u\C-s" 'latexinfo-show-structure)
44 (define-key LaTeXinfo-mode-map "\C-c\C-ud" 'makke:latexinfo-delete-structure)
45 (define-key LaTeXinfo-mode-map "\C-c\C-ug" 'latexinfo-goto-node)
46 (define-key LaTeXinfo-mode-map "\C-c\C-ui" 'makke:latexinfo-structure))
47
48 (or (assq 'LaTeXinfo-mode minor-mode-map-alist)
49 (setq minor-mode-map-alist
50 (cons (cons 'LaTeXinfo-mode LaTeXinfo-mode-map)
51 minor-mode-map-alist)))
52
53 (defun TeX-arg-latexinfo-index (optional &optional prompt)
54 "Prompt for a LaTeXinfo index type with completion."
55 (TeX-argument-insert
56 (completing-read (TeX-argument-prompt optional prompt "Index")
57 '(("cp") ("vr") ("fn") ("tp") ("pg") ("ky"))
58 nil t)
59 optional))
60
61 (defun LaTeX-item-latexinfo-menu ()
62 "Insert a new menu item"
63 (insert "* ::")
64 (backward-char 2))
65
66 (defun latexinfo-goto-node () ; temporarily here, later in latexinfo-upd.el ??
67 "Place pointer on the node given by the user, read node with completion
68 This fails when the user types in the label of something else"
69 (interactive)
70 (let ((node-name (completing-read "Goto Node: " (LaTeX-label-list))))
71 (goto-char (point-min))
72 (if (re-search-forward
73 (concat
74 TeX-esc "node[ \\t]+" node-name ","
75 "\\|"
76 TeX-esc "label{" LaTeX-section-label node-name
77 "\\|"
78 TeX-esc "label{" node-name
79 )
80 (point-max) t)
81 (beginning-of-line 1)
82 (error "No such node"))))
83
84 ;;; Hook
85
86 (TeX-add-style-hook "latexinfo"
87 (function
88 (lambda ()
89 (require 'latexinfo)
90 (require 'latexinfo-structure)
91
92 (require 'min-map)
93 (setq LaTeXinfo-mode t)
94
95 (TeX-auto-add-regexp TeX-latexinfo-node-regexp)
96
97 (TeX-add-symbols
98 '("node"
99 (TeX-arg-literal " ")
100 (TeX-arg-free TeX-arg-define-label "Node name")
101 (TeX-arg-literal ", ")
102 (TeX-arg-free TeX-arg-label "Next node")
103 (TeX-arg-literal ", ")
104 (TeX-arg-free TeX-arg-label "Previous node")
105 (TeX-arg-literal ", ")
106 (TeX-arg-free TeX-arg-label "Up node"))
107 '("setfilename" TeX-arg-file)
108
109 '("var" t)
110 '("dfn" t)
111 '("emph" t)
112 '("kbd" t)
113 '("code" t)
114 '("samp" t)
115 '("key" t)
116 '("ctrl" t)
117 '("file" t)
118
119 '("comment"
120 (TeX-arg-literal " ")
121 (TeX-arg-free "Comment"))
122 '("c"
123 (TeX-arg-literal " ")
124 (TeX-arg-free "Comment"))
125
126 '("cindex" t)
127 '("cpsubindex" 2)
128 '("cpindexbold" t)
129
130 '("newindex" TeX-arg-latexinfo-index)
131
132 '("br" nil)
133 '("w" "Text")
134 '("dots" nil)
135 '("refill" nil)
136 '("bullet" nil)
137 '("copyright" nil)
138 '("sp" nil)
139
140 '("xref" TeX-arg-label)
141 '("pxref" TeX-arg-label)
142 '("inforef"
143 (TeX-arg-literal "{")
144 (TeX-arg-free "Name of node")
145 (TeX-arg-literal ", ")
146 (TeX-arg-free "Name for note")
147 (TeX-arg-literal ", ")
148 (TeX-arg-free TeX-arg-file "Info file")
149 (TeX-arg-literal "}")))
150
151 (LaTeX-add-environments "menu" "tex" "ignore" "ifinfo" "iftex"
152 "example" "same" "display" "format")
153
154 ; Menu's have a special kind of items
155 (make-local-variable 'LaTeX-item-list)
156 (setq LaTeX-item-list (cons '("menu" . LaTeX-item-latexinfo-menu)
157 LaTeX-item-list))
158
159 (make-local-variable 'TeX-font-list)
160 (setq TeX-font-list
161 (list (list ?\C-b (concat TeX-esc "b{") "}")
162 (list ?\C-c (concat TeX-esc "sc{") "}")
163 (list ?\C-e (concat TeX-esc "emph{") "}")
164 (list ?\C-i (concat TeX-esc "i{") "}")
165 (list ?\C-r (concat TeX-esc "r{") "}")
166 (list ?\C-s (concat TeX-esc "samp{") "}")
167 (list ?\C-t (concat TeX-esc "t{") "}")
168 (list ?s (concat TeX-esc "strong{") "}")
169 (list ?\C-f (concat TeX-esc "file{") "}")
170 (list ?\C-d (concat TeX-esc "dfn{") "}")
171 (list ?\C-v (concat TeX-esc "var{") "}")
172 (list ?k (concat TeX-esc "key{") "}")
173 (list ?\C-k (concat TeX-esc "kbd{") "}")
174 (list ?c (concat TeX-esc "code{") "}")
175 (list ?C (concat TeX-esc "cite{") "}")))
176
177 ;; need the following stuff to let xref and pxref work
178 (make-local-variable 'LaTeX-section-label)
179 (setq LaTeX-section-label ""))))
180
181 ;;; latexinfo.el ends here