annotate lisp/autoload.el @ 1495:c3cf7db99b98

[xemacs-hg @ 2003-05-22 07:41:20 by stephent] oldies faq <87iss3tpac.fsf@tleepslib.sk.tsukuba.ac.jp> split-string tweaks n dox <87n0hftpht.fsf@tleepslib.sk.tsukuba.ac.jp> missed commit of broken-sun.h <87r878ihhf.fsf@tleepslib.sk.tsukuba.ac.jp> already loaded message <87el2rtovc.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Thu, 22 May 2003 07:41:27 +0000
parents 781dc6d5baba
children 5903b079bee1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1 ;;; autoload.el --- maintain autoloads in auto-autoloads files.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
5 ;; Copyright (C) 1996, 2000, 2002, 2003 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Author: Roland McGrath <roland@gnu.ai.mit.edu>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 ;; Keywords: maint
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 ;; 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 ;;; Synched up with: Not synched with FSF.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
31 ;; This code keeps auto-autoloads.el files up to date. It interprets
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
32 ;; magic cookies (of the form ";;;###autoload" in Lisp source files
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
33 ;; and "/* ###autoload */" in C source files) in various useful ways.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
34
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
35 ;; Usage
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
36 ;; =====
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
37
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
38 ;; Recommended usage for this library, as implemented in the core
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
39 ;; build process, is
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
40
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
41 ;; xemacs -no-packages -batch \
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
42 ;; -eval "(setq generated-autoload-file \"PATH\")" \
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
43 ;; -l autoload -f autoload-update-directory-autoloads PREFIX DIRECTORY
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
44
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
45 ;; which causes XEmacs to update the file named by PATH from the .el
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
46 ;; files in DIRECTORY (but not recursing into subdirectories) and (if
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
47 ;; the autoload file is not already protected with a feature test) add
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
48 ;; a check and provide for 'PREFIX-autoloads. Currently there is no
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
49 ;; sanity check for the provided feature; it is recommended that you
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
50 ;; nuke any existing auto-autoloads.el before running the command.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
51
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
52 ;; There is not yet a recommended API for updating multiple directories
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
53 ;; into a single auto-autoloads file. Using the recipe above for each
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
54 ;; DIRECTORY with the same PATH should work but has not been tested.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
55 ;; There is no API for recursing into subdirectories. There probably
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
56 ;; won't be; given the wide variety of ways that existing Lisp packages
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
57 ;; arrange their files, and the fact that source packages and installed
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
58 ;; packages have a somewhat different directory structure, this seems far
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
59 ;; too risky. Use a script or a Lisp library with an explicit list of
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
60 ;; PATHs; see update-elc.el for how to do this without recursive invocation
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
61 ;; of XEmacs).
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
62
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
63 ;; The probable next step is to fix up the packages to use the
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
64 ;; `autoload-update-directory-autoloads' API. However, for backward
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
65 ;; compatibility with XEmacs 21.4 and 21.1, this can't be done quickly.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
66
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
67 ;; For now the API used in update-elc-2.el:
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
68
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
69 ;; (let* ((dir "DIRECTORY")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
70 ;; (generated-autoload-file (expand-file-name "auto-autoloads.el" dir))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
71 ;; (autoload-package-name "PREFIX"))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
72 ;; (update-autoload-files (list muledir))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
73 ;; (byte-recompile-file generated-autoload-file 0))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
74
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
75 ;; is available, but this ugly kludge is deprecated. It will be removed
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
76 ;; in favor of using proper arguments instead of special variables.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
77
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
78 ;; For backward compatibility the API used in the packages/XEmacs.rules:
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
79
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
80 ;; xemacs -vanilla -batch -eval "$(AUTOLOAD_PACKAGE_NAME)" \
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
81 ;; -l autoload -f batch-update-directory $(AUTOLOAD_PATH)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
82
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
83 ;; is supported, and the implementation is unchanged. However,
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
84 ;; revision of the API (in a backward compatible way) and the
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
85 ;; implementation are planned, and until those stabilize it is too
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
86 ;; risky to use this version of XEmacs for package releases.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
87
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
88 ;; Implementation:
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
89 ;; ===============
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
90
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
91 ;; #### This section should be moved to the Internals manual, or
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
92 ;; (maybe) the Lispref, and integrated with the information above.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
93 ;; Don't believe anything written here; the code is still a mess, and
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
94 ;; this is a lot of guesswork.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
95
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
96 ;; Autoloads are used in a number of contexts, including core Lisp,
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
97 ;; packaged Lisp, and ELLs (dynamically loadable compiled objects
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
98 ;; providing Lisp functionality). There two general strategies for
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
99 ;; collecting autoloads. The first is to put autoloads for a package
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
100 ;; in a package-specific auto-autoloads file. This is easy to
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
101 ;; implement, and allows packages to be distributed with prebuilt
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
102 ;; auto-autoloads files. The second is to collect all the autoloads
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
103 ;; in a single global auto-autoloads file. This is alleged to speed
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
104 ;; up initialization significantly, but requires care to ensure that
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
105 ;; auto-autoloads files remain synchronized with the libraries.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
106
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
107 ;; The traditional logic for determining where to put autoload
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
108 ;; definitions is complex and is now deprecated. The special variable
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
109 ;; `generated-autoload-file' is used to hold the path to the file, and
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
110 ;; is initialized to the traditional (well, it's a new tradition with
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
111 ;; XEmacs 20) $blddir/lisp/auto-autoloads.el. However, this variable
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
112 ;; may be bound by calling code, or may be generated at collect time
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
113 ;; and I'm not even sure the initialized value was ever used any more.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
114
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
115 ;; Because there may be multiple auto-autoloads files in use (in XEmacs
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
116 ;; 21.x with a full complement of packages there are dozens), and they may
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
117 ;; contain initializations that would be dangerous to reexecute, each is
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
118 ;; protected by a feature test. By convention, the feature symbol is of
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
119 ;; the form "NAME-autoloads". For packages, the special variable
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
120 ;; `autoload-package-name' is used to determine NAME. In the core,
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
121 ;; autoloads are defined in the modules (all of which are collected in a
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
122 ;; single auto-autoloads file), using NAME=modules, in the lisp directory
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
123 ;; using NAME=lisp, and in the lisp/mule directory, using NAME=mule, for
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
124 ;; the autoloads feature. These latter are computed by the autoloads
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
125 ;; function at collect time.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 ;; ChangeLog:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
129 ;; See ./ChangeLog.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
133 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
134 ;; Standard file and directory names
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
135
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
136 ;; `autoload-file-name' is defvar'd and initialized in packages.el,
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
137 ;; which is loaded (and dumped) very early. If you find it isn't, you
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
138 ;; know what you're doing.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
139
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
140 (defconst autoload-target-directory "../lisp/"
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
141 "Standard directory containing autoload declaration file.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
142
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
143 Use `generated-autoload-file' (q.v.) to change its installation location.")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
144
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
145 ;; Dynamic variables for communication among functions
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
146
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
147 (defvar generated-autoload-file
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
148 (expand-file-name autoload-file-name lisp-directory)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
149 "*File `update-file-autoloads' puts autoloads into.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
150 A .el file can set this in its local variables section to make its
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
151 autoloads go somewhere else.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
152
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
153 Note that `batch-update-directory' binds this variable to its own value,
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
154 generally the file named by `autoload-file-name' in the directory being
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
155 updated. XEmacs.rules setq's this variable for package autoloads.")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
156
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
157 (define-obsolete-variable-alias 'autoload-package-name
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
158 'autoload-feature-prefix)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
159 (defvar autoload-feature-prefix nil
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
160 "If non-nil, use this string to prefix the autoload feature name.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
161
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
162 Usually a package name (from AUTOLOAD_PACKAGE_NAME, defined in XEmacs.rules
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
163 in the top of the package hierarchy), or \"auto\" (reserved for the core Lisp
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
164 auto-autoloads file). Highest priority candidate except for an explicit
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
165 argument to `autoload-make-feature-name' (q.v.).")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
166
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
167 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
168 ;; Magic strings in source files
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
169
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
170 (defconst generate-autoload-cookie ";;;###autoload"
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
171 "Magic comment indicating the following form should be autoloaded.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
172 Used by `update-file-autoloads'. This string should be
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
173 meaningless to Lisp (e.g., a comment).
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
174
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
175 This string is used:
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
176
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
177 ;;;###autoload
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
178 \(defun function-to-be-autoloaded () ...)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
179
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
180 If this string appears alone on a line, the following form will be
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
181 read and an autoload made for it. If it is followed by the string
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
182 \"immediate\", then the form on the following line will be copied
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
183 verbatim. If there is further text on the line, that text will be
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
184 copied verbatim to `generated-autoload-file'.")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
185
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
186 (defconst generate-c-autoload-cookie "/* ###autoload"
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
187 "Magic C comment indicating the following form should be autoloaded.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
188 Used by `update-file-autoloads'. This string should be
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
189 meaningless to C (e.g., a comment).
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
190
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
191 This string is used:
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
192
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
193 /* ###autoload */
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
194 DEFUN (\"function-to-be-autoloaded\", ... )
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
195
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
196 If this string appears alone on a line, the following form will be
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
197 read and an autoload made for it. If there is further text on the line,
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
198 that text will be copied verbatim to `generated-autoload-file'.")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
199
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
200 (defconst generate-c-autoload-module "/* ###module"
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
201 "Magic C comment indicating the module containing autoloaded functions.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
202 Since a module can consist of multiple C files, the module name may not be
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
203 the same as the C source file base name. In that case, use this comment to
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
204 indicate the actual name of the module from which to autoload functions.")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
205
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
206 (defconst generate-autoload-section-header "\f\n;;;### "
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
207 "String inserted before the form identifying
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
208 the section of autoloads for a file.")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
209
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
210 (defconst generate-autoload-section-trailer "\n;;;***\n"
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
211 "String which indicates the end of the section of autoloads for a file.")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
212
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
213 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
214 ;; Parsing the source file text.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
215 ;; Autoloads in C source differ from those in Lisp source. For historical
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
216 ;; reasons, functions handling only Lisp don't have "lisp" in their names;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
217 ;; maybe this should be changed.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
218
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 (defun make-autoload (form file)
969
d41e92ee6d12 [xemacs-hg @ 2002-08-22 11:19:45 by stephent]
stephent
parents: 778
diff changeset
220 "Turn a definition generator FORM into an autoload for source file FILE.
d41e92ee6d12 [xemacs-hg @ 2002-08-22 11:19:45 by stephent]
stephent
parents: 778
diff changeset
221 Returns nil if FORM is not a defun, defun*, defmacro, defmacro*,
d41e92ee6d12 [xemacs-hg @ 2002-08-22 11:19:45 by stephent]
stephent
parents: 778
diff changeset
222 define-skeleton, or define-derived-mode."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 (let ((car (car-safe form)))
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 646
diff changeset
224 (if (memq car '(defun defun* define-skeleton defmacro defmacro*
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 646
diff changeset
225 define-derived-mode))
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 646
diff changeset
226 (let ((macrop (memq car '(defmacro defmacro*)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 name doc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 (setq form (cdr form)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 name (car form)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 ;; Ignore the arguments.
646
00c54252fe4f [xemacs-hg @ 2001-08-08 12:15:04 by didierv]
didierv
parents: 645
diff changeset
231 form (cdr (cond ((eq car 'define-skeleton)
00c54252fe4f [xemacs-hg @ 2001-08-08 12:15:04 by didierv]
didierv
parents: 645
diff changeset
232 form)
00c54252fe4f [xemacs-hg @ 2001-08-08 12:15:04 by didierv]
didierv
parents: 645
diff changeset
233 ((eq car 'define-derived-mode)
00c54252fe4f [xemacs-hg @ 2001-08-08 12:15:04 by didierv]
didierv
parents: 645
diff changeset
234 (cddr form))
00c54252fe4f [xemacs-hg @ 2001-08-08 12:15:04 by didierv]
didierv
parents: 645
diff changeset
235 (t
00c54252fe4f [xemacs-hg @ 2001-08-08 12:15:04 by didierv]
didierv
parents: 645
diff changeset
236 (cdr form))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 doc (car form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 (if (stringp doc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 (setq form (cdr form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 (setq doc nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 (list 'autoload (list 'quote name) file doc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 (or (eq car 'define-skeleton)
646
00c54252fe4f [xemacs-hg @ 2001-08-08 12:15:04 by didierv]
didierv
parents: 645
diff changeset
243 (eq car 'define-derived-mode)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 (eq (car-safe (car form)) 'interactive))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 (if macrop (list 'quote 'macro) nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
248 (defun make-c-autoload (module)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
249 "Make an autoload list for the DEFUN at point in MODULE.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
250 Returns nil if the DEFUN is malformed."
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
251 (and
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
252 ;; Match the DEFUN
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
253 (search-forward "DEFUN" nil t)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
254 ;; Match the opening parenthesis
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
255 (progn
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
256 (skip-syntax-forward " ")
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
257 (eq (char-after) ?\())
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
258 ;; Match the opening quote of the Lisp function name
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
259 (progn
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
260 (forward-char)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
261 (skip-syntax-forward " ")
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
262 (eq (char-after) ?\"))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
263 ;; Extract the Lisp function name, interactive indicator, and docstring
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
264 (let* ((func-name (let ((begin (progn (forward-char) (point))))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
265 (search-forward "\"" nil t)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
266 (backward-char)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
267 (intern (buffer-substring begin (point)))))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
268 (interact (progn
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
269 (search-forward "," nil t 4)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
270 (skip-syntax-forward " ")
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
271 (not (eq (char-after) ?0))))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
272 (begin (progn
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
273 (search-forward "/*" nil t)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
274 (forward-line 1)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
275 (point))))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
276 (search-forward "*/" nil t)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
277 (goto-char (match-beginning 0))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
278 (skip-chars-backward " \t\n\f")
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
279 (list 'autoload (list 'quote func-name) module
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
280 (buffer-substring begin (point)) interact nil))))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
281
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
282 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
283 ;; Generating autoloads for a single file
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 (defun generate-file-autoloads (file &optional funlist)
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
287 "Insert at point an autoload section for FILE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 autoloads are generated for defuns and defmacros in FILE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 marked by `generate-autoload-cookie' (which see).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 If FILE is being visited in a buffer, the contents of the buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 are used."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 (interactive "fGenerate autoloads for file: ")
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
293 (cond ((string-match "\\.el$" file)
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
294 (generate-autoload-ish-1
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
295 file
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
296 (replace-in-string (file-name-nondirectory file) "\\.elc?$" "")
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
297 nil #'generate-file-autoloads-1
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
298 funlist))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
299 ;; #### jj, are C++ modules possible?
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
300 ((string-match "\\.c$" file)
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
301 (generate-autoload-ish-1
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
302 file
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
303 (replace-in-string (file-name-nondirectory file) "\\.c$" "")
1302
781dc6d5baba [xemacs-hg @ 2003-02-15 00:31:58 by ben]
ben
parents: 1298
diff changeset
304 t #'generate-c-file-autoloads-1
781dc6d5baba [xemacs-hg @ 2003-02-15 00:31:58 by ben]
ben
parents: 1298
diff changeset
305 funlist))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
306 (t
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
307 (error 'wrong-type-argument file "not a C or Elisp source file"))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
309 (defun* generate-autoload-ish-1 (file load-name literal fun-to-call &rest args)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
310 "Insert at point an autoload-type section for FILE.
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
311 If LITERAL, open the file literally, without decoding.
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
312 Calls FUN-TO-CALL to compute the autoloads, passing it OUTBUF, LOAD-NAME,
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
313 TRIM-NAME, and ARGS."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 (let ((outbuf (current-buffer))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
315 (trim-name (autoload-trim-file-name file))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 (autoloads-done '())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 (print-length nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 (print-readably t) ; XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 (float-output-format nil)
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
320 (visited (get-file-buffer file))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 ;; (done-any nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 output-end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 ;; If the autoload section we create here uses an absolute
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 ;; pathname for FILE in its header, and then Emacs is installed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 ;; under a different path on another system,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 ;; `update-autoloads-here' won't be able to find the files to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 ;; autoloaded. So, if FILE is in the same directory or a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 ;; subdirectory of the current buffer's directory, we'll make it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 ;; relative to the current buffer's directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 (setq file (expand-file-name file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 (let ((find-file-hooks nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 (enable-local-variables nil))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
338 (set-buffer (or visited (find-file-noselect file literal literal
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
339 )))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
340 ;; This doesn't look right for C files, but it is. The only
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
341 ;; place we need the syntax table is when snarfing the Lisp
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
342 ;; function name.
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 442
diff changeset
343 (set-syntax-table emacs-lisp-mode-syntax-table))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
344 (unless (setq autoloads-done
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
345 (apply fun-to-call outbuf load-name trim-name args))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
346 (return-from generate-autoload-ish-1))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
347 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 (unless visited
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
349 ;; We created this buffer, so we should kill it.
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
350 (kill-buffer (current-buffer)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 (set-buffer outbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 (setq output-end (point-marker))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 (if t ;; done-any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 ;; XEmacs -- always do this so that we cache the information
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 ;; that we've processed the file already.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 (insert generate-autoload-section-header)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 (prin1 (list 'autoloads autoloads-done load-name trim-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 outbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 (terpri outbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 ;;;; (insert ";;; Generated autoloads from "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 ;;;; (autoload-trim-file-name file) "\n")
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
363 ;; Warn if we put a line in auto-autoloads.el
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 ;; that is long enough to cause trouble.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 (when (< output-end (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 (setq output-end (point-marker)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 (while (< (point) output-end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 ;; (let ((beg (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 (end-of-line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 ;; Emacs -- I still haven't figured this one out.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 ;; (if (> (- (point) beg) 900)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 ;; (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 ;; (message "A line is too long--over 900 characters")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 ;; (sleep-for 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 ;; (goto-char output-end)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 ;; )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 (forward-line 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 (goto-char output-end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 (insert generate-autoload-section-trailer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 (or noninteractive ; XEmacs: only need one line in -batch mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 (message "Generating autoloads for %s...done" file))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
383 (defun* generate-file-autoloads-1 (outbuf load-name trim-name funlist)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
384 "Insert at point an autoload section for FILE.
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
385 autoloads are generated for defuns and defmacros in FILE
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
386 marked by `generate-autoload-cookie' (which see).
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
387 If FILE is being visited in a buffer, the contents of the buffer
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
388 are used."
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
389 (let ((autoloads-done '())
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
390 (dofiles (not (null funlist)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
391 )
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
392
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
393 (save-excursion
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
394 (save-restriction
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
395 (widen)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
396 (goto-char (point-min))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
397 (unless (search-forward generate-autoload-cookie nil t)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
398 (message "No autoloads found in %s" trim-name)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
399 (return-from generate-file-autoloads-1 nil))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
400
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
401 (message "Generating autoloads for %s..." trim-name)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
402 (goto-char (point-min))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
403 (while (if dofiles funlist (not (eobp)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
404 (if (not dofiles)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
405 (skip-chars-forward " \t\n\f")
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
406 (goto-char (point-min))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
407 (re-search-forward
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
408 (concat "(def\\(un\\|var\\|const\\|macro\\) "
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
409 (regexp-quote (symbol-name (car funlist)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
410 "\\s "))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
411 (goto-char (match-beginning 0)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
412 (cond
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
413 ((or dofiles
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
414 (looking-at (regexp-quote generate-autoload-cookie)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
415 (if dofiles
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
416 nil
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
417 (search-forward generate-autoload-cookie)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
418 (skip-chars-forward " \t"))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
419 ;; (setq done-any t)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
420 (if (or dofiles (eolp))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
421 ;; Read the next form and make an autoload.
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
422 (let* ((form (prog1 (read (current-buffer))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
423 (or (bolp) (forward-line 1))))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
424 (autoload (make-autoload form load-name))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
425 (doc-string-elt (get (car-safe form)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
426 'doc-string-elt)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
427 (if autoload
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
428 (setq autoloads-done (cons (nth 1 form)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
429 autoloads-done))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
430 (setq autoload form))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
431 (print-autoload autoload doc-string-elt outbuf ""))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
432 ;; Copy the rest of the line to the output.
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
433 (let ((begin (point)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
434 ;; (terpri outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
435 (cond ((looking-at "immediate\\s *$") ; XEmacs
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
436 ;; This is here so that you can automatically
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
437 ;; have small hook functions copied to
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
438 ;; auto-autoloads.el so that it's not necessary
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
439 ;; to load a whole file just to get a two-line
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
440 ;; do-nothing find-file-hook... --Stig
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
441 (forward-line 1)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
442 (setq begin (point))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
443 (forward-sexp)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
444 (forward-line 1))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
445 (t
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
446 (forward-line 1)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
447 (princ (buffer-substring begin (point)) outbuf))))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
448 ((looking-at ";")
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
449 ;; Don't read the comment.
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
450 (forward-line 1))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
451 (t
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
452 (forward-sexp 1)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
453 (forward-line 1)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
454 (if dofiles
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
455 (setq funlist (cdr funlist))))))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
456 autoloads-done))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
457
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
458 (defun* generate-c-file-autoloads-1 (outbuf load-name trim-name funlist)
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
459 "Insert at point an autoload section for the C file FILE.
1048
edc95b5fe4cb [xemacs-hg @ 2002-10-11 14:09:46 by james]
james
parents: 996
diff changeset
460 autoloads are generated for defuns and defmacros in FILE
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
461 marked by `generate-c-autoload-cookie' (which see).
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
462 If FILE is being visited in a buffer, the contents of the buffer
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
463 are used."
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
464 (let ((exists-p-format
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
465 "(file-exists-p (expand-file-name \"%s.%s\" module-directory))")
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
466 (autoloads-done '())
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
467 )
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
468
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
469 (save-excursion
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
470 (save-restriction
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
471 (widen)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
472 (goto-char (point-min))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
473 ;; Is there a module name comment?
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
474 (when (search-forward generate-c-autoload-module nil t)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
475 (skip-chars-forward " \t")
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
476 (let ((begin (point)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
477 (skip-chars-forward "^ \t\n\f")
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
478 (setq load-name (buffer-substring begin (point)))))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
479 (if funlist
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
480 (progn
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
481 (message "Generating autoloads for %s..." trim-name)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
482 (princ "(when (or\n " outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
483 (princ (format exists-p-format load-name "ell") outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
484 (princ "\n " outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
485 (princ (format exists-p-format load-name "dll") outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
486 (princ "\n " outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
487 (princ (format exists-p-format load-name "so") outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
488 ;; close the princ'd `or' form
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
489 (princ ")\n " outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
490 (dolist (arg funlist)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
491 (goto-char (point-min))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
492 (re-search-forward
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
493 (concat "DEFUN (\""
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
494 (regexp-quote (symbol-name arg))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
495 "\""))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
496 (goto-char (match-beginning 0))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
497 (let ((autoload (make-c-autoload load-name)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
498 (when autoload
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
499 (push (nth 1 (nth 1 autoload)) autoloads-done)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
500 (print-autoload autoload 3 outbuf " "))))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
501 ;; close the princ'd `when' form
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
502 (princ ")" outbuf))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
503 (goto-char (point-min))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
504 (let ((match
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
505 (search-forward generate-c-autoload-cookie nil t)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
506 (unless match
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
507 (message "No autoloads found in %s" trim-name)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
508 (return-from generate-c-file-autoloads-1 nil))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
509
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
510 (message "Generating autoloads for %s..." trim-name)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
511 (princ "(when (or\n " outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
512 (princ (format exists-p-format load-name "ell") outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
513 (princ "\n " outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
514 (princ (format exists-p-format load-name "dll") outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
515 (princ "\n " outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
516 (princ (format exists-p-format load-name "so") outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
517 ;; close the princ'd `or' form
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
518 (princ ")\n " outbuf)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
519 (while match
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
520 (forward-line 1)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
521 (let ((autoload (make-c-autoload load-name)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
522 (when autoload
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
523 (push (nth 1 (nth 1 autoload)) autoloads-done)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
524 (print-autoload autoload 3 outbuf " ")))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
525 (setq match
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
526 (search-forward generate-c-autoload-cookie nil t)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
527 ;; close the princ'd `when' form
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
528 (princ ")" outbuf)))))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
529 autoloads-done))
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
530
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
531 ;; Assorted utilities for generating autoloads and pieces thereof
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
532
1048
edc95b5fe4cb [xemacs-hg @ 2002-10-11 14:09:46 by james]
james
parents: 996
diff changeset
533 (defun print-autoload (autoload doc-string-elt outbuf margin)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
534 "Print an autoload form, handling special characters.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
535 In particular, print docstrings with escapes inserted before left parentheses
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
536 at the beginning of lines and ^L characters."
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
537 (if (and doc-string-elt (stringp (nth doc-string-elt autoload)))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
538 ;; We need to hack the printing because the doc-string must be
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
539 ;; printed specially for make-docfile (sigh).
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
540 (let* ((p (nthcdr (1- doc-string-elt) autoload))
1048
edc95b5fe4cb [xemacs-hg @ 2002-10-11 14:09:46 by james]
james
parents: 996
diff changeset
541 (elt (cdr p))
edc95b5fe4cb [xemacs-hg @ 2002-10-11 14:09:46 by james]
james
parents: 996
diff changeset
542 (start-string (format "\n%s(" margin)))
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
543 (setcdr p nil)
1048
edc95b5fe4cb [xemacs-hg @ 2002-10-11 14:09:46 by james]
james
parents: 996
diff changeset
544 (princ start-string outbuf)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
545 ;; XEmacs change: don't let ^^L's get into
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
546 ;; the file or sorting is hard.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
547 (let ((print-escape-newlines t)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
548 (p (save-excursion
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
549 (set-buffer outbuf)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
550 (point)))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
551 p2)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
552 (mapcar #'(lambda (elt)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
553 (prin1 elt outbuf)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
554 (princ " " outbuf))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
555 autoload)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
556 (save-excursion
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
557 (set-buffer outbuf)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
558 (setq p2 (point-marker))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
559 (goto-char p)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
560 (save-match-data
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
561 (while (search-forward "\^L" p2 t)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
562 (delete-char -1)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
563 (insert "\\^L")))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
564 (goto-char p2)))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
565 (princ "\"\\\n" outbuf)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
566 (let ((begin (save-excursion
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
567 (set-buffer outbuf)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
568 (point))))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
569 (princ (substring (prin1-to-string (car elt)) 1) outbuf)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
570 ;; Insert a backslash before each ( that appears at the beginning
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
571 ;; of a line in the doc string.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
572 (save-excursion
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
573 (set-buffer outbuf)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
574 (save-excursion
1048
edc95b5fe4cb [xemacs-hg @ 2002-10-11 14:09:46 by james]
james
parents: 996
diff changeset
575 (while (search-backward start-string begin t)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
576 (forward-char 1)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
577 (insert "\\"))))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
578 (if (null (cdr elt))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
579 (princ ")" outbuf)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
580 (princ " " outbuf)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
581 (princ (substring (prin1-to-string (cdr elt)) 1) outbuf))
1048
edc95b5fe4cb [xemacs-hg @ 2002-10-11 14:09:46 by james]
james
parents: 996
diff changeset
582 (terpri outbuf)
edc95b5fe4cb [xemacs-hg @ 2002-10-11 14:09:46 by james]
james
parents: 996
diff changeset
583 (princ margin outbuf)))
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
584 ;; XEmacs change: another ^L hack
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
585 (let ((p (save-excursion
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
586 (set-buffer outbuf)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
587 (point)))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
588 (print-escape-newlines t)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
589 p2)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
590 (print autoload outbuf)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
591 (save-excursion
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
592 (set-buffer outbuf)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
593 (setq p2 (point-marker))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
594 (goto-char p)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
595 (save-match-data
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
596 (while (search-forward "\^L" p2 t)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
597 (delete-char -1)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
598 (insert "\\^L")))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
599 (goto-char p2)))))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
600
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
601 ;;; Forms which have doc-strings which should be printed specially.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
602 ;;; A doc-string-elt property of ELT says that (nth ELT FORM) is
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
603 ;;; the doc-string in FORM.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
604 ;;;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
605 ;;; defvar and defconst should be also be marked in this way. There is
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
606 ;;; no interference from make-docfile, which only processes those files
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
607 ;;; that are loaded into the dumped Emacs, and those files should
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
608 ;;; never have anything autoloaded here. Problems only occur with files
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
609 ;;; which have autoloaded entries *and* are processed by make-docfile;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
610 ;;; there should be no such files.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
612 (put 'autoload 'doc-string-elt 3)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
613 (put 'defun 'doc-string-elt 3)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
614 (put 'defun* 'doc-string-elt 3)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
615 (put 'defvar 'doc-string-elt 3)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
616 (put 'defconst 'doc-string-elt 3)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
617 (put 'defmacro 'doc-string-elt 3)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
618 (put 'defmacro* 'doc-string-elt 3)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
619 (put 'define-skeleton 'doc-string-elt 3)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
620 (put 'define-derived-mode 'doc-string-elt 4)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
621
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
622 (defun autoload-trim-file-name (file)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
623 "Returns relative pathname of FILE including the last directory.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
625 Hard-codes the directory separator as a forward slash."
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
626 (setq file (expand-file-name file))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
627 (replace-in-string
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
628 (file-relative-name file (file-name-directory
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
629 (directory-file-name
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
630 (file-name-directory file))))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
631 ;; #### is this a good idea?
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
632 "\\\\" "/"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 (defun update-file-autoloads (file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 "Update the autoloads for FILE in `generated-autoload-file'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 \(which FILE might bind in its local variables).
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
638 This function is a no-op for an autoloads file (ie, a file whose name is
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
639 equal to `autoload-file-name')."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 (interactive "fUpdate autoloads for file: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 (setq file (expand-file-name file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 (when (and (file-newer-than-file-p file generated-autoload-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 (not (member (file-name-nondirectory file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 (list autoload-file-name))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 (let ((load-name (replace-in-string (file-name-nondirectory file)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
647 "\\.\\(elc?\\|c\\)$"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 ""))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 (trim-name (autoload-trim-file-name file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 section-begin form)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 (let ((find-file-hooks nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 (set-buffer (or (get-file-buffer generated-autoload-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 (find-file-noselect generated-autoload-file))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 ;; Make sure we can scribble in it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 (setq buffer-read-only nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 ;; First delete all sections for this file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 (while (search-forward generate-autoload-section-header nil t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 (setq section-begin (match-beginning 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 (setq form (read (current-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 (when (string= (nth 2 form) load-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 (search-forward generate-autoload-section-trailer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 (delete-region section-begin (point))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 ;; Now find insertion point for new section
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 (block find-insertion-point
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 (while (search-forward generate-autoload-section-header nil t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 (setq form (read (current-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 (when (string< trim-name (nth 3 form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 ;; Found alphabetically correct insertion point
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 (goto-char (match-beginning 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 (return-from find-insertion-point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 (search-forward generate-autoload-section-trailer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 (when (eq (point) (point-min)) ; No existing entries?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 (goto-char (point-max)))) ; Append.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 ;; Add in new sections for file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 (generate-file-autoloads file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 (when (interactive-p) (save-buffer)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 (defun update-autoloads-here ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 "Update sections of the current buffer generated by `update-file-autoloads'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 (let ((generated-autoload-file (buffer-file-name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 (while (search-forward generate-autoload-section-header nil t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 (let* ((form (condition-case ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 (read (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 (end-of-file nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 (file (nth 3 form)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 ;; XEmacs change: if we can't find the file as specified, look
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 ;; around a bit more.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 (cond ((and (stringp file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 (or (get-file-buffer file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 (file-exists-p file))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 ((and (stringp file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 (save-match-data
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 (let ((loc (locate-file (file-name-nondirectory file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 load-path)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 (if (null loc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 (setq loc (expand-file-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 (autoload-trim-file-name loc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 ".."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 (if (or (get-file-buffer loc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 (file-exists-p loc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 (setq file loc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 nil))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 (setq file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 (if (y-or-n-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 (format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 "Can't find library `%s'; remove its autoloads? "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 (nth 2 form) file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 (condition-case ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 (read-file-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 (format "Find `%s' load file: "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 (nth 2 form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 nil nil t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 (quit nil))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 (if file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 (let ((begin (match-beginning 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 (search-forward generate-autoload-section-trailer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 (delete-region begin (point))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 (if (stringp file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 (generate-file-autoloads file)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
734 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
735 ;; Utilities for batch updates
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
736
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
737 ;;;###autoload
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
738 (defun autoload-update-directory-autoloads ()
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
739 "Update the autoloads for a directory, using a specified feature prefix.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
740 Must be used only with -batch. The feature prefix and directory to update
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
741 are taken from the first and second elements of `command-line-args-left',
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
742 respectively, and they are then removed from `command-line-args-left'.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
743
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
744 Runs `update-file-autoloads' on each file in the given directory. Always
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
745 rewrites the autoloads file, even if unchanged. Makes a feature name by
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
746 applying `autoload-make-feature-name' to the specified feature prefix.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
747
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
748 #### The API and semantics of this function are subject to change."
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
749 (unless noninteractive
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
750 (error "autoload-batch-update-autoloads: may be used only with -batch"))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
751 (let* ((autoload-feature-prefix (car command-line-args-left))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
752 (dir (cadr command-line-args-left))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
753 (generated-autoload-file (expand-file-name autoload-file-name dir)))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
754 (update-autoload-files (list dir) t t)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
755 (setq command-line-args-left (cddr command-line-args-left))))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
756
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
757 ;;;###autoload
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
758 (defun update-autoload-files (files-or-dirs &optional all-into-one-file force)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
759 "Update all the autoload files associated with FILES-OR-DIRS.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
760 FILES-OR-DIRS is a list of files and/or directories to be processed.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
761
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
762 An appropriate autoload file is chosen and a feature constructed for
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
763 each element of FILES-OR-DIRS. Fixup code testing for the autoload file's
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
764 feature and to provide the feature is added.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
765
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
766 If optional ALL-INTO-ONE-FILE is non-`nil', `generated-autoload-file'
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
767 should be set to the name of an autoload file and all autoloads will be
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
768 placed in that file. `autoload-feature-prefix' should be set to an
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
769 appropriate prefix which will be concatenated with \"-autoloads\" to
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
770 produce the feature name. Otherwise the appropriate autoload file for
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
771 each file or directory (located in that directory, or in the directory of
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
772 the specified file) will be updated with the directory's or file's
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
773 autoloads and the protective forms will be added, and the files will be
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
774 saved. Use of the default here is unreliable, and therefore deprecated.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
775
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
776 Note that if some of FILES-OR-DIRS are directories, recursion goes only
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
777 one level deep.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
778
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
779 If FORCE is non-nil, always save out the autoload files even if unchanged."
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
780 (let ((defdir (directory-file-name default-directory))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
781 ;; value for all-into-one-file
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
782 (autoload-feature-name (autoload-make-feature-name))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
783 (enable-local-eval nil)) ; Don't query in batch mode.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
784 (dolist (arg files-or-dirs)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
785 (setq arg (expand-file-name arg defdir))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
786 (cond
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
787 ((file-directory-p arg)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
788 (message "Updating autoloads for directory %s..." arg)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
789 (update-autoloads-from-directory arg))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
790 ((file-exists-p arg)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
791 (update-file-autoloads arg))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
792 (t (error "No such file or directory: %s" arg)))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
793 (when (not all-into-one-file)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
794 (autoload-featurep-protect-autoloads
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
795 (autoload-make-feature-name
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
796 (file-name-nondirectory (directory-file-name arg))))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
797 (if force (set-buffer-modified-p
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
798 t (find-file-noselect generated-autoload-file)))))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
799 (when all-into-one-file
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
800 (autoload-featurep-protect-autoloads autoload-feature-name)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
801 (if force (set-buffer-modified-p
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
802 t (find-file-noselect generated-autoload-file))))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
803 (save-some-buffers t)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
804 ))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
805
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 (defun update-autoloads-from-directory (dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 "Update `generated-autoload-file' with all the current autoloads from DIR.
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
809 This runs `update-file-autoloads' on each .el and .c file in DIR.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
810 Obsolete autoload entries for files that no longer exist are deleted.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
811 Note that, if this function is called from `batch-update-directory',
528
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
812 `generated-autoload-file' was rebound in that function.
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
813
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
814 You don't really want to be calling this function. Try using
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
815 `update-autoload-files' instead."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 (interactive "DUpdate autoloads for directory: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 (setq dir (expand-file-name dir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 (let ((simple-dir (file-name-as-directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 (file-name-nondirectory
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
820 (directory-file-name dir))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 (enable-local-eval nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 (let ((find-file-hooks nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 (set-buffer (find-file-noselect generated-autoload-file)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 (while (search-forward generate-autoload-section-header nil t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 (let* ((begin (match-beginning 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 (form (condition-case ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 (read (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 (end-of-file nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 (file (nth 3 form)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 (when (and (stringp file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 (string= (file-name-directory file) simple-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 (not (file-exists-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 (expand-file-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 (file-name-nondirectory file) dir))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 ;; Remove the obsolete section.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 (search-forward generate-autoload-section-trailer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 (delete-region begin (point)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 ;; Update or create autoload sections for existing files.
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
841 (mapcar 'update-file-autoloads
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
842 (directory-files dir t "^[^=].*\\.\\(el\\|c\\)$"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 (unless noninteractive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 (save-buffer)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
846 (defun autoload-featurep-protect-autoloads (sym)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 (set-buffer (find-file-noselect generated-autoload-file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 (if (and (not (= (point-min) (point-max)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 (not (looking-at ";;; DO NOT MODIFY THIS FILE")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 (insert ";;; DO NOT MODIFY THIS FILE\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 (insert "(if (featurep '" sym ")")
1495
c3cf7db99b98 [xemacs-hg @ 2003-05-22 07:41:20 by stephent]
stephent
parents: 1302
diff changeset
855 (insert " (error \"Feature " sym " already loaded\"))\n")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 (goto-char (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 (insert "\n(provide '" sym ")\n")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
859 (defun autoload-make-feature-name (&optional prefix)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
860 "Generate the feature name to protect this auto-autoloads file from PREFIX.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
862 If PREFIX is nil, it defaults to the value of `autoload-feature-prefix' if
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
863 that is non-nil.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
864
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
865 The feature name must be globally unique for this version of XEmacs,
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
866 including packages.
528
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
867
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
868 For backward compatibility, if PREFIX and `autoload-feature-prefix' are both
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
869 `nil', PREFIX is computed as the last directory component of
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
870 `generated-autoload-file'. This is likely to result in non-uniqueness, so
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
871 do not use this feature."
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
872 (concat
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
873 (cond (prefix)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
874 (autoload-feature-prefix)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
875 ((stringp generated-autoload-file)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
876 (message "Warning: autoload computing feature prefix.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
877 You should specify it as an argument to `autoload-make-feature-name'.")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
878 (file-name-nondirectory
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
879 (directory-file-name
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
880 (file-name-directory generated-autoload-file))))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
881 (t (error 'invalid-argument
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
882 "Could not compute a feature name")))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
883 "-autoloads"))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
884
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
885 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
886 ;; Deprecated entry points
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
887
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
888 ;; A grep of the core and packages shows use of `batch-update-autoloads'
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
889 ;; by XEmacs.rules, pcomplete, eshell, oort-gnus; `batch-update-directory'
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
890 ;; by liece.
528
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
891
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
892 ;; #### these entry points below are a big mess, especially the
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
893 ;; first two. there don't seem to be very many packages that use the
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
894 ;; first one (the "all-into-one-file" variety), and do they actually
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
895 ;; rely on this functionality? --ben
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
896 ;; but XEmacs.rules does, though maybe it doesn't "rely" on it, and
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
897 ;; modules do now, and that relies on it. --sjt
528
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
898
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
899 ;;;###autoload
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
900 (defun batch-update-autoloads ()
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
901 "Update the autoloads for the files or directories on the command line.
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
902 Runs `update-file-autoloads' on files and `update-directory-autoloads'
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
903 on directories. Must be used only with -batch, and kills Emacs on completion.
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
904 Each file will be processed even if an error occurred previously.
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
905 For example, invoke `xemacs -batch -f batch-update-autoloads *.el'.
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
906 The directory to which the auto-autoloads.el file must be the first parameter
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
907 on the command line."
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
908 (unless noninteractive
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
909 (error "batch-update-autoloads is to be used only with -batch"))
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
910 (update-autoload-files command-line-args-left t)
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
911 (kill-emacs 0))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
912
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 (defun batch-update-directory ()
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
915 "Update the autoloads for the directories on the command line.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
916 Runs `update-file-autoloads' on each file in the given directory, and must
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
917 be used only with -batch.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
918
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
919 Uses and removes the first element of `command-line-args-left'."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 (unless noninteractive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 (error "batch-update-directory is to be used only with -batch"))
528
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
922 (update-autoload-files command-line-args-left)
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
923 ;; (kill-emacs 0)
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
924 (setq command-line-args-left nil))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
925
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
926 ;;;###autoload
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
927 (defun batch-update-one-directory ()
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
928 "Update the autoloads for a single directory on the command line.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
929 Runs `update-file-autoloads' on each file in the given directory, and must
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
930 be used only with -batch."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
931 (unless noninteractive
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
932 (error "batch-update-one-directory is to be used only with -batch"))
528
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
933 (let ((arg (car command-line-args-left)))
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
934 (setq command-line-args-left (cdr command-line-args-left))
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
935 (update-autoload-files (list arg))))
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
936
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
937 ;;;###autoload
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
938 (defun batch-force-update-one-directory ()
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
939 "Update the autoloads for a single directory on the command line.
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
940 Runs `update-file-autoloads' on each file in the given directory, and must
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
941 be used only with -batch. Always rewrites the autoloads file, even if
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
942 unchanged.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
943
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
944 Uses and removes the first element of `command-line-args-left'."
528
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
945 (unless noninteractive
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
946 (error "batch-force-update-directory is to be used only with -batch"))
528
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
947 (let ((arg (car command-line-args-left)))
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
948 (setq command-line-args-left (cdr command-line-args-left))
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 528
diff changeset
949 (update-autoload-files (list arg) nil t)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
950
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
951 ;; Declare obsolescence
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
952
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
953 (make-obsolete-variable 'autoload-target-directory
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
954 "Don't use this. Bind `generated-autoload-file' to an absolute path.")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
955 (make-obsolete 'batch-update-autoloads
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
956 'autoload-update-directory-autoloads)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
957 (make-obsolete 'batch-update-directory
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
958 'autoload-update-directory-autoloads)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
959 (make-obsolete 'batch-update-one-directory
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
960 'autoload-update-directory-autoloads)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
961 (make-obsolete 'batch-force-update-one-directory
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
962 'autoload-update-directory-autoloads)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
963
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 (provide 'autoload)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 ;;; autoload.el ends here