annotate lisp/autoload.el @ 412:697ef44129c6 r21-2-14

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