File: latexinfo.el

package info (click to toggle)
auctex 9.9j-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,248 kB
  • ctags: 767
  • sloc: lisp: 11,580; makefile: 290; sh: 223
file content (183 lines) | stat: -rw-r--r-- 5,687 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
;;; latexinfo.el - Support for LaTeXinfo files.

;; Copyright (C) 1993 Marc Gemis <makke@wins.uia.ac.be>

;; Author: Marc Gemis <makke@wins.uia.ac.be>
;; Version: $Id: latexinfo.el,v 1.5 1994/07/30 05:40:07 amanda Exp $

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; 
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;; 
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

;;; Code:

(require 'latex)

;;; LaTeXinfo mode

(defvar TeX-latexinfo-node-regexp
  '("\\\\node[ \t]+\\([^,\n\r%]+\\)" 1 TeX-auto-label)
  "Matches LaTeXinfo \\node commands, only current node will be found.
We ignore next, previous and up fields.")

(defvar LaTeXinfo-mode nil
  "Non-nil means LaTeXinfo minor mode is active.")
  (make-variable-buffer-local 'LaTeXinfo-mode)

(defvar LaTeXinfo-mode-map nil
  "Keymap containing LaTeXinfo commands.")

(if LaTeXinfo-mode-map
    ()
  (setq LaTeXinfo-mode-map (make-sparse-keymap))
  (define-key LaTeXinfo-mode-map "\C-c\C-u\C-b" 'latexinfo-format-buffer)
  (define-key LaTeXinfo-mode-map "\C-c\C-u\C-r" 'latexinfo-format-region)
  (define-key LaTeXinfo-mode-map "\C-c\C-u\C-s" 'latexinfo-show-structure)
  (define-key LaTeXinfo-mode-map "\C-c\C-ud" 'makke:latexinfo-delete-structure)
  (define-key LaTeXinfo-mode-map "\C-c\C-ug" 'latexinfo-goto-node)
  (define-key LaTeXinfo-mode-map "\C-c\C-ui" 'makke:latexinfo-structure))

(or (assq 'LaTeXinfo-mode minor-mode-map-alist)
    (setq minor-mode-map-alist
	  (cons (cons 'LaTeXinfo-mode LaTeXinfo-mode-map)
		minor-mode-map-alist)))

(defun TeX-arg-latexinfo-index (optional &optional prompt)
  "Prompt for a LaTeXinfo index type with completion."
  (TeX-argument-insert
   (completing-read (TeX-argument-prompt optional prompt "Index")
		    '(("cp") ("vr") ("fn") ("tp") ("pg") ("ky"))
		    nil t)
   optional))

(defun LaTeX-item-latexinfo-menu ()
  "Insert a new menu item"
  (insert "* ::")
  (backward-char 2))

(defun latexinfo-goto-node () ; temporarily here, later in latexinfo-upd.el ??
  "Place pointer on the node given by the user, read node with completion
This fails when the user types in the label of something else"
  (interactive)
  (let ((node-name (completing-read "Goto Node: " (LaTeX-label-list))))
    (goto-char (point-min))
    (if (re-search-forward
	 (concat
	  TeX-esc "node[ \\t]+" node-name ","
	  "\\|"
	  TeX-esc "label{" LaTeX-section-label node-name
	  "\\|"
	  TeX-esc "label{" node-name
	  )
	 (point-max) t)
	(beginning-of-line 1)
    (error "No such node"))))

;;; Hook

(TeX-add-style-hook "latexinfo"
 (function
  (lambda ()
    (require 'latexinfo)
    (require 'latexinfo-structure)

    (require 'min-map)
    (setq LaTeXinfo-mode t)
    
    (TeX-auto-add-regexp TeX-latexinfo-node-regexp)

    (TeX-add-symbols
     '("node"
       (TeX-arg-literal " ")
       (TeX-arg-free TeX-arg-define-label "Node name")
       (TeX-arg-literal ", ")
       (TeX-arg-free TeX-arg-label "Next node")
       (TeX-arg-literal ", ")
       (TeX-arg-free TeX-arg-label "Previous node")
       (TeX-arg-literal ", ")
       (TeX-arg-free TeX-arg-label "Up node"))
     '("setfilename" TeX-arg-file)

     '("var" t)
     '("dfn" t)
     '("emph" t)
     '("kbd" t)
     '("code" t)
     '("samp" t)
     '("key" t)
     '("ctrl" t)
     '("file" t)

     '("comment"
       (TeX-arg-literal " ")
       (TeX-arg-free "Comment"))
     '("c"
       (TeX-arg-literal " ")
       (TeX-arg-free "Comment"))

     '("cindex" t)
     '("cpsubindex" 2)
     '("cpindexbold" t)

     '("newindex" TeX-arg-latexinfo-index)

     '("br" nil)
     '("w" "Text")
     '("dots" nil)
     '("refill" nil)
     '("bullet" nil)
     '("copyright" nil)
     '("sp" nil)

     '("xref" TeX-arg-label)
     '("pxref" TeX-arg-label)
     '("inforef"
       (TeX-arg-literal "{")
       (TeX-arg-free "Name of node")
       (TeX-arg-literal ", ")
       (TeX-arg-free "Name for note")
       (TeX-arg-literal ", ")
       (TeX-arg-free TeX-arg-file "Info file")
       (TeX-arg-literal "}")))

    (LaTeX-add-environments "menu" "tex" "ignore" "ifinfo" "iftex"
			    "example" "same" "display" "format")

    ; Menu's have a special kind of items
    (make-local-variable 'LaTeX-item-list)
    (setq LaTeX-item-list (cons '("menu" . LaTeX-item-latexinfo-menu)
				LaTeX-item-list))

    (make-local-variable 'TeX-font-list)
    (setq TeX-font-list
	  (list (list ?\C-b (concat TeX-esc "b{") "}")
		(list ?\C-c (concat TeX-esc "sc{") "}")
		(list ?\C-e (concat TeX-esc "emph{") "}")
		(list ?\C-i (concat TeX-esc "i{") "}")
		(list ?\C-r (concat TeX-esc "r{") "}")
		(list ?\C-s (concat TeX-esc "samp{") "}")
		(list ?\C-t (concat TeX-esc "t{") "}")
		(list ?s    (concat TeX-esc "strong{") "}")
		(list ?\C-f (concat TeX-esc "file{") "}")
		(list ?\C-d (concat TeX-esc "dfn{") "}")
		(list ?\C-v (concat TeX-esc "var{") "}")
		(list ?k    (concat TeX-esc "key{") "}")
		(list ?\C-k (concat TeX-esc "kbd{") "}")
		(list ?c    (concat TeX-esc "code{") "}")
		(list ?C    (concat TeX-esc "cite{") "}")))

    ;; need the following stuff to let xref and pxref work
    (make-local-variable 'LaTeX-section-label)
    (setq LaTeX-section-label ""))))

;;; latexinfo.el ends here