428
|
1 ;;; autoload.el --- maintain autoloads in loaddefs.el.
|
|
2
|
|
3 ;; Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
|
778
|
5 ;; Copyright (C) 1996, 2000, 2002 Ben Wing.
|
428
|
6
|
|
7 ;; Author: Roland McGrath <roland@gnu.ai.mit.edu>
|
|
8 ;; Keywords: maint
|
|
9
|
|
10 ;; This file is part of XEmacs.
|
|
11
|
|
12 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
13 ;; under the terms of the GNU General Public License as published by
|
|
14 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
15 ;; any later version.
|
|
16
|
|
17 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 ;; General Public License for more details.
|
|
21
|
|
22 ;; 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 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
25 ;; 02111-1307, USA.
|
|
26
|
|
27 ;;; Synched up with: Not synched with FSF.
|
|
28
|
|
29 ;;; Commentary:
|
|
30
|
613
|
31 ;; This code helps XEmacs maintainers keep the loaddefs.el file up to
|
428
|
32 ;; date. It interprets magic cookies of the form ";;;###autoload" in
|
|
33 ;; lisp source files in various useful ways. To learn more, read the
|
|
34 ;; source; if you're going to use this, you'd better be able to.
|
|
35
|
|
36 ;; ChangeLog:
|
|
37
|
|
38 ;; Sep-26-1997: slb removed code dealing with customization.
|
|
39
|
|
40 ;;; Code:
|
|
41
|
|
42 (defun make-autoload (form file)
|
|
43 "Turn FORM, a defun or defmacro, into an autoload for source file FILE.
|
|
44 Returns nil if FORM is not a defun, define-skeleton or defmacro."
|
|
45 (let ((car (car-safe form)))
|
778
|
46 (if (memq car '(defun defun* define-skeleton defmacro defmacro*
|
|
47 define-derived-mode))
|
|
48 (let ((macrop (memq car '(defmacro defmacro*)))
|
428
|
49 name doc)
|
|
50 (setq form (cdr form)
|
|
51 name (car form)
|
|
52 ;; Ignore the arguments.
|
646
|
53 form (cdr (cond ((eq car 'define-skeleton)
|
|
54 form)
|
|
55 ((eq car 'define-derived-mode)
|
|
56 (cddr form))
|
|
57 (t
|
|
58 (cdr form))))
|
428
|
59 doc (car form))
|
|
60 (if (stringp doc)
|
|
61 (setq form (cdr form))
|
|
62 (setq doc nil))
|
|
63 (list 'autoload (list 'quote name) file doc
|
|
64 (or (eq car 'define-skeleton)
|
646
|
65 (eq car 'define-derived-mode)
|
428
|
66 (eq (car-safe (car form)) 'interactive))
|
|
67 (if macrop (list 'quote 'macro) nil)))
|
|
68 nil)))
|
|
69
|
|
70 (defvar generate-autoload-cookie ";;;###autoload"
|
|
71 "Magic comment indicating the following form should be autoloaded.
|
|
72 Used by `update-file-autoloads'. This string should be
|
|
73 meaningless to Lisp (e.g., a comment).
|
|
74
|
|
75 This string is used:
|
|
76
|
|
77 ;;;###autoload
|
|
78 \(defun function-to-be-autoloaded () ...)
|
|
79
|
|
80 If this string appears alone on a line, the following form will be
|
|
81 read and an autoload made for it. If it is followed by the string
|
|
82 \"immediate\", then the form on the following line will be copied
|
|
83 verbatim. If there is further text on the line, that text will be
|
|
84 copied verbatim to `generated-autoload-file'.")
|
|
85
|
|
86 (defvar generate-autoload-section-header "\f\n;;;### "
|
|
87 "String inserted before the form identifying
|
|
88 the section of autoloads for a file.")
|
|
89
|
|
90 (defvar generate-autoload-section-trailer "\n;;;***\n"
|
|
91 "String which indicates the end of the section of autoloads for a file.")
|
|
92
|
442
|
93 (defvar autoload-package-name nil)
|
|
94
|
428
|
95 ;;; Forms which have doc-strings which should be printed specially.
|
|
96 ;;; A doc-string-elt property of ELT says that (nth ELT FORM) is
|
|
97 ;;; the doc-string in FORM.
|
|
98 ;;;
|
|
99 ;;; There used to be the following note here:
|
|
100 ;;; ;;; Note: defconst and defvar should NOT be marked in this way.
|
|
101 ;;; ;;; We don't want to produce defconsts and defvars that
|
|
102 ;;; ;;; make-docfile can grok, because then it would grok them twice,
|
|
103 ;;; ;;; once in foo.el (where they are given with ;;;###autoload) and
|
|
104 ;;; ;;; once in loaddefs.el.
|
|
105 ;;;
|
|
106 ;;; Counter-note: Yes, they should be marked in this way.
|
|
107 ;;; make-docfile only processes those files that are loaded into the
|
|
108 ;;; dumped Emacs, and those files should never have anything
|
|
109 ;;; autoloaded here. The above-feared problem only occurs with files
|
|
110 ;;; which have autoloaded entries *and* are processed by make-docfile;
|
|
111 ;;; there should be no such files.
|
|
112
|
|
113 (put 'autoload 'doc-string-elt 3)
|
|
114 (put 'defun 'doc-string-elt 3)
|
778
|
115 (put 'defun* 'doc-string-elt 3)
|
428
|
116 (put 'defvar 'doc-string-elt 3)
|
|
117 (put 'defconst 'doc-string-elt 3)
|
|
118 (put 'defmacro 'doc-string-elt 3)
|
778
|
119 (put 'defmacro* 'doc-string-elt 3)
|
|
120 (put 'define-skeleton 'doc-string-elt 3)
|
428
|
121
|
|
122 (defun autoload-trim-file-name (file)
|
|
123 "Returns a relative pathname of FILE including the last directory."
|
|
124 (setq file (expand-file-name file))
|
442
|
125 (replace-in-string
|
|
126 (file-relative-name file (file-name-directory
|
|
127 (directory-file-name
|
|
128 (file-name-directory file))))
|
|
129 "\\\\" "/"))
|
428
|
130
|
|
131 ;;;###autoload
|
|
132 (defun generate-file-autoloads (file &optional funlist)
|
|
133 "Insert at point a loaddefs autoload section for FILE.
|
|
134 autoloads are generated for defuns and defmacros in FILE
|
|
135 marked by `generate-autoload-cookie' (which see).
|
|
136 If FILE is being visited in a buffer, the contents of the buffer
|
|
137 are used."
|
|
138 (interactive "fGenerate autoloads for file: ")
|
|
139 (generate-file-autoloads-1 file funlist))
|
|
140
|
|
141 (defun* generate-file-autoloads-1 (file funlist)
|
|
142 "Insert at point a loaddefs autoload section for FILE.
|
|
143 autoloads are generated for defuns and defmacros in FILE
|
|
144 marked by `generate-autoload-cookie' (which see).
|
|
145 If FILE is being visited in a buffer, the contents of the buffer
|
|
146 are used."
|
|
147 (let ((outbuf (current-buffer))
|
|
148 (autoloads-done '())
|
|
149 (load-name (replace-in-string (file-name-nondirectory file)
|
|
150 "\\.elc?$"
|
|
151 ""))
|
|
152 (trim-name (autoload-trim-file-name file))
|
|
153 (dofiles (not (null funlist)))
|
|
154 (print-length nil)
|
|
155 (print-readably t) ; XEmacs
|
|
156 (float-output-format nil)
|
|
157 ;; (done-any nil)
|
|
158 (visited (get-file-buffer file))
|
|
159 output-end)
|
|
160
|
|
161 ;; If the autoload section we create here uses an absolute
|
|
162 ;; pathname for FILE in its header, and then Emacs is installed
|
|
163 ;; under a different path on another system,
|
|
164 ;; `update-autoloads-here' won't be able to find the files to be
|
|
165 ;; autoloaded. So, if FILE is in the same directory or a
|
|
166 ;; subdirectory of the current buffer's directory, we'll make it
|
|
167 ;; relative to the current buffer's directory.
|
|
168 (setq file (expand-file-name file))
|
|
169
|
|
170 (save-excursion
|
|
171 (unwind-protect
|
|
172 (progn
|
|
173 (let ((find-file-hooks nil)
|
|
174 (enable-local-variables nil))
|
|
175 (set-buffer (or visited (find-file-noselect file)))
|
460
|
176 (set-syntax-table emacs-lisp-mode-syntax-table))
|
428
|
177 (save-excursion
|
|
178 (save-restriction
|
|
179 (widen)
|
|
180 (goto-char (point-min))
|
|
181 (unless (search-forward generate-autoload-cookie nil t)
|
|
182 (message "No autoloads found in %s" trim-name)
|
|
183 (return-from generate-file-autoloads-1))
|
|
184
|
|
185 (message "Generating autoloads for %s..." trim-name)
|
|
186 (goto-char (point-min))
|
|
187 (while (if dofiles funlist (not (eobp)))
|
|
188 (if (not dofiles)
|
|
189 (skip-chars-forward " \t\n\f")
|
|
190 (goto-char (point-min))
|
|
191 (re-search-forward
|
|
192 (concat "(def\\(un\\|var\\|const\\|macro\\) "
|
|
193 (regexp-quote (symbol-name (car funlist)))
|
|
194 "\\s "))
|
|
195 (goto-char (match-beginning 0)))
|
|
196 (cond
|
|
197 ((or dofiles
|
|
198 (looking-at (regexp-quote generate-autoload-cookie)))
|
|
199 (if dofiles
|
|
200 nil
|
|
201 (search-forward generate-autoload-cookie)
|
|
202 (skip-chars-forward " \t"))
|
|
203 ;; (setq done-any t)
|
|
204 (if (or dofiles (eolp))
|
|
205 ;; Read the next form and make an autoload.
|
|
206 (let* ((form (prog1 (read (current-buffer))
|
|
207 (or (bolp) (forward-line 1))))
|
|
208 (autoload (make-autoload form load-name))
|
|
209 (doc-string-elt (get (car-safe form)
|
|
210 'doc-string-elt)))
|
|
211 (if autoload
|
|
212 (setq autoloads-done (cons (nth 1 form)
|
|
213 autoloads-done))
|
|
214 (setq autoload form))
|
|
215 (if (and doc-string-elt
|
|
216 (stringp (nth doc-string-elt autoload)))
|
|
217 ;; We need to hack the printing because the
|
|
218 ;; doc-string must be printed specially for
|
|
219 ;; make-docfile (sigh).
|
|
220 (let* ((p (nthcdr (1- doc-string-elt)
|
|
221 autoload))
|
|
222 (elt (cdr p)))
|
|
223 (setcdr p nil)
|
|
224 (princ "\n(" outbuf)
|
|
225 ;; XEmacs change: don't let ^^L's get into
|
|
226 ;; the file or sorting is hard.
|
|
227 (let ((print-escape-newlines t)
|
|
228 (p (save-excursion
|
|
229 (set-buffer outbuf)
|
|
230 (point)))
|
|
231 p2)
|
|
232 (mapcar (function (lambda (elt)
|
|
233 (prin1 elt outbuf)
|
|
234 (princ " " outbuf)))
|
|
235 autoload)
|
|
236 (save-excursion
|
|
237 (set-buffer outbuf)
|
|
238 (setq p2 (point-marker))
|
|
239 (goto-char p)
|
|
240 (save-match-data
|
|
241 (while (search-forward "\^L" p2 t)
|
|
242 (delete-char -1)
|
|
243 (insert "\\^L")))
|
|
244 (goto-char p2)
|
|
245 ))
|
|
246 (princ "\"\\\n" outbuf)
|
|
247 (let ((begin (save-excursion
|
|
248 (set-buffer outbuf)
|
|
249 (point))))
|
|
250 (princ (substring
|
|
251 (prin1-to-string (car elt)) 1)
|
|
252 outbuf)
|
|
253 ;; Insert a backslash before each ( that
|
|
254 ;; appears at the beginning of a line in
|
|
255 ;; the doc string.
|
|
256 (save-excursion
|
|
257 (set-buffer outbuf)
|
|
258 (save-excursion
|
|
259 (while (search-backward "\n(" begin t)
|
|
260 (forward-char 1)
|
|
261 (insert "\\"))))
|
|
262 (if (null (cdr elt))
|
|
263 (princ ")" outbuf)
|
|
264 (princ " " outbuf)
|
|
265 (princ (substring
|
|
266 (prin1-to-string (cdr elt))
|
|
267 1)
|
|
268 outbuf))
|
|
269 (terpri outbuf)))
|
|
270 ;; XEmacs change: another fucking ^L hack
|
|
271 (let ((p (save-excursion
|
|
272 (set-buffer outbuf)
|
|
273 (point)))
|
|
274 (print-escape-newlines t)
|
|
275 p2)
|
|
276 (print autoload outbuf)
|
|
277 (save-excursion
|
|
278 (set-buffer outbuf)
|
|
279 (setq p2 (point-marker))
|
|
280 (goto-char p)
|
|
281 (save-match-data
|
|
282 (while (search-forward "\^L" p2 t)
|
|
283 (delete-char -1)
|
|
284 (insert "\\^L")))
|
|
285 (goto-char p2)
|
|
286 ))
|
|
287 ))
|
|
288 ;; Copy the rest of the line to the output.
|
|
289 (let ((begin (point)))
|
|
290 ;; (terpri outbuf)
|
|
291 (cond ((looking-at "immediate\\s *$") ; XEmacs
|
|
292 ;; This is here so that you can automatically
|
|
293 ;; have small hook functions copied to
|
|
294 ;; loaddefs.el so that it's not necessary to
|
|
295 ;; load a whole file just to get a two-line
|
|
296 ;; do-nothing find-file-hook... --Stig
|
|
297 (forward-line 1)
|
|
298 (setq begin (point))
|
|
299 (forward-sexp)
|
|
300 (forward-line 1))
|
|
301 (t
|
|
302 (forward-line 1)))
|
|
303 (princ (buffer-substring begin (point)) outbuf))))
|
|
304 ((looking-at ";")
|
|
305 ;; Don't read the comment.
|
|
306 (forward-line 1))
|
|
307 (t
|
|
308 (forward-sexp 1)
|
|
309 (forward-line 1)))
|
|
310 (if dofiles
|
|
311 (setq funlist (cdr funlist)))))))
|
|
312 (unless visited
|
|
313 ;; We created this buffer, so we should kill it.
|
|
314 (kill-buffer (current-buffer)))
|
|
315 (set-buffer outbuf)
|
|
316 (setq output-end (point-marker))))
|
|
317 (if t ;; done-any
|
|
318 ;; XEmacs -- always do this so that we cache the information
|
|
319 ;; that we've processed the file already.
|
|
320 (progn
|
|
321 (insert generate-autoload-section-header)
|
|
322 (prin1 (list 'autoloads autoloads-done load-name trim-name)
|
|
323 outbuf)
|
|
324 (terpri outbuf)
|
|
325 ;;;; (insert ";;; Generated autoloads from "
|
|
326 ;;;; (autoload-trim-file-name file) "\n")
|
|
327 ;; Warn if we put a line in loaddefs.el
|
|
328 ;; that is long enough to cause trouble.
|
|
329 (when (< output-end (point))
|
|
330 (setq output-end (point-marker)))
|
|
331 (while (< (point) output-end)
|
|
332 ;; (let ((beg (point)))
|
|
333 (end-of-line)
|
|
334 ;; Emacs -- I still haven't figured this one out.
|
|
335 ;; (if (> (- (point) beg) 900)
|
|
336 ;; (progn
|
|
337 ;; (message "A line is too long--over 900 characters")
|
|
338 ;; (sleep-for 2)
|
|
339 ;; (goto-char output-end)))
|
|
340 ;; )
|
|
341 (forward-line 1))
|
|
342 (goto-char output-end)
|
|
343 (insert generate-autoload-section-trailer)))
|
|
344 (or noninteractive ; XEmacs: only need one line in -batch mode.
|
|
345 (message "Generating autoloads for %s...done" file))))
|
|
346
|
|
347
|
|
348 (defconst autoload-file-name "auto-autoloads.el"
|
|
349 "Generic filename to put autoloads into.
|
|
350 Unless you are an XEmacs maintainer, it is probably unwise to change this.")
|
|
351
|
442
|
352 (defvar autoload-target-directory "../lisp/"
|
428
|
353 "Directory to put autoload declaration file into.
|
|
354 Unless you know what you're doing, don't mess with this.")
|
|
355
|
|
356 (defvar generated-autoload-file
|
|
357 (expand-file-name (concat autoload-target-directory
|
|
358 autoload-file-name)
|
|
359 data-directory)
|
|
360 "*File `update-file-autoloads' puts autoloads into.
|
|
361 A .el file can set this in its local variables section to make its
|
442
|
362 autoloads go somewhere else.
|
|
363
|
|
364 Note that `batch-update-directory' binds this variable to its own value,
|
|
365 generally the file named `autoload-file-name' in the directory being
|
|
366 updated.")
|
428
|
367
|
|
368 (defconst cusload-file-name "custom-load.el"
|
442
|
369 "Generic filename to put custom loads into.
|
|
370 Unless you are an XEmacs maintainer, it is probably unwise to change this.")
|
428
|
371
|
|
372 ;;;###autoload
|
|
373 (defun update-file-autoloads (file)
|
|
374 "Update the autoloads for FILE in `generated-autoload-file'
|
|
375 \(which FILE might bind in its local variables).
|
438
|
376 This function refuses to update autoloads files."
|
428
|
377 (interactive "fUpdate autoloads for file: ")
|
|
378 (setq file (expand-file-name file))
|
|
379 (when (and (file-newer-than-file-p file generated-autoload-file)
|
|
380 (not (member (file-name-nondirectory file)
|
|
381 (list autoload-file-name))))
|
|
382
|
|
383 (let ((load-name (replace-in-string (file-name-nondirectory file)
|
|
384 "\\.elc?$"
|
|
385 ""))
|
|
386 (trim-name (autoload-trim-file-name file))
|
|
387 section-begin form)
|
|
388 (save-excursion
|
|
389 (let ((find-file-hooks nil))
|
|
390 (set-buffer (or (get-file-buffer generated-autoload-file)
|
|
391 (find-file-noselect generated-autoload-file))))
|
|
392 ;; Make sure we can scribble in it.
|
|
393 (setq buffer-read-only nil)
|
|
394 ;; First delete all sections for this file.
|
|
395 (goto-char (point-min))
|
|
396 (while (search-forward generate-autoload-section-header nil t)
|
|
397 (setq section-begin (match-beginning 0))
|
|
398 (setq form (read (current-buffer)))
|
|
399 (when (string= (nth 2 form) load-name)
|
|
400 (search-forward generate-autoload-section-trailer)
|
|
401 (delete-region section-begin (point))))
|
|
402
|
|
403 ;; Now find insertion point for new section
|
|
404 (block find-insertion-point
|
|
405 (goto-char (point-min))
|
|
406 (while (search-forward generate-autoload-section-header nil t)
|
|
407 (setq form (read (current-buffer)))
|
|
408 (when (string< trim-name (nth 3 form))
|
|
409 ;; Found alphabetically correct insertion point
|
|
410 (goto-char (match-beginning 0))
|
|
411 (return-from find-insertion-point))
|
|
412 (search-forward generate-autoload-section-trailer))
|
|
413 (when (eq (point) (point-min)) ; No existing entries?
|
|
414 (goto-char (point-max)))) ; Append.
|
|
415
|
|
416 ;; Add in new sections for file
|
|
417 (generate-file-autoloads file))
|
|
418
|
|
419 (when (interactive-p) (save-buffer)))))
|
|
420
|
|
421 ;;;###autoload
|
|
422 (defun update-autoloads-here ()
|
|
423 "Update sections of the current buffer generated by `update-file-autoloads'."
|
|
424 (interactive)
|
|
425 (let ((generated-autoload-file (buffer-file-name)))
|
|
426 (save-excursion
|
|
427 (goto-char (point-min))
|
|
428 (while (search-forward generate-autoload-section-header nil t)
|
|
429 (let* ((form (condition-case ()
|
|
430 (read (current-buffer))
|
|
431 (end-of-file nil)))
|
|
432 (file (nth 3 form)))
|
|
433 ;; XEmacs change: if we can't find the file as specified, look
|
|
434 ;; around a bit more.
|
|
435 (cond ((and (stringp file)
|
|
436 (or (get-file-buffer file)
|
|
437 (file-exists-p file))))
|
|
438 ((and (stringp file)
|
|
439 (save-match-data
|
|
440 (let ((loc (locate-file (file-name-nondirectory file)
|
|
441 load-path)))
|
|
442 (if (null loc)
|
|
443 nil
|
|
444 (setq loc (expand-file-name
|
|
445 (autoload-trim-file-name loc)
|
|
446 ".."))
|
|
447 (if (or (get-file-buffer loc)
|
|
448 (file-exists-p loc))
|
|
449 (setq file loc)
|
|
450 nil))))))
|
|
451 (t
|
|
452 (setq file
|
|
453 (if (y-or-n-p
|
|
454 (format
|
|
455 "Can't find library `%s'; remove its autoloads? "
|
|
456 (nth 2 form) file))
|
|
457 t
|
|
458 (condition-case ()
|
|
459 (read-file-name
|
|
460 (format "Find `%s' load file: "
|
|
461 (nth 2 form))
|
|
462 nil nil t)
|
|
463 (quit nil))))))
|
|
464 (if file
|
|
465 (let ((begin (match-beginning 0)))
|
|
466 (search-forward generate-autoload-section-trailer)
|
|
467 (delete-region begin (point))))
|
|
468 (if (stringp file)
|
|
469 (generate-file-autoloads file)))))))
|
|
470
|
|
471 ;;;###autoload
|
|
472 (defun update-autoloads-from-directory (dir)
|
|
473 "Update `generated-autoload-file' with all the current autoloads from DIR.
|
|
474 This runs `update-file-autoloads' on each .el file in DIR.
|
442
|
475 Obsolete autoload entries for files that no longer exist are deleted.
|
|
476 Note that, if this function is called from `batch-update-directory',
|
528
|
477 `generated-autoload-file' was rebound in that function.
|
|
478
|
|
479 You don't really want to be calling this function. Try using
|
|
480 `update-autoload-files' instead."
|
428
|
481 (interactive "DUpdate autoloads for directory: ")
|
|
482 (setq dir (expand-file-name dir))
|
|
483 (let ((simple-dir (file-name-as-directory
|
|
484 (file-name-nondirectory
|
|
485 (directory-file-name dir))))
|
|
486 (enable-local-eval nil))
|
|
487 (save-excursion
|
|
488 (let ((find-file-hooks nil))
|
|
489 (set-buffer (find-file-noselect generated-autoload-file)))
|
|
490 (goto-char (point-min))
|
|
491 (while (search-forward generate-autoload-section-header nil t)
|
|
492 (let* ((begin (match-beginning 0))
|
|
493 (form (condition-case ()
|
|
494 (read (current-buffer))
|
|
495 (end-of-file nil)))
|
|
496 (file (nth 3 form)))
|
|
497 (when (and (stringp file)
|
|
498 (string= (file-name-directory file) simple-dir)
|
|
499 (not (file-exists-p
|
|
500 (expand-file-name
|
|
501 (file-name-nondirectory file) dir))))
|
|
502 ;; Remove the obsolete section.
|
|
503 (search-forward generate-autoload-section-trailer)
|
|
504 (delete-region begin (point)))))
|
|
505 ;; Update or create autoload sections for existing files.
|
|
506 (mapcar 'update-file-autoloads (directory-files dir t "^[^=].*\\.el$"))
|
|
507 (unless noninteractive
|
|
508 (save-buffer)))))
|
|
509
|
|
510 (defun fixup-autoload-buffer (sym)
|
|
511 (save-excursion
|
|
512 (set-buffer (find-file-noselect generated-autoload-file))
|
|
513 (goto-char (point-min))
|
|
514 (if (and (not (= (point-min) (point-max)))
|
|
515 (not (looking-at ";;; DO NOT MODIFY THIS FILE")))
|
|
516 (progn
|
|
517 (insert ";;; DO NOT MODIFY THIS FILE\n")
|
|
518 (insert "(if (featurep '" sym ")")
|
|
519 (insert " (error \"Already loaded\"))\n")
|
|
520 (goto-char (point-max))
|
|
521 (insert "\n(provide '" sym ")\n")))))
|
|
522
|
|
523 (defvar autoload-package-name nil)
|
|
524
|
528
|
525 ;;;###autoload
|
|
526 (defun update-autoload-files (files-or-dirs &optional all-into-one-file force)
|
|
527 "Update all the autoload files associated with FILES-OR-DIRS.
|
|
528 FILES-OR-DIRS should be a list of files or directories to be
|
|
529 processed. If ALL-INTO-ONE-FILE is not given, the appropriate
|
|
530 autoload file for each file or directory (located in that directory,
|
|
531 or in the directory of the specified file) will be updated with the
|
|
532 directory's or file's autoloads, some additional fixup text will be
|
|
533 added, and the files will be saved. If ALL-INTO-ONE-FILE is given,
|
|
534 `generated-autoload-file' should be set to the name of the autoload
|
|
535 file into which the autoloads will be generated, and the autoloads
|
|
536 for all files and directories will go into that same file.
|
|
537
|
|
538 If FORCE is non-nil, always save out the autoload files even if unchanged."
|
645
|
539 (let ((defdir (directory-file-name default-directory))
|
528
|
540 (enable-local-eval nil)) ; Don't query in batch mode.
|
|
541 ;; (message "Updating autoloads in %s..." generated-autoload-file)
|
|
542 (dolist (arg files-or-dirs)
|
|
543 (setq arg (expand-file-name arg defdir))
|
|
544 (let ((generated-autoload-file
|
|
545 (if all-into-one-file generated-autoload-file
|
|
546 (expand-file-name autoload-file-name
|
|
547 (if (file-directory-p arg) arg
|
|
548 (file-name-directory arg))))))
|
|
549 (cond
|
|
550 ((file-directory-p arg)
|
|
551 (message "Updating autoloads for directory %s..." arg)
|
|
552 (update-autoloads-from-directory arg))
|
|
553 ((file-exists-p arg)
|
|
554 (update-file-autoloads arg))
|
|
555 (t (error "No such file or directory: %s" arg)))
|
|
556 (when (not all-into-one-file)
|
|
557 (fixup-autoload-buffer (concat (if autoload-package-name
|
|
558 autoload-package-name
|
|
559 (file-name-nondirectory defdir))
|
|
560 "-autoloads"))
|
|
561 (if force (set-buffer-modified-p
|
|
562 t (find-file-noselect generated-autoload-file))))))
|
|
563 (when all-into-one-file
|
|
564 (fixup-autoload-buffer (concat (if autoload-package-name
|
|
565 autoload-package-name
|
|
566 (file-name-nondirectory defdir))
|
|
567 "-autoloads"))
|
|
568 (if force (set-buffer-modified-p
|
|
569 t (find-file-noselect generated-autoload-file))))
|
|
570 (save-some-buffers t)
|
|
571 ;; (message "Done")
|
|
572 ))
|
|
573
|
|
574 ;; #### these entry points below are a big mess, especially the
|
|
575 ;; first two. there don't seem to be very many packages that use the
|
|
576 ;; first one (the "all-into-one-file" variety), and do they actually
|
|
577 ;; rely on this functionality? --ben
|
|
578
|
|
579 ;;;###autoload
|
|
580 (defun batch-update-autoloads ()
|
|
581 "Update the autoloads for the files or directories on the command line.
|
|
582 Runs `update-file-autoloads' on files and `update-directory-autoloads'
|
|
583 on directories. Must be used only with -batch, and kills Emacs on completion.
|
|
584 Each file will be processed even if an error occurred previously.
|
|
585 For example, invoke `xemacs -batch -f batch-update-autoloads *.el'.
|
|
586 The directory to which the auto-autoloads.el file must be the first parameter
|
|
587 on the command line."
|
|
588 (unless noninteractive
|
|
589 (error "batch-update-autoloads is to be used only with -batch"))
|
|
590 (update-autoload-files command-line-args-left t)
|
|
591 (kill-emacs 0))
|
442
|
592
|
428
|
593 ;;;###autoload
|
|
594 (defun batch-update-directory ()
|
442
|
595 "Update the autoloads for the directories on the command line.
|
|
596 Runs `update-file-autoloads' on each file in the given directory, and must
|
|
597 be used only with -batch."
|
428
|
598 (unless noninteractive
|
|
599 (error "batch-update-directory is to be used only with -batch"))
|
528
|
600 (update-autoload-files command-line-args-left)
|
|
601 ;; (kill-emacs 0)
|
|
602 (setq command-line-args-left nil))
|
442
|
603
|
|
604 ;;;###autoload
|
|
605 (defun batch-update-one-directory ()
|
|
606 "Update the autoloads for a single directory on the command line.
|
|
607 Runs `update-file-autoloads' on each file in the given directory, and must
|
|
608 be used only with -batch."
|
|
609 (unless noninteractive
|
|
610 (error "batch-update-directory is to be used only with -batch"))
|
528
|
611 (let ((arg (car command-line-args-left)))
|
|
612 (setq command-line-args-left (cdr command-line-args-left))
|
|
613 (update-autoload-files (list arg))))
|
|
614
|
|
615 ;;;###autoload
|
|
616 (defun batch-force-update-one-directory ()
|
|
617 "Update the autoloads for a single directory on the command line.
|
|
618 Runs `update-file-autoloads' on each file in the given directory, and must
|
|
619 be used only with -batch. Always rewrite the autoloads file, even if
|
|
620 unchanged."
|
|
621 (unless noninteractive
|
|
622 (error "batch-update-directory is to be used only with -batch"))
|
|
623 (let ((arg (car command-line-args-left)))
|
|
624 (setq command-line-args-left (cdr command-line-args-left))
|
546
|
625 (update-autoload-files (list arg) nil t)))
|
442
|
626
|
428
|
627 (provide 'autoload)
|
|
628
|
|
629 ;;; autoload.el ends here
|