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>
6 ;; Version: $Id: latexinfo.el,v 1.7 2008/02/03 14:53:30 angeli Exp $
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)
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.
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.
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.")
31 (defvar LaTeXinfo-mode nil
32 "Non-nil means LaTeXinfo minor mode is active.")
33 (make-variable-buffer-local 'LaTeXinfo-mode)
35 (defvar LaTeXinfo-mode-map nil
36 "Keymap containing LaTeXinfo commands.")
38 (if LaTeXinfo-mode-map
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))
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)))
53 (defun TeX-arg-latexinfo-index (optional &optional prompt)
54 "Prompt for a LaTeXinfo index type with completion."
56 (completing-read (TeX-argument-prompt optional prompt "Index")
57 '(("cp") ("vr") ("fn") ("tp") ("pg") ("ky"))
61 (defun LaTeX-item-latexinfo-menu ()
62 "Insert a new menu item"
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"
70 (let ((node-name (completing-read "Goto Node: " (LaTeX-label-list))))
71 (goto-char (point-min))
72 (if (re-search-forward
74 TeX-esc "node[ \\t]+" node-name ","
76 TeX-esc "label{" LaTeX-section-label node-name
78 TeX-esc "label{" node-name
82 (error "No such node"))))
86 (TeX-add-style-hook "latexinfo"
90 (require 'latexinfo-structure)
93 (setq LaTeXinfo-mode t)
95 (TeX-auto-add-regexp TeX-latexinfo-node-regexp)
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)
120 (TeX-arg-literal " ")
121 (TeX-arg-free "Comment"))
123 (TeX-arg-literal " ")
124 (TeX-arg-free "Comment"))
130 '("newindex" TeX-arg-latexinfo-index)
140 '("xref" TeX-arg-label)
141 '("pxref" TeX-arg-label)
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 "}")))
151 (LaTeX-add-environments "menu" "tex" "ignore" "ifinfo" "iftex"
152 "example" "same" "display" "format")
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)
159 (make-local-variable '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{") "}")))
177 ;; need the following stuff to let xref and pxref work
178 (make-local-variable 'LaTeX-section-label)
179 (setq LaTeX-section-label ""))))
181 ;;; latexinfo.el ends here