diff options
| author | Richard M. Stallman | 2002-12-22 22:05:16 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-12-22 22:05:16 +0000 |
| commit | 67f5dcb800032f4acf2e68a270d1670cbf3bb537 (patch) | |
| tree | b319ca7763811bee6eeb6e5e91789f169f82922f /lisp/textmodes | |
| parent | f584b4c796b81795985460fe93fba386b6ad79ad (diff) | |
| download | emacs-67f5dcb800032f4acf2e68a270d1670cbf3bb537.tar.gz emacs-67f5dcb800032f4acf2e68a270d1670cbf3bb537.zip | |
(makeinfo-buffer): Display result using Info-mode.
(makeinfo-compilation-sentinel-buffer, makeinfo-current-node): New functions.
(makeinfo-compile): Add a sentinel parameter.
(makeinfo-compilation-sentinel-region): Renamed from
makeinfo-compilation-sentinel, and makeinfo-temp-file now never nil.
(makeinfo-region): Use this.
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/makeinfo.el | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/lisp/textmodes/makeinfo.el b/lisp/textmodes/makeinfo.el index b4857e0d143..22a03b852ad 100644 --- a/lisp/textmodes/makeinfo.el +++ b/lisp/textmodes/makeinfo.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; makeinfo.el --- run makeinfo conveniently | 1 | ;;; makeinfo.el --- run makeinfo conveniently |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1991, 1993 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1991, 1993, 2002 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Robert J. Chassell | 5 | ;; Author: Robert J. Chassell |
| 6 | ;; Maintainer: FSF | 6 | ;; Maintainer: FSF |
| @@ -47,6 +47,7 @@ | |||
| 47 | ;;; Variables used by `makeinfo' | 47 | ;;; Variables used by `makeinfo' |
| 48 | 48 | ||
| 49 | (require 'compile) | 49 | (require 'compile) |
| 50 | (require 'info) | ||
| 50 | 51 | ||
| 51 | (defgroup makeinfo nil | 52 | (defgroup makeinfo nil |
| 52 | "Run makeinfo conveniently" | 53 | "Run makeinfo conveniently" |
| @@ -78,6 +79,9 @@ the proper way to specify those is with the Texinfo commands | |||
| 78 | (defvar makeinfo-output-file-name nil | 79 | (defvar makeinfo-output-file-name nil |
| 79 | "Info file name used for text output by `makeinfo'.") | 80 | "Info file name used for text output by `makeinfo'.") |
| 80 | 81 | ||
| 82 | (defvar makeinfo-output-node-name nil | ||
| 83 | "Node name to visit in output file, for `makeinfo-buffer'.") | ||
| 84 | |||
| 81 | 85 | ||
| 82 | ;;; The `makeinfo' function definitions | 86 | ;;; The `makeinfo' function definitions |
| 83 | 87 | ||
| @@ -167,12 +171,13 @@ command to gain use of `next-error'." | |||
| 167 | " " | 171 | " " |
| 168 | makeinfo-temp-file) | 172 | makeinfo-temp-file) |
| 169 | "Use `makeinfo-buffer' to gain use of the `next-error' command" | 173 | "Use `makeinfo-buffer' to gain use of the `next-error' command" |
| 170 | nil))))))) | 174 | nil |
| 175 | 'makeinfo-compilation-sentinel-region))))))) | ||
| 171 | 176 | ||
| 172 | ;;; Actually run makeinfo. COMMAND is the command to run. | 177 | ;;; Actually run makeinfo. COMMAND is the command to run. |
| 173 | ;;; ERROR-MESSAGE is what to say when next-error can't find another error. | 178 | ;;; ERROR-MESSAGE is what to say when next-error can't find another error. |
| 174 | ;;; If PARSE-ERRORS is non-nil, do try to parse error messages. | 179 | ;;; If PARSE-ERRORS is non-nil, do try to parse error messages. |
| 175 | (defun makeinfo-compile (command error-message parse-errors) | 180 | (defun makeinfo-compile (command error-message parse-errors sentinel) |
| 176 | (let ((buffer | 181 | (let ((buffer |
| 177 | (compile-internal command error-message nil | 182 | (compile-internal command error-message nil |
| 178 | (and (not parse-errors) | 183 | (and (not parse-errors) |
| @@ -181,27 +186,36 @@ command to gain use of `next-error'." | |||
| 181 | ;; ever find any errors. | 186 | ;; ever find any errors. |
| 182 | (lambda (&rest ignore) | 187 | (lambda (&rest ignore) |
| 183 | (setq compilation-error-list nil)))))) | 188 | (setq compilation-error-list nil)))))) |
| 184 | (set-process-sentinel (get-buffer-process buffer) | 189 | (set-process-sentinel (get-buffer-process buffer) sentinel))) |
| 185 | 'makeinfo-compilation-sentinel))) | ||
| 186 | 190 | ||
| 187 | ;; Delete makeinfo-temp-file after processing is finished, | 191 | ;; Delete makeinfo-temp-file after processing is finished, |
| 188 | ;; and visit Info file. | 192 | ;; and visit Info file. |
| 189 | ;; This function is called when the compilation process changes state. | 193 | ;; This function is called when the compilation process changes state. |
| 190 | ;; Based on `compilation-sentinel' in compile.el | 194 | ;; Based on `compilation-sentinel' in compile.el |
| 191 | (defun makeinfo-compilation-sentinel (proc msg) | 195 | (defun makeinfo-compilation-sentinel-region (proc msg) |
| 196 | "Sentinel for `makeinfo-compile' run from `makeinfo-region'." | ||
| 192 | (compilation-sentinel proc msg) | 197 | (compilation-sentinel proc msg) |
| 193 | (if (and makeinfo-temp-file (file-exists-p makeinfo-temp-file)) | 198 | (when (memq (process-status proc) '(signal exit)) |
| 194 | (delete-file makeinfo-temp-file)) | 199 | (if (file-exists-p makeinfo-temp-file) |
| 195 | ;; Always use the version on disk. | 200 | (delete-file makeinfo-temp-file)) |
| 196 | (let ((buffer (get-file-buffer makeinfo-output-file-name))) | 201 | ;; Always use the version on disk. |
| 197 | (if buffer | 202 | (let ((buffer (get-file-buffer makeinfo-output-file-name))) |
| 198 | (with-current-buffer buffer | 203 | (if buffer |
| 199 | (revert-buffer t t)) | 204 | (with-current-buffer buffer |
| 200 | (setq buffer (find-file-noselect makeinfo-output-file-name))) | 205 | (revert-buffer t t)) |
| 201 | (if (window-dedicated-p (selected-window)) | 206 | (setq buffer (find-file-noselect makeinfo-output-file-name))) |
| 202 | (switch-to-buffer-other-window buffer) | 207 | (if (window-dedicated-p (selected-window)) |
| 203 | (switch-to-buffer buffer))) | 208 | (switch-to-buffer-other-window buffer) |
| 204 | (goto-char (point-min))) | 209 | (switch-to-buffer buffer))) |
| 210 | (goto-char (point-min)))) | ||
| 211 | |||
| 212 | (defun makeinfo-current-node () | ||
| 213 | "Return the name of the node containing point, in a texinfo file." | ||
| 214 | (save-excursion | ||
| 215 | (end-of-line) ; in case point is at the start of an @node line | ||
| 216 | (if (re-search-backward "^@node\\s-+\\([^,\n]+\\)" (point-min) t) | ||
| 217 | (match-string 1) | ||
| 218 | "Top"))) | ||
| 205 | 219 | ||
| 206 | (defun makeinfo-buffer () | 220 | (defun makeinfo-buffer () |
| 207 | "Make Info file from current buffer. | 221 | "Make Info file from current buffer. |
| @@ -225,16 +239,27 @@ Use the \\[next-error] command to move to the next error | |||
| 225 | "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" | 239 | "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" |
| 226 | search-end t) | 240 | search-end t) |
| 227 | (setq makeinfo-output-file-name | 241 | (setq makeinfo-output-file-name |
| 228 | (buffer-substring (match-beginning 1) (match-end 1))) | 242 | (expand-file-name |
| 243 | (buffer-substring (match-beginning 1) (match-end 1)))) | ||
| 229 | (error | 244 | (error |
| 230 | "The texinfo file needs a line saying: @setfilename <name>")))) | 245 | "The texinfo file needs a line saying: @setfilename <name>")))) |
| 246 | (setq makeinfo-output-node-name (makeinfo-current-node)) | ||
| 231 | 247 | ||
| 232 | (save-excursion | 248 | (save-excursion |
| 233 | (makeinfo-compile | 249 | (makeinfo-compile |
| 234 | (concat makeinfo-run-command " " makeinfo-options | 250 | (concat makeinfo-run-command " " makeinfo-options |
| 235 | " " buffer-file-name) | 251 | " " buffer-file-name) |
| 236 | "No more errors." | 252 | "No more errors." |
| 237 | t))) | 253 | t |
| 254 | 'makeinfo-compilation-sentinel-buffer))) | ||
| 255 | |||
| 256 | (defun makeinfo-compilation-sentinel-buffer (proc msg) | ||
| 257 | "Sentinel for `makeinfo-compile' run from `makeinfo-buffer'." | ||
| 258 | (compilation-sentinel proc msg) | ||
| 259 | (when (memq (process-status proc) '(signal exit)) | ||
| 260 | (when (file-exists-p makeinfo-output-file-name) | ||
| 261 | (Info-revert-find-node | ||
| 262 | makeinfo-output-file-name makeinfo-output-node-name)))) | ||
| 238 | 263 | ||
| 239 | (defun makeinfo-recenter-compilation-buffer (linenum) | 264 | (defun makeinfo-recenter-compilation-buffer (linenum) |
| 240 | "Redisplay `*compilation*' buffer so most recent output can be seen. | 265 | "Redisplay `*compilation*' buffer so most recent output can be seen. |