Mercurial > emacs
annotate lisp/emacs-lisp/autoload.el @ 78217:935157c0b596
Switch license to GPLv3 or later.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Wed, 25 Jul 2007 04:09:49 +0000 |
parents | a70527c58a3f |
children | 78ee6fae0e41 b98604865ea0 |
rev | line source |
---|---|
50806
50dd49abb157
(update-directory-autoloads): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
1 ;; autoload.el --- maintain autoloads in loaddefs.el |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
648
diff
changeset
|
2 |
63785
1220f6122b90
(make-autoload): Add the :setter for defcustoms corresponding to minor modes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61177
diff
changeset
|
3 ;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2001, 2002, 2003, |
75346 | 4 ;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc. |
14169 | 5 |
25278 | 6 ;; Author: Roland McGrath <roland@gnu.org> |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1975
diff
changeset
|
7 ;; Keywords: maint |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
8 |
14169 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
78217
935157c0b596
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75640
diff
changeset
|
13 ;; the Free Software Foundation; either version 3, or (at your option) |
14169 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
473 | 25 |
7942 | 26 ;;; Commentary: |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
27 |
7437 | 28 ;; 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
|
29 ;; 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
|
30 ;; 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
|
31 ;; 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
|
32 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
33 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
34 |
39763
c8f0d7b4bb40
(doc-string-elt): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39560
diff
changeset
|
35 (require 'lisp-mode) ;for `doc-string-elt' properties. |
47664
a0d27828cf39
(make-autoload): Add usage info to docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42767
diff
changeset
|
36 (require 'help-fns) ;for help-add-fundoc-usage. |
51012
a7817088fe0d
(make-autoload): Add arglist for define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50815
diff
changeset
|
37 (eval-when-compile (require 'cl)) |
39763
c8f0d7b4bb40
(doc-string-elt): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39560
diff
changeset
|
38 |
19170
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
39 (defvar generated-autoload-file "loaddefs.el" |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
40 "*File \\[update-file-autoloads] puts autoloads into. |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
41 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
|
42 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
|
43 trailer starting with a FormFeed character.") |
19170
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 (defconst generate-autoload-cookie ";;;###autoload" |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
46 "Magic comment indicating the following form should be autoloaded. |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
47 Used by \\[update-file-autoloads]. This string should be |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
48 meaningless to Lisp (e.g., a comment). |
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 This string is used: |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
51 |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
52 ;;;###autoload |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
53 \(defun function-to-be-autoloaded () ...) |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
54 |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
55 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
|
56 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
|
57 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
|
58 |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
59 (defconst generate-autoload-section-header "\f\n;;;### " |
21479
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
60 "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
|
61 |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
62 (defconst generate-autoload-section-trailer "\n;;;***\n" |
ecc4375537e3
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
19131
diff
changeset
|
63 "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
|
64 |
21479
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
65 (defconst generate-autoload-section-continuation ";;;;;; " |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
66 "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
|
67 |
473 | 68 (defun make-autoload (form file) |
17750
f11a3a49088c
(defcustom): Add doc-string-elt property.
Richard M. Stallman <rms@gnu.org>
parents:
17591
diff
changeset
|
69 "Turn FORM into an autoload or defvar for source file FILE. |
29549
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
70 Returns nil if FORM is not a special autoload form (i.e. a function definition |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
71 or macro definition or a defcustom)." |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
72 (let ((car (car-safe form)) expand) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
73 (cond |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
74 ;; For complex cases, try again on the macro-expansion. |
61177
64c207ce6c20
(make-autoload): Handle define-global-minor-mode.
Richard M. Stallman <rms@gnu.org>
parents:
59427
diff
changeset
|
75 ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode |
75640
a70527c58a3f
(global-cwarn-mode): Add define-globalized-minor-mode.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
76 define-globalized-minor-mode |
29549
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
77 easy-mmode-define-minor-mode define-minor-mode)) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
78 (setq expand (let ((load-file-name file)) (macroexpand form))) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
79 (eq (car expand) 'progn) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
80 (memq :autoload-end expand)) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
81 (let ((end (memq :autoload-end expand))) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
82 ;; Cut-off anything after the :autoload-end marker. |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
83 (setcdr end nil) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
84 (cons 'progn |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
85 (mapcar (lambda (form) (make-autoload form file)) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
86 (cdr expand))))) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
87 |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
88 ;; For special function-like operators, use the `autoload' function. |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
89 ((memq car '(defun define-skeleton defmacro define-derived-mode |
67291
cf5b42f7a962
(make-autoload): Add define-global-minor-mode.
Juri Linkov <juri@jurta.org>
parents:
67223
diff
changeset
|
90 define-compilation-mode define-generic-mode |
cf5b42f7a962
(make-autoload): Add define-global-minor-mode.
Juri Linkov <juri@jurta.org>
parents:
67223
diff
changeset
|
91 easy-mmode-define-global-mode define-global-minor-mode |
75640
a70527c58a3f
(global-cwarn-mode): Add define-globalized-minor-mode.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
92 define-globalized-minor-mode |
67291
cf5b42f7a962
(make-autoload): Add define-global-minor-mode.
Juri Linkov <juri@jurta.org>
parents:
67223
diff
changeset
|
93 easy-mmode-define-minor-mode define-minor-mode |
cf5b42f7a962
(make-autoload): Add define-global-minor-mode.
Juri Linkov <juri@jurta.org>
parents:
67223
diff
changeset
|
94 defun* defmacro*)) |
41811
0343ccd72be1
(make-autoload): Also generate autoloads for `defmacro*' forms.
Colin Walters <walters@gnu.org>
parents:
39763
diff
changeset
|
95 (let* ((macrop (memq car '(defmacro defmacro*))) |
29549
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
96 (name (nth 1 form)) |
51012
a7817088fe0d
(make-autoload): Add arglist for define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50815
diff
changeset
|
97 (args (case car |
a7817088fe0d
(make-autoload): Add arglist for define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50815
diff
changeset
|
98 ((defun defmacro defun* defmacro*) (nth 2 form)) |
a7817088fe0d
(make-autoload): Add arglist for define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50815
diff
changeset
|
99 ((define-skeleton) '(&optional str arg)) |
56995
fd1be95301bf
(make-autoload): Handle `define-compilation-mode'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
55208
diff
changeset
|
100 ((define-generic-mode define-derived-mode |
fd1be95301bf
(make-autoload): Handle `define-compilation-mode'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
55208
diff
changeset
|
101 define-compilation-mode) nil) |
51012
a7817088fe0d
(make-autoload): Add arglist for define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50815
diff
changeset
|
102 (t))) |
29549
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
103 (body (nthcdr (get car 'doc-string-elt) form)) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
104 (doc (if (stringp (car body)) (pop body)))) |
47664
a0d27828cf39
(make-autoload): Add usage info to docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42767
diff
changeset
|
105 (when (listp args) |
a0d27828cf39
(make-autoload): Add usage info to docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42767
diff
changeset
|
106 ;; Add the usage form at the end where describe-function-1 |
a0d27828cf39
(make-autoload): Add usage info to docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42767
diff
changeset
|
107 ;; can recover it. |
a0d27828cf39
(make-autoload): Add usage info to docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42767
diff
changeset
|
108 (setq doc (help-add-fundoc-usage doc args))) |
29549
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
109 ;; `define-generic-mode' quotes the name, so take care of that |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
110 (list 'autoload (if (listp name) name (list 'quote name)) file doc |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
111 (or (and (memq car '(define-skeleton define-derived-mode |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
112 define-generic-mode |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
113 easy-mmode-define-global-mode |
67291
cf5b42f7a962
(make-autoload): Add define-global-minor-mode.
Juri Linkov <juri@jurta.org>
parents:
67223
diff
changeset
|
114 define-global-minor-mode |
75640
a70527c58a3f
(global-cwarn-mode): Add define-globalized-minor-mode.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
115 define-globalized-minor-mode |
29549
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
116 easy-mmode-define-minor-mode |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
117 define-minor-mode)) t) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
118 (eq (car-safe (car body)) 'interactive)) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
119 (if macrop (list 'quote 'macro) nil)))) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
120 |
49100
b418e4d949ac
(make-autoload): Generate custom-autoload for autoloaded defcustoms.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48855
diff
changeset
|
121 ;; Convert defcustom to less space-consuming data. |
29549
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
122 ((eq car 'defcustom) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
123 (let ((varname (car-safe (cdr-safe form))) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
124 (init (car-safe (cdr-safe (cdr-safe form)))) |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
125 (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form))))) |
49100
b418e4d949ac
(make-autoload): Generate custom-autoload for autoloaded defcustoms.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48855
diff
changeset
|
126 ;; (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form))))) |
b418e4d949ac
(make-autoload): Generate custom-autoload for autoloaded defcustoms.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48855
diff
changeset
|
127 ) |
b418e4d949ac
(make-autoload): Generate custom-autoload for autoloaded defcustoms.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48855
diff
changeset
|
128 `(progn |
b418e4d949ac
(make-autoload): Generate custom-autoload for autoloaded defcustoms.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48855
diff
changeset
|
129 (defvar ,varname ,init ,doc) |
71955
e768c05d6e71
(make-autoload): Use new arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71874
diff
changeset
|
130 (custom-autoload ',varname ,file |
e768c05d6e71
(make-autoload): Use new arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71874
diff
changeset
|
131 ,(condition-case nil |
e768c05d6e71
(make-autoload): Use new arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71874
diff
changeset
|
132 (null (cadr (memq :set form))) |
e768c05d6e71
(make-autoload): Use new arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71874
diff
changeset
|
133 (error nil)))))) |
29549
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
134 |
67223
23fa76e60a61
(make-autoload): Handle defgroup specially.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66748
diff
changeset
|
135 ((eq car 'defgroup) |
23fa76e60a61
(make-autoload): Handle defgroup specially.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66748
diff
changeset
|
136 ;; In Emacs this is normally handled separately by cus-dep.el, but for |
23fa76e60a61
(make-autoload): Handle defgroup specially.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66748
diff
changeset
|
137 ;; third party packages, it can be convenient to explicitly autoload |
23fa76e60a61
(make-autoload): Handle defgroup specially.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66748
diff
changeset
|
138 ;; a group. |
23fa76e60a61
(make-autoload): Handle defgroup specially.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66748
diff
changeset
|
139 (let ((groupname (nth 1 form))) |
23fa76e60a61
(make-autoload): Handle defgroup specially.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66748
diff
changeset
|
140 `(let ((loads (get ',groupname 'custom-loads))) |
23fa76e60a61
(make-autoload): Handle defgroup specially.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66748
diff
changeset
|
141 (if (member ',file loads) nil |
23fa76e60a61
(make-autoload): Handle defgroup specially.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66748
diff
changeset
|
142 (put ',groupname 'custom-loads (cons ',file loads)))))) |
23fa76e60a61
(make-autoload): Handle defgroup specially.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66748
diff
changeset
|
143 |
29549
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
144 ;; nil here indicates that this is not a special autoload form. |
eafd45bcdcc1
(make-autoload): Use `cond'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29419
diff
changeset
|
145 (t nil)))) |
473 | 146 |
47664
a0d27828cf39
(make-autoload): Add usage info to docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42767
diff
changeset
|
147 ;; Forms which have doc-strings which should be printed specially. |
a0d27828cf39
(make-autoload): Add usage info to docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42767
diff
changeset
|
148 ;; A doc-string-elt property of ELT says that (nth ELT FORM) is |
a0d27828cf39
(make-autoload): Add usage info to docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42767
diff
changeset
|
149 ;; the doc-string in FORM. |
a0d27828cf39
(make-autoload): Add usage info to docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42767
diff
changeset
|
150 ;; Those properties are now set in lisp-mode.el. |
22247
7db7ffb27feb
(make-autoload): Add support for define-derived-mode. Update the
Richard M. Stallman <rms@gnu.org>
parents:
22242
diff
changeset
|
151 |
473 | 152 |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
153 (defun autoload-trim-file-name (file) |
59427 | 154 ;; Returns a relative file path for FILE |
7477
a01cc9d6398d
(autoload-trim-file-name): Make it relative
Richard M. Stallman <rms@gnu.org>
parents:
7472
diff
changeset
|
155 ;; 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
|
156 ;; 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
|
157 ;; 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
|
158 ;; 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
|
159 (setq file (expand-file-name file)) |
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
160 (file-relative-name file |
7477
a01cc9d6398d
(autoload-trim-file-name): Make it relative
Richard M. Stallman <rms@gnu.org>
parents:
7472
diff
changeset
|
161 (file-name-directory generated-autoload-file))) |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
162 |
21479
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
163 (defun autoload-read-section-header () |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
164 "Read a section header form. |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
165 Since continuation lines have been marked as comments, |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
166 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
|
167 markers before we call `read'." |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
168 (save-match-data |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
169 (let ((beginning (point)) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
170 string) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
171 (forward-line 1) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
172 (while (looking-at generate-autoload-section-continuation) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
173 (forward-line 1)) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
174 (setq string (buffer-substring beginning (point))) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
175 (with-current-buffer (get-buffer-create " *autoload*") |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
176 (erase-buffer) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
177 (insert string) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
178 (goto-char (point-min)) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
179 (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
|
180 (replace-match " ")) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
181 (goto-char (point-min)) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
182 (read (current-buffer)))))) |
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
183 |
66015
4ad1dc6bc1e0
(update-directory-autoloads): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64751
diff
changeset
|
184 (defvar autoload-print-form-outbuf nil |
4ad1dc6bc1e0
(update-directory-autoloads): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64751
diff
changeset
|
185 "Buffer which gets the output of `autoload-print-form'.") |
48718
c1ae448c795b
(autoload-print-form-outbuf): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48368
diff
changeset
|
186 |
29416
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
187 (defun autoload-print-form (form) |
48718
c1ae448c795b
(autoload-print-form-outbuf): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48368
diff
changeset
|
188 "Print FORM such that `make-docfile' will find the docstrings. |
c1ae448c795b
(autoload-print-form-outbuf): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48368
diff
changeset
|
189 The variable `autoload-print-form-outbuf' specifies the buffer to |
c1ae448c795b
(autoload-print-form-outbuf): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48368
diff
changeset
|
190 put the output in." |
29416
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
191 (cond |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
192 ;; If the form is a sequence, recurse. |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
193 ((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
|
194 ;; Symbols at the toplevel are meaningless. |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
195 ((symbolp form) nil) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
196 (t |
48718
c1ae448c795b
(autoload-print-form-outbuf): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48368
diff
changeset
|
197 (let ((doc-string-elt (get (car-safe form) 'doc-string-elt)) |
c1ae448c795b
(autoload-print-form-outbuf): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
48368
diff
changeset
|
198 (outbuf autoload-print-form-outbuf)) |
29416
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
199 (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
|
200 ;; We need to hack the printing because the |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
201 ;; doc-string must be printed specially for |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
202 ;; make-docfile (sigh). |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
203 (let* ((p (nthcdr (1- doc-string-elt) form)) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
204 (elt (cdr p))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
205 (setcdr p nil) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
206 (princ "\n(" outbuf) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
207 (let ((print-escape-newlines t) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
208 (print-escape-nonascii t)) |
47867
f91cebb0f333
(autoload-print-form): Cleanup.
Richard M. Stallman <rms@gnu.org>
parents:
47664
diff
changeset
|
209 (dolist (elt form) |
f91cebb0f333
(autoload-print-form): Cleanup.
Richard M. Stallman <rms@gnu.org>
parents:
47664
diff
changeset
|
210 (prin1 elt outbuf) |
f91cebb0f333
(autoload-print-form): Cleanup.
Richard M. Stallman <rms@gnu.org>
parents:
47664
diff
changeset
|
211 (princ " " outbuf))) |
29416
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
212 (princ "\"\\\n" outbuf) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
213 (let ((begin (with-current-buffer outbuf (point)))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
214 (princ (substring (prin1-to-string (car elt)) 1) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
215 outbuf) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
216 ;; Insert a backslash before each ( that |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
217 ;; appears at the beginning of a line in |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
218 ;; the doc string. |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
219 (with-current-buffer outbuf |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
220 (save-excursion |
47664
a0d27828cf39
(make-autoload): Add usage info to docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42767
diff
changeset
|
221 (while (re-search-backward "\n[[(]" begin t) |
29416
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
222 (forward-char 1) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
223 (insert "\\")))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
224 (if (null (cdr elt)) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
225 (princ ")" outbuf) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
226 (princ " " outbuf) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
227 (princ (substring (prin1-to-string (cdr elt)) 1) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
228 outbuf)) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
229 (terpri outbuf))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
230 (let ((print-escape-newlines t) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
231 (print-escape-nonascii t)) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
232 (print form outbuf))))))) |
6d8ceb166666
(make-autoload): Simplify docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28400
diff
changeset
|
233 |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
234 (defun autoload-ensure-default-file (file) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
235 "Make sure that the autoload file FILE exists and if not create it." |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
236 (unless (file-exists-p file) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
237 (write-region |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
238 (concat ";;; " (file-name-nondirectory file) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
239 " --- automatically extracted autoloads\n" |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
240 ";;\n" |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
241 ";;; Code:\n\n" |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
242 "\n;; Local Variables:\n" |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
243 ";; version-control: never\n" |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
244 ";; no-byte-compile: t\n" |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
245 ";; no-update-autoloads: t\n" |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
246 ";; End:\n" |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
247 ";;; " (file-name-nondirectory file) |
48855
b2730a8dee9a
(autoload-ensure-default-file): insert
David Kastrup <dak@gnu.org>
parents:
48718
diff
changeset
|
248 " ends here\n") |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
249 nil file)) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
250 file) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
251 |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
252 (defun autoload-insert-section-header (outbuf autoloads load-name file time) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
253 "Insert the section-header line, |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
254 which lists the file name and which functions are in it, etc." |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
255 (insert generate-autoload-section-header) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
256 (prin1 (list 'autoloads autoloads load-name |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
257 (if (stringp file) (autoload-trim-file-name file) file) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
258 time) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
259 outbuf) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
260 (terpri outbuf) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
261 ;; Break that line at spaces, to avoid very long lines. |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
262 ;; Make each sub-line into a comment. |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
263 (with-current-buffer outbuf |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
264 (save-excursion |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
265 (forward-line -1) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
266 (while (not (eolp)) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
267 (move-to-column 64) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
268 (skip-chars-forward "^ \n") |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
269 (or (eolp) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
270 (insert "\n" generate-autoload-section-continuation)))))) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
271 |
71047
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
272 (defun autoload-find-file (file) |
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
273 "Fetch file and put it in a temp buffer. Return the buffer." |
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
274 ;; It is faster to avoid visiting the file. |
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
275 (with-current-buffer (get-buffer-create " *autoload-file*") |
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
276 (kill-all-local-variables) |
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
277 (erase-buffer) |
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
278 (setq buffer-undo-list t |
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
279 buffer-read-only nil) |
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
280 (emacs-lisp-mode) |
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
281 (insert-file-contents file nil) |
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
282 (let ((enable-local-variables :safe)) |
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
283 (hack-local-variables)) |
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
284 (current-buffer))) |
e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69167
diff
changeset
|
285 |
71048
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
286 (defvar no-update-autoloads nil |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
287 "File local variable to prevent scanning this file for autoload cookies.") |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
288 |
473 | 289 (defun generate-file-autoloads (file) |
290 "Insert at point a loaddefs autoload section for FILE. | |
71048
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
291 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
|
292 marked by `generate-autoload-cookie' (which see). |
473 | 293 If FILE is being visited in a buffer, the contents of the buffer |
71048
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
294 are used. |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
295 Return non-nil in the case where no autoloads were added at point." |
473 | 296 (interactive "fGenerate autoloads for file: ") |
297 (let ((outbuf (current-buffer)) | |
298 (autoloads-done '()) | |
299 (load-name (let ((name (file-name-nondirectory file))) | |
48136
c102d9848214
(generate-file-autoloads, update-file-autoloads): Strip .gz extensions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47867
diff
changeset
|
300 (if (string-match "\\.elc?\\(\\.\\|$\\)" name) |
473 | 301 (substring name 0 (match-beginning 0)) |
302 name))) | |
303 (print-length nil) | |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
304 (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
|
305 (float-output-format nil) |
473 | 306 (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
|
307 (visited (get-file-buffer file)) |
71048
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
308 output-start) |
727 | 309 |
310 ;; If the autoload section we create here uses an absolute | |
59427 | 311 ;; file name for FILE in its header, and then Emacs is installed |
727 | 312 ;; under a different path on another system, |
313 ;; `update-autoloads-here' won't be able to find the files to be | |
314 ;; autoloaded. So, if FILE is in the same directory or a | |
732 | 315 ;; subdirectory of the current buffer's directory, we'll make it |
727 | 316 ;; relative to the current buffer's directory. |
317 (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
|
318 (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
|
319 (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
|
320 (file-truename default-directory))) |
410395998370
(generate-file-autoloads): Fix FILE truename hacking to substring
Roland McGrath <roland@gnu.org>
parents:
4068
diff
changeset
|
321 (len (length dir-truename))) |
410395998370
(generate-file-autoloads): Fix FILE truename hacking to substring
Roland McGrath <roland@gnu.org>
parents:
4068
diff
changeset
|
322 (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
|
323 (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
|
324 (setq file (substring source-truename len)))) |
727 | 325 |
71048
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
326 (with-current-buffer (or visited |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
327 ;; It is faster to avoid visiting the file. |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
328 (autoload-find-file file)) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
329 ;; Obey the no-update-autoloads file local variable. |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
330 (unless no-update-autoloads |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
331 (message "Generating autoloads for %s..." file) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
332 (setq output-start (with-current-buffer outbuf (point))) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
333 (save-excursion |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
334 (save-restriction |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
335 (widen) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
336 (goto-char (point-min)) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
337 (while (not (eobp)) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
338 (skip-chars-forward " \t\n\f") |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
339 (cond |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
340 ((looking-at (regexp-quote generate-autoload-cookie)) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
341 (search-forward generate-autoload-cookie) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
342 (skip-chars-forward " \t") |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
343 (setq done-any t) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
344 (if (eolp) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
345 ;; Read the next form and make an autoload. |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
346 (let* ((form (prog1 (read (current-buffer)) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
347 (or (bolp) (forward-line 1)))) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
348 (autoload (make-autoload form load-name))) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
349 (if autoload |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
350 (push (nth 1 form) autoloads-done) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
351 (setq autoload form)) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
352 (let ((autoload-print-form-outbuf outbuf)) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
353 (autoload-print-form autoload))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49100
diff
changeset
|
354 |
71048
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
355 ;; Copy the rest of the line to the output. |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
356 (princ (buffer-substring |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
357 (progn |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
358 ;; Back up over whitespace, to preserve it. |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
359 (skip-chars-backward " \f\t") |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
360 (if (= (char-after (1+ (point))) ? ) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
361 ;; Eat one space. |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
362 (forward-char 1)) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
363 (point)) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
364 (progn (forward-line 1) (point))) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
365 outbuf))) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
366 ((looking-at ";") |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
367 ;; Don't read the comment. |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
368 (forward-line 1)) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
369 (t |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
370 (forward-sexp 1) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
371 (forward-line 1)))))) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
372 |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
373 (when done-any |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
374 (with-current-buffer outbuf |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
375 (save-excursion |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
376 ;; Insert the section-header line which lists the file name |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
377 ;; and which functions are in it, etc. |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
378 (goto-char output-start) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
379 (autoload-insert-section-header |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
380 outbuf autoloads-done load-name file |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
381 (nth 5 (file-attributes file))) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
382 (insert ";;; Generated autoloads from " |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
383 (autoload-trim-file-name file) "\n")) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
384 (insert generate-autoload-section-trailer))) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
385 (message "Generating autoloads for %s...done" file)) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
386 (or visited |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
387 ;; We created this buffer, so we should kill it. |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
388 (kill-buffer (current-buffer)))) |
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
389 (not done-any))) |
2535
86d5500624d5
(update-file-autoloads, update-directory-autoloads): If called
Roland McGrath <roland@gnu.org>
parents:
2494
diff
changeset
|
390 |
473 | 391 ;;;###autoload |
57880
52307ec50b54
(update-file-autoloads): Don't use interactive-p; take new arg SAVE-AFTER.
Richard M. Stallman <rms@gnu.org>
parents:
56995
diff
changeset
|
392 (defun update-file-autoloads (file &optional save-after) |
473 | 393 "Update the autoloads for FILE in `generated-autoload-file' |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
394 \(which FILE might bind in its local variables). |
57880
52307ec50b54
(update-file-autoloads): Don't use interactive-p; take new arg SAVE-AFTER.
Richard M. Stallman <rms@gnu.org>
parents:
56995
diff
changeset
|
395 If SAVE-AFTER is non-nil (which is always, when called interactively), |
52307ec50b54
(update-file-autoloads): Don't use interactive-p; take new arg SAVE-AFTER.
Richard M. Stallman <rms@gnu.org>
parents:
56995
diff
changeset
|
396 save the buffer too. |
52307ec50b54
(update-file-autoloads): Don't use interactive-p; take new arg SAVE-AFTER.
Richard M. Stallman <rms@gnu.org>
parents:
56995
diff
changeset
|
397 |
52307ec50b54
(update-file-autoloads): Don't use interactive-p; take new arg SAVE-AFTER.
Richard M. Stallman <rms@gnu.org>
parents:
56995
diff
changeset
|
398 Return FILE if there was no autoload cookie in it, else nil." |
52307ec50b54
(update-file-autoloads): Don't use interactive-p; take new arg SAVE-AFTER.
Richard M. Stallman <rms@gnu.org>
parents:
56995
diff
changeset
|
399 (interactive "fUpdate autoloads for file: \np") |
473 | 400 (let ((load-name (let ((name (file-name-nondirectory file))) |
48136
c102d9848214
(generate-file-autoloads, update-file-autoloads): Strip .gz extensions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47867
diff
changeset
|
401 (if (string-match "\\.elc?\\(\\.\\|$\\)" name) |
473 | 402 (substring name 0 (match-beginning 0)) |
403 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
|
404 (found nil) |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
405 (existing-buffer (get-file-buffer file)) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
406 (no-autoloads nil)) |
473 | 407 (save-excursion |
408 ;; We want to get a value for generated-autoload-file from | |
409 ;; 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
|
410 (if existing-buffer |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
411 (set-buffer existing-buffer)) |
34267
6144bd28b9b5
(update-file-autoloads): Use raw-text to
Eli Zaretskii <eliz@gnu.org>
parents:
29549
diff
changeset
|
412 ;; We must read/write the file without any code conversion, |
6144bd28b9b5
(update-file-autoloads): Use raw-text to
Eli Zaretskii <eliz@gnu.org>
parents:
29549
diff
changeset
|
413 ;; but still decode EOLs. |
6144bd28b9b5
(update-file-autoloads): Use raw-text to
Eli Zaretskii <eliz@gnu.org>
parents:
29549
diff
changeset
|
414 (let ((coding-system-for-read 'raw-text)) |
21369
9ca6953d7ce8
(update-file-autoloads): Redo 1997-08-23 change.
Richard M. Stallman <rms@gnu.org>
parents:
21119
diff
changeset
|
415 (set-buffer (find-file-noselect |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
416 (autoload-ensure-default-file |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
417 (expand-file-name generated-autoload-file |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
418 (expand-file-name "lisp" |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
419 source-directory))))) |
34267
6144bd28b9b5
(update-file-autoloads): Use raw-text to
Eli Zaretskii <eliz@gnu.org>
parents:
29549
diff
changeset
|
420 ;; This is to make generated-autoload-file have Unix EOLs, so |
6144bd28b9b5
(update-file-autoloads): Use raw-text to
Eli Zaretskii <eliz@gnu.org>
parents:
29549
diff
changeset
|
421 ;; that it is portable to all platforms. |
6144bd28b9b5
(update-file-autoloads): Use raw-text to
Eli Zaretskii <eliz@gnu.org>
parents:
29549
diff
changeset
|
422 (setq buffer-file-coding-system 'raw-text-unix)) |
20817
297fefd12ecf
(update-file-autoloads): Give clean errors
Richard M. Stallman <rms@gnu.org>
parents:
19482
diff
changeset
|
423 (or (> (buffer-size) 0) |
297fefd12ecf
(update-file-autoloads): Give clean errors
Richard M. Stallman <rms@gnu.org>
parents:
19482
diff
changeset
|
424 (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
|
425 (or (file-writable-p buffer-file-name) |
297fefd12ecf
(update-file-autoloads): Give clean errors
Richard M. Stallman <rms@gnu.org>
parents:
19482
diff
changeset
|
426 (error "Autoloads file %s is not writable" buffer-file-name)) |
473 | 427 (save-excursion |
428 (save-restriction | |
429 (widen) | |
430 (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
|
431 ;; 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
|
432 (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
|
433 (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
|
434 (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
|
435 (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
|
436 ;; 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
|
437 ;; 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
|
438 (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
|
439 (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
|
440 (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
|
441 (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
|
442 (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
|
443 (listp last-time) (= (length last-time) 2) |
55208
12f4731fd3aa
(autoload-before-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
52401
diff
changeset
|
444 (not (time-less-p last-time file-time))) |
5815
b1e5e6efed1d
(update-file-autoloads): Never ask the user where to put a new section.
Roland McGrath <roland@gnu.org>
parents:
4555
diff
changeset
|
445 (progn |
14252
7ef2eabb1a9c
(update-file-autoloads): Only give "up to date" msg if (interactive-p).
Roland McGrath <roland@gnu.org>
parents:
14192
diff
changeset
|
446 (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
|
447 (message "\ |
7ef2eabb1a9c
(update-file-autoloads): Only give "up to date" msg if (interactive-p).
Roland McGrath <roland@gnu.org>
parents:
14192
diff
changeset
|
448 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
|
449 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
|
450 (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
|
451 (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
|
452 (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
|
453 (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
|
454 ((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
|
455 ;; 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
|
456 ;; 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
|
457 ;; 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
|
458 ;; 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
|
459 (goto-char (match-beginning 0)) |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
460 (setq found 'new))))) |
14044
1c331f9332ae
(update-file-autoloads): Fix placement of new sections.
Roland McGrath <roland@gnu.org>
parents:
14043
diff
changeset
|
461 (or found |
1c331f9332ae
(update-file-autoloads): Fix placement of new sections.
Roland McGrath <roland@gnu.org>
parents:
14043
diff
changeset
|
462 (progn |
1c331f9332ae
(update-file-autoloads): Fix placement of new sections.
Roland McGrath <roland@gnu.org>
parents:
14043
diff
changeset
|
463 (setq found 'new) |
1c331f9332ae
(update-file-autoloads): Fix placement of new sections.
Roland McGrath <roland@gnu.org>
parents:
14043
diff
changeset
|
464 ;; 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
|
465 (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
|
466 (search-backward "\f" nil t))) |
5837
fd1e2c6f7bf5
(autoload-trim-file-name): New function.
Roland McGrath <roland@gnu.org>
parents:
5815
diff
changeset
|
467 (or (eq found 'up-to-date) |
71048
29150c5d541b
(no-update-autoloads): Declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71047
diff
changeset
|
468 (setq no-autoloads (generate-file-autoloads file))))) |
57880
52307ec50b54
(update-file-autoloads): Don't use interactive-p; take new arg SAVE-AFTER.
Richard M. Stallman <rms@gnu.org>
parents:
56995
diff
changeset
|
469 (and save-after |
21479
89c1bfb63571
(generate-autoload-section-header): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
21369
diff
changeset
|
470 (buffer-modified-p) |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
471 (save-buffer)) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
472 |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
473 (if no-autoloads file)))) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
474 |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
475 (defun autoload-remove-section (begin) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
476 (goto-char begin) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
477 (search-forward generate-autoload-section-trailer) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
478 (delete-region begin (point))) |
473 | 479 |
480 ;;;###autoload | |
50806
50dd49abb157
(update-directory-autoloads): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
481 (defun update-directory-autoloads (&rest dirs) |
3774
3b0cb275ca29
(generate-autoload-cookie, update-autoloads-here): Doc fixes.
Roland McGrath <roland@gnu.org>
parents:
2535
diff
changeset
|
482 "\ |
17851
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
483 Update loaddefs.el with all the current autoloads from DIRS, and no old ones. |
66015
4ad1dc6bc1e0
(update-directory-autoloads): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64751
diff
changeset
|
484 This uses `update-file-autoloads' (which see) to do its work. |
50806
50dd49abb157
(update-directory-autoloads): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
485 In an interactive call, you must give one argument, the name |
50dd49abb157
(update-directory-autoloads): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
486 of a single directory. In a call from Lisp, you can supply multiple |
50dd49abb157
(update-directory-autoloads): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
487 directories as separate arguments, but this usage is discouraged. |
50dd49abb157
(update-directory-autoloads): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
488 |
50dd49abb157
(update-directory-autoloads): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
489 The function does NOT recursively descend into subdirectories of the |
50dd49abb157
(update-directory-autoloads): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
490 directory or directories specified." |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
491 (interactive "DUpdate autoloads from directory: ") |
48136
c102d9848214
(generate-file-autoloads, update-file-autoloads): Strip .gz extensions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47867
diff
changeset
|
492 (let* ((files-re (let ((tmp nil)) |
69167
35ff03ec3238
(update-directory-autoloads): Use `get-load-suffixes' instead of
Luc Teirlinck <teirllm@auburn.edu>
parents:
68648
diff
changeset
|
493 (dolist (suf (get-load-suffixes) |
48136
c102d9848214
(generate-file-autoloads, update-file-autoloads): Strip .gz extensions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47867
diff
changeset
|
494 (concat "^[^=.].*" (regexp-opt tmp t) "\\'")) |
c102d9848214
(generate-file-autoloads, update-file-autoloads): Strip .gz extensions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47867
diff
changeset
|
495 (unless (string-match "\\.elc" suf) (push suf tmp))))) |
c102d9848214
(generate-file-autoloads, update-file-autoloads): Strip .gz extensions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47867
diff
changeset
|
496 (files (apply 'nconc |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
497 (mapcar (lambda (dir) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
498 (directory-files (expand-file-name dir) |
48136
c102d9848214
(generate-file-autoloads, update-file-autoloads): Strip .gz extensions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47867
diff
changeset
|
499 t files-re)) |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
500 dirs))) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
501 (this-time (current-time)) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
502 (no-autoloads nil) ;files with no autoload cookies. |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
503 (autoloads-file |
19019
65f371a2cf00
(update-autoloads-from-directories):
Richard M. Stallman <rms@gnu.org>
parents:
17851
diff
changeset
|
504 (expand-file-name generated-autoload-file |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
505 (expand-file-name "lisp" source-directory))) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
506 (top-dir (file-name-directory autoloads-file))) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
507 |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
508 (with-current-buffer |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
509 (find-file-noselect (autoload-ensure-default-file autoloads-file)) |
2535
86d5500624d5
(update-file-autoloads, update-directory-autoloads): If called
Roland McGrath <roland@gnu.org>
parents:
2494
diff
changeset
|
510 (save-excursion |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
511 |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
512 ;; Canonicalize file names and remove the autoload file itself. |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
513 (setq files (delete (autoload-trim-file-name buffer-file-name) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
514 (mapcar 'autoload-trim-file-name files))) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
515 |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
516 (goto-char (point-min)) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
517 (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
|
518 (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
|
519 (file (nth 3 form))) |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
520 (cond ((and (consp file) (stringp (car file))) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
521 ;; This is a list of files that have no autoload cookies. |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
522 ;; There shouldn't be more than one such entry. |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
523 ;; Remove the obsolete section. |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
524 (autoload-remove-section (match-beginning 0)) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
525 (let ((last-time (nth 4 form))) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
526 (dolist (file file) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
527 (let ((file-time (nth 5 (file-attributes file)))) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
528 (when (and file-time |
55208
12f4731fd3aa
(autoload-before-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
52401
diff
changeset
|
529 (not (time-less-p last-time file-time))) |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
530 ;; file unchanged |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
531 (push file no-autoloads) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
532 (setq files (delete file files))))))) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
533 ((not (stringp file))) |
17851
6e7bb77cd7e1
(update-autoloads-from-directories): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
17750
diff
changeset
|
534 ((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
|
535 ;; Remove the obsolete section. |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
536 (autoload-remove-section (match-beginning 0))) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
537 ((equal (nth 4 form) (nth 5 (file-attributes file))) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
538 ;; File hasn't changed. |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
539 nil) |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
540 (t |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
541 (update-file-autoloads file))) |
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
542 (setq files (delete file files))))) |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
543 ;; Elements remaining in FILES have no existing autoload sections yet. |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
544 (setq no-autoloads |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
545 (append no-autoloads |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
546 (delq nil (mapcar 'update-file-autoloads files)))) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
547 (when no-autoloads |
48368
1fa683e2a917
(update-autoloads-from-directories): Sort the list of files with no
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48136
diff
changeset
|
548 ;; Sort them for better readability. |
1fa683e2a917
(update-autoloads-from-directories): Sort the list of files with no
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48136
diff
changeset
|
549 (setq no-autoloads (sort no-autoloads 'string<)) |
39560
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
550 ;; Add the `no-autoloads' section. |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
551 (goto-char (point-max)) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
552 (search-backward "\f" nil t) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
553 (autoload-insert-section-header |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
554 (current-buffer) nil nil no-autoloads this-time) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
555 (insert generate-autoload-section-trailer)) |
a05ad383618d
(autoload-ensure-default-file, autoload-insert-section-header)
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
556 |
14043
d44a43c284e7
(update-file-autoloads): Notice when searching found nothing at all.
Roland McGrath <roland@gnu.org>
parents:
14022
diff
changeset
|
557 (save-buffer)))) |
473 | 558 |
66748
80aac6382ded
(update-directory-autoloads): Add obsolete function alias.
Lars Hansen <larsh@soem.dk>
parents:
66015
diff
changeset
|
559 (define-obsolete-function-alias 'update-autoloads-from-directories |
80aac6382ded
(update-directory-autoloads): Add obsolete function alias.
Lars Hansen <larsh@soem.dk>
parents:
66015
diff
changeset
|
560 'update-directory-autoloads "22.1") |
80aac6382ded
(update-directory-autoloads): Add obsolete function alias.
Lars Hansen <larsh@soem.dk>
parents:
66015
diff
changeset
|
561 |
473 | 562 ;;;###autoload |
563 (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
|
564 "Update loaddefs.el autoloads in batch mode. |
50815
4972b38db032
(batch-update-autoloads): Call `update-directory-autoloads'.
John Paul Wallington <jpw@pobox.com>
parents:
50806
diff
changeset
|
565 Calls `update-directory-autoloads' on the command line arguments." |
4972b38db032
(batch-update-autoloads): Call `update-directory-autoloads'.
John Paul Wallington <jpw@pobox.com>
parents:
50806
diff
changeset
|
566 (apply 'update-directory-autoloads 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
|
567 (setq command-line-args-left nil)) |
473 | 568 |
569 (provide 'autoload) | |
648 | 570 |
63785
1220f6122b90
(make-autoload): Add the :setter for defcustoms corresponding to minor modes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61177
diff
changeset
|
571 ;; arch-tag: 00244766-98f4-4767-bf42-8a22103441c6 |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
648
diff
changeset
|
572 ;;; autoload.el ends here |