Mercurial > emacs
annotate lisp/textmodes/makeinfo.el @ 3952:f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
New arg TITLE.
(describe_buffer_bindings): Corresponding changes.
(shadow_lookup): New function.
(describe_map_2): Call it. SHADOW is now a list of maps.
(describe_vector): Likewise.
(describe_map): SHADOW is now a list of maps.
(describe_map_tree): Likewise.
(describe_buffer_bindings): Build suitable list to pass as SHADOW.
(Faccessible_keymaps): New arg PREFIX. Callers changed.
(describe_map_tree): New arg PREFIX.
(Fdescribe_bindings): New arg PREFIX.
Pass to describe_buffer_bindings along with buffer.
(describe_buffer_bindings): Extract PREFIX and pass along.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 02 Jul 1993 05:21:05 +0000 |
parents | ef8b4ed0de91 |
children | f1c57e8c8bde |
rev | line source |
---|---|
3856 | 1 ;;;; makeinfo.el -- run makeinfo conveniently. |
2 ;;; Copyright (C) 1991, 1993 Free Software Foundation, Inc. | |
3 | |
4 ;;; Author: Robert J. Chassell | |
5 ;;; Maintainer: FSF | |
6 | |
7 ;;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs 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 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs 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 GNU Emacs; see the file COPYING. If not, write to | |
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
22 | |
23 ;;; Commentary: | |
24 | |
25 ;;; The Texinfo mode `makeinfo' related commands are: | |
26 | |
27 ;; makeinfo-region to run makeinfo on the current region. | |
28 ;; makeinfo-buffer to run makeinfo on the current buffer, or | |
29 ;; with optional prefix arg, on current region | |
30 ;; kill-compilation to kill currently running makeinfo job | |
31 ;; makeinfo-recenter-makeinfo-buffer to redisplay *compilation* buffer | |
32 | |
33 ;;; Keybindings (defined in `texinfo.el') | |
34 | |
35 ;; makeinfo bindings | |
36 ; (define-key texinfo-mode-map "\C-c\C-m\C-r" 'makeinfo-region) | |
37 ; (define-key texinfo-mode-map "\C-c\C-m\C-b" 'makeinfo-buffer) | |
38 ; (define-key texinfo-mode-map "\C-c\C-m\C-k" 'kill-compilation) | |
39 ; (define-key texinfo-mode-map "\C-c\C-m\C-l" | |
40 ; 'makeinfo-recenter-compilation-buffer) | |
41 | |
42 ;;; Code: | |
43 | |
44 ;;; Variables used by `makeinfo' | |
45 | |
46 (require 'compile) | |
47 | |
48 (defvar makeinfo-run-command "makeinfo" | |
49 "*Command used to run `makeinfo' subjob. | |
50 The name of the file is appended to this string, separated by a space.") | |
51 | |
52 (defvar makeinfo-options "+fill-column=70" | |
53 "*String containing options for running `makeinfo'. | |
54 Do not include `--footnote-style' or `--paragraph-indent'; | |
55 the proper way to specify those is with the Texinfo commands | |
56 `@footnotestyle` and `@paragraphindent'.") | |
57 | |
58 (require 'texinfo) | |
59 (require 'texinfmt) | |
60 | |
61 (defvar makeinfo-compilation-process nil | |
62 "Process that runs `makeinfo'. Should start out nil.") | |
63 | |
64 (defvar makeinfo-temp-file nil | |
65 "Temporary file name used for text being sent as input to `makeinfo'.") | |
66 | |
67 (defvar makeinfo-output-file-name nil | |
68 "Info file name used for text output by `makeinfo'.") | |
69 | |
70 | |
71 ;;; The `makeinfo' function definitions | |
72 | |
73 (defun makeinfo-region (region-beginning region-end) | |
74 "Make Info file from region of current Texinfo file, and switch to it. | |
75 | |
76 This command does not offer the `next-error' feature since it would | |
77 apply to a temporary file, not the original; use the `makeinfo-buffer' | |
78 command to gain use of `next-error'." | |
79 | |
80 (interactive "r") | |
81 (let (filename-or-header | |
82 filename-or-header-beginning | |
83 filename-or-header-end) | |
84 ;; Cannot use `let' for makeinfo-temp-file or | |
85 ;; makeinfo-output-file-name since `makeinfo-compilation-sentinel' | |
86 ;; needs them. | |
87 | |
88 (setq makeinfo-temp-file | |
89 (concat | |
90 (make-temp-name | |
91 (substring (buffer-file-name) | |
92 0 | |
93 (or (string-match "\\.tex" (buffer-file-name)) | |
94 (length (buffer-file-name))))) | |
95 ".texinfo")) | |
96 | |
97 (save-excursion | |
98 (save-restriction | |
99 (widen) | |
100 (goto-char (point-min)) | |
101 (let ((search-end (save-excursion (forward-line 100) (point)))) | |
102 ;; Find and record the Info filename, | |
103 ;; or else explain that a filename is needed. | |
104 (if (re-search-forward | |
105 "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" | |
106 search-end t) | |
107 (setq makeinfo-output-file-name | |
108 (buffer-substring (match-beginning 1) (match-end 1))) | |
109 (error | |
110 "The texinfo file needs a line saying: @setfilename <name>")) | |
111 | |
112 ;; Find header and specify its beginning and end. | |
113 (goto-char (point-min)) | |
114 (if (and | |
115 (prog1 | |
116 (search-forward texinfo-start-of-header search-end t) | |
117 (beginning-of-line) | |
118 ;; Mark beginning of header. | |
119 (setq filename-or-header-beginning (point))) | |
120 (prog1 | |
121 (search-forward texinfo-end-of-header nil t) | |
122 (beginning-of-line) | |
123 ;; Mark end of header | |
124 (setq filename-or-header-end (point)))) | |
125 | |
126 ;; Insert the header into the temporary file. | |
127 (write-region | |
128 (min filename-or-header-beginning region-beginning) | |
129 filename-or-header-end | |
130 makeinfo-temp-file nil nil) | |
131 | |
132 ;; Else no header; insert @filename line into temporary file. | |
133 (goto-char (point-min)) | |
134 (search-forward "@setfilename" search-end t) | |
135 (beginning-of-line) | |
136 (setq filename-or-header-beginning (point)) | |
137 (forward-line 1) | |
138 (setq filename-or-header-end (point)) | |
139 (write-region | |
140 (min filename-or-header-beginning region-beginning) | |
141 filename-or-header-end | |
142 makeinfo-temp-file nil nil)) | |
143 | |
144 ;; Insert the region into the file. | |
145 (write-region | |
146 (max region-beginning filename-or-header-end) | |
147 region-end | |
148 makeinfo-temp-file t nil) | |
149 | |
150 ;; Run the `makeinfo-compile' command in the *compilation* buffer | |
151 (save-excursion | |
152 (makeinfo-compile | |
153 (concat makeinfo-run-command | |
154 " " | |
155 makeinfo-options | |
156 " " | |
157 makeinfo-temp-file) | |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
158 "Use `makeinfo-buffer' to gain use of the `next-error' command" |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
159 nil))))))) |
3856 | 160 |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
161 ;;; Actually run makeinfo. COMMAND is the command to run. |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
162 ;;; ERROR-MESSAGE is what to say when next-error can't find another error. |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
163 ;;; If PARSE-ERRORS is non-nil, do try to parse error messages. |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
164 (defun makeinfo-compile (command error-message parse-errors) |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
165 (let ((buffer |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
166 (compile-internal command error-message nil |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
167 (and (not parse-errors) |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
168 ;; If we do want to parse errors, pass nil. |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
169 ;; Otherwise, use this function, which won't |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
170 ;; ever find any errors. |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
171 '(lambda (&rest ignore) |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
172 (setq compilation-error-list nil)))))) |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
173 (set-process-sentinel (get-buffer-process buffer) |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
174 'makeinfo-compilation-sentinel))) |
3856 | 175 |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
176 ;; Delete makeinfo-temp-file after processing is finished, |
3856 | 177 ;; and visit Info file. |
178 ;; This function is called when the compilation process changes state. | |
179 ;; Based on `compilation-sentinel' in compile.el | |
180 (defun makeinfo-compilation-sentinel (proc msg) | |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
181 (compilation-sentinel proc msg) |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
182 (if (and makeinfo-temp-file (file-exists-p makeinfo-temp-file)) |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
183 (delete-file makeinfo-temp-file)) |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
184 ;; Always use the version on disk. |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
185 (if (get-file-buffer makeinfo-output-file-name) |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
186 (progn (set-buffer makeinfo-output-file-name) |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
187 (revert-buffer t t)) |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
188 (find-file makeinfo-output-file-name)) |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
189 (goto-char (point-min))) |
3856 | 190 |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
191 (defun makeinfo-buffer () |
3856 | 192 "Make Info file from current buffer. |
193 | |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
194 Use the \\[next-error] command to move to the next error |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
195 \(if there are errors\)." |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
196 |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
197 (interactive) |
3856 | 198 (cond ((null buffer-file-name) |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
199 (error "Buffer not visiting any file")) |
3856 | 200 ((buffer-modified-p) |
201 (if (y-or-n-p "Buffer modified; do you want to save it? ") | |
202 (save-buffer)))) | |
203 | |
204 ;; Find and record the Info filename, | |
205 ;; or else explain that a filename is needed. | |
206 (save-excursion | |
207 (goto-char (point-min)) | |
208 (let ((search-end (save-excursion (forward-line 100) (point)))) | |
209 (if (re-search-forward | |
210 "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" | |
211 search-end t) | |
212 (setq makeinfo-output-file-name | |
213 (buffer-substring (match-beginning 1) (match-end 1))) | |
214 (error | |
215 "The texinfo file needs a line saying: @setfilename <name>")))) | |
216 | |
217 (save-excursion | |
218 (makeinfo-compile | |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
219 (concat makeinfo-run-command " " makeinfo-options |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
220 " " buffer-file-name) |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
221 "No more errors." |
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
222 t))) |
3856 | 223 |
224 (defun makeinfo-recenter-compilation-buffer (linenum) | |
225 "Redisplay `*compilation*' buffer so most recent output can be seen. | |
226 The last line of the buffer is displayed on | |
227 line LINE of the window, or centered if LINE is nil." | |
228 (interactive "P") | |
229 (let ((makeinfo-buffer (get-buffer "*compilation*")) | |
230 (old-buffer (current-buffer))) | |
231 (if (null makeinfo-buffer) | |
232 (message "No *compilation* buffer") | |
233 (pop-to-buffer makeinfo-buffer) | |
234 (bury-buffer makeinfo-buffer) | |
235 (goto-char (point-max)) | |
236 (recenter (if linenum | |
237 (prefix-numeric-value linenum) | |
238 (/ (window-height) 2))) | |
239 (pop-to-buffer old-buffer) | |
240 ))) | |
241 | |
242 ;;; Place `provide' at end of file. | |
243 (provide 'makeinfo) | |
244 | |
245 ;;; makeinfo.el ends here | |
246 |