annotate lisp/autoload.el @ 646:00c54252fe4f

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