annotate lisp/textmodes/makeinfo.el @ 11584:3391bf365efa

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