annotate lisp/textmodes/makeinfo.el @ 65176:9be9d0d6527f

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