24
|
1 ;;; auc-old.el - Compatibility with AUC TeX 6.*
|
|
2 ;;
|
|
3 ;; Maintainer: Per Abrahamsen <auc-tex@sunsite.auc.dk>
|
|
4 ;; Version: 9.7i
|
|
5 ;;
|
|
6 ;; Copyright (C) 1991 Kresten Krab Thorup
|
|
7 ;; Copyright (C) 1993 Per Abrahamsen
|
|
8 ;;
|
|
9 ;; This program is free software; you can redistribute it and/or modify
|
|
10 ;; it under the terms of the GNU General Public License as published by
|
|
11 ;; the Free Software Foundation; either version 1, or (at your option)
|
|
12 ;; any later version.
|
|
13 ;;
|
|
14 ;; This program is distributed in the hope that it will be useful,
|
|
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 ;; GNU General Public License for more details.
|
|
18 ;;
|
|
19 ;; You should have received a copy of the GNU General Public License
|
|
20 ;; along with this program; if not, write to the Free Software
|
|
21 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
22
|
|
23 ;;; Commentary:
|
|
24
|
|
25 ;; This file contains an alternative keymapping, compatible with
|
|
26 ;; older versions of AUC TeX. You are strongly suggested to try the
|
|
27 ;; new keyboard layout, as we would like this file to go away
|
|
28 ;; eventually.
|
|
29
|
|
30 ;;; Code:
|
|
31
|
|
32 (require 'latex)
|
|
33
|
|
34 ;;; Keymaps
|
|
35
|
|
36 (defun TeX-define-key (key value)
|
|
37 "OBSOLETE: Define KEY to VALUE in TeX and LaTeX mode."
|
|
38 (define-key plain-TeX-mode-map key value)
|
|
39 (define-key LaTeX-mode-map key value))
|
|
40
|
|
41 (TeX-define-key "\n" 'TeX-terminate-paragraph)
|
|
42 (TeX-define-key "\e}" 'up-list)
|
|
43 (TeX-define-key "\e{" 'TeX-insert-braces)
|
|
44 (TeX-define-key "\C-c\C-b" 'TeX-bold)
|
|
45 (TeX-define-key "\C-c\C-i" 'TeX-italic)
|
|
46 (TeX-define-key "\C-c\C-s" 'TeX-slanted)
|
|
47 (TeX-define-key "\C-c\C-r" 'TeX-roman)
|
|
48 (TeX-define-key "\C-c\C-e" 'TeX-emphasize)
|
|
49 (TeX-define-key "\C-c\C-t" 'TeX-typewriter)
|
|
50 (TeX-define-key "\C-c\C-y" 'TeX-small-caps)
|
|
51 (TeX-define-key "\C-c\C-d" 'TeX-region)
|
|
52 (TeX-define-key "\C-c\C-a" 'TeX-buffer)
|
|
53 (TeX-define-key "\C-c\C-p" 'TeX-preview)
|
|
54 (TeX-define-key "\C-c\C-n" 'TeX-next-error)
|
|
55 (TeX-define-key "\C-c!" 'TeX-print)
|
|
56 (TeX-define-key "\e\t" 'TeX-complete-symbol)
|
|
57 (TeX-define-key "\C-c$" 'TeX-run-lacheck)
|
|
58
|
|
59 (define-key LaTeX-mode-map "\C-c\n" 'TeX-terminate-paragraph)
|
|
60 (define-key LaTeX-mode-map "\C-c\C-x" 'LaTeX-section)
|
|
61 (define-key LaTeX-mode-map "\C-c\C-c" 'LaTeX-environment)
|
|
62 (define-key LaTeX-mode-map "\C-c@" 'LaTeX-bibtex)
|
|
63 (define-key LaTeX-mode-map "\C-c#" 'LaTeX-makeindex)
|
|
64 (define-key LaTeX-mode-map "\em" 'LaTeX-math-mode)
|
|
65 (define-key LaTeX-mode-map "\es" 'LaTeX-fill-section)
|
|
66 (define-key LaTeX-mode-map "\e\C-e" 'LaTeX-mark-environment)
|
|
67 (define-key LaTeX-mode-map "\e\C-x" 'LaTeX-mark-section)
|
|
68 (define-key LaTeX-mode-map "\e\C-q" 'LaTeX-fill-environment)
|
|
69
|
|
70 ;;; Buffer
|
|
71
|
|
72 (defun TeX-region (begin end)
|
|
73 "OBSOLETE: Run TeX-command-default on current region."
|
|
74 (interactive "r")
|
|
75 (require 'tex-buf)
|
|
76 (setq TeX-current-process-region-p t)
|
|
77 (if (nth 4 (assoc TeX-command-default TeX-command-list))
|
|
78 (TeX-region-create (TeX-region-file "tex")
|
|
79 (buffer-substring begin end)
|
|
80 (file-name-nondirectory (buffer-file-name))
|
|
81 (count-lines (point-min) begin)))
|
|
82 (TeX-command TeX-command-default 'TeX-region-file))
|
|
83
|
|
84 (defun TeX-buffer ()
|
|
85 "OBSOLETE: Run TeX-command-default on the current document."
|
|
86 (interactive)
|
|
87 (save-some-buffers) ; added for compatibility reasons
|
|
88 (require 'tex-buf)
|
|
89 (setq TeX-current-process-region-p nil)
|
|
90 (TeX-command TeX-command-default 'TeX-master-file))
|
|
91
|
|
92 (defun TeX-old-command (name)
|
|
93 "OBSOLETE: Run command NAME on either the current document or region."
|
|
94 (require 'tex-buf)
|
|
95 (if TeX-current-process-region-p
|
|
96 (TeX-command name 'TeX-region-file)
|
|
97 (TeX-command name 'TeX-master-file)))
|
|
98
|
|
99 (defun TeX-preview ()
|
|
100 "OBSOLETE: Run View command on either the current document or region."
|
|
101 (interactive)
|
|
102 (TeX-old-command "View"))
|
|
103
|
|
104 (defun TeX-print ()
|
|
105 "OBSOLETE: Run Print command on either the current document or region."
|
|
106 (interactive)
|
|
107 (TeX-old-command "Print"))
|
|
108
|
|
109 (defun TeX-run-lacheck()
|
|
110 "OBSOLETE: Run lacheck command on either the current document or region."
|
|
111 (interactive)
|
|
112 (TeX-old-command "Check"))
|
|
113
|
|
114 (defun LaTeX-bibtex ()
|
|
115 "OBSOLETE: Run BibTeX command on either the current document or region."
|
|
116 (interactive)
|
|
117 (TeX-old-command TeX-command-BibTeX))
|
|
118
|
|
119 (defun LaTeX-makeindex ()
|
|
120 "OBSOLETE: Run Index command on either the current document or region."
|
|
121 (interactive)
|
|
122 (TeX-old-command "Index"))
|
|
123
|
|
124 ;;; Fonts
|
|
125
|
|
126 (defun TeX-bold ()
|
|
127 (interactive "*")
|
|
128 (insert TeX-grop TeX-esc "bf " TeX-grcl)
|
|
129 (backward-char 1))
|
|
130
|
|
131 (defun TeX-italic ()
|
|
132 (interactive "*")
|
|
133 (insert TeX-grop TeX-esc "it " TeX-esc "/" TeX-grcl)
|
|
134 (backward-char 3))
|
|
135
|
|
136 (defun TeX-slanted ()
|
|
137 (interactive "*")
|
|
138 (insert TeX-grop TeX-esc "sl " TeX-esc "/" TeX-grcl)
|
|
139 (backward-char 3))
|
|
140
|
|
141 (defun TeX-roman ()
|
|
142 (interactive "*")
|
|
143 (insert TeX-grop TeX-esc "rm " TeX-grcl)
|
|
144 (backward-char 1))
|
|
145
|
|
146 (defun TeX-emphasize ()
|
|
147 (interactive "*")
|
|
148 (insert TeX-grop TeX-esc "em " TeX-esc "/" TeX-grcl)
|
|
149 (backward-char 3))
|
|
150
|
|
151 (defun TeX-typewriter ()
|
|
152 (interactive "*")
|
|
153 (insert TeX-grop TeX-esc "tt " TeX-grcl)
|
|
154 (backward-char 1))
|
|
155
|
|
156 (defun TeX-small-caps ()
|
|
157 (interactive "*")
|
|
158 (insert TeX-grop TeX-esc "sc " TeX-grcl)
|
|
159 (backward-char 1))
|
|
160
|
|
161 ;;; AUC (La)TeX Mode
|
|
162 ;;
|
|
163 ;; Added by marsj@ida.liu.se Thu Mar 5 17:52:38 1992 to support
|
|
164 ;; automatic mode change after using insert-mode-line hook. Also
|
|
165 ;; modified regexp to choose tex mode to be more aware of latex
|
|
166 ;; (documentstyle is uniq, isn'it)
|
|
167
|
|
168 (defun insert-mode-line ()
|
|
169 "This little macro inserts `% -*- mode-name -*-' if not present.
|
|
170 You should insert this in your TeX-mode-hook!"
|
|
171 (interactive "*")
|
|
172 (save-excursion
|
|
173 (goto-char (point-min))
|
|
174 (if (not (re-search-forward "-\\*-.*-\\*-" 100 t))
|
|
175 (insert-string (concat "% -*- "
|
|
176 (substring (symbol-name major-mode) 0 -5)
|
|
177 " -*-\n")))))
|
|
178
|
|
179 (defun auc-tex-mode ()
|
|
180 "Called when we have a mode line specification in first line."
|
|
181 (interactive)
|
|
182 (plain-tex-mode))
|
|
183
|
|
184 (defun auc-latex-mode ()
|
|
185 "Called when we have a mode line specification in first line."
|
|
186 (interactive)
|
|
187 (latex-mode))
|
|
188
|
|
189 ;;; Validation
|
|
190
|
|
191 (defun TeX-validate-buffer ()
|
|
192 "Check current buffer for paragraphs containing mismatched $'s.
|
|
193 As each such paragraph is found, a mark is pushed at its beginning,
|
|
194 and the location is displayed for a few seconds."
|
|
195 (interactive)
|
|
196 (let ((opoint (point)))
|
|
197 (goto-char (point-max))
|
|
198 ;; Does not use save-excursion
|
|
199 ;; because we do not want to save the mark.
|
|
200 (unwind-protect
|
|
201 (while (and (not (input-pending-p)) (not (bobp)))
|
|
202 (let ((end (point)))
|
|
203 (search-backward "\n\n" nil 'move)
|
|
204 (or (TeX-validate-paragraph (point) end)
|
|
205 (progn
|
|
206 (push-mark (point))
|
|
207 (message "Mismatch found in pararaph starting here")
|
|
208 (sit-for 4)))))
|
|
209 (goto-char opoint))))
|
|
210
|
|
211 (defun TeX-validate-paragraph (start end)
|
|
212 (condition-case ()
|
|
213 (save-excursion
|
|
214 (save-restriction
|
|
215 (narrow-to-region start end)
|
|
216 (goto-char start)
|
|
217 (forward-sexp (- end start))
|
|
218 t))
|
|
219 (error nil)))
|
|
220
|
|
221 (defun TeX-terminate-paragraph (inhibit-validation)
|
|
222 "Insert two newlines, breaking a paragraph for TeX.
|
|
223 Check for mismatched braces/$'s in paragraph being terminated.
|
|
224 A prefix arg inhibits the checking."
|
|
225 (interactive "*P")
|
|
226 (or inhibit-validation
|
|
227 (TeX-validate-paragraph
|
|
228 (save-excursion
|
|
229 (search-backward "\n\n" nil 'move)
|
|
230 (point))
|
|
231 (point))
|
|
232 (message "Paragraph being closed appears to contain a mismatch"))
|
|
233 (reindent-then-newline-and-indent)
|
|
234 (newline-and-indent))
|
|
235
|
|
236 ;;; Miscellaneous
|
|
237
|
|
238 (defun TeX-cmd-on-region (begin end command)
|
|
239 "Reads a (La)TeX-command. Makes current region a TeX-group.
|
|
240 Inserts command at the start of the group."
|
|
241 (interactive "*r\ns(La)TeX-command on region: ")
|
|
242 (save-excursion
|
|
243 (goto-char end) (insert TeX-grcl)
|
|
244 (goto-char begin) (insert TeX-grop TeX-esc command " ")))
|
|
245
|
|
246 (provide 'auc-old)
|
|
247 (provide 'auc-tex)
|
|
248
|
|
249 ;;; auc-old.el ends here
|