Mercurial > emacs
annotate lisp/textmodes/makeinfo.el @ 107034:e7ffcc22ed5f
Add bug number to recent change.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Thu, 28 Jan 2010 21:09:25 +0800 |
parents | 1d1d5d9bd884 |
children | 7c4da622f181 376148b31b5e |
rev | line source |
---|---|
13337 | 1 ;;; makeinfo.el --- run makeinfo conveniently |
2 | |
74509 | 3 ;; Copyright (C) 1991, 1993, 2001, 2002, 2003, 2004, |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
3856 | 5 |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
6 ;; Author: Robert J. Chassell |
13337 | 7 ;; Maintainer: FSF |
38697
a19197c6442f
Keyword added and FSF specified as Maintainer.
Pavel Janík <Pavel@Janik.cz>
parents:
38412
diff
changeset
|
8 ;; Keywords: docs convenience |
3856 | 9 |
13337 | 10 ;; This file is part of GNU Emacs. |
3856 | 11 |
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
3856 | 13 ;; it under the terms of the GNU General Public License as published by |
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; (at your option) any later version. |
3856 | 16 |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
3856 | 24 |
25 ;;; Commentary: | |
26 | |
27 ;;; The Texinfo mode `makeinfo' related commands are: | |
28 | |
29 ;; makeinfo-region to run makeinfo on the current region. | |
30 ;; makeinfo-buffer to run makeinfo on the current buffer, or | |
31 ;; with optional prefix arg, on current region | |
32 ;; kill-compilation to kill currently running makeinfo job | |
33 ;; makeinfo-recenter-makeinfo-buffer to redisplay *compilation* buffer | |
34 | |
35 ;;; Keybindings (defined in `texinfo.el') | |
36 | |
37 ;; makeinfo bindings | |
38 ; (define-key texinfo-mode-map "\C-c\C-m\C-r" 'makeinfo-region) | |
39 ; (define-key texinfo-mode-map "\C-c\C-m\C-b" 'makeinfo-buffer) | |
40 ; (define-key texinfo-mode-map "\C-c\C-m\C-k" 'kill-compilation) | |
41 ; (define-key texinfo-mode-map "\C-c\C-m\C-l" | |
42 ; 'makeinfo-recenter-compilation-buffer) | |
43 | |
44 ;;; Code: | |
45 | |
46 ;;; Variables used by `makeinfo' | |
47 | |
48 (require 'compile) | |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
49 (require 'info) |
3856 | 50 |
65263
45ef6ad79344
(tex-end-of-header, tex-start-of-header): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65176
diff
changeset
|
51 (defvar tex-end-of-header) |
45ef6ad79344
(tex-end-of-header, tex-start-of-header): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65176
diff
changeset
|
52 (defvar tex-start-of-header) |
45ef6ad79344
(tex-end-of-header, tex-start-of-header): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65176
diff
changeset
|
53 |
45ef6ad79344
(tex-end-of-header, tex-start-of-header): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65176
diff
changeset
|
54 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
55 (defgroup makeinfo nil |
64056
2237b71ba613
(makeinfo): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
52401
diff
changeset
|
56 "Run makeinfo conveniently." |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
57 :group 'docs) |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
58 |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
59 |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
60 (defcustom makeinfo-run-command "makeinfo" |
3856 | 61 "*Command used to run `makeinfo' subjob. |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
62 The name of the file is appended to this string, separated by a space." |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
63 :type 'string |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
64 :group 'makeinfo) |
3856 | 65 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
66 (defcustom makeinfo-options "--fill-column=70" |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
67 "*String containing options for running `makeinfo'. |
3856 | 68 Do not include `--footnote-style' or `--paragraph-indent'; |
69 the proper way to specify those is with the Texinfo commands | |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
70 `@footnotestyle` and `@paragraphindent'." |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
71 :type 'string |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
72 :group 'makeinfo) |
3856 | 73 |
74 (require 'texinfo) | |
75 | |
76 (defvar makeinfo-compilation-process nil | |
77 "Process that runs `makeinfo'. Should start out nil.") | |
78 | |
79 (defvar makeinfo-temp-file nil | |
80 "Temporary file name used for text being sent as input to `makeinfo'.") | |
81 | |
82 (defvar makeinfo-output-file-name nil | |
83 "Info file name used for text output by `makeinfo'.") | |
84 | |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
85 (defvar makeinfo-output-node-name nil |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
86 "Node name to visit in output file, for `makeinfo-buffer'.") |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
87 |
3856 | 88 |
89 ;;; The `makeinfo' function definitions | |
90 | |
91 (defun makeinfo-region (region-beginning region-end) | |
92 "Make Info file from region of current Texinfo file, and switch to it. | |
93 | |
94 This command does not offer the `next-error' feature since it would | |
95 apply to a temporary file, not the original; use the `makeinfo-buffer' | |
96 command to gain use of `next-error'." | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
97 |
3856 | 98 (interactive "r") |
99 (let (filename-or-header | |
100 filename-or-header-beginning | |
101 filename-or-header-end) | |
102 ;; Cannot use `let' for makeinfo-temp-file or | |
103 ;; makeinfo-output-file-name since `makeinfo-compilation-sentinel' | |
104 ;; needs them. | |
105 | |
106 (setq makeinfo-temp-file | |
107 (concat | |
26039
fb6b9c37cdc4
Use make-temp-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
17411
diff
changeset
|
108 (make-temp-file |
3856 | 109 (substring (buffer-file-name) |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
110 0 |
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
111 (or (string-match "\\.tex" (buffer-file-name)) |
3856 | 112 (length (buffer-file-name))))) |
113 ".texinfo")) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
114 |
3856 | 115 (save-excursion |
116 (save-restriction | |
117 (widen) | |
118 (goto-char (point-min)) | |
119 (let ((search-end (save-excursion (forward-line 100) (point)))) | |
120 ;; Find and record the Info filename, | |
121 ;; or else explain that a filename is needed. | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
122 (if (re-search-forward |
3856 | 123 "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" |
124 search-end t) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
125 (setq makeinfo-output-file-name |
3856 | 126 (buffer-substring (match-beginning 1) (match-end 1))) |
127 (error | |
128 "The texinfo file needs a line saying: @setfilename <name>")) | |
129 | |
130 ;; Find header and specify its beginning and end. | |
131 (goto-char (point-min)) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
132 (if (and |
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
133 (prog1 |
6828
cccf812ed4f2
(makeinfo-region): Fix name of tex-start/end-of-header.
Richard M. Stallman <rms@gnu.org>
parents:
4149
diff
changeset
|
134 (search-forward tex-start-of-header search-end t) |
3856 | 135 (beginning-of-line) |
136 ;; Mark beginning of header. | |
137 (setq filename-or-header-beginning (point))) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
138 (prog1 |
6828
cccf812ed4f2
(makeinfo-region): Fix name of tex-start/end-of-header.
Richard M. Stallman <rms@gnu.org>
parents:
4149
diff
changeset
|
139 (search-forward tex-end-of-header nil t) |
3856 | 140 (beginning-of-line) |
141 ;; Mark end of header | |
142 (setq filename-or-header-end (point)))) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
143 |
3856 | 144 ;; Insert the header into the temporary file. |
145 (write-region | |
146 (min filename-or-header-beginning region-beginning) | |
147 filename-or-header-end | |
148 makeinfo-temp-file nil nil) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
149 |
3856 | 150 ;; Else no header; insert @filename line into temporary file. |
151 (goto-char (point-min)) | |
152 (search-forward "@setfilename" search-end t) | |
153 (beginning-of-line) | |
154 (setq filename-or-header-beginning (point)) | |
155 (forward-line 1) | |
156 (setq filename-or-header-end (point)) | |
157 (write-region | |
158 (min filename-or-header-beginning region-beginning) | |
159 filename-or-header-end | |
160 makeinfo-temp-file nil nil)) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
161 |
3856 | 162 ;; Insert the region into the file. |
163 (write-region | |
164 (max region-beginning filename-or-header-end) | |
165 region-end | |
166 makeinfo-temp-file t nil) | |
167 | |
168 ;; Run the `makeinfo-compile' command in the *compilation* buffer | |
169 (save-excursion | |
170 (makeinfo-compile | |
171 (concat makeinfo-run-command | |
172 " " | |
173 makeinfo-options | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
174 " " |
3856 | 175 makeinfo-temp-file) |
65176
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
176 t |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
177 'makeinfo-compilation-sentinel-region))))))) |
3856 | 178 |
65176
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
179 (defun makeinfo-next-error (arg reset) |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
180 "This function is used to disable `next-error' if the user has |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
181 used `makeinfo-region'. Since the compilation process is used on |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
182 a temporary file in that case, calling `next-error' would give |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
183 nonsensical results." |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
184 (error "Use `makeinfo-buffer' to gain use of the `next-error' command")) |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
185 |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
186 ;; Actually run makeinfo. COMMAND is the command to run. If |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
187 ;; DISABLE-ERRORS is non-nil, disable `next-error' by setting |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
188 ;; `next-error-function' to `makeinfo-next-error' in the compilation |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
189 ;; buffer. |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
190 (defun makeinfo-compile (command disable-errors sentinel) |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
191 (let ((buffer (compilation-start command))) |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
192 (with-current-buffer buffer |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
193 (setq next-error-function |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
194 (if disable-errors |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
195 'makeinfo-next-error |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
196 'compilation-next-error-function))) |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
197 (set-process-sentinel (get-buffer-process buffer) sentinel))) |
3856 | 198 |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
199 ;; Delete makeinfo-temp-file after processing is finished, |
3856 | 200 ;; and visit Info file. |
201 ;; This function is called when the compilation process changes state. | |
202 ;; Based on `compilation-sentinel' in compile.el | |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
203 (defun makeinfo-compilation-sentinel-region (proc msg) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
204 "Sentinel for `makeinfo-compile' run from `makeinfo-region'." |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
205 (compilation-sentinel proc msg) |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
206 (when (memq (process-status proc) '(signal exit)) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
207 (if (file-exists-p makeinfo-temp-file) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
208 (delete-file makeinfo-temp-file)) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
209 ;; Always use the version on disk. |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
210 (let ((buffer (get-file-buffer makeinfo-output-file-name))) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
211 (if buffer |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
212 (with-current-buffer buffer |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
213 (revert-buffer t t)) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
214 (setq buffer (find-file-noselect makeinfo-output-file-name))) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
215 (if (window-dedicated-p (selected-window)) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
216 (switch-to-buffer-other-window buffer) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
217 (switch-to-buffer buffer))) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
218 (goto-char (point-min)))) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
219 |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
220 (defun makeinfo-current-node () |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
221 "Return the name of the node containing point, in a texinfo file." |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
222 (save-excursion |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
223 (end-of-line) ; in case point is at the start of an @node line |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
224 (if (re-search-backward "^@node\\s-+\\([^,\n]+\\)" (point-min) t) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
225 (match-string 1) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
226 "Top"))) |
3856 | 227 |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
228 (defun makeinfo-buffer () |
3856 | 229 "Make Info file from current buffer. |
230 | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
231 Use the \\[next-error] command to move to the next error |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
232 \(if there are errors\)." |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
233 |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
234 (interactive) |
3856 | 235 (cond ((null buffer-file-name) |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
236 (error "Buffer not visiting any file")) |
3856 | 237 ((buffer-modified-p) |
238 (if (y-or-n-p "Buffer modified; do you want to save it? ") | |
239 (save-buffer)))) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
240 |
3856 | 241 ;; Find and record the Info filename, |
242 ;; or else explain that a filename is needed. | |
243 (save-excursion | |
244 (goto-char (point-min)) | |
245 (let ((search-end (save-excursion (forward-line 100) (point)))) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
246 (if (re-search-forward |
3856 | 247 "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" |
248 search-end t) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
249 (setq makeinfo-output-file-name |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
250 (expand-file-name |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
251 (buffer-substring (match-beginning 1) (match-end 1)))) |
3856 | 252 (error |
253 "The texinfo file needs a line saying: @setfilename <name>")))) | |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
254 (setq makeinfo-output-node-name (makeinfo-current-node)) |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
255 |
3856 | 256 (save-excursion |
257 (makeinfo-compile | |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
258 (concat makeinfo-run-command " " makeinfo-options |
65176
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
259 " " buffer-file-name) |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
260 nil |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
261 'makeinfo-compilation-sentinel-buffer))) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
262 |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
263 (defun makeinfo-compilation-sentinel-buffer (proc msg) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
264 "Sentinel for `makeinfo-compile' run from `makeinfo-buffer'." |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
265 (compilation-sentinel proc msg) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
266 (when (memq (process-status proc) '(signal exit)) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
267 (when (file-exists-p makeinfo-output-file-name) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
268 (Info-revert-find-node |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
269 makeinfo-output-file-name makeinfo-output-node-name)))) |
3856 | 270 |
271 (defun makeinfo-recenter-compilation-buffer (linenum) | |
272 "Redisplay `*compilation*' buffer so most recent output can be seen. | |
273 The last line of the buffer is displayed on | |
274 line LINE of the window, or centered if LINE is nil." | |
275 (interactive "P") | |
276 (let ((makeinfo-buffer (get-buffer "*compilation*")) | |
277 (old-buffer (current-buffer))) | |
278 (if (null makeinfo-buffer) | |
279 (message "No *compilation* buffer") | |
280 (pop-to-buffer makeinfo-buffer) | |
281 (bury-buffer makeinfo-buffer) | |
282 (goto-char (point-max)) | |
283 (recenter (if linenum | |
284 (prefix-numeric-value linenum) | |
285 (/ (window-height) 2))) | |
286 (pop-to-buffer old-buffer) | |
287 ))) | |
288 | |
289 ;;; Place `provide' at end of file. | |
290 (provide 'makeinfo) | |
291 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79719
diff
changeset
|
292 ;; arch-tag: 5f810713-3de2-4e20-8030-4bc3dd0d9604 |
3856 | 293 ;;; makeinfo.el ends here |