Mercurial > hg > xemacs-beta
comparison lisp/autoload.el @ 2548:c4c8a36043be
[xemacs-hg @ 2005-02-03 07:11:19 by ben]
behavior ws #4: package-suppress, autoload update/sync, add easy-mmode/regexp-opt to core
lread.c, lisp.h: Remove undeeded Vload_file_name_internal_the_purecopy,
Qload_file_name -- use internal_bind_lisp_object instead of
specbind.
Add load-suppress-alist.
* easy-mmode.el, regexp-opt.el:
Move these files into core.
Uncomment stuff depending on new custom.el.
autoload.el: Removed.
Major update. Sync with FSF 21.2.
Create the ability to make custom-defines files.
update-elc-2.el, update-elc.el: Rewrite to use new autoload API.
update-elc.el: Add easy-mmode.
author | ben |
---|---|
date | Thu, 03 Feb 2005 07:11:28 +0000 |
parents | 588465af3ca1 |
children | 744de5f3f284 |
comparison
equal
deleted
inserted
replaced
2547:a9527fcdf77f | 2548:c4c8a36043be |
---|---|
1 ;;; autoload.el --- maintain autoloads in auto-autoloads files. | 1 ;;; autoload.el --- maintain autoloads in auto-autoloads files. |
2 | 2 |
3 ;; Copyright (C) 1991-1994, 1997, 2003 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1991-1994, 1997, 2003 Free Software Foundation, Inc. |
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp. | 4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp. |
5 ;; Copyright (C) 1996, 2000, 2002, 2003 Ben Wing. | 5 ;; Copyright (C) 1996, 2000, 2002, 2003, 2004 Ben Wing. |
6 | 6 |
7 ;; Author: Roland McGrath <roland@gnu.ai.mit.edu> | 7 ;; Original Author: Roland McGrath <roland@gnu.ai.mit.edu> |
8 ;; Heavily Modified: XEmacs Maintainers | |
8 ;; Keywords: maint | 9 ;; Keywords: maint |
9 | 10 |
10 ;; This file is part of XEmacs. | 11 ;; This file is part of XEmacs. |
11 | 12 |
12 ;; XEmacs is free software; you can redistribute it and/or modify it | 13 ;; XEmacs is free software; you can redistribute it and/or modify it |
22 ;; You should have received a copy of the GNU General Public License | 23 ;; You should have received a copy of the GNU General Public License |
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free | 24 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 25 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
25 ;; 02111-1307, USA. | 26 ;; 02111-1307, USA. |
26 | 27 |
27 ;;; Synched up with: Not synched with FSF. | 28 ;;; Synched up with: FSF 21.2 by Ben Wing. |
29 ;;; Note that update-file-autoloads is seriously modified and not really | |
30 ;;; syncable. | |
28 | 31 |
29 ;;; Commentary: | 32 ;;; Commentary: |
30 | 33 |
31 ;; This code keeps auto-autoloads.el files up to date. It interprets | 34 ;; This code keeps auto-autoloads.el files up to date. It interprets |
32 ;; magic cookies (of the form ";;;###autoload" in Lisp source files | 35 ;; magic cookies (of the form ";;;###autoload" in Lisp source files |
33 ;; and "/* ###autoload */" in C source files) in various useful ways. | 36 ;; and "/* ###autoload */" in C source files) in various useful ways. |
37 ;; It is also used to maintain custom-defines.el files, since most of | |
38 ;; the logic for computing them is the same as for auto-autoloads.el. | |
34 | 39 |
35 ;; Usage | 40 ;; Usage |
36 ;; ===== | 41 ;; ===== |
37 | 42 |
38 ;; Recommended usage for this library, as implemented in the core | 43 ;; Recommended usage for this library, as implemented in the core |
39 ;; build process, is | 44 ;; build process, is |
40 | 45 |
41 ;; xemacs -no-packages -batch \ | 46 ;; xemacs -no-packages -batch \ |
42 ;; -eval "(setq generated-autoload-file \"PATH\")" \ | 47 ;; -l autoload -f batch-update-directory-autoloads PREFIX DIRECTORY |
43 ;; -l autoload -f autoload-update-directory-autoloads PREFIX DIRECTORY | |
44 | 48 |
45 ;; which causes XEmacs to update the file named by PATH from the .el | 49 ;; which causes XEmacs to update the file named by PATH from the .el |
46 ;; files in DIRECTORY (but not recursing into subdirectories) and (if | 50 ;; files in DIRECTORY (but not recursing into subdirectories) and (if |
47 ;; the autoload file is not already protected with a feature test) add | 51 ;; the autoload file is not already protected with a feature test) add |
48 ;; a check and provide for 'PREFIX-autoloads. Currently there is no | 52 ;; a check and provide for 'PREFIX-autoloads. Currently there is no |
59 ;; too risky. Use a script or a Lisp library with an explicit list of | 63 ;; too risky. Use a script or a Lisp library with an explicit list of |
60 ;; PATHs; see update-elc.el for how to do this without recursive invocation | 64 ;; PATHs; see update-elc.el for how to do this without recursive invocation |
61 ;; of XEmacs). | 65 ;; of XEmacs). |
62 | 66 |
63 ;; The probable next step is to fix up the packages to use the | 67 ;; The probable next step is to fix up the packages to use the |
64 ;; `autoload-update-directory-autoloads' API. However, for backward | 68 ;; `batch-update-directory-autoloads' API. However, for backward |
65 ;; compatibility with XEmacs 21.4 and 21.1, this can't be done quickly. | 69 ;; compatibility with XEmacs 21.4 and 21.1, this can't be done quickly. |
66 | 70 |
67 ;; For now the API used in update-elc-2.el: | |
68 | |
69 ;; (let* ((dir "DIRECTORY") | |
70 ;; (generated-autoload-file (expand-file-name "auto-autoloads.el" dir)) | |
71 ;; (autoload-package-name "PREFIX")) | |
72 ;; (update-autoload-files (list muledir)) | |
73 ;; (byte-recompile-file generated-autoload-file 0)) | |
74 | |
75 ;; is available, but this ugly kludge is deprecated. It will be removed | |
76 ;; in favor of using proper arguments instead of special variables. | |
77 | |
78 ;; For backward compatibility the API used in the packages/XEmacs.rules: | 71 ;; For backward compatibility the API used in the packages/XEmacs.rules: |
79 | 72 |
80 ;; xemacs -vanilla -batch -eval "$(AUTOLOAD_PACKAGE_NAME)" \ | 73 ;; xemacs -vanilla -batch -eval "$(AUTOLOAD_PACKAGE_NAME)" \ |
81 ;; -l autoload -f batch-update-directory $(AUTOLOAD_PATH) | 74 ;; -l autoload -f batch-update-autoloads $(AUTOLOAD_PATH) |
82 | 75 |
83 ;; is supported, and the implementation is unchanged. However, | 76 ;; is supported, and the implementation is unchanged. However, |
84 ;; revision of the API (in a backward compatible way) and the | 77 ;; revision of the API (in a backward compatible way) and the |
85 ;; implementation are planned, and until those stabilize it is too | 78 ;; implementation are planned, and until those stabilize it is too |
86 ;; risky to use this version of XEmacs for package releases. | 79 ;; risky to use this version of XEmacs for package releases. |
128 | 121 |
129 ;; See ./ChangeLog. | 122 ;; See ./ChangeLog. |
130 | 123 |
131 ;;; Code: | 124 ;;; Code: |
132 | 125 |
126 ;; Need to load easy-mmode because we expand macro calls to easy-mmode | |
127 ;; macros in make-autoloads below. | |
128 (require 'easy-mmode) | |
129 | |
133 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 130 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
134 ;; Standard file and directory names | 131 ;; Standard file and directory names |
135 | 132 |
136 ;; `autoload-file-name' is defvar'd and initialized in packages.el, | 133 ;; `autoload-file-name' is defvar'd and initialized in packages.el, |
137 ;; which is loaded (and dumped) very early. If you find it isn't, you | 134 ;; which is loaded (and dumped) very early. If you find it isn't, you |
141 "Standard directory containing autoload declaration file. | 138 "Standard directory containing autoload declaration file. |
142 | 139 |
143 Use `generated-autoload-file' (q.v.) to change its installation location.") | 140 Use `generated-autoload-file' (q.v.) to change its installation location.") |
144 | 141 |
145 ;; Dynamic variables for communication among functions | 142 ;; Dynamic variables for communication among functions |
143 | |
144 ;; FSF 21.2: | |
145 ;; The autoload file is assumed to contain a trailer starting with a FormFeed | |
146 ;; character. | |
146 | 147 |
147 (defvar generated-autoload-file | 148 (defvar generated-autoload-file |
148 (expand-file-name autoload-file-name lisp-directory) | 149 (expand-file-name autoload-file-name lisp-directory) |
149 "*File `update-file-autoloads' puts autoloads into. | 150 "*File `update-file-autoloads' puts autoloads into. |
150 A .el file can set this in its local variables section to make its | 151 A .el file can set this in its local variables section to make its |
152 | 153 |
153 Note that `batch-update-directory' binds this variable to its own value, | 154 Note that `batch-update-directory' binds this variable to its own value, |
154 generally the file named by `autoload-file-name' in the directory being | 155 generally the file named by `autoload-file-name' in the directory being |
155 updated. XEmacs.rules setq's this variable for package autoloads.") | 156 updated. XEmacs.rules setq's this variable for package autoloads.") |
156 | 157 |
158 (defvar generate-autoload-function | |
159 #'generate-file-autoloads | |
160 "Function to generate the autoloads for a file and insert at point. | |
161 Called with one argument, the file.") | |
162 | |
157 (define-obsolete-variable-alias 'autoload-package-name | 163 (define-obsolete-variable-alias 'autoload-package-name |
158 'autoload-feature-prefix) | 164 'autoload-feature-prefix) |
159 (defvar autoload-feature-prefix nil | 165 (defvar autoload-feature-prefix nil |
160 "If non-nil, use this string to prefix the autoload feature name. | 166 "If non-nil, use this string to prefix the autoload feature name. |
161 | 167 |
162 Usually a package name (from AUTOLOAD_PACKAGE_NAME, defined in XEmacs.rules | 168 Usually a package name (from AUTOLOAD_PACKAGE_NAME, defined in XEmacs.rules |
163 in the top of the package hierarchy), or \"auto\" (reserved for the core Lisp | 169 in the top of the package hierarchy), or \"auto\" (reserved for the core Lisp |
164 auto-autoloads file). Highest priority candidate except for an explicit | 170 auto-autoloads file). Highest priority candidate except for an explicit |
165 argument to `autoload-make-feature-name' (q.v.).") | 171 argument to `autoload-make-feature-name' (q.v.).") |
172 | |
173 (defvar autoload-feature-suffix "-autoloads" | |
174 "String added to `autoload-feature-prefix' to create the autoload feature name.") | |
166 | 175 |
167 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 176 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
168 ;; Magic strings in source files | 177 ;; Magic strings in source files |
169 | 178 |
170 (defconst generate-autoload-cookie ";;;###autoload" | 179 (defconst generate-autoload-cookie ";;;###autoload" |
208 the section of autoloads for a file.") | 217 the section of autoloads for a file.") |
209 | 218 |
210 (defconst generate-autoload-section-trailer "\n;;;***\n" | 219 (defconst generate-autoload-section-trailer "\n;;;***\n" |
211 "String which indicates the end of the section of autoloads for a file.") | 220 "String which indicates the end of the section of autoloads for a file.") |
212 | 221 |
222 (defconst generate-autoload-section-continuation ";;;;;; " | |
223 "String to add on each continuation of the section header form.") | |
224 | |
213 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 225 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
214 ;; Parsing the source file text. | 226 ;; Parsing the source file text. |
215 ;; Autoloads in C source differ from those in Lisp source. For historical | 227 ;; Autoloads in C source differ from those in Lisp source. |
216 ;; reasons, functions handling only Lisp don't have "lisp" in their names; | |
217 ;; maybe this should be changed. | |
218 | 228 |
219 (defun make-autoload (form file) | 229 (defun make-autoload (form file) |
220 "Turn a definition generator FORM into an autoload for source file FILE. | 230 "Turn FORM into an autoload or defvar for source file FILE. |
221 Returns nil if FORM is not a defun, defun*, defmacro, defmacro*, | 231 Returns nil if FORM is not a special autoload form (i.e. a function definition |
222 define-skeleton, or define-derived-mode." | 232 or macro definition or a defcustom)." |
223 (let ((car (car-safe form))) | 233 (let ((car (car-safe form)) expand) |
224 (if (memq car '(defun defun* define-skeleton defmacro defmacro* | 234 (cond |
225 define-derived-mode)) | 235 ;; For complex cases, try again on the macro-expansion. |
226 (let ((macrop (memq car '(defmacro defmacro*))) | 236 ((and (memq car '(easy-mmode-define-global-mode |
227 name doc) | 237 easy-mmode-define-minor-mode define-minor-mode)) |
228 (setq form (cdr form) | 238 (setq expand (let ((load-file-name file)) (macroexpand form))) |
229 name (car form) | 239 (eq (car expand) 'progn) |
230 ;; Ignore the arguments. | 240 (memq :autoload-end expand)) |
231 form (cdr (cond ((eq car 'define-skeleton) | 241 (let ((end (memq :autoload-end expand))) |
232 form) | 242 ;; Cut-off anything after the :autoload-end marker. |
233 ((eq car 'define-derived-mode) | 243 (setcdr end nil) |
234 (cddr form)) | 244 (cons 'progn |
235 (t | 245 (mapcar (lambda (form) (make-autoload form file)) |
236 (cdr form)))) | 246 (cdr expand))))) |
237 doc (car form)) | 247 |
238 (if (stringp doc) | 248 ;; For special function-like operators, use the `autoload' function. |
239 (setq form (cdr form)) | 249 ((memq car '(defun define-skeleton defmacro define-derived-mode |
240 (setq doc nil)) | 250 define-generic-mode easy-mmode-define-minor-mode |
241 (list 'autoload (list 'quote name) file doc | 251 easy-mmode-define-global-mode |
242 (or (eq car 'define-skeleton) | 252 define-minor-mode defun* defmacro*)) |
243 (eq car 'define-derived-mode) | 253 (let* ((macrop (memq car '(defmacro defmacro*))) |
244 (eq (car-safe (car form)) 'interactive)) | 254 (name (nth 1 form)) |
245 (if macrop (list 'quote 'macro) nil))) | 255 (body (nthcdr (get car 'doc-string-elt) form)) |
246 nil))) | 256 (doc (if (stringp (car body)) (pop body)))) |
257 ;; `define-generic-mode' quotes the name, so take care of that | |
258 (list 'autoload (if (listp name) name (list 'quote name)) file doc | |
259 (or (and (memq car '(define-skeleton define-derived-mode | |
260 define-generic-mode | |
261 easy-mmode-define-global-mode | |
262 easy-mmode-define-minor-mode | |
263 define-minor-mode)) t) | |
264 (eq (car-safe (car body)) 'interactive)) | |
265 (if macrop (list 'quote 'macro) nil)))) | |
266 | |
267 ;; Convert defcustom to a simpler (and less space-consuming) defvar, | |
268 ;; but add some extra stuff if it uses :require. | |
269 ((eq car 'defcustom) | |
270 (let ((varname (car-safe (cdr-safe form))) | |
271 (init (car-safe (cdr-safe (cdr-safe form)))) | |
272 (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form))))) | |
273 (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form)))))) | |
274 (if (not (plist-get rest :require)) | |
275 `(defvar ,varname ,init ,doc) | |
276 `(progn | |
277 (defvar ,varname ,init ,doc) | |
278 (custom-add-to-group ,(plist-get rest :group) | |
279 ',varname 'custom-variable) | |
280 (custom-add-load ',varname | |
281 ,(plist-get rest :require)))))) | |
282 | |
283 ;; nil here indicates that this is not a special autoload form. | |
284 (t nil)))) | |
247 | 285 |
248 (defun make-c-autoload (module) | 286 (defun make-c-autoload (module) |
249 "Make an autoload list for the DEFUN at point in MODULE. | 287 "Make an autoload list for the DEFUN at point in MODULE. |
250 Returns nil if the DEFUN is malformed." | 288 Returns nil if the DEFUN is malformed." |
251 (and | 289 (and |
281 | 319 |
282 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 320 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
283 ;; Generating autoloads for a single file | 321 ;; Generating autoloads for a single file |
284 | 322 |
285 ;;;###autoload | 323 ;;;###autoload |
286 (defun generate-file-autoloads (file &optional funlist) | 324 (defun generate-file-autoloads (file) |
287 "Insert at point an autoload section for FILE. | 325 "Insert at point an autoload section for FILE. |
288 autoloads are generated for defuns and defmacros in FILE | 326 autoloads are generated for defuns and defmacros in FILE |
289 marked by `generate-autoload-cookie' (which see). | 327 marked by `generate-autoload-cookie' (which see). |
290 If FILE is being visited in a buffer, the contents of the buffer | 328 If FILE is being visited in a buffer, the contents of the buffer |
291 are used." | 329 are used." |
292 (interactive "fGenerate autoloads for file: ") | 330 (interactive "fGenerate autoloads for file: ") |
293 (cond ((string-match "\\.el$" file) | 331 (cond ((string-match "\\.el$" file) |
294 (generate-autoload-ish-1 | 332 (generate-autoload-type-section |
295 file | 333 file |
296 (replace-in-string (file-name-nondirectory file) "\\.elc?$" "") | 334 (replace-in-string (file-name-nondirectory file) "\\.elc?$" "") |
297 nil #'generate-file-autoloads-1 | 335 nil #'generate-lisp-file-autoloads-1)) |
298 funlist)) | |
299 ;; #### jj, are C++ modules possible? | 336 ;; #### jj, are C++ modules possible? |
300 ((string-match "\\.c$" file) | 337 ((string-match "\\.c$" file) |
301 (generate-autoload-ish-1 | 338 (generate-autoload-type-section |
302 file | 339 file |
303 (replace-in-string (file-name-nondirectory file) "\\.c$" "") | 340 (replace-in-string (file-name-nondirectory file) "\\.c$" "") |
304 t #'generate-c-file-autoloads-1 | 341 t #'generate-c-file-autoloads-1)) |
305 funlist)) | |
306 (t | 342 (t |
307 (error 'wrong-type-argument file "not a C or Elisp source file")))) | 343 (error 'wrong-type-argument file "not a C or Elisp source file")))) |
308 | 344 |
309 (defun* generate-autoload-ish-1 (file load-name literal fun-to-call &rest args) | 345 (defun* generate-autoload-type-section (file load-name literal fun-to-call) |
310 "Insert at point an autoload-type section for FILE. | 346 "Insert at point an autoload-type section for FILE. |
311 If LITERAL, open the file literally, without decoding. | 347 LOAD-NAME is the non-directory portion of the name, with the final .el, .elc |
312 Calls FUN-TO-CALL to compute the autoloads, passing it OUTBUF, LOAD-NAME, | 348 or .c section removed. If LITERAL, open the file literally, without decoding. |
313 TRIM-NAME, and ARGS." | 349 Calls FUN-TO-CALL to compute the autoloads, with the loaded file in the |
350 current buffer, passing it OUTBUF (where to write the autoloads), LOAD-NAME, | |
351 and TRIM-NAME (result of calling `autoload-trim-file-name' on FILE)." | |
314 (let ((outbuf (current-buffer)) | 352 (let ((outbuf (current-buffer)) |
315 (trim-name (autoload-trim-file-name file)) | 353 (trim-name (autoload-trim-file-name file)) |
316 (autoloads-done '()) | 354 (autoloads-done '()) |
317 (print-length nil) | 355 (print-length nil) |
318 (print-readably t) ; XEmacs | 356 (print-readably t) ; XEmacs |
319 (float-output-format nil) | 357 (float-output-format nil) |
320 (visited (get-file-buffer file)) | 358 (visited (get-file-buffer file)) |
359 suppress-form | |
321 ;; (done-any nil) | 360 ;; (done-any nil) |
322 output-end) | 361 output-end) |
323 | 362 |
324 ;; If the autoload section we create here uses an absolute | 363 ;; If the autoload section we create here uses an absolute |
325 ;; pathname for FILE in its header, and then Emacs is installed | 364 ;; pathname for FILE in its header, and then Emacs is installed |
327 ;; `update-autoloads-here' won't be able to find the files to be | 366 ;; `update-autoloads-here' won't be able to find the files to be |
328 ;; autoloaded. So, if FILE is in the same directory or a | 367 ;; autoloaded. So, if FILE is in the same directory or a |
329 ;; subdirectory of the current buffer's directory, we'll make it | 368 ;; subdirectory of the current buffer's directory, we'll make it |
330 ;; relative to the current buffer's directory. | 369 ;; relative to the current buffer's directory. |
331 (setq file (expand-file-name file)) | 370 (setq file (expand-file-name file)) |
371 ;; #### FSF 21.2. Do we want this? | |
372 ; (let* ((source-truename (file-truename file)) | |
373 ; (dir-truename (file-name-as-directory | |
374 ; (file-truename default-directory))) | |
375 ; (len (length dir-truename))) | |
376 ; (if (and (< len (length source-truename)) | |
377 ; (string= dir-truename (substring source-truename 0 len))) | |
378 ; (setq file (substring source-truename len)))) | |
379 | |
380 ;; Check for suppression form (XEmacs) | |
381 (let* ((dir (file-name-directory file)) | |
382 (_pkg (expand-file-name "_pkg.el" dir)) | |
383 (pkg-vis (get-file-buffer _pkg)) | |
384 pkg-buf) | |
385 (save-excursion | |
386 (when (file-readable-p _pkg) | |
387 (unwind-protect | |
388 (progn | |
389 (let ((find-file-hooks nil) | |
390 (enable-local-variables nil)) | |
391 (set-buffer (or pkg-vis (find-file-noselect _pkg))) | |
392 (set-syntax-table emacs-lisp-mode-syntax-table)) | |
393 (save-excursion | |
394 (save-restriction | |
395 (widen) | |
396 (goto-char (point-min)) | |
397 (block nil | |
398 (while (search-forward "(package-suppress" nil t) | |
399 ;; skip over package-name | |
400 (forward-sexp 1) | |
401 (let ((supfile (read (current-buffer)))) | |
402 (when (equal supfile load-name) | |
403 (setq suppress-form (eval (read (current-buffer)))) | |
404 (return)))))))) | |
405 (unless pkg-vis | |
406 ;; We created this buffer, so we should kill it. | |
407 (if pkg-buf (kill-buffer pkg-buf))))))) | |
332 | 408 |
333 (save-excursion | 409 (save-excursion |
334 (unwind-protect | 410 (unwind-protect |
335 (progn | 411 (progn |
336 (let ((find-file-hooks nil) | 412 (let (;(find-file-hooks nil) |
337 (enable-local-variables nil)) | 413 ;(enable-local-variables nil) |
414 ) | |
338 (set-buffer (or visited (find-file-noselect file literal literal | 415 (set-buffer (or visited (find-file-noselect file literal literal |
339 ))) | 416 ))) |
340 ;; This doesn't look right for C files, but it is. The only | 417 ;; This doesn't look right for C files, but it is. The only |
341 ;; place we need the syntax table is when snarfing the Lisp | 418 ;; place we need the syntax table is when snarfing the Lisp |
342 ;; function name. | 419 ;; function name. |
343 (set-syntax-table emacs-lisp-mode-syntax-table)) | 420 (set-syntax-table emacs-lisp-mode-syntax-table)) |
421 ; (if visited | |
422 ; (set-buffer visited) | |
423 ; ;; It is faster to avoid visiting the file. | |
424 ; (set-buffer (get-buffer-create " *generate-autoload-file*")) | |
425 ; (kill-all-local-variables) | |
426 ; (erase-buffer) | |
427 ; (setq buffer-undo-list t | |
428 ; buffer-read-only nil) | |
429 ; ;; This doesn't look right for C files, but it is. The only | |
430 ; ;; place we need the syntax table is when snarfing the Lisp | |
431 ; ;; function name. | |
432 ; (emacs-lisp-mode) | |
433 ; (if literal | |
434 ; (insert-file-contents-literally file nil) | |
435 ; (insert-file-contents file nil))) | |
344 (unless (setq autoloads-done | 436 (unless (setq autoloads-done |
345 (apply fun-to-call outbuf load-name trim-name args)) | 437 (funcall fun-to-call outbuf load-name trim-name)) |
346 (return-from generate-autoload-ish-1)) | 438 (return-from generate-autoload-type-section)) |
347 ) | 439 ) |
348 (unless visited | 440 (unless visited |
349 ;; We created this buffer, so we should kill it. | 441 ;; We created this buffer, so we should kill it. |
350 (kill-buffer (current-buffer))) | 442 (kill-buffer (current-buffer))) |
351 (set-buffer outbuf) | 443 (set-buffer outbuf) |
352 (setq output-end (point-marker)))) | 444 (setq output-end (point-marker)))) |
353 (if t ;; done-any | 445 (if t ;; done-any |
354 ;; XEmacs -- always do this so that we cache the information | 446 ;; XEmacs -- always do this so that we cache the information |
355 ;; that we've processed the file already. | 447 ;; that we've processed the file already. |
356 (progn | 448 (progn |
449 ;; Insert the section-header line | |
450 ;; which lists the file name and which functions are in it, etc. | |
357 (insert generate-autoload-section-header) | 451 (insert generate-autoload-section-header) |
358 (prin1 (list 'autoloads autoloads-done load-name trim-name) | 452 (prin1 (list 'autoloads autoloads-done load-name trim-name |
453 ;; In FSF 21.2. Also in FSF 19.30. Presumably | |
454 ;; deleted from XEmacs. | |
455 ;; (nth 5 (file-attributes file)) | |
456 ) | |
359 outbuf) | 457 outbuf) |
360 (terpri outbuf) | 458 (terpri outbuf) |
361 ;;;; (insert ";;; Generated autoloads from " | 459 ;; #### Alas, we will have to think about this. Adding this means |
362 ;;;; (autoload-trim-file-name file) "\n") | 460 ;; that, once we have created or maintained an auto-autoloads file, |
363 ;; Warn if we put a line in auto-autoloads.el | 461 ;; we alone and our successors can update the file. The file itself |
364 ;; that is long enough to cause trouble. | 462 ;; will work fine in older XEmacsen, but they won't be able to |
365 (when (< output-end (point)) | 463 ;; update autoloads -- hence, to build. |
366 (setq output-end (point-marker))) | 464 ; ;; Break that line at spaces, to avoid very long lines. |
367 (while (< (point) output-end) | 465 ; ;; Make each sub-line into a comment. |
368 ;; (let ((beg (point))) | 466 ; (with-current-buffer outbuf |
369 (end-of-line) | 467 ; (save-excursion |
370 ;; Emacs -- I still haven't figured this one out. | 468 ; (forward-line -1) |
371 ;; (if (> (- (point) beg) 900) | 469 ; (while (not (eolp)) |
372 ;; (progn | 470 ; (move-to-column 64) |
373 ;; (message "A line is too long--over 900 characters") | 471 ; (skip-chars-forward "^ \n") |
374 ;; (sleep-for 2) | 472 ; (or (eolp) |
375 ;; (goto-char output-end))) | 473 ; (insert "\n" generate-autoload-section-continuation))))) |
376 ;; ) | 474 ;; XEmacs: This was commented out before. #### Correct? |
377 (forward-line 1)) | 475 ; (insert ";;; Generated autoloads from " |
476 ; (autoload-trim-file-name file) "\n") | |
477 ;; XEmacs -- handle suppression | |
478 (when suppress-form | |
479 (insert "\n;;; Suppress form from _pkg.el\n") | |
480 (insert "(unless " (prin1-to-string suppress-form) "\n\n")) | |
378 (goto-char output-end) | 481 (goto-char output-end) |
482 ;; XEmacs -- handle suppression | |
483 (when suppress-form | |
484 (insert "\n) ;; unless (suppressed)\n")) | |
379 (insert generate-autoload-section-trailer))) | 485 (insert generate-autoload-section-trailer))) |
380 (or noninteractive ; XEmacs: only need one line in -batch mode. | 486 )) |
381 (message "Generating autoloads for %s...done" file)))) | 487 |
382 | 488 |
383 (defun* generate-file-autoloads-1 (outbuf load-name trim-name funlist) | 489 (defun process-one-lisp-autoload (autoloads-done outbuf load-name) |
384 "Insert at point an autoload section for FILE. | 490 "Process a single autoload at point and write to OUTBUF. |
385 autoloads are generated for defuns and defmacros in FILE | 491 Point should be just after a magic cookie string (e.g. ;;;###autoload). |
386 marked by `generate-autoload-cookie' (which see). | 492 Updates AUTOLOADS-DONE and returns the new value." |
387 If FILE is being visited in a buffer, the contents of the buffer | 493 (skip-chars-forward " \t") |
388 are used." | 494 ;; (setq done-any t) |
495 (if (eolp) | |
496 ;; Read the next form and make an autoload. | |
497 (let* ((form (prog1 (read (current-buffer)) | |
498 (or (bolp) (forward-line 1)))) | |
499 (autoload (make-autoload form load-name))) | |
500 (if autoload | |
501 (setq autoloads-done (cons (nth 1 form) | |
502 autoloads-done)) | |
503 (setq autoload form)) | |
504 (autoload-print-form autoload outbuf "")) | |
505 ;; Copy the rest of the line to the output. | |
506 (cond ((looking-at "immediate\\s *$") ; XEmacs | |
507 ;; This is here so that you can automatically | |
508 ;; have small hook functions copied to | |
509 ;; auto-autoloads.el so that it's not necessary | |
510 ;; to load a whole file just to get a two-line | |
511 ;; do-nothing find-file-hook... --Stig | |
512 (forward-line 1) | |
513 (let ((begin (point))) | |
514 (forward-sexp) | |
515 (forward-line 1) | |
516 (princ (buffer-substring begin (point)) outbuf))) | |
517 (t | |
518 (princ (buffer-substring | |
519 (progn | |
520 ;; Back up over whitespace, to preserve it. | |
521 (skip-chars-backward " \f\t") | |
522 (if (= (char-after (1+ (point))) ? ) | |
523 ;; Eat one space. | |
524 (forward-char 1)) | |
525 (point)) | |
526 (progn (forward-line 1) (point))) | |
527 outbuf)))) | |
528 autoloads-done) | |
529 | |
530 (defun* generate-lisp-file-autoloads-1 (outbuf load-name trim-name) | |
531 "Insert at point in OUTBUF an autoload section for an Elisp file. | |
532 The file is assumed to be already loaded and in the current buffer. | |
533 autoloads are generated for defuns and defmacros marked by | |
534 `generate-autoload-cookie' (which see)." | |
389 (let ((autoloads-done '()) | 535 (let ((autoloads-done '()) |
390 (dofiles (not (null funlist))) | |
391 ) | 536 ) |
392 | |
393 (save-excursion | 537 (save-excursion |
394 (save-restriction | 538 (save-restriction |
395 (widen) | 539 (widen) |
396 (goto-char (point-min)) | 540 (goto-char (point-min)) |
397 (unless (search-forward generate-autoload-cookie nil t) | 541 (unless (search-forward generate-autoload-cookie nil t) |
398 (message "No autoloads found in %s" trim-name) | 542 (message "No autoloads found in %s" trim-name) |
399 (return-from generate-file-autoloads-1 nil)) | 543 (return-from generate-lisp-file-autoloads-1 nil)) |
400 | 544 |
401 (message "Generating autoloads for %s..." trim-name) | 545 (message "Generating autoloads for %s..." trim-name) |
402 (goto-char (point-min)) | 546 (goto-char (point-min)) |
403 (while (if dofiles funlist (not (eobp))) | 547 (while (not (eobp)) |
404 (if (not dofiles) | 548 (skip-chars-forward " \t\n\f") |
405 (skip-chars-forward " \t\n\f") | |
406 (goto-char (point-min)) | |
407 (re-search-forward | |
408 (concat "(def\\(un\\|var\\|const\\|macro\\) " | |
409 (regexp-quote (symbol-name (car funlist))) | |
410 "\\s ")) | |
411 (goto-char (match-beginning 0))) | |
412 (cond | 549 (cond |
413 ((or dofiles | 550 ((looking-at (regexp-quote generate-autoload-cookie)) |
414 (looking-at (regexp-quote generate-autoload-cookie))) | 551 (search-forward generate-autoload-cookie) |
415 (if dofiles | 552 (setq autoloads-done |
416 nil | 553 (process-one-lisp-autoload autoloads-done outbuf load-name))) |
417 (search-forward generate-autoload-cookie) | |
418 (skip-chars-forward " \t")) | |
419 ;; (setq done-any t) | |
420 (if (or dofiles (eolp)) | |
421 ;; Read the next form and make an autoload. | |
422 (let* ((form (prog1 (read (current-buffer)) | |
423 (or (bolp) (forward-line 1)))) | |
424 (autoload (make-autoload form load-name)) | |
425 (doc-string-elt (get (car-safe form) | |
426 'doc-string-elt))) | |
427 (if autoload | |
428 (setq autoloads-done (cons (nth 1 form) | |
429 autoloads-done)) | |
430 (setq autoload form)) | |
431 (print-autoload autoload doc-string-elt outbuf "")) | |
432 ;; Copy the rest of the line to the output. | |
433 (let ((begin (point))) | |
434 ;; (terpri outbuf) | |
435 (cond ((looking-at "immediate\\s *$") ; XEmacs | |
436 ;; This is here so that you can automatically | |
437 ;; have small hook functions copied to | |
438 ;; auto-autoloads.el so that it's not necessary | |
439 ;; to load a whole file just to get a two-line | |
440 ;; do-nothing find-file-hook... --Stig | |
441 (forward-line 1) | |
442 (setq begin (point)) | |
443 (forward-sexp) | |
444 (forward-line 1)) | |
445 (t | |
446 (forward-line 1))) | |
447 (princ (buffer-substring begin (point)) outbuf)))) | |
448 ((looking-at ";") | 554 ((looking-at ";") |
449 ;; Don't read the comment. | 555 ;; Don't read the comment. |
450 (forward-line 1)) | 556 (forward-line 1)) |
451 (t | 557 (t |
452 (forward-sexp 1) | 558 (forward-sexp 1) |
453 (forward-line 1))) | 559 (forward-line 1))) |
454 (if dofiles | 560 ))) |
455 (setq funlist (cdr funlist)))))) | 561 (or noninteractive ; XEmacs: only need one line in -batch mode. |
562 (message "Generating autoloads for %s...done" trim-name)) | |
456 autoloads-done)) | 563 autoloads-done)) |
457 | 564 |
458 (defun* generate-c-file-autoloads-1 (outbuf load-name trim-name funlist) | 565 (defun* generate-c-file-autoloads-1 (outbuf load-name trim-name |
566 &optional funlist) | |
459 "Insert at point an autoload section for the C file FILE. | 567 "Insert at point an autoload section for the C file FILE. |
460 autoloads are generated for defuns and defmacros in FILE | 568 autoloads are generated for defuns and defmacros in FILE |
461 marked by `generate-c-autoload-cookie' (which see). | 569 marked by `generate-c-autoload-cookie' (which see). |
462 If FILE is being visited in a buffer, the contents of the buffer | 570 If FILE is being visited in a buffer, the contents of the buffer |
463 are used." | 571 are used." |
486 "\"")) | 594 "\"")) |
487 (goto-char (match-beginning 0)) | 595 (goto-char (match-beginning 0)) |
488 (let ((autoload (make-c-autoload load-name))) | 596 (let ((autoload (make-c-autoload load-name))) |
489 (when autoload | 597 (when autoload |
490 (push (nth 1 (nth 1 autoload)) autoloads-done) | 598 (push (nth 1 (nth 1 autoload)) autoloads-done) |
491 (print-autoload autoload 3 outbuf " ")))) | 599 (autoload-print-form autoload outbuf " ")))) |
492 ;; close the princ'd `when' form | 600 ;; close the princ'd `when' form |
493 (princ ")" outbuf)) | 601 (princ ")" outbuf)) |
494 (goto-char (point-min)) | 602 (goto-char (point-min)) |
495 (let ((match | 603 (let ((match |
496 (search-forward generate-c-autoload-cookie nil t))) | 604 (search-forward generate-c-autoload-cookie nil t))) |
503 (while match | 611 (while match |
504 (forward-line 1) | 612 (forward-line 1) |
505 (let ((autoload (make-c-autoload load-name))) | 613 (let ((autoload (make-c-autoload load-name))) |
506 (when autoload | 614 (when autoload |
507 (push (nth 1 (nth 1 autoload)) autoloads-done) | 615 (push (nth 1 (nth 1 autoload)) autoloads-done) |
508 (print-autoload autoload 3 outbuf " "))) | 616 (autoload-print-form autoload outbuf " "))) |
509 (setq match | 617 (setq match |
510 (search-forward generate-c-autoload-cookie nil t))) | 618 (search-forward generate-c-autoload-cookie nil t))) |
511 ;; close the princ'd `when' form | 619 ;; close the princ'd `when' form |
512 (princ ")" outbuf))))) | 620 (princ ")" outbuf))))) |
621 (or noninteractive ; XEmacs: only need one line in -batch mode. | |
622 (message "Generating autoloads for %s...done" trim-name)) | |
513 autoloads-done)) | 623 autoloads-done)) |
514 | 624 |
515 ;; Assorted utilities for generating autoloads and pieces thereof | 625 ;;;###autoload |
516 | 626 (defun generate-custom-defines (file) |
517 (defun print-autoload (autoload doc-string-elt outbuf margin) | 627 "Insert at point a custom-define section for FILE. |
628 If FILE is being visited in a buffer, the contents of the buffer | |
629 are used." | |
630 (interactive "fGenerate custom defines for file: ") | |
631 (cond ((string-match "\\.el$" file) | |
632 (generate-autoload-type-section | |
633 file | |
634 (replace-in-string (file-name-nondirectory file) "\\.elc?$" "") | |
635 nil #'generate-custom-defines-1)) | |
636 ((string-match "\\.c$" file) | |
637 ;; no way to generate custom-defines for C files (currently?), | |
638 ;; but cannot signal an error. | |
639 nil) | |
640 (t | |
641 (error 'wrong-type-argument file "not a C or Elisp source file")))) | |
642 | |
643 (defun* generate-custom-defines-1 (outbuf load-name trim-name) | |
644 "Insert at point in OUTBUF a custom-define section for an Elisp file. | |
645 This contains all defcustoms and defgroups in the file. | |
646 The file is assumed to be already loaded and in the current buffer." | |
647 (let* ((search-regexp-1 "^(\\(defcustom\\|defgroup\\) ") | |
648 (search-string-2 ";;;###custom-define") | |
649 (search-regexp-2 (regexp-quote search-string-2)) | |
650 (autoloads-done '())) | |
651 (save-excursion | |
652 (save-restriction | |
653 (widen) | |
654 (goto-char (point-min)) | |
655 (unless (or (re-search-forward search-regexp-1 nil t) | |
656 (re-search-forward search-regexp-2 nil t)) | |
657 (message "No custom defines found in %s" trim-name) | |
658 (return-from generate-custom-defines-1 nil)) | |
659 (message "Generating custom defines for %s..." trim-name) | |
660 (princ "(defconst custom-define-current-source-file " outbuf) | |
661 (prin1 (file-relative-name (buffer-file-name) | |
662 (symbol-value-in-buffer 'default-directory | |
663 outbuf)) outbuf) | |
664 (princ ")\n" outbuf) | |
665 | |
666 (goto-char (point-min)) | |
667 (while (not (eobp)) | |
668 (skip-chars-forward " \t\n\f") | |
669 (cond | |
670 ((looking-at search-regexp-1) | |
671 ;; Read the next form and copy it to make an autoload. | |
672 (let* ((form (prog1 (read (current-buffer)) | |
673 (or (bolp) (forward-line 1)))) | |
674 (autoload form ;(make-autoload form load-name) | |
675 )) | |
676 (if autoload | |
677 (setq autoloads-done (cons (nth 1 form) | |
678 autoloads-done)) | |
679 (setq autoload form)) | |
680 (autoload-print-form autoload outbuf "")) | |
681 ) | |
682 ((looking-at search-regexp-2) | |
683 (search-forward search-string-2) | |
684 (beep) | |
685 (setq autoloads-done | |
686 (process-one-lisp-autoload autoloads-done outbuf load-name))) | |
687 ((looking-at ";") | |
688 ;; Don't read the comment. | |
689 (forward-line 1)) | |
690 (t | |
691 (forward-sexp 1) | |
692 (forward-line 1))) | |
693 ))) | |
694 (or noninteractive ; XEmacs: only need one line in -batch mode. | |
695 (message "Generating custom defines for %s...done" trim-name)) | |
696 autoloads-done)) | |
697 | |
698 ;; Assorted utilities for generating autoloads and pieces thereof | |
699 | |
700 (defun autoload-print-form (form outbuf margin) | |
518 "Print an autoload form, handling special characters. | 701 "Print an autoload form, handling special characters. |
519 In particular, print docstrings with escapes inserted before left parentheses | 702 In particular, print docstrings with escapes inserted before left parentheses |
520 at the beginning of lines and ^L characters." | 703 at the beginning of lines and ^L characters." |
521 (if (and doc-string-elt (stringp (nth doc-string-elt autoload))) | 704 (cond |
522 ;; We need to hack the printing because the doc-string must be | 705 ;; If the form is a sequence, recurse. |
523 ;; printed specially for make-docfile (sigh). | 706 ((eq (car form) 'progn) |
524 (let* ((p (nthcdr (1- doc-string-elt) autoload)) | 707 (mapcar #'(lambda (x) (autoload-print-form x outbuf margin)) |
525 (elt (cdr p)) | 708 (cdr form))) |
526 (start-string (format "\n%s(" margin))) | 709 ;; Symbols at the toplevel are meaningless. |
527 (setcdr p nil) | 710 ((symbolp form) nil) |
528 (princ start-string outbuf) | 711 (t |
529 ;; XEmacs change: don't let ^^L's get into | 712 (let ((doc-string-elt (get (car-safe form) 'doc-string-elt))) |
530 ;; the file or sorting is hard. | 713 (if (and doc-string-elt (stringp (nth doc-string-elt form))) |
531 (let ((print-escape-newlines t) | 714 ;; We need to hack the printing because the doc-string must be |
532 (p (save-excursion | 715 ;; printed specially for make-docfile (sigh). |
533 (set-buffer outbuf) | 716 (let* ((p (nthcdr (1- doc-string-elt) form)) |
534 (point))) | 717 (elt (cdr p)) |
718 (start-string (format "\n%s(" margin))) | |
719 (setcdr p nil) | |
720 (princ start-string outbuf) | |
721 ;; XEmacs change: don't let ^^L's get into | |
722 ;; the file or sorting is hard. | |
723 (let ((print-escape-newlines t) | |
724 ;;#### FSF 21.2 (print-escape-nonascii t) | |
725 (p (point outbuf)) | |
726 p2) | |
727 (mapcar #'(lambda (elt) | |
728 (prin1 elt outbuf) | |
729 (princ " " outbuf)) | |
730 form) | |
731 (with-current-buffer outbuf | |
732 (setq p2 (point-marker)) | |
733 (goto-char p) | |
734 (save-match-data | |
735 (while (search-forward "\^L" p2 t) | |
736 (delete-char -1) | |
737 (insert "\\^L"))) | |
738 (goto-char p2))) | |
739 (princ "\"\\\n" outbuf) | |
740 (let ((begin (point outbuf))) | |
741 (princ (substring (prin1-to-string (car elt)) 1) outbuf) | |
742 ;; Insert a backslash before each ( that appears at the beginning | |
743 ;; of a line in the doc string. | |
744 (with-current-buffer outbuf | |
745 (save-excursion | |
746 (while (search-backward start-string begin t) | |
747 (forward-char 1) | |
748 (insert "\\")))) | |
749 (if (null (cdr elt)) | |
750 (princ ")" outbuf) | |
751 (princ " " outbuf) | |
752 (princ (substring (prin1-to-string (cdr elt)) 1) outbuf)) | |
753 (terpri outbuf) | |
754 (princ margin outbuf))) | |
755 ;; XEmacs change: another ^L hack | |
756 (let ((p (point outbuf)) | |
757 (print-escape-newlines t) | |
758 ;;#### FSF 21.2 (print-escape-nonascii t) | |
535 p2) | 759 p2) |
536 (mapcar #'(lambda (elt) | 760 (print form outbuf) |
537 (prin1 elt outbuf) | 761 (with-current-buffer outbuf |
538 (princ " " outbuf)) | |
539 autoload) | |
540 (save-excursion | |
541 (set-buffer outbuf) | |
542 (setq p2 (point-marker)) | 762 (setq p2 (point-marker)) |
543 (goto-char p) | 763 (goto-char p) |
544 (save-match-data | 764 (save-match-data |
545 (while (search-forward "\^L" p2 t) | 765 (while (search-forward "\^L" p2 t) |
546 (delete-char -1) | 766 (delete-char -1) |
547 (insert "\\^L"))) | 767 (insert "\\^L"))) |
548 (goto-char p2))) | 768 (goto-char p2)))))))) |
549 (princ "\"\\\n" outbuf) | |
550 (let ((begin (save-excursion | |
551 (set-buffer outbuf) | |
552 (point)))) | |
553 (princ (substring (prin1-to-string (car elt)) 1) outbuf) | |
554 ;; Insert a backslash before each ( that appears at the beginning | |
555 ;; of a line in the doc string. | |
556 (save-excursion | |
557 (set-buffer outbuf) | |
558 (save-excursion | |
559 (while (search-backward start-string begin t) | |
560 (forward-char 1) | |
561 (insert "\\")))) | |
562 (if (null (cdr elt)) | |
563 (princ ")" outbuf) | |
564 (princ " " outbuf) | |
565 (princ (substring (prin1-to-string (cdr elt)) 1) outbuf)) | |
566 (terpri outbuf) | |
567 (princ margin outbuf))) | |
568 ;; XEmacs change: another ^L hack | |
569 (let ((p (save-excursion | |
570 (set-buffer outbuf) | |
571 (point))) | |
572 (print-escape-newlines t) | |
573 p2) | |
574 (print autoload outbuf) | |
575 (save-excursion | |
576 (set-buffer outbuf) | |
577 (setq p2 (point-marker)) | |
578 (goto-char p) | |
579 (save-match-data | |
580 (while (search-forward "\^L" p2 t) | |
581 (delete-char -1) | |
582 (insert "\\^L"))) | |
583 (goto-char p2))))) | |
584 | 769 |
585 ;;; Forms which have doc-strings which should be printed specially. | 770 ;;; Forms which have doc-strings which should be printed specially. |
586 ;;; A doc-string-elt property of ELT says that (nth ELT FORM) is | 771 ;;; A doc-string-elt property of ELT says that (nth ELT FORM) is |
587 ;;; the doc-string in FORM. | 772 ;;; the doc-string in FORM. |
588 ;;; | 773 ;;; |
589 ;;; defvar and defconst should be also be marked in this way. There is | 774 ;;; There used to be the following note here: |
590 ;;; no interference from make-docfile, which only processes those files | 775 ;;; ;;; Note: defconst and defvar should NOT be marked in this way. |
591 ;;; that are loaded into the dumped Emacs, and those files should | 776 ;;; ;;; We don't want to produce defconsts and defvars that |
592 ;;; never have anything autoloaded here. Problems only occur with files | 777 ;;; ;;; make-docfile can grok, because then it would grok them twice, |
778 ;;; ;;; once in foo.el (where they are given with ;;;###autoload) and | |
779 ;;; ;;; once in loaddefs.el. | |
780 ;;; | |
781 ;;; Counter-note: Yes, they should be marked in this way. | |
782 ;;; make-docfile only processes those files that are loaded into the | |
783 ;;; dumped Emacs, and those files should never have anything | |
784 ;;; autoloaded here. The above-feared problem only occurs with files | |
593 ;;; which have autoloaded entries *and* are processed by make-docfile; | 785 ;;; which have autoloaded entries *and* are processed by make-docfile; |
594 ;;; there should be no such files. | 786 ;;; there should be no such files. |
595 | 787 |
596 (put 'autoload 'doc-string-elt 3) | 788 (put 'autoload 'doc-string-elt 3) |
597 (put 'defun 'doc-string-elt 3) | 789 (put 'defun 'doc-string-elt 3) |
598 (put 'defun* 'doc-string-elt 3) | 790 (put 'defun* 'doc-string-elt 3) |
599 (put 'defvar 'doc-string-elt 3) | 791 (put 'defvar 'doc-string-elt 3) |
792 (put 'defcustom 'doc-string-elt 3) | |
600 (put 'defconst 'doc-string-elt 3) | 793 (put 'defconst 'doc-string-elt 3) |
601 (put 'defmacro 'doc-string-elt 3) | 794 (put 'defmacro 'doc-string-elt 3) |
602 (put 'defmacro* 'doc-string-elt 3) | 795 (put 'defmacro* 'doc-string-elt 3) |
603 (put 'define-skeleton 'doc-string-elt 3) | 796 (put 'defsubst 'doc-string-elt 3) |
797 (put 'define-skeleton 'doc-string-elt 2) | |
604 (put 'define-derived-mode 'doc-string-elt 4) | 798 (put 'define-derived-mode 'doc-string-elt 4) |
799 (put 'easy-mmode-define-minor-mode 'doc-string-elt 2) | |
800 (put 'define-minor-mode 'doc-string-elt 2) | |
801 (put 'define-generic-mode 'doc-string-elt 7) | |
802 ;; defin-global-mode has no explicit docstring. | |
803 (put 'easy-mmode-define-global-mode 'doc-string-elt 1000) | |
605 | 804 |
606 (defun autoload-trim-file-name (file) | 805 (defun autoload-trim-file-name (file) |
607 "Returns relative pathname of FILE including the last directory. | 806 "Returns relative pathname of FILE including the last directory. |
608 | 807 |
609 Hard-codes the directory separator as a forward slash." | 808 Hard-codes the directory separator as a forward slash." |
612 (file-relative-name file (file-name-directory | 811 (file-relative-name file (file-name-directory |
613 (directory-file-name | 812 (directory-file-name |
614 (file-name-directory file)))) | 813 (file-name-directory file)))) |
615 ;; #### is this a good idea? | 814 ;; #### is this a good idea? |
616 "\\\\" "/")) | 815 "\\\\" "/")) |
816 | |
817 (defun autoload-read-section-header () | |
818 "Read a section header form. | |
819 Since continuation lines have been marked as comments, | |
820 we must copy the text of the form and remove those comment | |
821 markers before we call `read'." | |
822 (save-match-data | |
823 (let ((beginning (point)) | |
824 string) | |
825 (forward-line 1) | |
826 (while (looking-at generate-autoload-section-continuation) | |
827 (forward-line 1)) | |
828 (setq string (buffer-substring beginning (point))) | |
829 (with-current-buffer (get-buffer-create " *autoload*") | |
830 (erase-buffer) | |
831 (insert string) | |
832 (goto-char (point-min)) | |
833 (while (search-forward generate-autoload-section-continuation nil t) | |
834 (replace-match " ")) | |
835 (goto-char (point-min)) | |
836 (read (current-buffer)))))) | |
617 | 837 |
618 ;;;###autoload | 838 ;;;###autoload |
619 (defun update-file-autoloads (file) | 839 (defun update-file-autoloads (file) |
620 "Update the autoloads for FILE in `generated-autoload-file' | 840 "Update the autoloads for FILE in `generated-autoload-file' |
621 \(which FILE might bind in its local variables). | 841 \(which FILE might bind in its local variables). |
631 "\\.\\(elc?\\|c\\)$" | 851 "\\.\\(elc?\\|c\\)$" |
632 "")) | 852 "")) |
633 (trim-name (autoload-trim-file-name file)) | 853 (trim-name (autoload-trim-file-name file)) |
634 section-begin form) | 854 section-begin form) |
635 (save-excursion | 855 (save-excursion |
856 ;; FSF has: [[ We want to get a value for generated-autoload-file | |
857 ;; from the local variables section if it's there. ]] Not | |
858 ;; applicable in XEmacs, since we always keep the autoloads | |
859 ;; up-to-date. | |
860 | |
861 ;; #### FSF 21.2 adds: [[ We must read/write the file without any | |
862 ;; code conversion, but still decode EOLs. ]] Not clear if we need | |
863 ;; this. --ben | |
864 ;; (let ((coding-system-for-read 'raw-text)) | |
636 (let ((find-file-hooks nil)) | 865 (let ((find-file-hooks nil)) |
637 (set-buffer (or (get-file-buffer generated-autoload-file) | 866 (set-buffer (or (get-file-buffer generated-autoload-file) |
638 (find-file-noselect generated-autoload-file)))) | 867 (find-file-noselect generated-autoload-file)))) |
868 ;; FSF 21.2 says: | |
869 | |
870 ;; [[ This is to make generated-autoload-file have Unix EOLs, so | |
871 ;; that it is portable to all platforms. ]] | |
872 ;; (setq buffer-file-coding-system 'raw-text-unix)) | |
873 ;; Not applicable in XEmacs, since we always keep the autoloads | |
874 ;; up-to-date and recompile when we build. | |
875 | |
876 ;; FSF 21.2: [not applicable to XEmacs] | |
877 ; (or (> (buffer-size) 0) | |
878 ; (error "Autoloads file %s does not exist" buffer-file-name)) | |
879 ; (or (file-writable-p buffer-file-name) | |
880 ; (error "Autoloads file %s is not writable" buffer-file-name)) | |
881 | |
882 ;; NOTE: The rest of this function is totally changed from FSF. | |
883 ;; Hence, not synched. | |
884 | |
639 ;; Make sure we can scribble in it. | 885 ;; Make sure we can scribble in it. |
640 (setq buffer-read-only nil) | 886 (setq buffer-read-only nil) |
641 ;; First delete all sections for this file. | 887 ;; First delete all sections for this file. |
642 (goto-char (point-min)) | 888 (goto-char (point-min)) |
643 (while (search-forward generate-autoload-section-header nil t) | 889 (while (search-forward generate-autoload-section-header nil t) |
644 (setq section-begin (match-beginning 0)) | 890 (setq section-begin (match-beginning 0)) |
645 (setq form (read (current-buffer))) | 891 (setq form (autoload-read-section-header)) |
646 (when (string= (nth 2 form) load-name) | 892 (when (string= (nth 2 form) load-name) |
647 (search-forward generate-autoload-section-trailer) | 893 (search-forward generate-autoload-section-trailer) |
648 (delete-region section-begin (point)))) | 894 (delete-region section-begin (point)))) |
649 | 895 |
650 ;; Now find insertion point for new section | 896 ;; Now find insertion point for new section |
651 (block find-insertion-point | 897 (block find-insertion-point |
652 (goto-char (point-min)) | 898 (goto-char (point-min)) |
653 (while (search-forward generate-autoload-section-header nil t) | 899 (while (search-forward generate-autoload-section-header nil t) |
654 (setq form (read (current-buffer))) | 900 (setq form (autoload-read-section-header)) |
655 (when (string< trim-name (nth 3 form)) | 901 (when (string< trim-name (nth 3 form)) |
656 ;; Found alphabetically correct insertion point | 902 ;; Found alphabetically correct insertion point |
657 (goto-char (match-beginning 0)) | 903 (goto-char (match-beginning 0)) |
658 (return-from find-insertion-point)) | 904 (return-from find-insertion-point)) |
659 (search-forward generate-autoload-section-trailer)) | 905 (search-forward generate-autoload-section-trailer)) |
660 (when (eq (point) (point-min)) ; No existing entries? | 906 (when (eq (point) (point-min)) ; No existing entries? |
661 (goto-char (point-max)))) ; Append. | 907 (goto-char (point-max)))) ; Append. |
662 | 908 |
663 ;; Add in new sections for file | 909 ;; Add in new sections for file |
664 (generate-file-autoloads file)) | 910 (funcall generate-autoload-function file)) |
665 | 911 |
666 (when (interactive-p) (save-buffer))))) | 912 (when (interactive-p) (save-buffer))))) |
667 | |
668 ;;;###autoload | |
669 (defun update-autoloads-here () | |
670 "Update sections of the current buffer generated by `update-file-autoloads'." | |
671 (interactive) | |
672 (let ((generated-autoload-file (buffer-file-name))) | |
673 (save-excursion | |
674 (goto-char (point-min)) | |
675 (while (search-forward generate-autoload-section-header nil t) | |
676 (let* ((form (condition-case () | |
677 (read (current-buffer)) | |
678 (end-of-file nil))) | |
679 (file (nth 3 form))) | |
680 ;; XEmacs change: if we can't find the file as specified, look | |
681 ;; around a bit more. | |
682 (cond ((and (stringp file) | |
683 (or (get-file-buffer file) | |
684 (file-exists-p file)))) | |
685 ((and (stringp file) | |
686 (save-match-data | |
687 (let ((loc (locate-file (file-name-nondirectory file) | |
688 load-path))) | |
689 (if (null loc) | |
690 nil | |
691 (setq loc (expand-file-name | |
692 (autoload-trim-file-name loc) | |
693 "..")) | |
694 (if (or (get-file-buffer loc) | |
695 (file-exists-p loc)) | |
696 (setq file loc) | |
697 nil)))))) | |
698 (t | |
699 (setq file | |
700 (if (y-or-n-p | |
701 (format | |
702 "Can't find library `%s'; remove its autoloads? " | |
703 (nth 2 form) file)) | |
704 t | |
705 (condition-case () | |
706 (read-file-name | |
707 (format "Find `%s' load file: " | |
708 (nth 2 form)) | |
709 nil nil t) | |
710 (quit nil)))))) | |
711 (if file | |
712 (let ((begin (match-beginning 0))) | |
713 (search-forward generate-autoload-section-trailer) | |
714 (delete-region begin (point)))) | |
715 (if (stringp file) | |
716 (generate-file-autoloads file))))))) | |
717 | 913 |
718 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 914 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
719 ;; Utilities for batch updates | 915 ;; Utilities for batch updates |
720 | 916 |
721 ;;;###autoload | 917 ;;;###autoload |
722 (defun autoload-update-directory-autoloads () | 918 (defun batch-update-directory-autoloads () |
723 "Update the autoloads for a directory, using a specified feature prefix. | 919 "Update the autoloads for a directory, using a specified feature prefix. |
724 Must be used only with -batch. The feature prefix and directory to update | 920 Must be used only with -batch. The feature prefix and directory to update |
725 are taken from the first and second elements of `command-line-args-left', | 921 are taken from the first and second elements of `command-line-args-left', |
726 respectively, and they are then removed from `command-line-args-left'. | 922 respectively, and they are then removed from `command-line-args-left'. |
727 | 923 |
729 rewrites the autoloads file, even if unchanged. Makes a feature name by | 925 rewrites the autoloads file, even if unchanged. Makes a feature name by |
730 applying `autoload-make-feature-name' to the specified feature prefix. | 926 applying `autoload-make-feature-name' to the specified feature prefix. |
731 | 927 |
732 #### The API and semantics of this function are subject to change." | 928 #### The API and semantics of this function are subject to change." |
733 (unless noninteractive | 929 (unless noninteractive |
734 (error "autoload-batch-update-autoloads: may be used only with -batch")) | 930 (error "batch-update-directory-autoloads: may be used only with -batch")) |
735 (let* ((autoload-feature-prefix (car command-line-args-left)) | 931 (update-autoload-files (list (cadr command-line-args-left)) |
736 (dir (cadr command-line-args-left)) | 932 (car command-line-args-left) nil t) |
737 (generated-autoload-file (expand-file-name autoload-file-name dir))) | 933 (setq command-line-args-left (cddr command-line-args-left))) |
738 (update-autoload-files (list dir) t t) | |
739 (setq command-line-args-left (cddr command-line-args-left)))) | |
740 | 934 |
741 ;;;###autoload | 935 ;;;###autoload |
742 (defun update-autoload-files (files-or-dirs &optional all-into-one-file force) | 936 (defun batch-update-directory-custom-defines () |
937 "Update the custom defines for a directory, using a specified feature prefix. | |
938 Must be used only with -batch. The feature prefix and directory to update | |
939 are taken from the first and second elements of `command-line-args-left', | |
940 respectively, and they are then removed from `command-line-args-left'. | |
941 | |
942 Runs `update-file-autoloads' on each file in the given directory. Always | |
943 rewrites the autoloads file, even if unchanged. Makes a feature name by | |
944 applying `autoload-make-feature-name' to the specified feature prefix. | |
945 | |
946 #### The API and semantics of this function are subject to change." | |
947 (unless noninteractive | |
948 (error "batch-update-directory-custom-defines: may be used only with -batch")) | |
949 (update-custom-define-files (list (cadr command-line-args-left)) | |
950 (car command-line-args-left) nil t) | |
951 (setq command-line-args-left (cddr command-line-args-left))) | |
952 | |
953 ;;;###autoload | |
954 (defun update-autoload-files (files-or-dirs feature-prefix | |
955 &optional into-file force) | |
743 "Update all the autoload files associated with FILES-OR-DIRS. | 956 "Update all the autoload files associated with FILES-OR-DIRS. |
744 FILES-OR-DIRS is a list of files and/or directories to be processed. | 957 FILES-OR-DIRS is a list of files and/or directories to be processed. |
745 | 958 |
746 An appropriate autoload file is chosen and a feature constructed for | 959 An appropriate autoload file is chosen and a feature constructed for |
747 each element of FILES-OR-DIRS. Fixup code testing for the autoload file's | 960 each element of FILES-OR-DIRS. Fixup code testing for the autoload file's |
748 feature and to provide the feature is added. | 961 feature and to provide the feature is added. |
749 | 962 |
750 If optional ALL-INTO-ONE-FILE is non-`nil', `generated-autoload-file' | 963 If optional INTO-FILE is non-`nil', it should specify a file into which |
751 should be set to the name of an autoload file and all autoloads will be | 964 the autoloads will be placed. Otherwise, the autoloads will be placed into |
752 placed in that file. `autoload-feature-prefix' should be set to an | 965 a file named `auto-autoloads.el' in the directory of each element in |
753 appropriate prefix which will be concatenated with \"-autoloads\" to | 966 FILES-OR-DIRS. |
754 produce the feature name. Otherwise the appropriate autoload file for | 967 |
755 each file or directory (located in that directory, or in the directory of | 968 FEATURE-PREFIX should be set to an appropriate prefix which will |
756 the specified file) will be updated with the directory's or file's | 969 be concatenated with \"-autoloads\" to produce the feature name. Otherwise |
757 autoloads and the protective forms will be added, and the files will be | 970 the appropriate autoload file for each file or directory (located in that |
758 saved. Use of the default here is unreliable, and therefore deprecated. | 971 directory, or in the directory of the specified file) will be updated with |
972 the directory's or file's autoloads and the protective forms will be added, | |
973 and the files will be saved. Use of the default here is unreliable, and | |
974 therefore deprecated. | |
759 | 975 |
760 Note that if some of FILES-OR-DIRS are directories, recursion goes only | 976 Note that if some of FILES-OR-DIRS are directories, recursion goes only |
761 one level deep. | 977 one level deep. |
762 | 978 |
763 If FORCE is non-nil, always save out the autoload files even if unchanged." | 979 If FORCE is non-nil, always save out the autoload files even if unchanged." |
980 (or (listp files-or-dirs) (setq files-or-dirs (list files-or-dirs))) | |
764 (let ((defdir (directory-file-name default-directory)) | 981 (let ((defdir (directory-file-name default-directory)) |
765 ;; value for all-into-one-file | 982 ;; value for all-into-one-file |
766 (autoload-feature-name (autoload-make-feature-name)) | 983 (autoload-feature-name (autoload-make-feature-name feature-prefix)) |
767 (enable-local-eval nil)) ; Don't query in batch mode. | 984 (enable-local-eval nil) ; Don't query in batch mode. |
985 (autoload-feature-prefix feature-prefix) | |
986 ;; protect from change | |
987 (generated-autoload-file generated-autoload-file)) | |
768 (dolist (arg files-or-dirs) | 988 (dolist (arg files-or-dirs) |
769 (setq arg (expand-file-name arg defdir)) | 989 (setq arg (expand-file-name arg defdir)) |
770 (cond | 990 (cond |
771 ((file-directory-p arg) | 991 ((file-directory-p arg) |
992 (setq generated-autoload-file | |
993 (or into-file (expand-file-name autoload-file-name arg))) | |
772 (message "Updating autoloads for directory %s..." arg) | 994 (message "Updating autoloads for directory %s..." arg) |
773 (update-autoloads-from-directory arg)) | 995 (let ((simple-dir (file-name-as-directory |
996 (file-name-nondirectory | |
997 (directory-file-name arg)))) | |
998 (enable-local-eval nil)) | |
999 (save-excursion | |
1000 (let ((find-file-hooks nil)) | |
1001 (set-buffer (find-file-noselect generated-autoload-file))) | |
1002 (goto-char (point-min)) | |
1003 (while (search-forward generate-autoload-section-header nil t) | |
1004 (let* ((begin (match-beginning 0)) | |
1005 (form (autoload-read-section-header)) | |
1006 (file (nth 3 form))) | |
1007 (when (and (stringp file) | |
1008 (string= (file-name-directory file) simple-dir) | |
1009 (not (file-exists-p | |
1010 (expand-file-name | |
1011 (file-name-nondirectory file) arg)))) | |
1012 ;; Remove the obsolete section. | |
1013 (search-forward generate-autoload-section-trailer) | |
1014 (delete-region begin (point))))) | |
1015 ;; Update or create autoload sections for existing files. | |
1016 (mapcar 'update-file-autoloads | |
1017 (directory-files arg t "^[^=].*\\.\\(el\\|c\\)$"))))) | |
774 ((file-exists-p arg) | 1018 ((file-exists-p arg) |
1019 (setq generated-autoload-file | |
1020 (or into-file (expand-file-name autoload-file-name | |
1021 (file-name-directory arg)))) | |
775 (update-file-autoloads arg)) | 1022 (update-file-autoloads arg)) |
776 (t (error "No such file or directory: %s" arg))) | 1023 (t (error "No such file or directory: %s" arg))) |
777 (when (not all-into-one-file) | 1024 (when (not into-file) |
778 (autoload-featurep-protect-autoloads | 1025 (autoload-featurep-protect-autoloads |
779 (autoload-make-feature-name | 1026 (autoload-make-feature-name |
780 (file-name-nondirectory (directory-file-name arg)))) | 1027 (or feature-prefix |
1028 (file-name-nondirectory (directory-file-name arg))))) | |
781 (if force (set-buffer-modified-p | 1029 (if force (set-buffer-modified-p |
782 t (find-file-noselect generated-autoload-file))))) | 1030 t (find-file-noselect generated-autoload-file))))) |
783 (when all-into-one-file | 1031 (when into-file |
784 (autoload-featurep-protect-autoloads autoload-feature-name) | 1032 (autoload-featurep-protect-autoloads autoload-feature-name) |
785 (if force (set-buffer-modified-p | 1033 (if force (set-buffer-modified-p |
786 t (find-file-noselect generated-autoload-file)))) | 1034 t (find-file-noselect into-file)))) |
787 (save-some-buffers t) | 1035 (save-some-buffers t) |
788 )) | 1036 )) |
789 | 1037 |
790 ;;;###autoload | 1038 ;;;###autoload |
791 (defun update-autoloads-from-directory (dir) | 1039 (defun update-custom-define-files (files-or-dirs feature-prefix |
792 "Update `generated-autoload-file' with all the current autoloads from DIR. | 1040 &optional into-file force) |
793 This runs `update-file-autoloads' on each .el and .c file in DIR. | 1041 "Update all the custom-define files associated with FILES-OR-DIRS. |
794 Obsolete autoload entries for files that no longer exist are deleted. | 1042 Works just like `update-file-autoloads'." |
795 Note that, if this function is called from `batch-update-directory', | 1043 (let* ((autoload-feature-suffix "-custom-defines") |
796 `generated-autoload-file' was rebound in that function. | 1044 (autoload-file-name "custom-defines.el") |
797 | 1045 (generate-autoload-function #'generate-custom-defines)) |
798 You don't really want to be calling this function. Try using | 1046 (update-autoload-files files-or-dirs feature-prefix into-file force))) |
799 `update-autoload-files' instead." | |
800 (interactive "DUpdate autoloads for directory: ") | |
801 (setq dir (expand-file-name dir)) | |
802 (let ((simple-dir (file-name-as-directory | |
803 (file-name-nondirectory | |
804 (directory-file-name dir)))) | |
805 (enable-local-eval nil)) | |
806 (save-excursion | |
807 (let ((find-file-hooks nil)) | |
808 (set-buffer (find-file-noselect generated-autoload-file))) | |
809 (goto-char (point-min)) | |
810 (while (search-forward generate-autoload-section-header nil t) | |
811 (let* ((begin (match-beginning 0)) | |
812 (form (condition-case () | |
813 (read (current-buffer)) | |
814 (end-of-file nil))) | |
815 (file (nth 3 form))) | |
816 (when (and (stringp file) | |
817 (string= (file-name-directory file) simple-dir) | |
818 (not (file-exists-p | |
819 (expand-file-name | |
820 (file-name-nondirectory file) dir)))) | |
821 ;; Remove the obsolete section. | |
822 (search-forward generate-autoload-section-trailer) | |
823 (delete-region begin (point))))) | |
824 ;; Update or create autoload sections for existing files. | |
825 (mapcar 'update-file-autoloads | |
826 (directory-files dir t "^[^=].*\\.\\(el\\|c\\)$")) | |
827 (unless noninteractive | |
828 (save-buffer))))) | |
829 | 1047 |
830 (defun autoload-featurep-protect-autoloads (sym) | 1048 (defun autoload-featurep-protect-autoloads (sym) |
831 (save-excursion | 1049 (save-excursion |
832 (set-buffer (find-file-noselect generated-autoload-file)) | 1050 (set-buffer (find-file-noselect generated-autoload-file)) |
833 (goto-char (point-min)) | 1051 (goto-char (point-min)) |
834 (if (and (not (= (point-min) (point-max))) | 1052 (cond ((eq (point-min) (point-max)) nil) |
835 (not (looking-at ";;; DO NOT MODIFY THIS FILE"))) | 1053 ;; if there's some junk in the file but no sections, just |
836 (progn | 1054 ;; delete everything. the junk might be stuff inserted by |
837 (insert ";;; DO NOT MODIFY THIS FILE\n") | 1055 ;; an older version of this function. |
838 (insert "(if (featurep '" sym ")") | 1056 ((not (search-forward generate-autoload-section-header nil t)) |
839 (insert " (error \"Feature " sym " already loaded\"))\n") | 1057 (delete-region (point-min) (point-max))) |
840 (goto-char (point-max)) | 1058 (t |
841 (insert "\n(provide '" sym ")\n"))))) | 1059 (goto-char (point-min)) |
1060 (when (looking-at ";;; DO NOT MODIFY THIS FILE") | |
1061 (delete-region (point-min) | |
1062 (progn | |
1063 (search-forward generate-autoload-section-header) | |
1064 (match-beginning 0)))) | |
1065 ;; Determine and set the coding system for the file if under Mule. | |
1066 ;; If there are any extended characters in the input file, use | |
1067 ;; `escape-quoted' to make sure that both binary and extended | |
1068 ;; characters are output properly and distinguished properly. | |
1069 ;; Otherwise, use `raw-text' for maximum portability with non-Mule | |
1070 ;; Emacsen. | |
1071 (if (or (featurep '(not mule)) ;; Don't scan if no Mule support | |
1072 (progn | |
1073 (goto-char (point-min)) | |
1074 ;; mrb- There must be a better way than skip-chars-forward | |
1075 (skip-chars-forward (concat (char-to-string 0) "-" | |
1076 (char-to-string 255))) | |
1077 (eq (point) (point-max)))) | |
1078 (setq buffer-file-coding-system 'raw-text-unix) | |
1079 (setq buffer-file-coding-system 'escape-quoted)) | |
1080 (goto-char (point-min)) | |
1081 (insert ";;; DO NOT MODIFY THIS FILE") | |
1082 ;; NOTE: XEmacs prior to 21.5.12 or so had a bug in that it | |
1083 ;; recognized only one of the two magic-cookie styles (the -*- kind) | |
1084 ;; in find-file, but both of them in load. We go ahead and put both | |
1085 ;; in, just to be safe. | |
1086 (when (eq buffer-file-coding-system 'escape-quoted) | |
1087 (insert " -*- coding: escape-quoted; -*- | |
1088 \(or (featurep 'mule) (error \"Loading this file requires Mule support\")) | |
1089 ;;;###coding system: escape-quoted")) | |
1090 (insert "\n(if (featurep '" sym ")") | |
1091 (insert " (error \"Feature " sym " already loaded\"))\n") | |
1092 (goto-char (point-max)) | |
1093 (save-excursion | |
1094 (forward-line -1) | |
1095 (when (looking-at "(provide") | |
1096 (delete-region (point) (point-max)))) | |
1097 (unless (bolp) (insert "\n")) | |
1098 (unless (eq (char-before (1- (point))) ?\^L) | |
1099 (insert "\^L\n")) | |
1100 (insert "(provide '" sym ")\n"))))) | |
842 | 1101 |
843 (defun autoload-make-feature-name (&optional prefix) | 1102 (defun autoload-make-feature-name (&optional prefix) |
844 "Generate the feature name to protect this auto-autoloads file from PREFIX. | 1103 "Generate the feature name to protect this auto-autoloads file from PREFIX. |
845 | 1104 |
846 If PREFIX is nil, it defaults to the value of `autoload-feature-prefix' if | 1105 If PREFIX is nil, it defaults to the value of `autoload-feature-prefix' if |
862 (file-name-nondirectory | 1121 (file-name-nondirectory |
863 (directory-file-name | 1122 (directory-file-name |
864 (file-name-directory generated-autoload-file)))) | 1123 (file-name-directory generated-autoload-file)))) |
865 (t (error 'invalid-argument | 1124 (t (error 'invalid-argument |
866 "Could not compute a feature name"))) | 1125 "Could not compute a feature name"))) |
867 "-autoloads")) | 1126 autoload-feature-suffix)) |
868 | 1127 |
869 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1128 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
870 ;; Deprecated entry points | 1129 ;; Deprecated entry points |
871 | 1130 |
872 ;; A grep of the core and packages shows use of `batch-update-autoloads' | 1131 ;; A grep of the core and packages shows use of `batch-update-autoloads' |
873 ;; by XEmacs.rules, pcomplete, eshell, oort-gnus; `batch-update-directory' | 1132 ;; by XEmacs.rules, pcomplete, eshell, oort-gnus; `batch-update-directory' |
874 ;; by liece. | 1133 ;; by liece. The other two entry points (`batch-update-one-directory', |
875 | 1134 ;; `batch-force-update-one-directory') were not used at all. |
876 ;; #### these entry points below are a big mess, especially the | 1135 ;; |
877 ;; first two. there don't seem to be very many packages that use the | 1136 ;; All except the first are now history. liece has been updated. |
878 ;; first one (the "all-into-one-file" variety), and do they actually | 1137 ;; XEmacs.rules has been updated. The others will be, eventually. |
879 ;; rely on this functionality? --ben | 1138 |
1139 ;; There don't seem to be very many packages that use the first one (the | |
1140 ;; "all-into-one-file" variety), and do they actually rely on this | |
1141 ;; functionality? --ben | |
1142 | |
880 ;; but XEmacs.rules does, though maybe it doesn't "rely" on it, and | 1143 ;; but XEmacs.rules does, though maybe it doesn't "rely" on it, and |
881 ;; modules do now, and that relies on it. --sjt | 1144 ;; modules do now, and that relies on it. --sjt |
882 | 1145 |
883 ;;;###autoload | 1146 ;;;###autoload |
884 (defun batch-update-autoloads () | 1147 (defun batch-update-autoloads () |
889 For example, invoke `xemacs -batch -f batch-update-autoloads *.el'. | 1152 For example, invoke `xemacs -batch -f batch-update-autoloads *.el'. |
890 The directory to which the auto-autoloads.el file must be the first parameter | 1153 The directory to which the auto-autoloads.el file must be the first parameter |
891 on the command line." | 1154 on the command line." |
892 (unless noninteractive | 1155 (unless noninteractive |
893 (error "batch-update-autoloads is to be used only with -batch")) | 1156 (error "batch-update-autoloads is to be used only with -batch")) |
894 (update-autoload-files command-line-args-left t) | 1157 (update-autoload-files command-line-args-left generated-autoload-file) |
895 (kill-emacs 0)) | 1158 (kill-emacs 0)) |
896 | |
897 ;;;###autoload | |
898 (defun batch-update-directory () | |
899 "Update the autoloads for the directories on the command line. | |
900 Runs `update-file-autoloads' on each file in the given directory, and must | |
901 be used only with -batch. | |
902 | |
903 Uses and removes the first element of `command-line-args-left'." | |
904 (unless noninteractive | |
905 (error "batch-update-directory is to be used only with -batch")) | |
906 (update-autoload-files command-line-args-left) | |
907 ;; (kill-emacs 0) | |
908 (setq command-line-args-left nil)) | |
909 | |
910 ;;;###autoload | |
911 (defun batch-update-one-directory () | |
912 "Update the autoloads for a single directory on the command line. | |
913 Runs `update-file-autoloads' on each file in the given directory, and must | |
914 be used only with -batch." | |
915 (unless noninteractive | |
916 (error "batch-update-one-directory is to be used only with -batch")) | |
917 (let ((arg (car command-line-args-left))) | |
918 (setq command-line-args-left (cdr command-line-args-left)) | |
919 (update-autoload-files (list arg)))) | |
920 | |
921 ;;;###autoload | |
922 (defun batch-force-update-one-directory () | |
923 "Update the autoloads for a single directory on the command line. | |
924 Runs `update-file-autoloads' on each file in the given directory, and must | |
925 be used only with -batch. Always rewrites the autoloads file, even if | |
926 unchanged. | |
927 | |
928 Uses and removes the first element of `command-line-args-left'." | |
929 (unless noninteractive | |
930 (error "batch-force-update-directory is to be used only with -batch")) | |
931 (let ((arg (car command-line-args-left))) | |
932 (setq command-line-args-left (cdr command-line-args-left)) | |
933 (update-autoload-files (list arg) nil t))) | |
934 | 1159 |
935 ;; Declare obsolescence | 1160 ;; Declare obsolescence |
936 | 1161 |
937 (make-obsolete-variable 'autoload-target-directory | 1162 (make-obsolete-variable 'autoload-target-directory |
938 "Don't use this. Bind `generated-autoload-file' to an absolute path.") | 1163 "Don't use this. Bind `generated-autoload-file' to an absolute path.") |
939 (make-obsolete 'batch-update-autoloads | 1164 (make-obsolete 'batch-update-autoloads |
940 'autoload-update-directory-autoloads) | 1165 'autoload-update-directory-autoloads) |
941 (make-obsolete 'batch-update-directory | |
942 'autoload-update-directory-autoloads) | |
943 (make-obsolete 'batch-update-one-directory | |
944 'autoload-update-directory-autoloads) | |
945 (make-obsolete 'batch-force-update-one-directory | |
946 'autoload-update-directory-autoloads) | |
947 | 1166 |
948 (provide 'autoload) | 1167 (provide 'autoload) |
949 | 1168 |
950 ;;; autoload.el ends here | 1169 ;;; autoload.el ends here |