]> code.delx.au - gnu-emacs-elpa/blob - packages/auctex/plain-tex.el
Don't provide the features auto-loads and preview-latex included in tex-site.
[gnu-emacs-elpa] / packages / auctex / plain-tex.el
1 ;;; plain-tex.el --- Support for plain TeX documents.
2
3 ;; Copyright (C) 2010 Free Software Foundation, Inc.
4
5 ;; Maintainer: auctex-devel@gnu.org
6 ;; Keywords: tex
7
8 ;; This file is part of AUCTeX.
9
10 ;; AUCTeX is free software; you can redistribute it and/or modify it
11 ;; under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
13 ;; any later version.
14
15 ;; AUCTeX is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with AUCTeX; see the file COPYING. If not, write to the Free
22 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 ;; 02110-1301, USA.
24
25 ;;; Commentary:
26
27 ;; This file provides support for plain TeX in AUCTeX.
28
29 ;;; Code:
30
31 (require 'tex)
32 (require 'tex-buf)
33
34 ;;; Tool bar
35
36 (defcustom plain-TeX-enable-toolbar t
37 "Enable TeX tool bar in plain TeX mode."
38 :group 'TeX-tool-bar
39 :type 'boolean)
40
41 (defun plain-TeX-maybe-install-toolbar ()
42 "Conditionally install tool bar buttons for plain TeX mode.
43 Install tool bar if `plain-TeX-enable-toolbar' is non-nil."
44 (when plain-TeX-enable-toolbar
45 ;; Defined in `tex-bar.el':
46 (TeX-install-toolbar)))
47
48
49 ;;; Keymap and menu
50
51 (defvar plain-TeX-mode-map
52 (let ((map (make-sparse-keymap)))
53 (set-keymap-parent map TeX-mode-map)
54 map)
55 "Keymap used in plain TeX mode.")
56
57 (defvar plain-TeX-menu-entries
58 (TeX-menu-with-help
59 `(["Macro..." TeX-insert-macro
60 :help "Insert a macro and possibly arguments"]
61 ["Complete" TeX-complete-symbol
62 :help "Complete the current macro"]
63 "-"
64 ("Insert Font"
65 ["Emphasize" (TeX-font nil ?\C-e) :keys "C-c C-f C-e"]
66 ["Bold" (TeX-font nil ?\C-b) :keys "C-c C-f C-b"]
67 ["Typewriter" (TeX-font nil ?\C-t) :keys "C-c C-f C-t"]
68 ["Small Caps" (TeX-font nil ?\C-c) :keys "C-c C-f C-c"]
69 ["Sans Serif" (TeX-font nil ?\C-f) :keys "C-c C-f C-f"]
70 ["Italic" (TeX-font nil ?\C-i) :keys "C-c C-f C-i"]
71 ["Slanted" (TeX-font nil ?\C-s) :keys "C-c C-f C-s"]
72 ["Roman" (TeX-font nil ?\C-r) :keys "C-c C-f C-r"]
73 ["Calligraphic" (TeX-font nil ?\C-a) :keys "C-c C-f C-a"])
74 ("Replace Font"
75 ["Emphasize" (TeX-font t ?\C-e) :keys "C-u C-c C-f C-e"]
76 ["Bold" (TeX-font t ?\C-b) :keys "C-u C-c C-f C-b"]
77 ["Typewriter" (TeX-font t ?\C-t) :keys "C-u C-c C-f C-t"]
78 ["Small Caps" (TeX-font t ?\C-c) :keys "C-u C-c C-f C-c"]
79 ["Sans Serif" (TeX-font t ?\C-f) :keys "C-u C-c C-f C-f"]
80 ["Italic" (TeX-font t ?\C-i) :keys "C-u C-c C-f C-i"]
81 ["Slanted" (TeX-font t ?\C-s) :keys "C-u C-c C-f C-s"]
82 ["Roman" (TeX-font t ?\C-r) :keys "C-u C-c C-f C-r"]
83 ["Calligraphic" (TeX-font t ?\C-a) :keys "C-u C-c C-f C-a"])
84 ["Delete Font" (TeX-font t ?\C-d) :keys "C-c C-f C-d"]
85 "-"
86 ["Comment or Uncomment Region" TeX-comment-or-uncomment-region
87 :help "Comment or uncomment the currently selected region"]
88 ["Comment or Uncomment Paragraph" TeX-comment-or-uncomment-paragraph
89 :help "Comment or uncomment the paragraph containing point"]
90 ,TeX-fold-menu
91 "-" . ,TeX-common-menu-entries)))
92
93 (easy-menu-define plain-TeX-mode-command-menu
94 plain-TeX-mode-map
95 "Command menu used in TeX mode."
96 (TeX-mode-specific-command-menu 'plain-tex-mode))
97
98 (easy-menu-define plain-TeX-mode-menu
99 plain-TeX-mode-map
100 "Menu used in plain TeX mode."
101 (cons "TeX" plain-TeX-menu-entries))
102
103
104 ;;; The mode
105
106 (defcustom plain-TeX-mode-hook nil
107 "A hook run in plain TeX mode buffers."
108 :type 'hook
109 :group 'TeX-misc)
110
111 (TeX-abbrev-mode-setup plain-tex-mode)
112
113 ;;;###autoload
114 (defun TeX-plain-tex-mode ()
115 "Major mode in AUCTeX for editing plain TeX files.
116 See info under AUCTeX for documentation.
117
118 Special commands:
119 \\{plain-TeX-mode-map}
120
121 Entering `plain-tex-mode' calls the value of `text-mode-hook',
122 then the value of `TeX-mode-hook', and then the value
123 of plain-TeX-mode-hook."
124 (interactive)
125 (plain-TeX-common-initialization)
126 (setq major-mode 'plain-tex-mode)
127 (use-local-map plain-TeX-mode-map)
128 (easy-menu-add plain-TeX-mode-menu plain-TeX-mode-map)
129 (easy-menu-add plain-TeX-mode-command-menu plain-TeX-mode-map)
130 (setq TeX-base-mode-name "TeX")
131 (setq TeX-command-default "TeX")
132 (setq TeX-sentinel-default-function 'TeX-TeX-sentinel)
133 (add-hook 'tool-bar-mode-on-hook 'plain-TeX-maybe-install-toolbar nil t)
134 (when (if (featurep 'xemacs)
135 (featurep 'toolbar)
136 (and (boundp 'tool-bar-mode) tool-bar-mode))
137 (plain-TeX-maybe-install-toolbar))
138 (TeX-run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'plain-TeX-mode-hook)
139 (TeX-set-mode-name))
140
141 (defun plain-TeX-common-initialization ()
142 "Common initialization for plain TeX like modes."
143 (VirTeX-common-initialization)
144 (set-syntax-table TeX-mode-syntax-table)
145 (setq local-abbrev-table latex-mode-abbrev-table)
146 (setq paragraph-start
147 (concat
148 "\\(^[ \t]*$"
149 "\\|" (regexp-quote TeX-esc) "par\\|"
150 "^[ \t]*"
151 (regexp-quote TeX-esc)
152 "\\("
153 "begin\\|end\\|part\\|chapter\\|"
154 "section\\|subsection\\|subsubsection\\|"
155 "paragraph\\|include\\|includeonly\\|"
156 "tableofcontents\\|appendix\\|label\\|caption\\|"
157 "\\[\\|\\]" ; display math delimitors
158 "\\)"
159 "\\|"
160 "^[ \t]*\\$\\$" ; display math delimitor
161 "\\)" ))
162 (setq paragraph-separate
163 (concat
164 "[ \t]*"
165 "\\("
166 (regexp-quote TeX-esc) "par\\|"
167 "%\\|"
168 "$\\|"
169 "\\$\\$\\|"
170 (regexp-quote TeX-esc)
171 "\\("
172 "begin\\|end\\|label\\|caption\\|part\\|chapter\\|"
173 "section\\|subsection\\|subsubsection\\|"
174 "paragraph\\|include\\|includeonly\\|"
175 "tableofcontents\\|appendix\\|" (regexp-quote TeX-esc)
176 "\\)"
177 "\\)"))
178 (setq TeX-header-end (regexp-quote "%**end of header"))
179 (setq TeX-trailer-start (regexp-quote (concat TeX-esc "bye")))
180 (TeX-add-symbols
181 ;; From the TeX Book, Appendix B
182 ;;
183 ;; XXX: This should be refined and extended by somebody who is
184 ;; familiar with plain TeX.
185 "dag"
186 "ddag"
187 "copyright"
188 "TeX"
189 "dots"
190 "break"
191 "nobreak"
192 "allowbreak"
193 "hbox"
194 "slash"
195 "enskip"
196 "quad"
197 "qquad"
198 "enspace"
199 "thinspace"
200 "negthinspace"
201 "smallskip"
202 "medskip"
203 "bigskip"
204 "eject"
205 "supereject"
206 "goodbreak"
207 "filbreak"
208 "smallbreak"
209 "medbreak"
210 "bigbreak"
211 "hrulefill"
212 "dotfill"
213 "rightarrowfill"
214 "leftarrowfill"
215 "upbracefill"
216 "downbracefill"
217 "halign"
218 "valign"
219 "omit"
220 "span"
221 "multispan"
222 "centerline"
223 "rightline"
224 "leftline"
225 "line"
226 "par"
227 "noindent"
228 "frenchspacing"
229 "nonfrenchspacing"
230 "llap"
231 "rlap"
232 "raggedright"
233 "ttraggedright"
234 "raggedbottom"
235 "normalbottom"
236 "obeylines"
237 "obeyspaces"
238 "hsize"
239 "vsize"
240 "hoffset"
241 "voffset"
242 "tolerance"
243 "looseness"
244 "parindent"
245 "baselineskip"
246 "parskip")
247 (TeX-run-style-hooks "TEX"))
248
249
250 ;;; Miscellaneous
251
252 (defcustom plain-TeX-clean-intermediate-suffixes
253 TeX-clean-default-intermediate-suffixes
254 "List of regexps matching suffixes of intermediate files to be deleted.
255 The regexps will be anchored at the end of the file name to be matched,
256 i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
257 :type '(repeat regexp)
258 :group 'TeX-command)
259
260 (defcustom plain-TeX-clean-output-suffixes TeX-clean-default-output-suffixes
261 "List of regexps matching suffixes of output files to be deleted.
262 The regexps will be anchored at the end of the file name to be matched,
263 i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
264 :type '(repeat regexp)
265 :group 'TeX-command)
266
267
268 ;;; AmSTeX
269
270 (defvar AmSTeX-mode-map
271 (let ((map (make-sparse-keymap)))
272 (set-keymap-parent map TeX-mode-map)
273 map)
274 "Keymap used in `AmSTeX-mode'.")
275
276 ;; Menu for AmSTeX mode
277 (easy-menu-define AmSTeX-mode-command-menu
278 AmSTeX-mode-map
279 "Command menu used in AmsTeX mode."
280 (TeX-mode-specific-command-menu 'ams-tex-mode))
281
282 (easy-menu-define AmSTeX-mode-menu
283 AmSTeX-mode-map
284 "Menu used in AMS-TeX mode."
285 (cons "AmS-TeX" plain-TeX-menu-entries))
286
287 ;;;###autoload
288 (defun ams-tex-mode ()
289 "Major mode in AUCTeX for editing AmS-TeX files.
290 See info under AUCTeX for documentation.
291
292 Special commands:
293 \\{AmSTeX-mode-map}
294
295 Entering AmS-tex-mode calls the value of `text-mode-hook',
296 then the value of `TeX-mode-hook', and then the value
297 of `AmS-TeX-mode-hook'."
298 (interactive)
299 (plain-TeX-common-initialization)
300 (setq major-mode 'ams-tex-mode)
301 (use-local-map AmSTeX-mode-map)
302
303 ;; Menu
304 (easy-menu-add AmSTeX-mode-menu AmSTeX-mode-map)
305 (easy-menu-add AmSTeX-mode-command-menu AmSTeX-mode-map)
306
307 (setq TeX-base-mode-name "AmS-TeX")
308 (setq TeX-command-default "AmSTeX")
309 (TeX-run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'AmS-TeX-mode-hook)
310 (TeX-set-mode-name))
311
312 (provide 'plain-tex)
313
314 ;;; plain-tex.el ends here