Mercurial > emacs
comparison lisp/textmodes/makeinfo.el @ 49599:5ade352e8d1c
Trailing whitespace deleted.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 04 Feb 2003 13:30:45 +0000 |
parents | 48b3aae63381 |
children | 695cf19ef79e d7ddb3e565de |
comparison
equal
deleted
inserted
replaced
49598:0d8b17d428b5 | 49599:5ade352e8d1c |
---|---|
1 ;;; makeinfo.el --- run makeinfo conveniently | 1 ;;; makeinfo.el --- run makeinfo conveniently |
2 | 2 |
3 ;; Copyright (C) 1991, 1993, 2002 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 |
7 ;; Keywords: docs convenience | 7 ;; Keywords: docs convenience |
8 | 8 |
9 ;; This file is part of GNU Emacs. | 9 ;; This file is part of GNU Emacs. |
10 | 10 |
59 The name of the file is appended to this string, separated by a space." | 59 The name of the file is appended to this string, separated by a space." |
60 :type 'string | 60 :type 'string |
61 :group 'makeinfo) | 61 :group 'makeinfo) |
62 | 62 |
63 (defcustom makeinfo-options "--fill-column=70" | 63 (defcustom makeinfo-options "--fill-column=70" |
64 "*String containing options for running `makeinfo'. | 64 "*String containing options for running `makeinfo'. |
65 Do not include `--footnote-style' or `--paragraph-indent'; | 65 Do not include `--footnote-style' or `--paragraph-indent'; |
66 the proper way to specify those is with the Texinfo commands | 66 the proper way to specify those is with the Texinfo commands |
67 `@footnotestyle` and `@paragraphindent'." | 67 `@footnotestyle` and `@paragraphindent'." |
68 :type 'string | 68 :type 'string |
69 :group 'makeinfo) | 69 :group 'makeinfo) |
89 "Make Info file from region of current Texinfo file, and switch to it. | 89 "Make Info file from region of current Texinfo file, and switch to it. |
90 | 90 |
91 This command does not offer the `next-error' feature since it would | 91 This command does not offer the `next-error' feature since it would |
92 apply to a temporary file, not the original; use the `makeinfo-buffer' | 92 apply to a temporary file, not the original; use the `makeinfo-buffer' |
93 command to gain use of `next-error'." | 93 command to gain use of `next-error'." |
94 | 94 |
95 (interactive "r") | 95 (interactive "r") |
96 (let (filename-or-header | 96 (let (filename-or-header |
97 filename-or-header-beginning | 97 filename-or-header-beginning |
98 filename-or-header-end) | 98 filename-or-header-end) |
99 ;; Cannot use `let' for makeinfo-temp-file or | 99 ;; Cannot use `let' for makeinfo-temp-file or |
102 | 102 |
103 (setq makeinfo-temp-file | 103 (setq makeinfo-temp-file |
104 (concat | 104 (concat |
105 (make-temp-file | 105 (make-temp-file |
106 (substring (buffer-file-name) | 106 (substring (buffer-file-name) |
107 0 | 107 0 |
108 (or (string-match "\\.tex" (buffer-file-name)) | 108 (or (string-match "\\.tex" (buffer-file-name)) |
109 (length (buffer-file-name))))) | 109 (length (buffer-file-name))))) |
110 ".texinfo")) | 110 ".texinfo")) |
111 | 111 |
112 (save-excursion | 112 (save-excursion |
113 (save-restriction | 113 (save-restriction |
114 (widen) | 114 (widen) |
115 (goto-char (point-min)) | 115 (goto-char (point-min)) |
116 (let ((search-end (save-excursion (forward-line 100) (point)))) | 116 (let ((search-end (save-excursion (forward-line 100) (point)))) |
117 ;; Find and record the Info filename, | 117 ;; Find and record the Info filename, |
118 ;; or else explain that a filename is needed. | 118 ;; or else explain that a filename is needed. |
119 (if (re-search-forward | 119 (if (re-search-forward |
120 "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" | 120 "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" |
121 search-end t) | 121 search-end t) |
122 (setq makeinfo-output-file-name | 122 (setq makeinfo-output-file-name |
123 (buffer-substring (match-beginning 1) (match-end 1))) | 123 (buffer-substring (match-beginning 1) (match-end 1))) |
124 (error | 124 (error |
125 "The texinfo file needs a line saying: @setfilename <name>")) | 125 "The texinfo file needs a line saying: @setfilename <name>")) |
126 | 126 |
127 ;; Find header and specify its beginning and end. | 127 ;; Find header and specify its beginning and end. |
128 (goto-char (point-min)) | 128 (goto-char (point-min)) |
129 (if (and | 129 (if (and |
130 (prog1 | 130 (prog1 |
131 (search-forward tex-start-of-header search-end t) | 131 (search-forward tex-start-of-header search-end t) |
132 (beginning-of-line) | 132 (beginning-of-line) |
133 ;; Mark beginning of header. | 133 ;; Mark beginning of header. |
134 (setq filename-or-header-beginning (point))) | 134 (setq filename-or-header-beginning (point))) |
135 (prog1 | 135 (prog1 |
136 (search-forward tex-end-of-header nil t) | 136 (search-forward tex-end-of-header nil t) |
137 (beginning-of-line) | 137 (beginning-of-line) |
138 ;; Mark end of header | 138 ;; Mark end of header |
139 (setq filename-or-header-end (point)))) | 139 (setq filename-or-header-end (point)))) |
140 | 140 |
141 ;; Insert the header into the temporary file. | 141 ;; Insert the header into the temporary file. |
142 (write-region | 142 (write-region |
143 (min filename-or-header-beginning region-beginning) | 143 (min filename-or-header-beginning region-beginning) |
144 filename-or-header-end | 144 filename-or-header-end |
145 makeinfo-temp-file nil nil) | 145 makeinfo-temp-file nil nil) |
146 | 146 |
147 ;; Else no header; insert @filename line into temporary file. | 147 ;; Else no header; insert @filename line into temporary file. |
148 (goto-char (point-min)) | 148 (goto-char (point-min)) |
149 (search-forward "@setfilename" search-end t) | 149 (search-forward "@setfilename" search-end t) |
150 (beginning-of-line) | 150 (beginning-of-line) |
151 (setq filename-or-header-beginning (point)) | 151 (setq filename-or-header-beginning (point)) |
153 (setq filename-or-header-end (point)) | 153 (setq filename-or-header-end (point)) |
154 (write-region | 154 (write-region |
155 (min filename-or-header-beginning region-beginning) | 155 (min filename-or-header-beginning region-beginning) |
156 filename-or-header-end | 156 filename-or-header-end |
157 makeinfo-temp-file nil nil)) | 157 makeinfo-temp-file nil nil)) |
158 | 158 |
159 ;; Insert the region into the file. | 159 ;; Insert the region into the file. |
160 (write-region | 160 (write-region |
161 (max region-beginning filename-or-header-end) | 161 (max region-beginning filename-or-header-end) |
162 region-end | 162 region-end |
163 makeinfo-temp-file t nil) | 163 makeinfo-temp-file t nil) |
166 (save-excursion | 166 (save-excursion |
167 (makeinfo-compile | 167 (makeinfo-compile |
168 (concat makeinfo-run-command | 168 (concat makeinfo-run-command |
169 " " | 169 " " |
170 makeinfo-options | 170 makeinfo-options |
171 " " | 171 " " |
172 makeinfo-temp-file) | 172 makeinfo-temp-file) |
173 "Use `makeinfo-buffer' to gain use of the `next-error' command" | 173 "Use `makeinfo-buffer' to gain use of the `next-error' command" |
174 nil | 174 nil |
175 'makeinfo-compilation-sentinel-region))))))) | 175 'makeinfo-compilation-sentinel-region))))))) |
176 | 176 |
218 "Top"))) | 218 "Top"))) |
219 | 219 |
220 (defun makeinfo-buffer () | 220 (defun makeinfo-buffer () |
221 "Make Info file from current buffer. | 221 "Make Info file from current buffer. |
222 | 222 |
223 Use the \\[next-error] command to move to the next error | 223 Use the \\[next-error] command to move to the next error |
224 \(if there are errors\)." | 224 \(if there are errors\)." |
225 | 225 |
226 (interactive) | 226 (interactive) |
227 (cond ((null buffer-file-name) | 227 (cond ((null buffer-file-name) |
228 (error "Buffer not visiting any file")) | 228 (error "Buffer not visiting any file")) |
229 ((buffer-modified-p) | 229 ((buffer-modified-p) |
230 (if (y-or-n-p "Buffer modified; do you want to save it? ") | 230 (if (y-or-n-p "Buffer modified; do you want to save it? ") |
231 (save-buffer)))) | 231 (save-buffer)))) |
232 | 232 |
233 ;; Find and record the Info filename, | 233 ;; Find and record the Info filename, |
234 ;; or else explain that a filename is needed. | 234 ;; or else explain that a filename is needed. |
235 (save-excursion | 235 (save-excursion |
236 (goto-char (point-min)) | 236 (goto-char (point-min)) |
237 (let ((search-end (save-excursion (forward-line 100) (point)))) | 237 (let ((search-end (save-excursion (forward-line 100) (point)))) |
238 (if (re-search-forward | 238 (if (re-search-forward |
239 "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" | 239 "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" |
240 search-end t) | 240 search-end t) |
241 (setq makeinfo-output-file-name | 241 (setq makeinfo-output-file-name |
242 (expand-file-name | 242 (expand-file-name |
243 (buffer-substring (match-beginning 1) (match-end 1)))) | 243 (buffer-substring (match-beginning 1) (match-end 1)))) |
244 (error | 244 (error |
245 "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)) | 246 (setq makeinfo-output-node-name (makeinfo-current-node)) |
247 | 247 |
248 (save-excursion | 248 (save-excursion |
249 (makeinfo-compile | 249 (makeinfo-compile |
250 (concat makeinfo-run-command " " makeinfo-options | 250 (concat makeinfo-run-command " " makeinfo-options |
251 " " buffer-file-name) | 251 " " buffer-file-name) |
252 "No more errors." | 252 "No more errors." |