annotate lisp/autoload.el @ 4702:eb1a409c317b

Unbreak autoload.el 2009-09-28 Mike Sperber <mike@xemacs.org> * autoload.el (make-autoload): Only try to add arguments to documentation when the form actually allows it. * cl-macs.el (cl-function-arglist): Add autoload; used in autoload.el.
author Mike Sperber <sperber@deinprogramm.de>
date Mon, 28 Sep 2009 18:04:07 +0200
parents fee33ab25966
children e29fcfd8df5f
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
1753
588465af3ca1 [xemacs-hg @ 2003-10-15 09:19:08 by stephent]
stephent
parents: 1733
diff changeset
3 ;; Copyright (C) 1991-1994, 1997, 2003 Free Software Foundation, Inc.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
5 ;; Copyright (C) 1996, 2000, 2002, 2003, 2004 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
7 ;; Original Author: Roland McGrath <roland@gnu.ai.mit.edu>
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
8 ;; Heavily Modified: XEmacs Maintainers
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; Keywords: maint
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; 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
25 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;; 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
28 ;;; Synched up with: FSF 21.2 by Ben Wing.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
29 ;;; Note that update-file-autoloads is seriously modified and not really
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
30 ;;; syncable.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
34 ;; 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
35 ;; 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
36 ;; and "/* ###autoload */" in C source files) in various useful ways.
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
37 ;; It is also used to maintain custom-defines.el files, since most of
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
38 ;; the logic for computing them is the same as for auto-autoloads.el.
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
39
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
40 ;; Usage
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
41 ;; =====
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
42
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
43 ;; 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
44 ;; build process, is
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
45
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
46 ;; xemacs -no-packages -batch \
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
47 ;; -l autoload -f batch-update-directory-autoloads PREFIX DIRECTORY
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
48
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
49 ;; 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
50 ;; 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
51 ;; 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
52 ;; 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
53 ;; 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
54 ;; 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
55
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
56 ;; 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
57 ;; 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
58 ;; 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
59 ;; 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
60 ;; 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
61 ;; 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
62 ;; 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
63 ;; 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
64 ;; 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
65 ;; of XEmacs).
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 ;; The probable next step is to fix up the packages to use the
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
68 ;; `batch-update-directory-autoloads' API. However, for backward
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
69 ;; 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
70
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
71 ;; 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
72
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
73 ;; xemacs -vanilla -batch -eval "$(AUTOLOAD_PACKAGE_NAME)" \
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
74 ;; -l autoload -f batch-update-autoloads $(AUTOLOAD_PATH)
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
75
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
76 ;; is supported, and the implementation is unchanged. However,
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
77 ;; 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
78 ;; 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
79 ;; 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
80
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
81 ;; Implementation:
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
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
84 ;; #### 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
85 ;; (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
86 ;; 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
87 ;; this is a lot of guesswork.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
88
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
89 ;; 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
90 ;; packaged Lisp, and ELLs (dynamically loadable compiled objects
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
91 ;; providing Lisp functionality). There two general strategies for
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
92 ;; 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
93 ;; 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
94 ;; 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
95 ;; 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
96 ;; 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
97 ;; 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
98 ;; auto-autoloads files remain synchronized with the libraries.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
99
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
100 ;; 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
101 ;; 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
102 ;; `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
103 ;; 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
104 ;; 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
105 ;; 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
106 ;; 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
107
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
108 ;; 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
109 ;; 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
110 ;; 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
111 ;; 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
112 ;; 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
113 ;; `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
114 ;; 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
115 ;; 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
116 ;; 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
117 ;; 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
118 ;; function at collect time.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 ;; ChangeLog:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
122 ;; See ./ChangeLog.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
126 ;; Need to load easy-mmode because we expand macro calls to easy-mmode
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
127 ;; macros in make-autoloads below.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
128 (require 'easy-mmode)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
129
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
130 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
131 ;; Standard file and directory names
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
132
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
133 ;; `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
134 ;; 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
135 ;; know what you're doing.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
136
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
137 (defconst autoload-target-directory "../lisp/"
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
138 "Standard directory containing autoload declaration file.
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 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
141
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
142 ;; Dynamic variables for communication among functions
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
143
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
144 ;; FSF 21.2:
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
145 ;; The autoload file is assumed to contain a trailer starting with a FormFeed
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
146 ;; character.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
147
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
148 (defvar generated-autoload-file
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
149 (expand-file-name autoload-file-name lisp-directory)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
150 "*File `update-file-autoloads' puts autoloads into.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
151 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
152 autoloads go somewhere else.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
153
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
154 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
155 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
156 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
157
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
158 (defvar generate-autoload-function
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
159 #'generate-file-autoloads
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
160 "Function to generate the autoloads for a file and insert at point.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
161 Called with one argument, the file.")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
162
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
163 (define-obsolete-variable-alias 'autoload-package-name
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
164 'autoload-feature-prefix)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
165 (defvar autoload-feature-prefix nil
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
166 "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
167
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
168 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
169 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
170 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
171 argument to `autoload-make-feature-name' (q.v.).")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
172
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
173 (defvar autoload-feature-suffix "-autoloads"
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
174 "String added to `autoload-feature-prefix' to create the autoload feature name.")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
175
1232
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 ;; Magic strings in source files
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
178
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
179 (defconst generate-autoload-cookie ";;;###autoload"
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
180 "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
181 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
182 meaningless to Lisp (e.g., a comment).
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
183
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
184 This string is used:
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 ;;;###autoload
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
187 \(defun function-to-be-autoloaded () ...)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
188
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
189 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
190 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
191 \"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
192 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
193 copied verbatim to `generated-autoload-file'.")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
194
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
195 (defconst generate-c-autoload-cookie "/* ###autoload"
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
196 "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
197 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
198 meaningless to C (e.g., a comment).
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 This string is used:
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
201
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
202 /* ###autoload */
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
203 DEFUN (\"function-to-be-autoloaded\", ... )
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
204
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
205 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
206 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
207 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
208
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
209 (defconst generate-c-autoload-module "/* ###module"
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
210 "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
211 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
212 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
213 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
214
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
215 (defconst generate-autoload-section-header "\f\n;;;### "
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
216 "String inserted before the form identifying
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
217 the section of autoloads for a file.")
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
218
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
219 (defconst generate-autoload-section-trailer "\n;;;***\n"
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
220 "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
221
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
222 (defconst generate-autoload-section-continuation ";;;;;; "
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
223 "String to add on each continuation of the section header form.")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
224
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
225 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
226 ;; Parsing the source file text.
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
227 ;; Autoloads in C source differ from those in Lisp source.
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
228
4425
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
229 ; Add operator definitions to autoload-operators.el in the xemacs-base
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
230 ; package.
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
231 (ignore-errors (require 'autoload-operators))
4352
d2f4dd8611d9 Factor out lists of operators specially treated by 'make-autoload'.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4332
diff changeset
232
4425
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
233 ; As autoload-operators is new, provide stopgap measure for a while.
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
234 (if (not (boundp 'autoload-make-autoload-operators))
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
235 (progn
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
236 (defvar autoload-make-autoload-operators
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
237 '(defun define-skeleton defmacro define-derived-mode define-generic-mode
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
238 easy-mmode-define-minor-mode easy-mmode-define-global-mode
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
239 define-minor-mode defun* defmacro*)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
240 "`defun'-like operators that use `autoload' to load the library.")
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
241
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
242 (defvar autoload-make-autoload-complex-operators
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
243 '(easy-mmode-define-minor-mode easy-mmode-define-global-mode
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
244 define-minor-mode)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
245 "`defun'-like operators to macroexpand before using `autoload'.")
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
246
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
247 (put 'autoload 'doc-string-elt 3)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
248 (put 'defun 'doc-string-elt 3)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
249 (put 'defun* 'doc-string-elt 3)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
250 (put 'defvar 'doc-string-elt 3)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
251 (put 'defcustom 'doc-string-elt 3)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
252 (put 'defconst 'doc-string-elt 3)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
253 (put 'defmacro 'doc-string-elt 3)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
254 (put 'defmacro* 'doc-string-elt 3)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
255 (put 'defsubst 'doc-string-elt 3)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
256 (put 'define-skeleton 'doc-string-elt 2)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
257 (put 'define-derived-mode 'doc-string-elt 4)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
258 (put 'easy-mmode-define-minor-mode 'doc-string-elt 2)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
259 (put 'define-minor-mode 'doc-string-elt 2)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
260 (put 'define-generic-mode 'doc-string-elt 7)
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
261 ;; defin-global-mode has no explicit docstring.
bfb8a26de3cb Move autoload operator definitions to xemacs-base.
Mike Sperber <sperber@deinprogramm.de>
parents: 4352
diff changeset
262 (put 'easy-mmode-define-global-mode 'doc-string-elt 1000)))
4352
d2f4dd8611d9 Factor out lists of operators specially treated by 'make-autoload'.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4332
diff changeset
263
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 (defun make-autoload (form file)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
265 "Turn FORM into an autoload or defvar for source file FILE.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
266 Returns nil if FORM is not a special autoload form (i.e. a function definition
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
267 or macro definition or a defcustom)."
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
268 (let ((car (car-safe form)) expand)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
269 (cond
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
270 ;; For complex cases, try again on the macro-expansion.
4352
d2f4dd8611d9 Factor out lists of operators specially treated by 'make-autoload'.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4332
diff changeset
271 ((and (memq car autoload-make-autoload-complex-operators)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
272 (setq expand (let ((load-file-name file)) (macroexpand form)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
273 (eq (car expand) 'progn)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
274 (memq :autoload-end expand))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
275 (let ((end (memq :autoload-end expand)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
276 ;; Cut-off anything after the :autoload-end marker.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
277 (setcdr end nil)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
278 (cons 'progn
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
279 (mapcar (lambda (form) (make-autoload form file))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
280 (cdr expand)))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
281
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
282 ;; For special function-like operators, use the `autoload' function.
4352
d2f4dd8611d9 Factor out lists of operators specially treated by 'make-autoload'.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4332
diff changeset
283 ((memq car autoload-make-autoload-operators)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
284 (let* ((macrop (memq car '(defmacro defmacro*)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
285 (name (nth 1 form))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
286 (body (nthcdr (get car 'doc-string-elt) form))
4702
eb1a409c317b Unbreak autoload.el
Mike Sperber <sperber@deinprogramm.de>
parents: 4695
diff changeset
287 (doc (if (stringp (car body)) (pop body))))
eb1a409c317b Unbreak autoload.el
Mike Sperber <sperber@deinprogramm.de>
parents: 4695
diff changeset
288 (if (memq car '(defmacro defmacro* defun defun*))
eb1a409c317b Unbreak autoload.el
Mike Sperber <sperber@deinprogramm.de>
parents: 4695
diff changeset
289 (let ((arglist (nth 2 form))
eb1a409c317b Unbreak autoload.el
Mike Sperber <sperber@deinprogramm.de>
parents: 4695
diff changeset
290 (placeholder (eval-when-compile (gensym))))
eb1a409c317b Unbreak autoload.el
Mike Sperber <sperber@deinprogramm.de>
parents: 4695
diff changeset
291 (setq doc (concat (or doc "")
eb1a409c317b Unbreak autoload.el
Mike Sperber <sperber@deinprogramm.de>
parents: 4695
diff changeset
292 "\n\narguments: "
eb1a409c317b Unbreak autoload.el
Mike Sperber <sperber@deinprogramm.de>
parents: 4695
diff changeset
293 (replace-in-string
eb1a409c317b Unbreak autoload.el
Mike Sperber <sperber@deinprogramm.de>
parents: 4695
diff changeset
294 (cl-function-arglist placeholder arglist)
eb1a409c317b Unbreak autoload.el
Mike Sperber <sperber@deinprogramm.de>
parents: 4695
diff changeset
295 (format "^(%s ?" placeholder)
eb1a409c317b Unbreak autoload.el
Mike Sperber <sperber@deinprogramm.de>
parents: 4695
diff changeset
296 "(") "\n"))))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
297 ;; `define-generic-mode' quotes the name, so take care of that
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
298 (list 'autoload (if (listp name) name (list 'quote name)) file doc
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
299 (or (and (memq car '(define-skeleton define-derived-mode
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
300 define-generic-mode
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
301 easy-mmode-define-global-mode
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
302 easy-mmode-define-minor-mode
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
303 define-minor-mode)) t)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
304 (eq (car-safe (car body)) 'interactive))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
305 (if macrop (list 'quote 'macro) nil))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
306
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
307 ;; Convert defcustom to a simpler (and less space-consuming) defvar,
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
308 ;; but add some extra stuff if it uses :require.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
309 ((eq car 'defcustom)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
310 (let ((varname (car-safe (cdr-safe form)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
311 (init (car-safe (cdr-safe (cdr-safe form))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
312 (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form)))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
313 (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form))))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
314 (if (not (plist-get rest :require))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
315 `(defvar ,varname ,init ,doc)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
316 `(progn
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
317 (defvar ,varname ,init ,doc)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
318 (custom-add-to-group ,(plist-get rest :group)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
319 ',varname 'custom-variable)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
320 (custom-add-load ',varname
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
321 ,(plist-get rest :require))))))
4303
cee827542370 [xemacs-hg @ 2007-12-04 20:18:33 by aidan]
aidan
parents: 4256
diff changeset
322 ;; Coding systems. #### Would be nice to handle the docstring here too.
cee827542370 [xemacs-hg @ 2007-12-04 20:18:33 by aidan]
aidan
parents: 4256
diff changeset
323 ((memq car '(make-coding-system make-8-bit-coding-system))
cee827542370 [xemacs-hg @ 2007-12-04 20:18:33 by aidan]
aidan
parents: 4256
diff changeset
324 `(autoload-coding-system ,(nth 1 form) '(load ,file)))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
325 ;; nil here indicates that this is not a special autoload form.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
326 (t nil))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
328 (defun make-c-autoload (module)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
329 "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
330 Returns nil if the DEFUN is malformed."
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
331 (and
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
332 ;; Match the DEFUN
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
333 (search-forward "DEFUN" nil t)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
334 ;; Match the opening parenthesis
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
335 (progn
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
336 (skip-syntax-forward " ")
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
337 (eq (char-after) ?\())
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
338 ;; 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
339 (progn
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
340 (forward-char)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
341 (skip-syntax-forward " ")
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
342 (eq (char-after) ?\"))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
343 ;; 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
344 (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
345 (search-forward "\"" nil t)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
346 (backward-char)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
347 (intern (buffer-substring begin (point)))))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
348 (interact (progn
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
349 (search-forward "," nil t 4)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
350 (skip-syntax-forward " ")
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
351 (not (eq (char-after) ?0))))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
352 (begin (progn
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
353 (search-forward "/*" nil t)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
354 (forward-line 1)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
355 (point))))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
356 (search-forward "*/" nil t)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
357 (goto-char (match-beginning 0))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
358 (skip-chars-backward " \t\n\f")
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
359 (list 'autoload (list 'quote func-name) module
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
360 (buffer-substring begin (point)) interact nil))))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
361
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
362 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
363 ;; Generating autoloads for a single file
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 ;;;###autoload
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
366 (defun generate-file-autoloads (file)
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
367 "Insert at point an autoload section for FILE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 autoloads are generated for defuns and defmacros in FILE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 marked by `generate-autoload-cookie' (which see).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 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
371 are used."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 (interactive "fGenerate autoloads for file: ")
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
373 (cond ((string-match "\\.el$" file)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
374 (generate-autoload-type-section
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
375 file
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
376 (replace-in-string (file-name-nondirectory file) "\\.elc?$" "")
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
377 nil #'generate-lisp-file-autoloads-1))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
378 ;; #### jj, are C++ modules possible?
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
379 ((string-match "\\.c$" file)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
380 (generate-autoload-type-section
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
381 file
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
382 (replace-in-string (file-name-nondirectory file) "\\.c$" "")
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
383 t #'generate-c-file-autoloads-1))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
384 (t
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
385 (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
386
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
387 (defun* generate-autoload-type-section (file load-name literal fun-to-call)
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
388 "Insert at point an autoload-type section for FILE.
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
389 LOAD-NAME is the non-directory portion of the name, with the final .el, .elc
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
390 or .c section removed. If LITERAL, open the file literally, without decoding.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
391 Calls FUN-TO-CALL to compute the autoloads, with the loaded file in the
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
392 current buffer, passing it OUTBUF (where to write the autoloads), LOAD-NAME,
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
393 and TRIM-NAME (result of calling `autoload-trim-file-name' on FILE)."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 (let ((outbuf (current-buffer))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
395 (trim-name (autoload-trim-file-name file))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 (autoloads-done '())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 (print-length nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 (print-readably t) ; XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 (float-output-format nil)
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
400 (visited (get-file-buffer file))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
401 suppress-form
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 ;; (done-any nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 output-end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 ;; If the autoload section we create here uses an absolute
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 ;; pathname for FILE in its header, and then Emacs is installed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 ;; under a different path on another system,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 ;; `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
409 ;; autoloaded. So, if FILE is in the same directory or a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 ;; subdirectory of the current buffer's directory, we'll make it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 ;; relative to the current buffer's directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 (setq file (expand-file-name file))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
413 ;; #### FSF 21.2. Do we want this?
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
414 ; (let* ((source-truename (file-truename file))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
415 ; (dir-truename (file-name-as-directory
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
416 ; (file-truename default-directory)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
417 ; (len (length dir-truename)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
418 ; (if (and (< len (length source-truename))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
419 ; (string= dir-truename (substring source-truename 0 len)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
420 ; (setq file (substring source-truename len))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
421
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
422 ;; Check for suppression form (XEmacs)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
423 (let* ((dir (file-name-directory file))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
424 (_pkg (expand-file-name "_pkg.el" dir))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
425 (pkg-vis (get-file-buffer _pkg))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
426 pkg-buf)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
427 (save-excursion
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
428 (when (file-readable-p _pkg)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
429 (unwind-protect
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
430 (progn
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
431 (let ((find-file-hooks nil)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
432 (enable-local-variables nil))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
433 (set-buffer (or pkg-vis (find-file-noselect _pkg)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
434 (set-syntax-table emacs-lisp-mode-syntax-table))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
435 (save-excursion
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
436 (save-restriction
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
437 (widen)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
438 (goto-char (point-min))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
439 (block nil
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
440 (while (search-forward "(package-suppress" nil t)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
441 ;; skip over package-name
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
442 (forward-sexp 1)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
443 (let ((supfile (read (current-buffer))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
444 (when (equal supfile load-name)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
445 (setq suppress-form (eval (read (current-buffer))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
446 (return))))))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
447 (unless pkg-vis
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
448 ;; We created this buffer, so we should kill it.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
449 (if pkg-buf (kill-buffer pkg-buf)))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 (progn
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
454 (let (;(find-file-hooks nil)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
455 ;(enable-local-variables nil)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
456 )
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
457 (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
458 )))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
459 ;; 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
460 ;; 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
461 ;; function name.
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 442
diff changeset
462 (set-syntax-table emacs-lisp-mode-syntax-table))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
463 ; (if visited
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
464 ; (set-buffer visited)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
465 ; ;; It is faster to avoid visiting the file.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
466 ; (set-buffer (get-buffer-create " *generate-autoload-file*"))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
467 ; (kill-all-local-variables)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
468 ; (erase-buffer)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
469 ; (setq buffer-undo-list t
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
470 ; buffer-read-only nil)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
471 ; ;; This doesn't look right for C files, but it is. The only
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
472 ; ;; place we need the syntax table is when snarfing the Lisp
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
473 ; ;; function name.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
474 ; (emacs-lisp-mode)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
475 ; (if literal
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
476 ; (insert-file-contents-literally file nil)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
477 ; (insert-file-contents file nil)))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
478 (unless (setq autoloads-done
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
479 (funcall fun-to-call outbuf load-name trim-name))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
480 (return-from generate-autoload-type-section))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
481 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 (unless visited
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
483 ;; 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
484 (kill-buffer (current-buffer)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 (set-buffer outbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 (setq output-end (point-marker))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 (if t ;; done-any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 ;; XEmacs -- always do this so that we cache the information
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 ;; that we've processed the file already.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 (progn
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
491 ;; Insert the section-header line
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
492 ;; which lists the file name and which functions are in it, etc.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 (insert generate-autoload-section-header)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
494 (prin1 (list 'autoloads autoloads-done load-name trim-name
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
495 ;; In FSF 21.2. Also in FSF 19.30. Presumably
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
496 ;; deleted from XEmacs.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
497 ;; (nth 5 (file-attributes file))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
498 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 outbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 (terpri outbuf)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
501 ;; #### Alas, we will have to think about this. Adding this means
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
502 ;; that, once we have created or maintained an auto-autoloads file,
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
503 ;; we alone and our successors can update the file. The file itself
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
504 ;; will work fine in older XEmacsen, but they won't be able to
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
505 ;; update autoloads -- hence, to build.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
506 ; ;; Break that line at spaces, to avoid very long lines.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
507 ; ;; Make each sub-line into a comment.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
508 ; (with-current-buffer outbuf
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
509 ; (save-excursion
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
510 ; (forward-line -1)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
511 ; (while (not (eolp))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
512 ; (move-to-column 64)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
513 ; (skip-chars-forward "^ \n")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
514 ; (or (eolp)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
515 ; (insert "\n" generate-autoload-section-continuation)))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
516 ;; XEmacs: This was commented out before. #### Correct?
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
517 ; (insert ";;; Generated autoloads from "
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
518 ; (autoload-trim-file-name file) "\n")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
519 ;; XEmacs -- handle suppression
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
520 (when suppress-form
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
521 (insert "\n;;; Suppress form from _pkg.el\n")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
522 (insert "(unless " (prin1-to-string suppress-form) "\n\n"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 (goto-char output-end)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
524 ;; XEmacs -- handle suppression
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
525 (when suppress-form
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
526 (insert "\n) ;; unless (suppressed)\n"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 (insert generate-autoload-section-trailer)))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
528 ))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
529
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
531 (defun process-one-lisp-autoload (autoloads-done outbuf load-name)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
532 "Process a single autoload at point and write to OUTBUF.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
533 Point should be just after a magic cookie string (e.g. ;;;###autoload).
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
534 Updates AUTOLOADS-DONE and returns the new value."
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
535 (skip-chars-forward " \t")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
536 ;; (setq done-any t)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
537 (if (eolp)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
538 ;; Read the next form and make an autoload.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
539 (let* ((form (prog1 (read (current-buffer))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
540 (or (bolp) (forward-line 1))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
541 (autoload (make-autoload form load-name)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
542 (if autoload
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
543 (setq autoloads-done (cons (nth 1 form)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
544 autoloads-done))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
545 (setq autoload form))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
546 (autoload-print-form autoload outbuf ""))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
547 ;; Copy the rest of the line to the output.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
548 (cond ((looking-at "immediate\\s *$") ; XEmacs
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
549 ;; This is here so that you can automatically
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
550 ;; have small hook functions copied to
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
551 ;; auto-autoloads.el so that it's not necessary
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
552 ;; to load a whole file just to get a two-line
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
553 ;; do-nothing find-file-hook... --Stig
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
554 (forward-line 1)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
555 (let ((begin (point)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
556 (forward-sexp)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
557 (forward-line 1)
4332
6ad202d453cb Insert <immediate> into section header for immediate autoloads.
Mike Sperber <sperber@deinprogramm.de>
parents: 4303
diff changeset
558 (princ (buffer-substring begin (point)) outbuf))
6ad202d453cb Insert <immediate> into section header for immediate autoloads.
Mike Sperber <sperber@deinprogramm.de>
parents: 4303
diff changeset
559 (setq autoloads-done (cons '<immediate> autoloads-done)))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
560 (t
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
561 (princ (buffer-substring
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
562 (progn
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
563 ;; Back up over whitespace, to preserve it.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
564 (skip-chars-backward " \f\t")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
565 (if (= (char-after (1+ (point))) ? )
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
566 ;; Eat one space.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
567 (forward-char 1))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
568 (point))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
569 (progn (forward-line 1) (point)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
570 outbuf))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
571 autoloads-done)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
572
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
573 (defun* generate-lisp-file-autoloads-1 (outbuf load-name trim-name)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
574 "Insert at point in OUTBUF an autoload section for an Elisp file.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
575 The file is assumed to be already loaded and in the current buffer.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
576 autoloads are generated for defuns and defmacros marked by
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
577 `generate-autoload-cookie' (which see)."
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
578 (let ((autoloads-done '())
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
579 )
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
580 (save-excursion
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
581 (save-restriction
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
582 (widen)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
583 (goto-char (point-min))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
584 (unless (search-forward generate-autoload-cookie nil t)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
585 (message "No autoloads found in %s" trim-name)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
586 (return-from generate-lisp-file-autoloads-1 nil))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
587
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
588 (message "Generating autoloads for %s..." trim-name)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
589 (goto-char (point-min))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
590 (while (not (eobp))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
591 (skip-chars-forward " \t\n\f")
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
592 (cond
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
593 ((looking-at (regexp-quote generate-autoload-cookie))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
594 (search-forward generate-autoload-cookie)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
595 (setq autoloads-done
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
596 (process-one-lisp-autoload autoloads-done outbuf load-name)))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
597 ((looking-at ";")
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
598 ;; Don't read the comment.
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
599 (forward-line 1))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
600 (t
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
601 (forward-sexp 1)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
602 (forward-line 1)))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
603 )))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
604 (or noninteractive ; XEmacs: only need one line in -batch mode.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
605 (message "Generating autoloads for %s...done" trim-name))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
606 autoloads-done))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
607
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
608 (defun* generate-c-file-autoloads-1 (outbuf load-name trim-name
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
609 &optional funlist)
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
610 "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
611 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
612 marked by `generate-c-autoload-cookie' (which see).
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
613 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
614 are used."
1733
5903b079bee1 [xemacs-hg @ 2003-10-07 21:52:12 by james]
james
parents: 1495
diff changeset
615 (let ((exists-p-format
5903b079bee1 [xemacs-hg @ 2003-10-07 21:52:12 by james]
james
parents: 1495
diff changeset
616 "(when (locate-file \"%s\" module-load-path module-extensions)\n")
5903b079bee1 [xemacs-hg @ 2003-10-07 21:52:12 by james]
james
parents: 1495
diff changeset
617 autoloads-done)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
618 (save-excursion
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
619 (save-restriction
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
620 (widen)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
621 (goto-char (point-min))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
622 ;; Is there a module name comment?
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
623 (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
624 (skip-chars-forward " \t")
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
625 (let ((begin (point)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
626 (skip-chars-forward "^ \t\n\f")
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
627 (setq load-name (buffer-substring begin (point)))))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
628 (if funlist
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
629 (progn
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
630 (message "Generating autoloads for %s..." trim-name)
1733
5903b079bee1 [xemacs-hg @ 2003-10-07 21:52:12 by james]
james
parents: 1495
diff changeset
631 (princ (format exists-p-format load-name) outbuf)
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
632 (dolist (arg funlist)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
633 (goto-char (point-min))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
634 (re-search-forward
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
635 (concat "DEFUN (\""
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
636 (regexp-quote (symbol-name arg))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
637 "\""))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
638 (goto-char (match-beginning 0))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
639 (let ((autoload (make-c-autoload load-name)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
640 (when autoload
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
641 (push (nth 1 (nth 1 autoload)) autoloads-done)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
642 (autoload-print-form autoload outbuf " "))))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
643 ;; close the princ'd `when' form
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
644 (princ ")" outbuf))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
645 (goto-char (point-min))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
646 (let ((match
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
647 (search-forward generate-c-autoload-cookie nil t)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
648 (unless match
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
649 (message "No autoloads found in %s" trim-name)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
650 (return-from generate-c-file-autoloads-1 nil))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
651
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
652 (message "Generating autoloads for %s..." trim-name)
1733
5903b079bee1 [xemacs-hg @ 2003-10-07 21:52:12 by james]
james
parents: 1495
diff changeset
653 (princ (format exists-p-format load-name) outbuf)
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
654 (while match
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
655 (forward-line 1)
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
656 (let ((autoload (make-c-autoload load-name)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
657 (when autoload
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
658 (push (nth 1 (nth 1 autoload)) autoloads-done)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
659 (autoload-print-form autoload outbuf " ")))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
660 (setq match
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
661 (search-forward generate-c-autoload-cookie nil t)))
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
662 ;; close the princ'd `when' form
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
663 (princ ")" outbuf)))))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
664 (or noninteractive ; XEmacs: only need one line in -batch mode.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
665 (message "Generating autoloads for %s...done" trim-name))
1298
1b4bc72f433e [xemacs-hg @ 2003-02-14 12:05:06 by ben]
ben
parents: 1232
diff changeset
666 autoloads-done))
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
667
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
668 ;;;###autoload
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
669 (defun generate-custom-defines (file)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
670 "Insert at point a custom-define section for FILE.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
671 If FILE is being visited in a buffer, the contents of the buffer
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
672 are used."
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
673 (interactive "fGenerate custom defines for file: ")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
674 (cond ((string-match "\\.el$" file)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
675 (generate-autoload-type-section
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
676 file
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
677 (replace-in-string (file-name-nondirectory file) "\\.elc?$" "")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
678 nil #'generate-custom-defines-1))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
679 ((string-match "\\.c$" file)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
680 ;; no way to generate custom-defines for C files (currently?),
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
681 ;; but cannot signal an error.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
682 nil)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
683 (t
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
684 (error 'wrong-type-argument file "not a C or Elisp source file"))))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
685
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
686 (defun* generate-custom-defines-1 (outbuf load-name trim-name)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
687 "Insert at point in OUTBUF a custom-define section for an Elisp file.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
688 This contains all defcustoms and defgroups in the file.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
689 The file is assumed to be already loaded and in the current buffer."
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
690 (let* ((search-regexp-1 "^(\\(defcustom\\|defgroup\\) ")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
691 (search-string-2 ";;;###custom-define")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
692 (search-regexp-2 (regexp-quote search-string-2))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
693 (autoloads-done '()))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
694 (save-excursion
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
695 (save-restriction
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
696 (widen)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
697 (goto-char (point-min))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
698 (unless (or (re-search-forward search-regexp-1 nil t)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
699 (re-search-forward search-regexp-2 nil t))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
700 (message "No custom defines found in %s" trim-name)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
701 (return-from generate-custom-defines-1 nil))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
702 (message "Generating custom defines for %s..." trim-name)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
703 (princ "(defconst custom-define-current-source-file " outbuf)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
704 (prin1 (file-relative-name (buffer-file-name)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
705 (symbol-value-in-buffer 'default-directory
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
706 outbuf)) outbuf)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
707 (princ ")\n" outbuf)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
708
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
709 (goto-char (point-min))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
710 (while (not (eobp))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
711 (skip-chars-forward " \t\n\f")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
712 (cond
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
713 ((looking-at search-regexp-1)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
714 ;; Read the next form and copy it to make an autoload.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
715 (let* ((form (prog1 (read (current-buffer))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
716 (or (bolp) (forward-line 1))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
717 (autoload form ;(make-autoload form load-name)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
718 ))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
719 (if autoload
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
720 (setq autoloads-done (cons (nth 1 form)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
721 autoloads-done))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
722 (setq autoload form))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
723 (autoload-print-form autoload outbuf ""))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
724 )
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
725 ((looking-at search-regexp-2)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
726 (search-forward search-string-2)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
727 (beep)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
728 (setq autoloads-done
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
729 (process-one-lisp-autoload autoloads-done outbuf load-name)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
730 ((looking-at ";")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
731 ;; Don't read the comment.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
732 (forward-line 1))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
733 (t
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
734 (forward-sexp 1)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
735 (forward-line 1)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
736 )))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
737 (or noninteractive ; XEmacs: only need one line in -batch mode.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
738 (message "Generating custom defines for %s...done" trim-name))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
739 autoloads-done))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
740
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
741 ;; Assorted utilities for generating autoloads and pieces thereof
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
742
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
743 (defun autoload-print-form (form outbuf margin)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
744 "Print an autoload form, handling special characters.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
745 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
746 at the beginning of lines and ^L characters."
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
747 (cond
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
748 ;; If the form is a sequence, recurse.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
749 ((eq (car form) 'progn)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
750 (mapcar #'(lambda (x) (autoload-print-form x outbuf margin))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
751 (cdr form)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
752 ;; Symbols at the toplevel are meaningless.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
753 ((symbolp form) nil)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
754 (t
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
755 (let ((doc-string-elt (get (car-safe form) 'doc-string-elt)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
756 (if (and doc-string-elt (stringp (nth doc-string-elt form)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
757 ;; We need to hack the printing because the doc-string must be
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
758 ;; printed specially for make-docfile (sigh).
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
759 (let* ((p (nthcdr (1- doc-string-elt) form))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
760 (elt (cdr p))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
761 (start-string (format "\n%s(" margin)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
762 (setcdr p nil)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
763 (princ start-string outbuf)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
764 ;; XEmacs change: don't let ^^L's get into
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
765 ;; the file or sorting is hard.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
766 (let ((print-escape-newlines t)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
767 ;;#### FSF 21.2 (print-escape-nonascii t)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
768 (p (point outbuf))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
769 p2)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
770 (mapcar #'(lambda (elt)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
771 (prin1 elt outbuf)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
772 (princ " " outbuf))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
773 form)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
774 (with-current-buffer outbuf
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
775 (setq p2 (point-marker))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
776 (goto-char p)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
777 (save-match-data
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
778 (while (search-forward "\^L" p2 t)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
779 (delete-char -1)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
780 (insert "\\^L")))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
781 (goto-char p2)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
782 (princ "\"\\\n" outbuf)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
783 (let ((begin (point outbuf)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
784 (princ (substring (prin1-to-string (car elt)) 1) outbuf)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
785 ;; Insert a backslash before each ( that appears at the beginning
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
786 ;; of a line in the doc string.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
787 (with-current-buffer outbuf
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
788 (save-excursion
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
789 (while (search-backward start-string begin t)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
790 (forward-char 1)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
791 (insert "\\"))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
792 (if (null (cdr elt))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
793 (princ ")" outbuf)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
794 (princ " " outbuf)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
795 (princ (substring (prin1-to-string (cdr elt)) 1) outbuf))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
796 (terpri outbuf)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
797 (princ margin outbuf)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
798 ;; XEmacs change: another ^L hack
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
799 (let ((p (point outbuf))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
800 (print-escape-newlines t)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
801 ;;#### FSF 21.2 (print-escape-nonascii t)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
802 p2)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
803 (print form outbuf)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
804 (with-current-buffer outbuf
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
805 (setq p2 (point-marker))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
806 (goto-char p)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
807 (save-match-data
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
808 (while (search-forward "\^L" p2 t)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
809 (delete-char -1)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
810 (insert "\\^L")))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
811 (goto-char p2))))))))
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 969
diff changeset
812
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
813 (defun autoload-trim-file-name (file)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
814 "Returns relative pathname of FILE including the last directory.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
816 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
817 (setq file (expand-file-name file))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
818 (replace-in-string
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
819 (file-relative-name file (file-name-directory
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
820 (directory-file-name
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
821 (file-name-directory file))))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
822 ;; #### is this a good idea?
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
823 "\\\\" "/"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
825 (defun autoload-read-section-header ()
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
826 "Read a section header form.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
827 Since continuation lines have been marked as comments,
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
828 we must copy the text of the form and remove those comment
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
829 markers before we call `read'."
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
830 (save-match-data
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
831 (let ((beginning (point))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
832 string)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
833 (forward-line 1)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
834 (while (looking-at generate-autoload-section-continuation)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
835 (forward-line 1))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
836 (setq string (buffer-substring beginning (point)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
837 (with-current-buffer (get-buffer-create " *autoload*")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
838 (erase-buffer)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
839 (insert string)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
840 (goto-char (point-min))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
841 (while (search-forward generate-autoload-section-continuation nil t)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
842 (replace-match " "))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
843 (goto-char (point-min))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
844 (read (current-buffer))))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
845
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 (defun update-file-autoloads (file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 "Update the autoloads for FILE in `generated-autoload-file'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 \(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
850 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
851 equal to `autoload-file-name')."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 (interactive "fUpdate autoloads for file: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 (setq file (expand-file-name file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 (when (and (file-newer-than-file-p file generated-autoload-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 (not (member (file-name-nondirectory file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 (list autoload-file-name))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 (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
859 "\\.\\(elc?\\|c\\)$"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 ""))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 (trim-name (autoload-trim-file-name file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 section-begin form)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 (save-excursion
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
864 ;; FSF has: [[ We want to get a value for generated-autoload-file
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
865 ;; from the local variables section if it's there. ]] Not
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
866 ;; applicable in XEmacs, since we always keep the autoloads
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
867 ;; up-to-date.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
868
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
869 ;; #### FSF 21.2 adds: [[ We must read/write the file without any
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
870 ;; code conversion, but still decode EOLs. ]] Not clear if we need
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
871 ;; this. --ben
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
872 ;; (let ((coding-system-for-read 'raw-text))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 (let ((find-file-hooks nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 (set-buffer (or (get-file-buffer generated-autoload-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 (find-file-noselect generated-autoload-file))))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
876 ;; FSF 21.2 says:
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
877
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
878 ;; [[ This is to make generated-autoload-file have Unix EOLs, so
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
879 ;; that it is portable to all platforms. ]]
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
880 ;; (setq buffer-file-coding-system 'raw-text-unix))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
881 ;; Not applicable in XEmacs, since we always keep the autoloads
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
882 ;; up-to-date and recompile when we build.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
883
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
884 ;; FSF 21.2: [not applicable to XEmacs]
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
885 ; (or (> (buffer-size) 0)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
886 ; (error "Autoloads file %s does not exist" buffer-file-name))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
887 ; (or (file-writable-p buffer-file-name)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
888 ; (error "Autoloads file %s is not writable" buffer-file-name))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
889
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
890 ;; NOTE: The rest of this function is totally changed from FSF.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
891 ;; Hence, not synched.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
892
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 ;; Make sure we can scribble in it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 (setq buffer-read-only nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 ;; First delete all sections for this file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 (while (search-forward generate-autoload-section-header nil t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 (setq section-begin (match-beginning 0))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
899 (setq form (autoload-read-section-header))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 (when (string= (nth 2 form) load-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 (search-forward generate-autoload-section-trailer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 (delete-region section-begin (point))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 ;; Now find insertion point for new section
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 (block find-insertion-point
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 (while (search-forward generate-autoload-section-header nil t)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
908 (setq form (autoload-read-section-header))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 (when (string< trim-name (nth 3 form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 ;; Found alphabetically correct insertion point
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 (goto-char (match-beginning 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 (return-from find-insertion-point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 (search-forward generate-autoload-section-trailer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 (when (eq (point) (point-min)) ; No existing entries?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 (goto-char (point-max)))) ; Append.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 ;; Add in new sections for file
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
918 (funcall generate-autoload-function file))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 (when (interactive-p) (save-buffer)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
922 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
923 ;; Utilities for batch updates
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
924
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
925 ;;;###autoload
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
926 (defun batch-update-directory-autoloads ()
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
927 "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
928 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
929 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
930 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
931
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
932 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
933 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
934 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
935
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
936 #### 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
937 (unless noninteractive
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
938 (error "batch-update-directory-autoloads: may be used only with -batch"))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
939 (update-autoload-files (list (cadr command-line-args-left))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
940 (car command-line-args-left) nil t)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
941 (setq command-line-args-left (cddr command-line-args-left)))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
942
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
943 ;;;###autoload
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
944 (defun batch-update-directory-custom-defines ()
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
945 "Update the custom defines for a directory, using a specified feature prefix.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
946 Must be used only with -batch. The feature prefix and directory to update
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
947 are taken from the first and second elements of `command-line-args-left',
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
948 respectively, and they are then removed from `command-line-args-left'.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
949
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
950 Runs `update-file-autoloads' on each file in the given directory. Always
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
951 rewrites the autoloads file, even if unchanged. Makes a feature name by
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
952 applying `autoload-make-feature-name' to the specified feature prefix.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
953
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
954 #### The API and semantics of this function are subject to change."
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
955 (unless noninteractive
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
956 (error "batch-update-directory-custom-defines: may be used only with -batch"))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
957 (update-custom-define-files (list (cadr command-line-args-left))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
958 (car command-line-args-left) nil t)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
959 (setq command-line-args-left (cddr command-line-args-left)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
960
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
961 ;;;###autoload
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
962 (defun update-autoload-files (files-or-dirs feature-prefix
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
963 &optional into-file force)
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
964 "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
965 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
966
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
967 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
968 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
969 feature and to provide the feature is added.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
970
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
971 If optional INTO-FILE is non-`nil', it should specify a file into which
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
972 the autoloads will be placed. Otherwise, the autoloads will be placed into
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
973 a file named `auto-autoloads.el' in the directory of each element in
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
974 FILES-OR-DIRS.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
975
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
976 FEATURE-PREFIX should be set to an appropriate prefix which will
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
977 be concatenated with \"-autoloads\" to produce the feature name. Otherwise
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
978 the appropriate autoload file for each file or directory (located in that
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
979 directory, or in the directory of the specified file) will be updated with
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
980 the directory's or file's autoloads and the protective forms will be added,
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
981 and the files will be saved. Use of the default here is unreliable, and
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
982 therefore deprecated.
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
983
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
984 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
985 one level deep.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
986
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
987 If FORCE is non-nil, always save out the autoload files even if unchanged."
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
988 (or (listp files-or-dirs) (setq files-or-dirs (list files-or-dirs)))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
989 (let ((defdir (directory-file-name default-directory))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
990 ;; value for all-into-one-file
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
991 (autoload-feature-name (autoload-make-feature-name feature-prefix))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
992 (enable-local-eval nil) ; Don't query in batch mode.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
993 (autoload-feature-prefix feature-prefix)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
994 ;; protect from change
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
995 (generated-autoload-file generated-autoload-file))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
996 (dolist (arg files-or-dirs)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
997 (setq arg (expand-file-name arg defdir))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
998 (cond
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
999 ((file-directory-p arg)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1000 (setq generated-autoload-file
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1001 (or into-file (expand-file-name autoload-file-name arg)))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1002 (message "Updating autoloads for directory %s..." arg)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1003 (let ((simple-dir (file-name-as-directory
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1004 (file-name-nondirectory
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1005 (directory-file-name arg))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1006 (enable-local-eval nil))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1007 (save-excursion
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1008 (let ((find-file-hooks nil))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1009 (set-buffer (find-file-noselect generated-autoload-file)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1010 (goto-char (point-min))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1011 (while (search-forward generate-autoload-section-header nil t)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1012 (let* ((begin (match-beginning 0))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1013 (form (autoload-read-section-header))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1014 (file (nth 3 form)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1015 (when (and (stringp file)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1016 (string= (file-name-directory file) simple-dir)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1017 (not (file-exists-p
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1018 (expand-file-name
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1019 (file-name-nondirectory file) arg))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1020 ;; Remove the obsolete section.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1021 (search-forward generate-autoload-section-trailer)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1022 (delete-region begin (point)))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1023 ;; Update or create autoload sections for existing files.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1024 (mapcar 'update-file-autoloads
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1025 (directory-files arg t "^[^=].*\\.\\(el\\|c\\)$")))))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1026 ((file-exists-p arg)
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1027 (setq generated-autoload-file
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1028 (or into-file (expand-file-name autoload-file-name
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1029 (file-name-directory arg))))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1030 (update-file-autoloads arg))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1031 (t (error "No such file or directory: %s" arg)))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1032 (when (not into-file)
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1033 (autoload-featurep-protect-autoloads
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1034 (autoload-make-feature-name
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1035 (or feature-prefix
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1036 (file-name-nondirectory (directory-file-name arg)))))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1037 (if force (set-buffer-modified-p
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1038 t (find-file-noselect generated-autoload-file)))))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1039 (when into-file
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1040 (autoload-featurep-protect-autoloads autoload-feature-name)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1041 (if force (set-buffer-modified-p
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1042 t (find-file-noselect into-file))))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1043 (save-some-buffers t)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1044 ))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1045
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 ;;;###autoload
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1047 (defun update-custom-define-files (files-or-dirs feature-prefix
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1048 &optional into-file force)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1049 "Update all the custom-define files associated with FILES-OR-DIRS.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1050 Works just like `update-file-autoloads'."
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1051 (let* ((autoload-feature-suffix "-custom-defines")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1052 (autoload-file-name "custom-defines.el")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1053 (generate-autoload-function #'generate-custom-defines))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1054 (update-autoload-files files-or-dirs feature-prefix into-file force)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1056 (defun autoload-featurep-protect-autoloads (sym)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 (set-buffer (find-file-noselect generated-autoload-file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 (goto-char (point-min))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1060 (cond ((eq (point-min) (point-max)) nil)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1061 ;; if there's some junk in the file but no sections, just
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1062 ;; delete everything. the junk might be stuff inserted by
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1063 ;; an older version of this function.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1064 ((not (search-forward generate-autoload-section-header nil t))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1065 (delete-region (point-min) (point-max)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1066 (t
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1067 (goto-char (point-min))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1068 (when (looking-at ";;; DO NOT MODIFY THIS FILE")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1069 (delete-region (point-min)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1070 (progn
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1071 (search-forward generate-autoload-section-header)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1072 (match-beginning 0))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1073 ;; Determine and set the coding system for the file if under Mule.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1074 ;; If there are any extended characters in the input file, use
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1075 ;; `escape-quoted' to make sure that both binary and extended
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1076 ;; characters are output properly and distinguished properly.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1077 ;; Otherwise, use `raw-text' for maximum portability with non-Mule
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1078 ;; Emacsen.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1079 (if (or (featurep '(not mule)) ;; Don't scan if no Mule support
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1080 (progn
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1081 (goto-char (point-min))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1082 ;; mrb- There must be a better way than skip-chars-forward
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1083 (skip-chars-forward (concat (char-to-string 0) "-"
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1084 (char-to-string 255)))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1085 (eq (point) (point-max))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1086 (setq buffer-file-coding-system 'raw-text-unix)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1087 (setq buffer-file-coding-system 'escape-quoted))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1088 (goto-char (point-min))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1089 (insert ";;; DO NOT MODIFY THIS FILE")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1090 ;; NOTE: XEmacs prior to 21.5.12 or so had a bug in that it
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1091 ;; recognized only one of the two magic-cookie styles (the -*- kind)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1092 ;; in find-file, but both of them in load. We go ahead and put both
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1093 ;; in, just to be safe.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1094 (when (eq buffer-file-coding-system 'escape-quoted)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1095 (insert " -*- coding: escape-quoted; -*-
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1096 \(or (featurep 'mule) (error \"Loading this file requires Mule support\"))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1097 ;;;###coding system: escape-quoted"))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1098 (insert "\n(if (featurep '" sym ")")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1099 (insert " (error \"Feature " sym " already loaded\"))\n")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1100 (goto-char (point-max))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1101 (save-excursion
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1102 (forward-line -1)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1103 (when (looking-at "(provide")
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1104 (delete-region (point) (point-max))))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1105 (unless (bolp) (insert "\n"))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1106 (unless (eq (char-before (1- (point))) ?\^L)
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1107 (insert "\^L\n"))
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1108 (insert "(provide '" sym ")\n")))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1110 (defun autoload-make-feature-name (&optional prefix)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1111 "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
1112
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1113 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
1114 that is non-nil.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1115
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1116 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
1117 including packages.
528
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
1118
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1119 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
1120 `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
1121 `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
1122 do not use this feature."
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1123 (concat
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1124 (cond (prefix)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1125 (autoload-feature-prefix)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1126 ((stringp generated-autoload-file)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1127 (message "Warning: autoload computing feature prefix.
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1128 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
1129 (file-name-nondirectory
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1130 (directory-file-name
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1131 (file-name-directory generated-autoload-file))))
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1132 (t (error 'invalid-argument
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1133 "Could not compute a feature name")))
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1134 autoload-feature-suffix))
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1135
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1136 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1137 ;; Deprecated entry points
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1138
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1139 ;; 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
1140 ;; by XEmacs.rules, pcomplete, eshell, oort-gnus; `batch-update-directory'
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1141 ;; by liece. The other two entry points (`batch-update-one-directory',
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1142 ;; `batch-force-update-one-directory') were not used at all.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1143 ;;
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1144 ;; All except the first are now history. liece has been updated.
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1145 ;; XEmacs.rules has been updated. The others will be, eventually.
528
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
1146
2548
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1147 ;; There don't seem to be very many packages that use the first one (the
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1148 ;; "all-into-one-file" variety), and do they actually rely on this
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1149 ;; functionality? --ben
c4c8a36043be [xemacs-hg @ 2005-02-03 07:11:19 by ben]
ben
parents: 1753
diff changeset
1150
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1151 ;; 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
1152 ;; 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
1153
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
1154 ;;;###autoload
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
1155 (defun batch-update-autoloads ()
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
1156 "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
1157 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
1158 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
1159 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
1160 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
1161 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
1162 on the command line."
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
1163 (unless noninteractive
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
1164 (error "batch-update-autoloads is to be used only with -batch"))
3431
38d1f63a6b1f [xemacs-hg @ 2006-05-29 21:25:48 by james]
james
parents: 2565
diff changeset
1165 (update-autoload-files command-line-args-left autoload-feature-prefix
38d1f63a6b1f [xemacs-hg @ 2006-05-29 21:25:48 by james]
james
parents: 2565
diff changeset
1166 generated-autoload-file t)
528
ef4d2466a29c [xemacs-hg @ 2001-05-10 09:59:45 by ben]
ben
parents: 460
diff changeset
1167 (kill-emacs 0))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1168
1232
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1169 ;; Declare obsolescence
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1170
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1171 (make-obsolete-variable 'autoload-target-directory
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1172 "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
1173 (make-obsolete 'batch-update-autoloads
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1174 'autoload-update-directory-autoloads)
c08a6fa181d1 [xemacs-hg @ 2003-01-23 11:38:56 by stephent]
stephent
parents: 1048
diff changeset
1175
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 (provide 'autoload)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 ;;; autoload.el ends here