annotate lisp/utils/autoload.el @ 12:bcdc7deadc19 r19-15b7

Import from CVS: tag r19-15b7
author cvs
date Mon, 13 Aug 2007 08:48:16 +0200
parents 376386a54a3c
children 4103f0995bd7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; autoload.el --- maintain autoloads in loaddefs.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;; Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; Copyright (C) 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Author: Roland McGrath <roland@gnu.ai.mit.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Keywords: maint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
9 ;; This file is part of XEmacs.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
10
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
12 ;; under the terms of the GNU General Public License as published by
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
14 ;; any later version.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
19 ;; General Public License for more details.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
20
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
21 ;; You should have received a copy of the GNU General Public License
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
24 ;; 02111-1307, USA.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
25
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
26 ;;; Synched up with: Not synched with FSF.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; This code helps GNU Emacs maintainers keep the loaddefs.el file up to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; date. It interprets magic cookies of the form ";;;###autoload" in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; lisp source files in various useful ways. To learn more, read the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; source; if you're going to use this, you'd better be able to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defun make-autoload (form file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "Turn FORM, a defun or defmacro, into an autoload for source file FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 Returns nil if FORM is not a defun, define-skeleton or defmacro."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (let ((car (car-safe form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (if (memq car '(defun define-skeleton defmacro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (let ((macrop (eq car 'defmacro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 name doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (setq form (cdr form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 name (car form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; Ignore the arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 form (cdr (if (eq car 'define-skeleton)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (cdr form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 doc (car form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (if (stringp doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (setq form (cdr form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (setq doc nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (list 'autoload (list 'quote name) file doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (or (eq car 'define-skeleton)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (eq (car-safe (car form)) 'interactive))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (if macrop (list 'quote 'macro) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (put 'define-skeleton 'doc-string-elt 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
62 (defvar generate-autoload-cookie ";;;###autoload"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 "Magic comment indicating the following form should be autoloaded.
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
64 Used by `update-file-autoloads'. This string should be
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 meaningless to Lisp (e.g., a comment).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 This string is used:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 \(defun function-to-be-autoloaded () ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
72 If this string appears alone on a line, the following form will be
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
73 read and an autoload made for it. If it is followed by the string
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
74 \"immediate\", then the form on the following line will be copied
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
75 verbatim. If there is further text on the line, that text will be
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
76 copied verbatim to `generated-autoload-file'.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
78 (defvar generate-autoload-section-header "\f\n;;;### "
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 "String inserted before the form identifying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 the section of autoloads for a file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
82 (defvar generate-autoload-section-trailer "\n;;;***\n"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 "String which indicates the end of the section of autoloads for a file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;; Forms which have doc-strings which should be printed specially.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;; A doc-string-elt property of ELT says that (nth ELT FORM) is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; the doc-string in FORM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;; There used to be the following note here:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;; ;;; Note: defconst and defvar should NOT be marked in this way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; ;;; We don't want to produce defconsts and defvars that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;; ;;; make-docfile can grok, because then it would grok them twice,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;; ;;; once in foo.el (where they are given with ;;;###autoload) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; ;;; once in loaddefs.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;; Counter-note: Yes, they should be marked in this way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; make-docfile only processes those files that are loaded into the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; dumped Emacs, and those files should never have anything
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; autoloaded here. The above-feared problem only occurs with files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; which have autoloaded entries *and* are processed by make-docfile;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; there should be no such files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (put 'autoload 'doc-string-elt 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (put 'defun 'doc-string-elt 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (put 'defvar 'doc-string-elt 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (put 'defconst 'doc-string-elt 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (put 'defmacro 'doc-string-elt 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (defun autoload-trim-file-name (file)
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
110 "Returns a relative pathname of FILE including the last directory."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (setq file (expand-file-name file))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
112 (file-relative-name file (file-name-directory
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
113 (directory-file-name
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
114 (file-name-directory file)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (defun generate-file-autoloads (file &optional funlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 "Insert at point a loaddefs autoload section for FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 autoloads are generated for defuns and defmacros in FILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 marked by `generate-autoload-cookie' (which see).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 If FILE is being visited in a buffer, the contents of the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 are used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (interactive "fGenerate autoloads for file: ")
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
124 (generate-file-autoloads-1 file funlist))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
125
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
126 (defun* generate-file-autoloads-1 (file funlist)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
127 "Insert at point a loaddefs autoload section for FILE.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
128 autoloads are generated for defuns and defmacros in FILE
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
129 marked by `generate-autoload-cookie' (which see).
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
130 If FILE is being visited in a buffer, the contents of the buffer
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
131 are used."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (let ((outbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (autoloads-done '())
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
134 (load-name (replace-in-string (file-name-nondirectory file)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
135 "\\.elc?$"
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
136 ""))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
137 (trim-name (autoload-trim-file-name file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (dofiles (not (null funlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (print-length nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (print-readably t) ; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (float-output-format nil)
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
142 ;; (done-any nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (visited (get-file-buffer file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 output-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;; If the autoload section we create here uses an absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; pathname for FILE in its header, and then Emacs is installed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; under a different path on another system,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; `update-autoloads-here' won't be able to find the files to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;; autoloaded. So, if FILE is in the same directory or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; subdirectory of the current buffer's directory, we'll make it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; relative to the current buffer's directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (setq file (expand-file-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (progn
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
158 (set-buffer (or visited (find-file-noselect file)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (goto-char (point-min))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
163 (unless (search-forward generate-autoload-cookie nil t)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
164 (message "No autoloads found in %s" trim-name)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
165 (return-from generate-file-autoloads-1))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
166
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
167 (message "Generating autoloads for %s..." trim-name)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
168 (goto-char (point-min))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (while (if dofiles funlist (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (if (not dofiles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (skip-chars-forward " \t\n\f")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (concat "(def\\(un\\|var\\|const\\|macro\\) "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (regexp-quote (symbol-name (car funlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 "\\s "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (goto-char (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ((or dofiles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (looking-at (regexp-quote generate-autoload-cookie)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (if dofiles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (search-forward generate-autoload-cookie)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (skip-chars-forward " \t"))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
185 ;; (setq done-any t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (if (or dofiles (eolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; Read the next form and make an autoload.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (let* ((form (prog1 (read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (or (bolp) (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (autoload (make-autoload form load-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (doc-string-elt (get (car-safe form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 'doc-string-elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (if autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (setq autoloads-done (cons (nth 1 form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 autoloads-done))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (setq autoload form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (if (and doc-string-elt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (stringp (nth doc-string-elt autoload)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; We need to hack the printing because the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;; doc-string must be printed specially for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;; make-docfile (sigh).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (let* ((p (nthcdr (1- doc-string-elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 autoload))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (elt (cdr p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (setcdr p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (princ "\n(" outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; XEmacs change: don't let ^^L's get into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; the file or sorting is hard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (let ((print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (p (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 p2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (mapcar (function (lambda (elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (prin1 elt outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (princ " " outbuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 autoload)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (setq p2 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (while (search-forward "\^L" p2 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (insert "\\^L")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (goto-char p2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (princ "\"\\\n" outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (let ((begin (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (princ (substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (prin1-to-string (car elt)) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;; Insert a backslash before each ( that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;; appears at the beginning of a line in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;; the doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (while (search-backward "\n(" begin t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (insert "\\"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (if (null (cdr elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (princ ")" outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (princ " " outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (princ (substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (prin1-to-string (cdr elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 outbuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (terpri outbuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;; XEmacs change: another fucking ^L hack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (let ((p (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 p2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (print autoload outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (setq p2 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (while (search-forward "\^L" p2 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (insert "\\^L")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (goto-char p2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; Copy the rest of the line to the output.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (let ((begin (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (terpri outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (cond ((looking-at "immediate\\s *$") ; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;; This is here so that you can automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;; have small hook functions copied to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; loaddefs.el so that it's not necessary to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; load a whole file just to get a two-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;; do-nothing find-file-hook... --Stig
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (setq begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (princ (buffer-substring begin (point)) outbuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ((looking-at ";")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;; Don't read the comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (if dofiles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (setq funlist (cdr funlist)))))))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
294 (unless visited
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ;; We created this buffer, so we should kill it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (kill-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq output-end (point-marker))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (if t ;; done-any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;; XEmacs -- always do this so that we cache the information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;; that we've processed the file already.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (insert generate-autoload-section-header)
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
304 (prin1 (list 'autoloads autoloads-done load-name trim-name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (terpri outbuf)
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
307 ;;;; (insert ";;; Generated autoloads from "
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
308 ;;;; (autoload-trim-file-name file) "\n")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 ;; Warn if we put a line in loaddefs.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; that is long enough to cause trouble.
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
311 (when (< output-end (point))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
312 (setq output-end (point-marker)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (while (< (point) output-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (let ((beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (if (> (- (point) beg) 900)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (message "A line is too long--over 900 characters")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (sleep-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (goto-char output-end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (goto-char output-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (insert generate-autoload-section-trailer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (or noninteractive ; XEmacs: only need one line in -batch mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (message "Generating autoloads for %s...done" file))))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
326
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
328 (defvar generated-autoload-file
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
329 (expand-file-name "../lisp/prim/auto-autoloads.el" data-directory)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
330 "*File `update-file-autoloads' puts autoloads into.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 A .el file can set this in its local variables section to make its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 autoloads go somewhere else.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (defun update-file-autoloads (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 "Update the autoloads for FILE in `generated-autoload-file'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 \(which FILE might bind in its local variables)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (interactive "fUpdate autoloads for file: ")
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
339 (setq file (expand-file-name file))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
340 (let ((load-name (replace-in-string (file-name-nondirectory file)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
341 "\\.elc?$"
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
342 ""))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (trim-name (autoload-trim-file-name file))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
344 section-begin form)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (set-buffer (or (get-file-buffer generated-autoload-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (find-file-noselect generated-autoload-file)))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
348 ;; First delete all sections for this file.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
349 (goto-char (point-min))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
350 (while (search-forward generate-autoload-section-header nil t)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
351 (setq section-begin (match-beginning 0))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
352 (setq form (read (current-buffer)))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
353 (when (string= (nth 2 form) load-name)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
354 (search-forward generate-autoload-section-trailer)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
355 (delete-region section-begin (point))))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
356
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
357 ;; Now find insertion point for new section
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
358 (block find-insertion-point
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
359 (goto-char (point-min))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
360 (while (search-forward generate-autoload-section-header nil t)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
361 (setq form (read (current-buffer)))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
362 (when (string< trim-name (nth 3 form))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
363 ;; Found alphabetically correct insertion point
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
364 (goto-char (match-beginning 0))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
365 (return-from find-insertion-point))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
366 (search-forward generate-autoload-section-trailer))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
367 (when (eq (point) (point-min)) ; No existing entries?
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
368 (goto-char (point-max)))) ; Append.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
369
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
370 ;; Add in new sections for file
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
371 (generate-file-autoloads file))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
372
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
373 (when (interactive-p) (save-buffer))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (defun update-autoloads-here ()
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
377 "Update sections of the current buffer generated by `update-file-autoloads'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (let ((generated-autoload-file (buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (while (search-forward generate-autoload-section-header nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (let* ((form (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (end-of-file nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (file (nth 3 form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;; XEmacs change: if we can't find the file as specified, look
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 ;; around a bit more.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (cond ((and (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (or (get-file-buffer file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (file-exists-p file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 ((and (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (let ((loc (locate-file (file-name-nondirectory file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 load-path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (if (null loc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (setq loc (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (autoload-trim-file-name loc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ".."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (if (or (get-file-buffer loc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (file-exists-p loc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (setq file loc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (t
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
406 (setq file
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
407 (if (y-or-n-p
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
408 (format
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
409 "Can't find library `%s'; remove its autoloads? "
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
410 (nth 2 form) file))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
411 t
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
412 (condition-case ()
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
413 (read-file-name
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
414 (format "Find `%s' load file: "
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
415 (nth 2 form))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
416 nil nil t)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
417 (quit nil))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (let ((begin (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (search-forward generate-autoload-section-trailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (delete-region begin (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (if (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (generate-file-autoloads file)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 ;;;###autoload
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
426 (defun update-autoloads-from-directory (dir)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
427 "Update `generated-autoload-file' with all the current autoloads from DIR.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
428 This runs `update-file-autoloads' on each .el file in DIR.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
429 Obsolete autoload entries for files that no longer exist are deleted."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (interactive "DUpdate autoloads for directory: ")
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
431 (setq dir (expand-file-name dir))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
432 (let ((simple-dir (file-name-as-directory
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
433 (file-name-nondirectory
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
434 (directory-file-name dir))))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
435 (enable-local-eval nil))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
436 (save-excursion
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
437 (set-buffer (find-file-noselect generated-autoload-file))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
438 (goto-char (point-min))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
439 (while (search-forward generate-autoload-section-header nil t)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
440 (let* ((begin (match-beginning 0))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
441 (form (condition-case ()
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
442 (read (current-buffer))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
443 (end-of-file nil)))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
444 (file (nth 3 form)))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
445 (when (and (stringp file)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
446 (string= (file-name-directory file) simple-dir)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
447 (not (file-exists-p
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
448 (expand-file-name
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
449 (file-name-nondirectory file) dir))))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
450 ;; Remove the obsolete section.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
451 (search-forward generate-autoload-section-trailer)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
452 (delete-region begin (point)))))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
453 ;; Update or create autoload sections for existing files.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
454 (mapcar 'update-file-autoloads (directory-files dir t "^[^=].*\\.el$"))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
455 (unless noninteractive
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
456 (save-buffer)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (defun batch-update-autoloads ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 "Update the autoloads for the files or directories on the command line.
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
461 Runs `update-file-autoloads' on files and `update-directory-autoloads'
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 on directories. Must be used only with -batch, and kills Emacs on completion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 Each file will be processed even if an error occurred previously.
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
464 For example, invoke `xemacs -batch -f batch-update-autoloads *.el'."
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
465 (unless noninteractive
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
466 (error "batch-update-autoloads is to be used only with -batch"))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
467 (let ((defdir default-directory)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
468 (enable-local-eval nil)) ; Don't query in batch mode.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (message "Updating autoloads in %s..." generated-autoload-file)
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
470 (dolist (arg command-line-args-left)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
471 (setq arg (expand-file-name arg defdir))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
472 (cond
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
473 ((file-directory-p arg)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
474 (message "Updating autoloads for directory %s..." arg)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
475 (update-autoloads-from-directory arg))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
476 ((file-exists-p arg)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
477 (update-file-autoloads arg))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
478 (t (error "No such file or directory: %s" arg))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (save-some-buffers t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (message "Done")
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
481 (kill-emacs 0)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (provide 'autoload)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;;; autoload.el ends here