Mercurial > emacs
annotate lisp/textmodes/makeinfo.el @ 69299:9fea7c43a780
*** empty log message ***
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Mon, 06 Mar 2006 05:34:24 +0000 |
parents | 067115a6e738 |
children | f7702c5f335d c5406394f567 |
rev | line source |
---|---|
13337 | 1 ;;; makeinfo.el --- run makeinfo conveniently |
2 | |
64751
5b1a238fcbb4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 ;; Copyright (C) 1991, 1993, 2002, 2003, 2004, |
68648
067115a6e738
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65263
diff
changeset
|
4 ;; 2005, 2006 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 |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
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 | |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64084 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
3856 | 26 |
27 ;;; Commentary: | |
28 | |
29 ;;; The Texinfo mode `makeinfo' related commands are: | |
30 | |
31 ;; makeinfo-region to run makeinfo on the current region. | |
32 ;; makeinfo-buffer to run makeinfo on the current buffer, or | |
33 ;; with optional prefix arg, on current region | |
34 ;; kill-compilation to kill currently running makeinfo job | |
35 ;; makeinfo-recenter-makeinfo-buffer to redisplay *compilation* buffer | |
36 | |
37 ;;; Keybindings (defined in `texinfo.el') | |
38 | |
39 ;; makeinfo bindings | |
40 ; (define-key texinfo-mode-map "\C-c\C-m\C-r" 'makeinfo-region) | |
41 ; (define-key texinfo-mode-map "\C-c\C-m\C-b" 'makeinfo-buffer) | |
42 ; (define-key texinfo-mode-map "\C-c\C-m\C-k" 'kill-compilation) | |
43 ; (define-key texinfo-mode-map "\C-c\C-m\C-l" | |
44 ; 'makeinfo-recenter-compilation-buffer) | |
45 | |
46 ;;; Code: | |
47 | |
48 ;;; Variables used by `makeinfo' | |
49 | |
50 (require 'compile) | |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
51 (require 'info) |
3856 | 52 |
65263
45ef6ad79344
(tex-end-of-header, tex-start-of-header): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65176
diff
changeset
|
53 (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
|
54 (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
|
55 |
45ef6ad79344
(tex-end-of-header, tex-start-of-header): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65176
diff
changeset
|
56 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
57 (defgroup makeinfo nil |
64056
2237b71ba613
(makeinfo): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
52401
diff
changeset
|
58 "Run makeinfo conveniently." |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
59 :group 'docs) |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
60 |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
61 |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
62 (defcustom makeinfo-run-command "makeinfo" |
3856 | 63 "*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
|
64 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
|
65 :type 'string |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
66 :group 'makeinfo) |
3856 | 67 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
68 (defcustom makeinfo-options "--fill-column=70" |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
69 "*String containing options for running `makeinfo'. |
3856 | 70 Do not include `--footnote-style' or `--paragraph-indent'; |
71 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
|
72 `@footnotestyle` and `@paragraphindent'." |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
73 :type 'string |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
74 :group 'makeinfo) |
3856 | 75 |
76 (require 'texinfo) | |
77 | |
78 (defvar makeinfo-compilation-process nil | |
79 "Process that runs `makeinfo'. Should start out nil.") | |
80 | |
81 (defvar makeinfo-temp-file nil | |
82 "Temporary file name used for text being sent as input to `makeinfo'.") | |
83 | |
84 (defvar makeinfo-output-file-name nil | |
85 "Info file name used for text output by `makeinfo'.") | |
86 | |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
87 (defvar makeinfo-output-node-name nil |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
88 "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
|
89 |
3856 | 90 |
91 ;;; The `makeinfo' function definitions | |
92 | |
93 (defun makeinfo-region (region-beginning region-end) | |
94 "Make Info file from region of current Texinfo file, and switch to it. | |
95 | |
96 This command does not offer the `next-error' feature since it would | |
97 apply to a temporary file, not the original; use the `makeinfo-buffer' | |
98 command to gain use of `next-error'." | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
99 |
3856 | 100 (interactive "r") |
101 (let (filename-or-header | |
102 filename-or-header-beginning | |
103 filename-or-header-end) | |
104 ;; Cannot use `let' for makeinfo-temp-file or | |
105 ;; makeinfo-output-file-name since `makeinfo-compilation-sentinel' | |
106 ;; needs them. | |
107 | |
108 (setq makeinfo-temp-file | |
109 (concat | |
26039
fb6b9c37cdc4
Use make-temp-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
17411
diff
changeset
|
110 (make-temp-file |
3856 | 111 (substring (buffer-file-name) |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
112 0 |
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
113 (or (string-match "\\.tex" (buffer-file-name)) |
3856 | 114 (length (buffer-file-name))))) |
115 ".texinfo")) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
116 |
3856 | 117 (save-excursion |
118 (save-restriction | |
119 (widen) | |
120 (goto-char (point-min)) | |
121 (let ((search-end (save-excursion (forward-line 100) (point)))) | |
122 ;; Find and record the Info filename, | |
123 ;; or else explain that a filename is needed. | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
124 (if (re-search-forward |
3856 | 125 "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" |
126 search-end t) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
127 (setq makeinfo-output-file-name |
3856 | 128 (buffer-substring (match-beginning 1) (match-end 1))) |
129 (error | |
130 "The texinfo file needs a line saying: @setfilename <name>")) | |
131 | |
132 ;; Find header and specify its beginning and end. | |
133 (goto-char (point-min)) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
134 (if (and |
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
135 (prog1 |
6828
cccf812ed4f2
(makeinfo-region): Fix name of tex-start/end-of-header.
Richard M. Stallman <rms@gnu.org>
parents:
4149
diff
changeset
|
136 (search-forward tex-start-of-header search-end t) |
3856 | 137 (beginning-of-line) |
138 ;; Mark beginning of header. | |
139 (setq filename-or-header-beginning (point))) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
140 (prog1 |
6828
cccf812ed4f2
(makeinfo-region): Fix name of tex-start/end-of-header.
Richard M. Stallman <rms@gnu.org>
parents:
4149
diff
changeset
|
141 (search-forward tex-end-of-header nil t) |
3856 | 142 (beginning-of-line) |
143 ;; Mark end of header | |
144 (setq filename-or-header-end (point)))) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
145 |
3856 | 146 ;; Insert the header into the temporary file. |
147 (write-region | |
148 (min filename-or-header-beginning region-beginning) | |
149 filename-or-header-end | |
150 makeinfo-temp-file nil nil) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
151 |
3856 | 152 ;; Else no header; insert @filename line into temporary file. |
153 (goto-char (point-min)) | |
154 (search-forward "@setfilename" search-end t) | |
155 (beginning-of-line) | |
156 (setq filename-or-header-beginning (point)) | |
157 (forward-line 1) | |
158 (setq filename-or-header-end (point)) | |
159 (write-region | |
160 (min filename-or-header-beginning region-beginning) | |
161 filename-or-header-end | |
162 makeinfo-temp-file nil nil)) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
163 |
3856 | 164 ;; Insert the region into the file. |
165 (write-region | |
166 (max region-beginning filename-or-header-end) | |
167 region-end | |
168 makeinfo-temp-file t nil) | |
169 | |
170 ;; Run the `makeinfo-compile' command in the *compilation* buffer | |
171 (save-excursion | |
172 (makeinfo-compile | |
173 (concat makeinfo-run-command | |
174 " " | |
175 makeinfo-options | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
176 " " |
3856 | 177 makeinfo-temp-file) |
65176
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
178 t |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
179 'makeinfo-compilation-sentinel-region))))))) |
3856 | 180 |
65176
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
181 (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
|
182 "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
|
183 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
|
184 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
|
185 nonsensical results." |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
186 (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
|
187 |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
188 ;; 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
|
189 ;; 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
|
190 ;; `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
|
191 ;; buffer. |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
192 (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
|
193 (let ((buffer (compilation-start command))) |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
194 (with-current-buffer buffer |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
195 (setq next-error-function |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
196 (if disable-errors |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
197 'makeinfo-next-error |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
198 'compilation-next-error-function))) |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
199 (set-process-sentinel (get-buffer-process buffer) sentinel))) |
3856 | 200 |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
201 ;; Delete makeinfo-temp-file after processing is finished, |
3856 | 202 ;; and visit Info file. |
203 ;; This function is called when the compilation process changes state. | |
204 ;; 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
|
205 (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
|
206 "Sentinel for `makeinfo-compile' run from `makeinfo-region'." |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
207 (compilation-sentinel proc msg) |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
208 (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
|
209 (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
|
210 (delete-file makeinfo-temp-file)) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
211 ;; Always use the version on disk. |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
212 (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
|
213 (if buffer |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
214 (with-current-buffer buffer |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
215 (revert-buffer t t)) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
216 (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
|
217 (if (window-dedicated-p (selected-window)) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
218 (switch-to-buffer-other-window buffer) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
219 (switch-to-buffer buffer))) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
220 (goto-char (point-min)))) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
221 |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
222 (defun makeinfo-current-node () |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
223 "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
|
224 (save-excursion |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
225 (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
|
226 (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
|
227 (match-string 1) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
228 "Top"))) |
3856 | 229 |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
230 (defun makeinfo-buffer () |
3856 | 231 "Make Info file from current buffer. |
232 | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
233 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
|
234 \(if there are errors\)." |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
235 |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
236 (interactive) |
3856 | 237 (cond ((null buffer-file-name) |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
238 (error "Buffer not visiting any file")) |
3856 | 239 ((buffer-modified-p) |
240 (if (y-or-n-p "Buffer modified; do you want to save it? ") | |
241 (save-buffer)))) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
242 |
3856 | 243 ;; Find and record the Info filename, |
244 ;; or else explain that a filename is needed. | |
245 (save-excursion | |
246 (goto-char (point-min)) | |
247 (let ((search-end (save-excursion (forward-line 100) (point)))) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
248 (if (re-search-forward |
3856 | 249 "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" |
250 search-end t) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
251 (setq makeinfo-output-file-name |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
252 (expand-file-name |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
253 (buffer-substring (match-beginning 1) (match-end 1)))) |
3856 | 254 (error |
255 "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
|
256 (setq makeinfo-output-node-name (makeinfo-current-node)) |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48934
diff
changeset
|
257 |
3856 | 258 (save-excursion |
259 (makeinfo-compile | |
3857
ef8b4ed0de91
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
3856
diff
changeset
|
260 (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
|
261 " " buffer-file-name) |
9be9d0d6527f
(makeinfo-compile): Use `compilation-start'. Set `next-error-function'
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
262 nil |
48934
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
263 'makeinfo-compilation-sentinel-buffer))) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
264 |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
265 (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
|
266 "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
|
267 (compilation-sentinel proc msg) |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
268 (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
|
269 (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
|
270 (Info-revert-find-node |
48b3aae63381
(makeinfo-buffer): Display result using Info-mode.
Richard M. Stallman <rms@gnu.org>
parents:
42429
diff
changeset
|
271 makeinfo-output-file-name makeinfo-output-node-name)))) |
3856 | 272 |
273 (defun makeinfo-recenter-compilation-buffer (linenum) | |
274 "Redisplay `*compilation*' buffer so most recent output can be seen. | |
275 The last line of the buffer is displayed on | |
276 line LINE of the window, or centered if LINE is nil." | |
277 (interactive "P") | |
278 (let ((makeinfo-buffer (get-buffer "*compilation*")) | |
279 (old-buffer (current-buffer))) | |
280 (if (null makeinfo-buffer) | |
281 (message "No *compilation* buffer") | |
282 (pop-to-buffer makeinfo-buffer) | |
283 (bury-buffer makeinfo-buffer) | |
284 (goto-char (point-max)) | |
285 (recenter (if linenum | |
286 (prefix-numeric-value linenum) | |
287 (/ (window-height) 2))) | |
288 (pop-to-buffer old-buffer) | |
289 ))) | |
290 | |
291 ;;; Place `provide' at end of file. | |
292 (provide 'makeinfo) | |
293 | |
52401 | 294 ;;; arch-tag: 5f810713-3de2-4e20-8030-4bc3dd0d9604 |
3856 | 295 ;;; makeinfo.el ends here |