Mercurial > emacs
annotate lisp/emacs-lisp/autoload.el @ 29505:ca9466e54ffe
*** empty log message ***
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 08 Jun 2000 12:49:10 +0000 |
parents | b82691dc560e |
children | eafd45bcdcc1 |
rev | line source |
---|---|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
648
diff
changeset
|
1 ;;; autoload.el --- maintain autoloads in loaddefs.el. |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
648
diff
changeset
|
2 |
16995
22c9b578e220
(update-autoloads-from-directory): Get absolute file names from
Roland McGrath <roland@gnu.org>
parents:
16158
diff
changeset
|
3 ;; Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. |
14169 | 4 |
25278 | 5 ;; Author: Roland McGrath <roland@gnu.org> |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1975
diff
changeset
|
6 ;; Keywords: maint |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
7 |
14169 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
473 | 24 |
7942 | 25 ;;; Commentary: |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
26 |
7437 | 27 ;; This code helps GNU Emacs maintainers keep the loaddefs.el file up to |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
28 ;; date. It interprets magic cookies of the form ";;;###autoload" in |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
29 ;; lisp source files in various useful ways. To learn more, read the |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
30 ;; source; if you're going to use this, you'd better be able to. |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
31 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
32 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
33 |
19170
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
34 (defvar generated-autoload-file "loaddefs.el" |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
35 "*File \\[update-file-autoloads] puts autoloads into. |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
36 A `.el' file can set this in its local variables section to make its |
24896
701d2b4c7484
(generated-autoload-file): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
23092
diff
changeset
|
37 autoloads go somewhere else. The autoload file is assumed to contain a |
701d2b4c7484
(generated-autoload-file): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
23092
diff
changeset
|
38 trailer starting with a FormFeed character.") |
19170
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
39 |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
40 (defconst generate-autoload-cookie ";;;###autoload" |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
41 "Magic comment indicating the following form should be autoloaded. |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
42 Used by \\[update-file-autoloads]. This string should be |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
43 meaningless to Lisp (e.g., a comment). |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
44 |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
45 This string is used: |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
46 |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
47 ;;;###autoload |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
48 \(defun function-to-be-autoloaded () ...) |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
49 |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
50 If this string appears alone on a line, the following form will be |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
51 read and an autoload made for it. If there is further text on the line, |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
52 that text will be copied verbatim to `generated-autoload-file'.") |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
53 |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
54 (defconst generate-autoload-section-header "\f\n;;;### " |
21479
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
55 "String that marks the form at the start of a new file's autoload section.") |
19170
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
56 |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
57 (defconst generate-autoload-section-trailer "\n;;;***\n" |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
58 "String which indicates the end of the section of autoloads for a file.") |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
59 |
21479
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
60 (defconst generate-autoload-section-continuation ";;;;;; " |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
61 "String to add on each continuation of the section header form.") |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
62 |
473 | 63 (defun make-autoload (form file) |
17750
f11a3a49088c
(defcustom): Add doc-string-elt property.
Richard M. Stallman <rms@gnu.org>
parents:
17591
diff
changeset
|
64 "Turn FORM into an autoload or defvar for source file FILE. |
29416
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
65 Returns nil if FORM is not a function or variable or macro definition." |
473 | 66 (let ((car (car-safe form))) |
22371
f3cf0507c362
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
22249
diff
changeset
|
67 (if (memq car '(defun define-skeleton defmacro define-derived-mode |
25534
297c943363ed
(make-autoload): Handle defun* like defun.
Richard M. Stallman <rms@gnu.org>
parents:
25278
diff
changeset
|
68 define-generic-mode easy-mmode-define-minor-mode |
26552
88324520c7fc
(make-autoload): Recognize the new `define-minor-mode'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
25534
diff
changeset
|
69 define-minor-mode defun*)) |
29418
a6cd51379a76
(make-autoload): let* typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29416
diff
changeset
|
70 (let* ((macrop (eq car 'defmacro)) |
a6cd51379a76
(make-autoload): let* typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29416
diff
changeset
|
71 (name (nth 1 form)) |
a6cd51379a76
(make-autoload): let* typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29416
diff
changeset
|
72 (body (nthcdr (get car 'doc-string-elt) form)) |
a6cd51379a76
(make-autoload): let* typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29416
diff
changeset
|
73 (doc (if (stringp (car body)) (pop body)))) |
22371
f3cf0507c362
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
22249
diff
changeset
|
74 ;; `define-generic-mode' quotes the name, so take care of that |
f3cf0507c362
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
22249
diff
changeset
|
75 (list 'autoload (if (listp name) name (list 'quote name)) file doc |
29416
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
76 (or (and (memq car '(define-skeleton define-derived-mode |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
77 define-generic-mode |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
78 easy-mmode-define-minor-mode |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
79 define-minor-mode)) t) |
29419
b82691dc560e
(make-autoload): Other typo. I'm getting tired.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29418
diff
changeset
|
80 (eq (car-safe (car body)) 'interactive)) |
1552
f2901040a07b
* autoload.el (make-autoload): When creating an autoload
Jim Blandy <jimb@redhat.com>
parents:
1108
diff
changeset
|
81 (if macrop (list 'quote 'macro) nil))) |
19131
962be4e083c2
(make-autoload): For a defcustom,
Richard M. Stallman <rms@gnu.org>
parents:
19019
diff
changeset
|
82 ;; Convert defcustom to a simpler (and less space-consuming) defvar, |
962be4e083c2
(make-autoload): For a defcustom,
Richard M. Stallman <rms@gnu.org>
parents:
19019
diff
changeset
|
83 ;; but add some extra stuff if it uses :require. |
17750
f11a3a49088c
(defcustom): Add doc-string-elt property.
Richard M. Stallman <rms@gnu.org>
parents:
17591
diff
changeset
|
84 (if (eq car 'defcustom) |
f11a3a49088c
(defcustom): Add doc-string-elt property.
Richard M. Stallman <rms@gnu.org>
parents:
17591
diff
changeset
|
85 (let ((varname (car-safe (cdr-safe form))) |
f11a3a49088c
(defcustom): Add doc-string-elt property.
Richard M. Stallman <rms@gnu.org>
parents:
17591
diff
changeset
|
86 (init (car-safe (cdr-safe (cdr-safe form)))) |
19131
962be4e083c2
(make-autoload): For a defcustom,
Richard M. Stallman <rms@gnu.org>
parents:
19019
diff
changeset
|
87 (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form))))) |
962be4e083c2
(make-autoload): For a defcustom,
Richard M. Stallman <rms@gnu.org>
parents:
19019
diff
changeset
|
88 (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form)))))) |
962be4e083c2
(make-autoload): For a defcustom,
Richard M. Stallman <rms@gnu.org>
parents:
19019
diff
changeset
|
89 (if (not (plist-get rest :require)) |
962be4e083c2
(make-autoload): For a defcustom,
Richard M. Stallman <rms@gnu.org>
parents:
19019
diff
changeset
|
90 `(defvar ,varname ,init ,doc) |
962be4e083c2
(make-autoload): For a defcustom,
Richard M. Stallman <rms@gnu.org>
parents:
19019
diff
changeset
|
91 `(progn |
962be4e083c2
(make-autoload): For a defcustom,
Richard M. Stallman <rms@gnu.org>
parents:
19019
diff
changeset
|
92 (defvar ,varname ,init ,doc) |
962be4e083c2
(make-autoload): For a defcustom,
Richard M. Stallman <rms@gnu.org>
parents:
19019
diff
changeset
|
93 (custom-add-to-group ,(plist-get rest :group) |
962be4e083c2
(make-autoload): For a defcustom,
Richard M. Stallman <rms@gnu.org>
parents:
19019
diff
changeset
|
94 ',varname 'custom-variable) |
962be4e083c2
(make-autoload): For a defcustom,
Richard M. Stallman <rms@gnu.org>
parents:
19019
diff
changeset
|
95 (custom-add-load ',varname |
962be4e083c2
(make-autoload): For a defcustom,
Richard M. Stallman <rms@gnu.org>
parents:
19019
diff
changeset
|
96 ,(plist-get rest :require))))) |
17750
f11a3a49088c
(defcustom): Add doc-string-elt property.
Richard M. Stallman <rms@gnu.org>
parents:
17591
diff
changeset
|
97 nil)))) |
473 | 98 |
727 | 99 ;;; Forms which have doc-strings which should be printed specially. |
100 ;;; A doc-string-elt property of ELT says that (nth ELT FORM) is | |
101 ;;; the doc-string in FORM. | |
102 ;;; | |
103 ;;; There used to be the following note here: | |
104 ;;; ;;; Note: defconst and defvar should NOT be marked in this way. | |
105 ;;; ;;; We don't want to produce defconsts and defvars that | |
106 ;;; ;;; make-docfile can grok, because then it would grok them twice, | |
107 ;;; ;;; once in foo.el (where they are given with ;;;###autoload) and | |
108 ;;; ;;; once in loaddefs.el. | |
109 ;;; | |
110 ;;; Counter-note: Yes, they should be marked in this way. | |
111 ;;; make-docfile only processes those files that are loaded into the | |
112 ;;; dumped Emacs, and those files should never have anything | |
113 ;;; autoloaded here. The above-feared problem only occurs with files | |
114 ;;; which have autoloaded entries *and* are processed by make-docfile; | |
115 ;;; there should be no such files. | |
116 | |
473 | 117 (put 'autoload 'doc-string-elt 3) |
727 | 118 (put 'defun 'doc-string-elt 3) |
29416
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
119 (put 'defun* 'doc-string-elt 3) |
727 | 120 (put 'defvar 'doc-string-elt 3) |
17750
f11a3a49088c
(defcustom): Add doc-string-elt property.
Richard M. Stallman <rms@gnu.org>
parents:
17591
diff
changeset
|
121 (put 'defcustom 'doc-string-elt 3) |
727 | 122 (put 'defconst 'doc-string-elt 3) |
123 (put 'defmacro 'doc-string-elt 3) | |
28400
206604013d7f
Also print defsubst doc string
Andreas Schwab <schwab@suse.de>
parents:
26552
diff
changeset
|
124 (put 'defsubst 'doc-string-elt 3) |
29416
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
125 (put 'define-skeleton 'doc-string-elt 2) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
126 (put 'define-derived-mode 'doc-string-elt 4) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
127 (put 'easy-mmode-define-minor-mode 'doc-string-elt 2) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
128 (put 'define-minor-mode 'doc-string-elt 2) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
129 (put 'define-generic-mode 'doc-string-elt 7) |
22247
7db7ffb27feb
(make-autoload): Add support for define-derived-mode. Update the
Richard M. Stallman <rms@gnu.org>
parents:
22242
diff
changeset
|
130 |
473 | 131 |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
132 (defun autoload-trim-file-name (file) |
7477
a01cc9d6398d
(autoload-trim-file-name): Make it relative
Richard M. Stallman <rms@gnu.org>
parents:
7472
diff
changeset
|
133 ;; Returns a relative pathname of FILE |
a01cc9d6398d
(autoload-trim-file-name): Make it relative
Richard M. Stallman <rms@gnu.org>
parents:
7472
diff
changeset
|
134 ;; starting from the directory that loaddefs.el is in. |
a01cc9d6398d
(autoload-trim-file-name): Make it relative
Richard M. Stallman <rms@gnu.org>
parents:
7472
diff
changeset
|
135 ;; That is normally a directory in load-path, |
a01cc9d6398d
(autoload-trim-file-name): Make it relative
Richard M. Stallman <rms@gnu.org>
parents:
7472
diff
changeset
|
136 ;; which means Emacs will be able to find FILE when it looks. |
a01cc9d6398d
(autoload-trim-file-name): Make it relative
Richard M. Stallman <rms@gnu.org>
parents:
7472
diff
changeset
|
137 ;; Any extra directory names here would prevent finding the file. |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
138 (setq file (expand-file-name file)) |
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
139 (file-relative-name file |
7477
a01cc9d6398d
(autoload-trim-file-name): Make it relative
Richard M. Stallman <rms@gnu.org>
parents:
7472
diff
changeset
|
140 (file-name-directory generated-autoload-file))) |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
141 |
21479
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
142 (defun autoload-read-section-header () |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
143 "Read a section header form. |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
144 Since continuation lines have been marked as comments, |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
145 we must copy the text of the form and remove those comment |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
146 markers before we call `read'." |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
147 (save-match-data |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
148 (let ((beginning (point)) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
149 string) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
150 (forward-line 1) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
151 (while (looking-at generate-autoload-section-continuation) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
152 (forward-line 1)) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
153 (setq string (buffer-substring beginning (point))) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
154 (with-current-buffer (get-buffer-create " *autoload*") |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
155 (erase-buffer) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
156 (insert string) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
157 (goto-char (point-min)) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
158 (while (search-forward generate-autoload-section-continuation nil t) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
159 (replace-match " ")) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
160 (goto-char (point-min)) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
161 (read (current-buffer)))))) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
162 |
29416
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
163 ;; !! Requires OUTBUF to be bound !! |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
164 (defun autoload-print-form (form) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
165 "Print FORM such that make-docfile will find the docstrings." |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
166 (cond |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
167 ;; If the form is a sequence, recurse. |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
168 ((eq (car form) 'progn) (mapcar 'autoload-print-form (cdr form))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
169 ;; Symbols at the toplevel are meaningless. |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
170 ((symbolp form) nil) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
171 (t |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
172 (let ((doc-string-elt (get (car-safe form) 'doc-string-elt))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
173 (if (and doc-string-elt (stringp (nth doc-string-elt form))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
174 ;; We need to hack the printing because the |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
175 ;; doc-string must be printed specially for |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
176 ;; make-docfile (sigh). |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
177 (let* ((p (nthcdr (1- doc-string-elt) form)) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
178 (elt (cdr p))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
179 (setcdr p nil) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
180 (princ "\n(" outbuf) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
181 (let ((print-escape-newlines t) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
182 (print-escape-nonascii t)) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
183 (mapcar (lambda (elt) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
184 (prin1 elt outbuf) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
185 (princ " " outbuf)) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
186 form)) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
187 (princ "\"\\\n" outbuf) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
188 (let ((begin (with-current-buffer outbuf (point)))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
189 (princ (substring (prin1-to-string (car elt)) 1) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
190 outbuf) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
191 ;; Insert a backslash before each ( that |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
192 ;; appears at the beginning of a line in |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
193 ;; the doc string. |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
194 (with-current-buffer outbuf |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
195 (save-excursion |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
196 (while (search-backward "\n(" begin t) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
197 (forward-char 1) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
198 (insert "\\")))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
199 (if (null (cdr elt)) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
200 (princ ")" outbuf) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
201 (princ " " outbuf) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
202 (princ (substring (prin1-to-string (cdr elt)) 1) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
203 outbuf)) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
204 (terpri outbuf))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
205 (let ((print-escape-newlines t) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
206 (print-escape-nonascii t)) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
207 (print form outbuf))))))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
208 |
473 | 209 (defun generate-file-autoloads (file) |
210 "Insert at point a loaddefs autoload section for FILE. | |
211 autoloads are generated for defuns and defmacros in FILE | |
2494
c0fbbfadcb04
(generate-file-autoloads): Doc fix.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
212 marked by `generate-autoload-cookie' (which see). |
473 | 213 If FILE is being visited in a buffer, the contents of the buffer |
214 are used." | |
215 (interactive "fGenerate autoloads for file: ") | |
216 (let ((outbuf (current-buffer)) | |
217 (autoloads-done '()) | |
218 (load-name (let ((name (file-name-nondirectory file))) | |
219 (if (string-match "\\.elc?$" name) | |
220 (substring name 0 (match-beginning 0)) | |
221 name))) | |
222 (print-length nil) | |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
223 (print-readably t) ; This does something in Lucid Emacs. |
4555
434ef4c2fda7
(generate-file-autoloads): Set float-output-format to
Richard M. Stallman <rms@gnu.org>
parents:
4215
diff
changeset
|
224 (float-output-format nil) |
473 | 225 (done-any nil) |
1884
4a8bc12e7017
(generate-file-autoloads): If no buffer was visiting FILE when we started,
Roland McGrath <roland@gnu.org>
parents:
1552
diff
changeset
|
226 (visited (get-file-buffer file)) |
473 | 227 output-end) |
727 | 228 |
229 ;; If the autoload section we create here uses an absolute | |
230 ;; pathname for FILE in its header, and then Emacs is installed | |
231 ;; under a different path on another system, | |
232 ;; `update-autoloads-here' won't be able to find the files to be | |
233 ;; autoloaded. So, if FILE is in the same directory or a | |
732 | 234 ;; subdirectory of the current buffer's directory, we'll make it |
727 | 235 ;; relative to the current buffer's directory. |
236 (setq file (expand-file-name file)) | |
4089
410395998370
(generate-file-autoloads): Fix FILE truename hacking to substring
Roland McGrath <roland@gnu.org>
parents:
4068
diff
changeset
|
237 (let* ((source-truename (file-truename file)) |
410395998370
(generate-file-autoloads): Fix FILE truename hacking to substring
Roland McGrath <roland@gnu.org>
parents:
4068
diff
changeset
|
238 (dir-truename (file-name-as-directory |
410395998370
(generate-file-autoloads): Fix FILE truename hacking to substring
Roland McGrath <roland@gnu.org>
parents:
4068
diff
changeset
|
239 (file-truename default-directory))) |
410395998370
(generate-file-autoloads): Fix FILE truename hacking to substring
Roland McGrath <roland@gnu.org>
parents:
4068
diff
changeset
|
240 (len (length dir-truename))) |
410395998370
(generate-file-autoloads): Fix FILE truename hacking to substring
Roland McGrath <roland@gnu.org>
parents:
4068
diff
changeset
|
241 (if (and (< len (length source-truename)) |
410395998370
(generate-file-autoloads): Fix FILE truename hacking to substring
Roland McGrath <roland@gnu.org>
parents:
4068
diff
changeset
|
242 (string= dir-truename (substring source-truename 0 len))) |
410395998370
(generate-file-autoloads): Fix FILE truename hacking to substring
Roland McGrath <roland@gnu.org>
parents:
4068
diff
changeset
|
243 (setq file (substring source-truename len)))) |
727 | 244 |
473 | 245 (message "Generating autoloads for %s..." file) |
1975
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
246 (save-excursion |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
247 (unwind-protect |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
248 (progn |
13730
87eb8f956a00
(generate-file-autoloads): If no buffer visiting FILE exists, read it into
Roland McGrath <roland@gnu.org>
parents:
12500
diff
changeset
|
249 (if visited |
87eb8f956a00
(generate-file-autoloads): If no buffer visiting FILE exists, read it into
Roland McGrath <roland@gnu.org>
parents:
12500
diff
changeset
|
250 (set-buffer visited) |
87eb8f956a00
(generate-file-autoloads): If no buffer visiting FILE exists, read it into
Roland McGrath <roland@gnu.org>
parents:
12500
diff
changeset
|
251 ;; It is faster to avoid visiting the file. |
87eb8f956a00
(generate-file-autoloads): If no buffer visiting FILE exists, read it into
Roland McGrath <roland@gnu.org>
parents:
12500
diff
changeset
|
252 (set-buffer (get-buffer-create " *generate-autoload-file*")) |
87eb8f956a00
(generate-file-autoloads): If no buffer visiting FILE exists, read it into
Roland McGrath <roland@gnu.org>
parents:
12500
diff
changeset
|
253 (kill-all-local-variables) |
87eb8f956a00
(generate-file-autoloads): If no buffer visiting FILE exists, read it into
Roland McGrath <roland@gnu.org>
parents:
12500
diff
changeset
|
254 (erase-buffer) |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
255 (setq buffer-undo-list t |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
256 buffer-read-only nil) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
257 (emacs-lisp-mode) |
13730
87eb8f956a00
(generate-file-autoloads): If no buffer visiting FILE exists, read it into
Roland McGrath <roland@gnu.org>
parents:
12500
diff
changeset
|
258 (insert-file-contents file nil)) |
1975
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
259 (save-excursion |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
260 (save-restriction |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
261 (widen) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
262 (goto-char (point-min)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
263 (while (not (eobp)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
264 (skip-chars-forward " \t\n\f") |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
265 (cond |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
266 ((looking-at (regexp-quote generate-autoload-cookie)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
267 (search-forward generate-autoload-cookie) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
268 (skip-chars-forward " \t") |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
269 (setq done-any t) |
5854
9d1ae808403b
(generate-file-autoloads): Don't frob literal formfeeds into \f; just bind
Roland McGrath <roland@gnu.org>
parents:
5843
diff
changeset
|
270 (if (eolp) |
9d1ae808403b
(generate-file-autoloads): Don't frob literal formfeeds into \f; just bind
Roland McGrath <roland@gnu.org>
parents:
5843
diff
changeset
|
271 ;; Read the next form and make an autoload. |
9d1ae808403b
(generate-file-autoloads): Don't frob literal formfeeds into \f; just bind
Roland McGrath <roland@gnu.org>
parents:
5843
diff
changeset
|
272 (let* ((form (prog1 (read (current-buffer)) |
29416
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
273 (or (bolp) (forward-line 1)))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
274 (autoload (make-autoload form load-name))) |
5854
9d1ae808403b
(generate-file-autoloads): Don't frob literal formfeeds into \f; just bind
Roland McGrath <roland@gnu.org>
parents:
5843
diff
changeset
|
275 (if autoload |
9d1ae808403b
(generate-file-autoloads): Don't frob literal formfeeds into \f; just bind
Roland McGrath <roland@gnu.org>
parents:
5843
diff
changeset
|
276 (setq autoloads-done (cons (nth 1 form) |
9d1ae808403b
(generate-file-autoloads): Don't frob literal formfeeds into \f; just bind
Roland McGrath <roland@gnu.org>
parents:
5843
diff
changeset
|
277 autoloads-done)) |
9d1ae808403b
(generate-file-autoloads): Don't frob literal formfeeds into \f; just bind
Roland McGrath <roland@gnu.org>
parents:
5843
diff
changeset
|
278 (setq autoload form)) |
29416
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
279 (autoload-print-form autoload)) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
280 |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
281 ;; Copy the rest of the line to the output. |
13937
35c457f8bedf
(generate-file-autoloads): Preserve whitespace after cookie in literal text
Roland McGrath <roland@gnu.org>
parents:
13730
diff
changeset
|
282 (princ (buffer-substring |
35c457f8bedf
(generate-file-autoloads): Preserve whitespace after cookie in literal text
Roland McGrath <roland@gnu.org>
parents:
13730
diff
changeset
|
283 (progn |
35c457f8bedf
(generate-file-autoloads): Preserve whitespace after cookie in literal text
Roland McGrath <roland@gnu.org>
parents:
13730
diff
changeset
|
284 ;; Back up over whitespace, to preserve it. |
35c457f8bedf
(generate-file-autoloads): Preserve whitespace after cookie in literal text
Roland McGrath <roland@gnu.org>
parents:
13730
diff
changeset
|
285 (skip-chars-backward " \f\t") |
35c457f8bedf
(generate-file-autoloads): Preserve whitespace after cookie in literal text
Roland McGrath <roland@gnu.org>
parents:
13730
diff
changeset
|
286 (if (= (char-after (1+ (point))) ? ) |
35c457f8bedf
(generate-file-autoloads): Preserve whitespace after cookie in literal text
Roland McGrath <roland@gnu.org>
parents:
13730
diff
changeset
|
287 ;; Eat one space. |
35c457f8bedf
(generate-file-autoloads): Preserve whitespace after cookie in literal text
Roland McGrath <roland@gnu.org>
parents:
13730
diff
changeset
|
288 (forward-char 1)) |
35c457f8bedf
(generate-file-autoloads): Preserve whitespace after cookie in literal text
Roland McGrath <roland@gnu.org>
parents:
13730
diff
changeset
|
289 (point)) |
35c457f8bedf
(generate-file-autoloads): Preserve whitespace after cookie in literal text
Roland McGrath <roland@gnu.org>
parents:
13730
diff
changeset
|
290 (progn (forward-line 1) (point))) |
35c457f8bedf
(generate-file-autoloads): Preserve whitespace after cookie in literal text
Roland McGrath <roland@gnu.org>
parents:
13730
diff
changeset
|
291 outbuf))) |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
292 ((looking-at ";") |
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
293 ;; Don't read the comment. |
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
294 (forward-line 1)) |
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
295 (t |
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
296 (forward-sexp 1) |
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
297 (forward-line 1))))))) |
1975
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
298 (or visited |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
299 ;; We created this buffer, so we should kill it. |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
300 (kill-buffer (current-buffer))) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
301 (set-buffer outbuf) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
302 (setq output-end (point-marker)))) |
473 | 303 (if done-any |
304 (progn | |
21479
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
305 ;; Insert the section-header line |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
306 ;; which lists the file name and which functions are in it, etc. |
473 | 307 (insert generate-autoload-section-header) |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
308 (prin1 (list 'autoloads autoloads-done load-name |
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
309 (autoload-trim-file-name file) |
473 | 310 (nth 5 (file-attributes file))) |
311 outbuf) | |
312 (terpri outbuf) | |
21479
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
313 ;; Break that line at spaces, to avoid very long lines. |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
314 ;; Make each sub-line into a comment. |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
315 (with-current-buffer outbuf |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
316 (save-excursion |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
317 (forward-line -1) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
318 (while (not (eolp)) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
319 (move-to-column 64) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
320 (skip-chars-forward "^ \n") |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
321 (or (eolp) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
322 (insert "\n" generate-autoload-section-continuation))))) |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
323 (insert ";;; Generated autoloads from " |
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
324 (autoload-trim-file-name file) "\n") |
8864
65731429a2c1
(generate-file-autoloads): Warn if we put a line
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
325 ;; Warn if we put a line in loaddefs.el |
65731429a2c1
(generate-file-autoloads): Warn if we put a line
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
326 ;; that is long enough to cause trouble. |
65731429a2c1
(generate-file-autoloads): Warn if we put a line
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
327 (while (< (point) output-end) |
65731429a2c1
(generate-file-autoloads): Warn if we put a line
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
328 (let ((beg (point))) |
65731429a2c1
(generate-file-autoloads): Warn if we put a line
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
329 (end-of-line) |
65731429a2c1
(generate-file-autoloads): Warn if we put a line
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
330 (if (> (- (point) beg) 900) |
65731429a2c1
(generate-file-autoloads): Warn if we put a line
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
331 (progn |
65731429a2c1
(generate-file-autoloads): Warn if we put a line
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
332 (message "A line is too long--over 900 characters") |
65731429a2c1
(generate-file-autoloads): Warn if we put a line
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
333 (sleep-for 2) |
65731429a2c1
(generate-file-autoloads): Warn if we put a line
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
334 (goto-char output-end)))) |
65731429a2c1
(generate-file-autoloads): Warn if we put a line
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
335 (forward-line 1)) |
473 | 336 (goto-char output-end) |
337 (insert generate-autoload-section-trailer))) | |
338 (message "Generating autoloads for %s...done" file))) | |
2535
86d5500624d5
(update-file-autoloads, update-directory-autoloads): If called
Roland McGrath <roland@gnu.org>
parents:
2494
diff
changeset
|
339 |
473 | 340 ;;;###autoload |
341 (defun update-file-autoloads (file) | |
342 "Update the autoloads for FILE in `generated-autoload-file' | |
343 \(which FILE might bind in its local variables)." | |
344 (interactive "fUpdate autoloads for file: ") | |
345 (let ((load-name (let ((name (file-name-nondirectory file))) | |
346 (if (string-match "\\.elc?$" name) | |
347 (substring name 0 (match-beginning 0)) | |
348 name))) | |
5815
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
349 (found nil) |
473 | 350 (existing-buffer (get-file-buffer file))) |
351 (save-excursion | |
352 ;; We want to get a value for generated-autoload-file from | |
353 ;; the local variables section if it's there. | |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
354 (if existing-buffer |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
355 (set-buffer existing-buffer)) |
17001
ce8565274e49
(update-file-autoloads): Read loaddefs.el without
Karl Heuer <kwzh@gnu.org>
parents:
16995
diff
changeset
|
356 ;; We must read/write the file without any code conversion. |
ce8565274e49
(update-file-autoloads): Read loaddefs.el without
Karl Heuer <kwzh@gnu.org>
parents:
16995
diff
changeset
|
357 (let ((coding-system-for-read 'no-conversion)) |
21369
9ca6953d7ce8
(update-file-autoloads): Redo 1997-08-23 change.
Richard M. Stallman <rms@gnu.org>
parents:
21119
diff
changeset
|
358 (set-buffer (find-file-noselect |
9ca6953d7ce8
(update-file-autoloads): Redo 1997-08-23 change.
Richard M. Stallman <rms@gnu.org>
parents:
21119
diff
changeset
|
359 (expand-file-name generated-autoload-file |
9ca6953d7ce8
(update-file-autoloads): Redo 1997-08-23 change.
Richard M. Stallman <rms@gnu.org>
parents:
21119
diff
changeset
|
360 (expand-file-name "lisp" |
9ca6953d7ce8
(update-file-autoloads): Redo 1997-08-23 change.
Richard M. Stallman <rms@gnu.org>
parents:
21119
diff
changeset
|
361 source-directory))))) |
20817
297fefd12ecf
(update-file-autoloads): Give clean errors
Richard M. Stallman <rms@gnu.org>
parents:
19482
diff
changeset
|
362 (or (> (buffer-size) 0) |
297fefd12ecf
(update-file-autoloads): Give clean errors
Richard M. Stallman <rms@gnu.org>
parents:
19482
diff
changeset
|
363 (error "Autoloads file %s does not exist" buffer-file-name)) |
297fefd12ecf
(update-file-autoloads): Give clean errors
Richard M. Stallman <rms@gnu.org>
parents:
19482
diff
changeset
|
364 (or (file-writable-p buffer-file-name) |
297fefd12ecf
(update-file-autoloads): Give clean errors
Richard M. Stallman <rms@gnu.org>
parents:
19482
diff
changeset
|
365 (error "Autoloads file %s is not writable" buffer-file-name)) |
473 | 366 (save-excursion |
367 (save-restriction | |
368 (widen) | |
369 (goto-char (point-min)) | |
5815
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
370 ;; Look for the section for LOAD-NAME. |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
371 (while (and (not found) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
372 (search-forward generate-autoload-section-header nil t)) |
21479
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
373 (let ((form (autoload-read-section-header))) |
5815
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
374 (cond ((string= (nth 2 form) load-name) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
375 ;; We found the section for this file. |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
376 ;; Check if it is up to date. |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
377 (let ((begin (match-beginning 0)) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
378 (last-time (nth 4 form)) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
379 (file-time (nth 5 (file-attributes file)))) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
380 (if (and (or (null existing-buffer) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
381 (not (buffer-modified-p existing-buffer))) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
382 (listp last-time) (= (length last-time) 2) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
383 (or (> (car last-time) (car file-time)) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
384 (and (= (car last-time) (car file-time)) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
385 (>= (nth 1 last-time) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
386 (nth 1 file-time))))) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
387 (progn |
14252
7ef2eabb1a9c
(update-file-autoloads): Only give "up to date" msg if (interactive-p).
Roland McGrath <roland@gnu.org>
parents:
14192
diff
changeset
|
388 (if (interactive-p) |
7ef2eabb1a9c
(update-file-autoloads): Only give "up to date" msg if (interactive-p).
Roland McGrath <roland@gnu.org>
parents:
14192
diff
changeset
|
389 (message "\ |
7ef2eabb1a9c
(update-file-autoloads): Only give "up to date" msg if (interactive-p).
Roland McGrath <roland@gnu.org>
parents:
14192
diff
changeset
|
390 Autoload section for %s is up to date." |
7ef2eabb1a9c
(update-file-autoloads): Only give "up to date" msg if (interactive-p).
Roland McGrath <roland@gnu.org>
parents:
14192
diff
changeset
|
391 file)) |
5815
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
392 (setq found 'up-to-date)) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
393 (search-forward generate-autoload-section-trailer) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
394 (delete-region begin (point)) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
395 (setq found t)))) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
396 ((string< load-name (nth 2 form)) |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
397 ;; We've come to a section alphabetically later than |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
398 ;; LOAD-NAME. We assume the file is in order and so |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
399 ;; there must be no section for LOAD-NAME. We will |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
400 ;; insert one before the section here. |
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
401 (goto-char (match-beginning 0)) |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
402 (setq found 'new))))) |
14044
1c331f9332ae
(update-file-autoloads): Fix placement of new sections.
Roland McGrath <roland@gnu.org>
parents:
14043
diff
changeset
|
403 (or found |
1c331f9332ae
(update-file-autoloads): Fix placement of new sections.
Roland McGrath <roland@gnu.org>
parents:
14043
diff
changeset
|
404 (progn |
1c331f9332ae
(update-file-autoloads): Fix placement of new sections.
Roland McGrath <roland@gnu.org>
parents:
14043
diff
changeset
|
405 (setq found 'new) |
1c331f9332ae
(update-file-autoloads): Fix placement of new sections.
Roland McGrath <roland@gnu.org>
parents:
14043
diff
changeset
|
406 ;; No later sections in the file. Put before the last page. |
1c331f9332ae
(update-file-autoloads): Fix placement of new sections.
Roland McGrath <roland@gnu.org>
parents:
14043
diff
changeset
|
407 (goto-char (point-max)) |
16158
af6ef293cb42
(update-file-autoloads): Don't barf if autoloads file
Richard M. Stallman <rms@gnu.org>
parents:
14252
diff
changeset
|
408 (search-backward "\f" nil t))) |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
409 (or (eq found 'up-to-date) |
14044
1c331f9332ae
(update-file-autoloads): Fix placement of new sections.
Roland McGrath <roland@gnu.org>
parents:
14043
diff
changeset
|
410 (and (eq found 'new) |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
411 ;; Check that FILE has any cookies before generating a |
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
412 ;; new section for it. |
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
413 (save-excursion |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
414 (if existing-buffer |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
415 (set-buffer existing-buffer) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
416 ;; It is faster to avoid visiting the file. |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
417 (set-buffer (get-buffer-create " *autoload-file*")) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
418 (kill-all-local-variables) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
419 (erase-buffer) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
420 (setq buffer-undo-list t |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
421 buffer-read-only nil) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
422 (emacs-lisp-mode) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
423 (insert-file-contents file nil)) |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
424 (save-excursion |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
425 (save-restriction |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
426 (widen) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
427 (goto-char (point-min)) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
428 (prog1 |
19209
50857b41060a
(update-file-autoloads): Use anchored regexp search instead of requiring
Roland McGrath <roland@gnu.org>
parents:
19170
diff
changeset
|
429 (if (re-search-forward |
50857b41060a
(update-file-autoloads): Use anchored regexp search instead of requiring
Roland McGrath <roland@gnu.org>
parents:
19170
diff
changeset
|
430 (concat "^" (regexp-quote |
50857b41060a
(update-file-autoloads): Use anchored regexp search instead of requiring
Roland McGrath <roland@gnu.org>
parents:
19170
diff
changeset
|
431 generate-autoload-cookie)) |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
432 nil t) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
433 nil |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
434 (if (interactive-p) |
14192
b1bc0f5d8cf3
(update-file-autoloads): Fix message.
Erik Naggum <erik@naggum.no>
parents:
14169
diff
changeset
|
435 (message "%s has no autoloads" file)) |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
436 t) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
437 (or existing-buffer |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
438 (kill-buffer (current-buffer)))))))) |
7456
493a32789e7d
(update-file-autoloads): Delete leftover variable.
Karl Heuer <kwzh@gnu.org>
parents:
7437
diff
changeset
|
439 (generate-file-autoloads file)))) |
21479
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
440 (and (interactive-p) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
441 (buffer-modified-p) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
442 (save-buffer))))) |
473 | 443 |
444 ;;;###autoload | |
17851
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
445 (defun update-autoloads-from-directories (&rest dirs) |
3774
3b0cb275ca29
(generate-autoload-cookie, update-autoloads-here): Doc fixes.
Roland McGrath <roland@gnu.org>
parents:
2535
diff
changeset
|
446 "\ |
17851
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
447 Update loaddefs.el with all the current autoloads from DIRS, and no old ones. |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
448 This uses `update-file-autoloads' (which see) do its work." |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
449 (interactive "DUpdate autoloads from directory: ") |
17851
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
450 (let ((files (apply 'nconc |
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
451 (mapcar (function (lambda (dir) |
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
452 (directory-files (expand-file-name dir) |
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
453 t |
19170
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
454 "^[^=.].*\\.el$"))) |
17851
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
455 dirs))) |
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
456 autoloads-file |
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
457 top-dir) |
19019
65f371a2cf00
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
17851
diff
changeset
|
458 (setq autoloads-file |
65f371a2cf00
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
17851
diff
changeset
|
459 (expand-file-name generated-autoload-file |
65f371a2cf00
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
17851
diff
changeset
|
460 (expand-file-name "lisp" |
65f371a2cf00
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
17851
diff
changeset
|
461 source-directory))) |
17851
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
462 (setq top-dir (file-name-directory autoloads-file)) |
473 | 463 (save-excursion |
17851
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
464 (set-buffer (find-file-noselect autoloads-file)) |
2535
86d5500624d5
(update-file-autoloads, update-directory-autoloads): If called
Roland McGrath <roland@gnu.org>
parents:
2494
diff
changeset
|
465 (save-excursion |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
466 (goto-char (point-min)) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
467 (while (search-forward generate-autoload-section-header nil t) |
21479
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
468 (let* ((form (autoload-read-section-header)) |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
469 (file (nth 3 form))) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
470 (cond ((not (stringp file))) |
17851
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
471 ((not (file-exists-p (expand-file-name file top-dir))) |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
472 ;; Remove the obsolete section. |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
473 (let ((begin (match-beginning 0))) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
474 (search-forward generate-autoload-section-trailer) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
475 (delete-region begin (point)))) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
476 (t |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
477 (update-file-autoloads file))) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
478 (setq files (delete file files))))) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
479 ;; Elements remaining in FILES have no existing autoload sections. |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
480 (mapcar 'update-file-autoloads files) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
481 (save-buffer)))) |
473 | 482 |
483 ;;;###autoload | |
484 (defun batch-update-autoloads () | |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
485 "Update loaddefs.el autoloads in batch mode. |
17851
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
486 Calls `update-autoloads-from-directories' on the command line arguments." |
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
487 (apply 'update-autoloads-from-directories command-line-args-left) |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
488 (setq command-line-args-left nil)) |
473 | 489 |
490 (provide 'autoload) | |
648 | 491 |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
648
diff
changeset
|
492 ;;; autoload.el ends here |