1 ;;; plain-tex.el --- Support for plain TeX documents.
3 ;; Copyright (C) 2010 Free Software Foundation, Inc.
5 ;; Maintainer: auctex-devel@gnu.org
8 ;; This file is part of AUCTeX.
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)
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.
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
27 ;; This file provides support for plain TeX in AUCTeX.
36 (defcustom plain-TeX-enable-toolbar t
37 "Enable TeX tool bar in plain TeX mode."
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)))
51 (defvar plain-TeX-mode-map
52 (let ((map (make-sparse-keymap)))
53 (set-keymap-parent map TeX-mode-map)
55 "Keymap used in plain TeX mode.")
57 (defvar plain-TeX-menu-entries
59 `(["Macro..." TeX-insert-macro
60 :help "Insert a macro and possibly arguments"]
61 ["Complete" TeX-complete-symbol
62 :help "Complete the current macro"]
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"])
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"]
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"]
91 "-" . ,TeX-common-menu-entries)))
93 (easy-menu-define plain-TeX-mode-command-menu
95 "Command menu used in TeX mode."
96 (TeX-mode-specific-command-menu 'plain-tex-mode))
98 (easy-menu-define plain-TeX-mode-menu
100 "Menu used in plain TeX mode."
101 (cons "TeX" plain-TeX-menu-entries))
106 (defcustom plain-TeX-mode-hook nil
107 "A hook run in plain TeX mode buffers."
111 (TeX-abbrev-mode-setup plain-tex-mode)
114 (defun TeX-plain-tex-mode ()
115 "Major mode in AUCTeX for editing plain TeX files.
116 See info under AUCTeX for documentation.
119 \\{plain-TeX-mode-map}
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."
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)
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)
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
149 "\\|" (regexp-quote TeX-esc) "par\\|"
151 (regexp-quote TeX-esc)
153 "begin\\|end\\|part\\|chapter\\|"
154 "section\\|subsection\\|subsubsection\\|"
155 "paragraph\\|include\\|includeonly\\|"
156 "tableofcontents\\|appendix\\|label\\|caption\\|"
157 "\\[\\|\\]" ; display math delimitors
160 "^[ \t]*\\$\\$" ; display math delimitor
162 (setq paragraph-separate
166 (regexp-quote TeX-esc) "par\\|"
170 (regexp-quote TeX-esc)
172 "begin\\|end\\|label\\|caption\\|part\\|chapter\\|"
173 "section\\|subsection\\|subsubsection\\|"
174 "paragraph\\|include\\|includeonly\\|"
175 "tableofcontents\\|appendix\\|" (regexp-quote TeX-esc)
178 (setq TeX-header-end (regexp-quote "%**end of header"))
179 (setq TeX-trailer-start (regexp-quote (concat TeX-esc "bye")))
181 ;; From the TeX Book, Appendix B
183 ;; XXX: This should be refined and extended by somebody who is
184 ;; familiar with plain TeX.
247 (TeX-run-style-hooks "TEX"))
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)
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)
270 (defvar AmSTeX-mode-map
271 (let ((map (make-sparse-keymap)))
272 (set-keymap-parent map TeX-mode-map)
274 "Keymap used in `AmSTeX-mode'.")
276 ;; Menu for AmSTeX mode
277 (easy-menu-define AmSTeX-mode-command-menu
279 "Command menu used in AmsTeX mode."
280 (TeX-mode-specific-command-menu 'ams-tex-mode))
282 (easy-menu-define AmSTeX-mode-menu
284 "Menu used in AMS-TeX mode."
285 (cons "AmS-TeX" plain-TeX-menu-entries))
288 (defun ams-tex-mode ()
289 "Major mode in AUCTeX for editing AmS-TeX files.
290 See info under AUCTeX for documentation.
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'."
299 (plain-TeX-common-initialization)
300 (setq major-mode 'ams-tex-mode)
301 (use-local-map AmSTeX-mode-map)
304 (easy-menu-add AmSTeX-mode-menu AmSTeX-mode-map)
305 (easy-menu-add AmSTeX-mode-command-menu AmSTeX-mode-map)
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)
314 ;;; plain-tex.el ends here