Mercurial > hg > xemacs-beta
annotate lisp/packages.el @ 5353:38e24b8be4ea
Improve the lexical scoping in #'block, #'return-from.
lisp/ChangeLog addition:
2011-02-07 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el:
* bytecomp.el (byte-compile-initial-macro-environment):
Shadow `block', `return-from' here, we implement them differently
when byte-compiling.
* bytecomp.el (byte-compile-active-blocks): New.
* bytecomp.el (byte-compile-block-1): New.
* bytecomp.el (byte-compile-return-from-1): New.
* bytecomp.el (return-from-1): New.
* bytecomp.el (block-1): New.
These are two aliases that exist to have their own associated
byte-compile functions, which functions implement `block' and
`return-from'.
* cl-extra.el (cl-macroexpand-all):
Fix a bug here when macros in the environment have been compiled.
* cl-macs.el (block):
* cl-macs.el (return):
* cl-macs.el (return-from):
Be more careful about lexical scope in these macros.
* cl.el:
* cl.el ('cl-block-wrapper): Removed.
* cl.el ('cl-block-throw): Removed.
These aren't needed in code generated by this XEmacs. They
shouldn't be needed in code generated by XEmacs 21.4, but if it
turns out the packages do need them, we can put them back.
2011-01-30 Mike Sperber <mike@xemacs.org>
* font-lock.el (font-lock-fontify-pending-extents): Don't fail if
`font-lock-mode' is unset, which can happen in the middle of
`revert-buffer'.
2011-01-23 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (delete):
* cl-macs.el (delq):
* cl-macs.el (remove):
* cl-macs.el (remq):
Don't use the compiler macro if these functions were given the
wrong number of arguments, as happens in lisp-tests.el.
* cl-seq.el (remove, remq): Removed.
I added these to subr.el, and forgot to remove them from here.
2011-01-22 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-setq, byte-compile-set):
Remove kludge allowing keywords' values to be set, all the code
that does that is gone.
* cl-compat.el (elt-satisfies-test-p):
* faces.el (set-face-parent):
* faces.el (face-doc-string):
* gtk-font-menu.el:
* gtk-font-menu.el (gtk-reset-device-font-menus):
* msw-font-menu.el:
* msw-font-menu.el (mswindows-reset-device-font-menus):
* package-get.el (package-get-installedp):
* select.el (select-convert-from-image-data):
* sound.el:
* sound.el (load-sound-file):
* x-font-menu.el (x-reset-device-font-menus-core):
Don't quote keywords, they're self-quoting, and the
win from backward-compatibility is sufficiently small now that the
style problem overrides it.
2011-01-22 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (block, return-from): Require that NAME be a symbol
in these macros, as always documented in the #'block docstring and
as required by Common Lisp.
* descr-text.el (unidata-initialize-unihan-database):
Correct the use of non-symbols in #'block and #'return-from in
this function.
2011-01-15 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (concatenate): Accept more complicated TYPEs in this
function, handing the sequences over to #'coerce if we don't
understand them here.
* cl-macs.el (inline): Don't proclaim #'concatenate as inline, its
compiler macro is more useful than doing that.
2011-01-11 Aidan Kehoe <kehoea@parhasard.net>
* subr.el (delete, delq, remove, remq): Move #'remove, #'remq
here, they don't belong in cl-seq.el; move #'delete, #'delq here
from fns.c, implement them in terms of #'delete*, allowing support
for sequences generally.
* update-elc.el (do-autoload-commands): Use #'delete*, not #'delq
here, now the latter's no longer dumped.
* cl-macs.el (delete, delq): Add compiler macros transforming
#'delete and #'delq to #'delete* calls.
2011-01-10 Aidan Kehoe <kehoea@parhasard.net>
* dialog.el (make-dialog-box): Correct a misplaced parenthesis
here, thank you Mats Lidell in 87zkr9gqrh.fsf@mail.contactor.se !
2011-01-02 Aidan Kehoe <kehoea@parhasard.net>
* dialog.el (make-dialog-box):
* list-mode.el (display-completion-list):
These functions used to use cl-parsing-keywords; change them to
use defun* instead, fixing the build. (Not sure what led to me
not including this change in d1b17a33450b!)
2011-01-02 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (define-star-compiler-macros):
Make sure the form has ITEM and LIST specified before attempting
to change to calls with explicit tests; necessary for some tests
in lisp-tests.el to compile correctly.
(stable-union, stable-intersection): Add compiler macros for these
functions, in the same way we do for most of the other functions
in cl-seq.el.
2011-01-01 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (dolist, dotimes, do-symbols, macrolet)
(symbol-macrolet):
Define these macros with defmacro* instead of parsing the argument
list by hand, for the sake of style and readability; use backquote
where appropriate, instead of calling #'list and and friends, for
the same reason.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* x-misc.el (device-x-display):
Provide this function, documented in the Lispref for years, but
not existing previously. Thank you Julian Bradfield, thank you
Jeff Mincy.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* cl-seq.el:
Move the heavy lifting from this file to C. Dump the
cl-parsing-keywords macro, but don't use defun* for the functions
we define that do take keywords, dynamic scope lossage makes that
not practical.
* subr.el (sort, fillarray): Move these aliases here.
(map-plist): #'nsublis is now built-in, but at this point #'eql
isn't necessarily available as a test; use #'eq.
* obsolete.el (cl-delete-duplicates): Make this available for old
compiler macros and old code.
(memql): Document that this is equivalent to #'member*, and worse.
* cl.el (adjoin, subst): Removed. These are in C.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* simple.el (assoc-ignore-case): Remove a duplicate definition of
this function (it's already in subr.el).
* iso8859-1.el (char-width):
On non-Mule, make this function equivalent to that produced by
(constantly 1), but preserve its docstring.
* subr.el (subst-char-in-string): Define this in terms of
#'substitute, #'nsubstitute.
(string-width): Define this using #'reduce and #'char-width.
(char-width): Give this a simpler definition, it makes far more
sense to check for mule at load time and redefine, as we do in
iso8859-1.el.
(store-substring): Implement this in terms of #'replace, now
#'replace is cheap.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* update-elc.el (lisp-files-needed-for-byte-compilation)
(lisp-files-needing-early-byte-compilation):
cl-macs belongs in the former, not the latter, it is as
fundamental as bytecomp.el.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* cl.el:
Provde the Common Lisp program-error, type-error as error
symbols. This doesn't nearly go far enough for anyone using the
Common Lisp errors.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (delete-duplicates):
If the form has an incorrect number of arguments, don't attempt a
compiler macroexpansion.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (cl-safe-expr-p):
Forms that start with the symbol lambda are also safe.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (= < > <= >=):
For these functions' compiler macros, the optimisation is safe
even if the first and the last arguments have side effects, since
they're only used the once.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (inline-side-effect-free-compiler-macros):
Unroll a loop here at macro-expansion time, so these compiler
macros are compiled. Use #'eql instead of #'eq in a couple of
places for better style.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (notany, notevery): Avoid some dynamic scope
stupidity with local variable names in these functions, when they
weren't prefixed with cl-; go into some more detail in the doc
strings.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* byte-optimize.el (side-effect-free-fns): #'remove, #'remq are
free of side-effects.
(side-effect-and-error-free-fns):
Drop dot, dot-marker from the list.
2010-11-17 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (coerce):
In the argument list, name the first argument OBJECT, not X; the
former name was always used in the doc string and is clearer.
Handle vector type specifications which include the length of the
target sequence, error if there's a mismatch.
* cl-macs.el (cl-make-type-test): Handle type specifications
starting with the symbol 'eql.
2010-11-14 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (eql): Don't remove the byte-compile property of this
symbol. That was necessary to override a bug in bytecomp.el where
#'eql was confused with #'eq, which bug we no longer have.
If neither expression is constant, don't attempt to handle the
expression in this compiler macro, leave it to byte-compile-eql,
which produces better code anyway.
* bytecomp.el (eq): #'eql is not the function associated with the
byte-eq byte code.
(byte-compile-eql): Add an explicit compile method for this
function, for cases where the cl-macs compiler macro hasn't
reduced it to #'eq or #'equal.
2010-10-25 Aidan Kehoe <kehoea@parhasard.net>
Add compiler macros and compilation sanity-checking for various
functions that take keywords.
* byte-optimize.el (side-effect-free-fns): #'symbol-value is
side-effect free and not error free.
* bytecomp.el (byte-compile-normal-call): Check keyword argument
lists for sanity; store information about the positions where
keyword arguments start using the new byte-compile-keyword-start
property.
* cl-macs.el (cl-const-expr-val): Take a new optional argument,
cl-not-constant, defaulting to nil, in this function; return it if
the expression is not constant.
(cl-non-fixnum-number-p): Make this into a separate function, we
want to pass it to #'every.
(eql): Use it.
(define-star-compiler-macros): Use the same code to generate the
member*, assoc* and rassoc* compiler macros; special-case some
code in #'add-to-list in subr.el.
(remove, remq): Add compiler macros for these two functions, in
preparation for #'remove being in C.
(define-foo-if-compiler-macros): Transform (remove-if-not ...) calls to
(remove ... :if-not) at compile time, which will be a real win
once the latter is in C.
(define-substitute-if-compiler-macros)
(define-subst-if-compiler-macros): Similarly for these functions.
(delete-duplicates): Change this compiler macro to use
#'plists-equal; if we don't have information about the type of
SEQUENCE at compile time, don't bother attempting to inline the
call, the function will be in C soon enough.
(equalp): Remove an old commented-out compiler macro for this, if
we want to see it it's in version control.
(subst-char-in-string): Transform this to a call to nsubstitute or
nsubstitute, if that is appropriate.
* cl.el (ldiff): Don't call setf here, this makes for a load-time
dependency problem in cl-macs.el
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* term/vt100.el:
Refer to XEmacs, not GNU Emacs, in permissions.
* term/bg-mouse.el:
* term/sup-mouse.el:
Put copyright notice in canonical "Copyright DATE AUTHOR" form.
Refer to XEmacs, not GNU Emacs, in permissions.
* site-load.el:
Add permission boilerplate.
* mule/canna-leim.el:
* alist.el:
Refer to XEmacs, not APEL/this program, in permissions.
* mule/canna-leim.el:
Remove my copyright, I've assigned it to the FSF.
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* gtk.el:
* gtk-widget-accessors.el:
* gtk-package.el:
* gtk-marshal.el:
* gtk-compose.el:
* gnome.el:
Add copyright notice based on internal evidence.
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* easymenu.el: Add reference to COPYING to permission notice.
* gutter.el:
* gutter-items.el:
* menubar-items.el:
Fix typo "Xmacs" in permissions notice.
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* auto-save.el:
* font.el:
* fontconfig.el:
* mule/kinsoku.el:
Add "part of XEmacs" text to permission notice.
2010-10-14 Aidan Kehoe <kehoea@parhasard.net>
* byte-optimize.el (side-effect-free-fns):
* cl-macs.el (remf, getf):
* cl-extra.el (tailp, cl-set-getf, cl-do-remf):
* cl.el (ldiff, endp):
Tighten up Common Lisp compatibility for #'ldiff, #'endp, #'tailp;
add circularity checking for the first two.
#'cl-set-getf and #'cl-do-remf were Lisp implementations of
#'plist-put and #'plist-remprop; change the names to aliases,
changes the macros that use them to using #'plist-put and
#'plist-remprop directly.
2010-10-12 Aidan Kehoe <kehoea@parhasard.net>
* abbrev.el (fundamental-mode-abbrev-table, global-abbrev-table):
Create both these abbrev tables using the usual
#'define-abbrev-table calls, rather than attempting to
special-case them.
* cl-extra.el: Force cl-macs to be loaded here, if cl-extra.el is
being loaded interpreted. Previously other, later files would
redundantly call (load "cl-macs") when interpreted, it's more
reasonable to do it here, once.
* cmdloop.el (read-quoted-char-radix): Use defcustom here, we
don't have any dump-order dependencies that would prevent that.
* custom.el (eval-when-compile): Don't load cl-macs when
interpreted or when byte-compiling, rely on cl-extra.el in the
former case and the appropriate entry in bytecomp-load-hook in the
latter. Get rid of custom-declare-variable-list, we have no
dump-time dependencies that would require it.
* faces.el (eval-when-compile): Don't load cl-macs when
interpreted or when byte-compiling.
* packages.el: Remove some inaccurate comments.
* post-gc.el (cleanup-simple-finalizers): Use #'delete-if-not
here, now the order of preloaded-file-list has been changed to
make it available.
* subr.el (custom-declare-variable-list): Remove. No need for it.
Also remove a stub define-abbrev-table from this file, given the
current order of preloaded-file-list there's no need for it.
2010-10-10 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-constp) Forms quoted with FUNCTION are
also constant.
(byte-compile-initial-macro-environment): In #'the, if FORM is
constant and does not match TYPE, warn at byte-compile time.
2010-10-10 Aidan Kehoe <kehoea@parhasard.net>
* backquote.el (bq-vector-contents, bq-list*): Remove; the former
is equivalent to (append VECTOR nil), the latter to (list* ...).
(bq-process-2): Use (append VECTOR nil) instead of using
#'bq-vector-contents to convert to a list.
(bq-process-1): Now we use list* instead of bq-list
* subr.el (list*): Moved from cl.el, since it is now required to
be available the first time a backquoted form is encountered.
* cl.el (list*): Move to subr.el.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* test-harness.el (Check-Message):
Add an omitted comma here, thank you the buildbot.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* hash-table.el (hash-table-key-list, hash-table-value-list)
(hash-table-key-value-alist, hash-table-key-value-plist):
Remove some useless #'nreverse calls in these files; our hash
tables have no order, it's not helpful to pretend they do.
* behavior.el (read-behavior):
Do the same in this file, in some code evidently copied from
hash-table.el.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* info.el (Info-insert-dir):
* format.el (format-deannotate-region):
* files.el (cd, save-buffers-kill-emacs):
Use #'some, #'every and related functions for applying boolean
operations to lists, instead of rolling our own ones that cons and
don't short-circuit.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-initial-macro-environment):
* cl-macs.el (the):
Rephrase the docstring, make its implementation when compiling
files a little nicer.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* descr-text.el (unidata-initialize-unicodedata-database)
(unidata-initialize-unihan-database, describe-char-unicode-data)
(describe-char-unicode-data):
Wrap calls to the database functions with (with-fboundp ...),
avoiding byte compile warnings on builds without support for the
database functions.
(describe-char): (reduce #'max ...), not (apply #'max ...), no
need to cons needlessly.
(describe-char): Remove a redundant lambda wrapping
#'extent-properties.
(describe-char-unicode-data): Call #'nsubst when replacing "" with
nil in the result of #'split-string, instead of consing inside
mapcar.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* x-faces.el (x-available-font-sizes):
* specifier.el (let-specifier):
* package-ui.el (pui-add-required-packages):
* msw-faces.el (mswindows-available-font-sizes):
* modeline.el (modeline-minor-mode-menu):
* minibuf.el (minibuf-directory-files):
Replace the O2N (delq nil (mapcar (lambda (W) (and X Y)) Z)) with
the ON (mapcan (lambda (W) (and X (list Y))) Z) in these files.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (= < > <= >=):
When these functions are handed more than two arguments, and those
arguments have no side effects, transform to a series of two
argument calls, avoiding funcall in the byte-compiled code.
* mule/mule-cmds.el (finish-set-language-environment):
Take advantage of this change in a function called 256 times at
startup.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-function-form, byte-compile-quote)
(byte-compile-quote-form):
Warn at compile time, and error at runtime, if a (quote ...) or a
(function ...) form attempts to quote more than one object.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* byte-optimize.el (byte-optimize-apply): Transform (apply 'nconc
(mapcar ...)) to (mapcan ...); warn about use of the first idiom.
* update-elc.el (do-autoload-commands):
* packages.el (packages-find-package-library-path):
* frame.el (frame-list):
* extents.el (extent-descendants):
* etags.el (buffer-tag-table-files):
* dumped-lisp.el (preloaded-file-list):
* device.el (device-list):
* bytecomp-runtime.el (proclaim-inline, proclaim-notinline)
Use #'mapcan, not (apply #'nconc (mapcar ...) in all these files.
* bytecomp-runtime.el (eval-when-compile, eval-and-compile):
In passing, mention that these macros also evaluate the body when
interpreted.
tests/ChangeLog addition:
2011-02-07 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el:
Test lexical scope for `block', `return-from'; add a
Known-Bug-Expect-Failure for a contorted example that fails when
byte-compiled.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 07 Feb 2011 12:01:24 +0000 |
parents | d27c1ee1943b |
children | 311f6817efc2 b9167d522a9a |
rev | line source |
---|---|
428 | 1 ;;; packages.el --- Low level support for XEmacs packages |
2 | |
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. | |
2557 | 4 ;; Copyright (C) 2002, 2003, 2004 Ben Wing. |
428 | 5 |
6 ;; Author: Steven L Baur <steve@xemacs.org> | |
7 ;; Maintainer: Steven L Baur <steve@xemacs.org> | |
8 ;; Keywords: internal, lisp, dumped | |
9 | |
10 ;; This file is part of XEmacs. | |
11 | |
12 ;; XEmacs is free software; you can redistribute it and/or modify it | |
13 ;; under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; XEmacs is distributed in the hope that it will be useful, but | |
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 ;; General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
25 ;; 02111-1307, USA. | |
26 | |
27 ;;; Synched up with: Not in FSF | |
28 | |
29 ;;; Commentary: | |
30 | |
31 ;; This file is dumped with XEmacs. | |
32 | |
33 ;; This file provides low level facilities for XEmacs startup -- | |
5284
d27c1ee1943b
Make the order of preloaded-file-list more sane.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
34 ;; particularly regarding the package setup. |
428 | 35 |
36 ;; This file requires find-paths.el. | |
37 | |
38 ;;; Code: | |
39 | |
40 ;;; Package versioning | |
41 | |
42 (defvar packages-package-list nil | |
454 | 43 "Database of installed packages and version numbers") |
428 | 44 |
2456 | 45 ;;; Directories and paths |
46 | |
47 ;;; Terminology: | |
48 | |
49 ;;; A *package hierarchy* is a directory that contains a collection of | |
50 ;;; packages; it has lisp/, info/, etc/ etc. subdirectories that | |
51 ;;; contain the files constituting the packages. | |
52 | |
53 ;;; A *package directory* contains package hierarchies---the package | |
54 ;;; hierarchies are typically in directories "xemacs-packages", | |
55 ;;; "mule-packages", and so on. A package hierarchy might only be | |
56 ;;; applicable for specific variants of XEmacs. | |
57 | |
58 ;;; Package hierarchies come in "early", "late", and "last" variants, | |
59 ;;; depending on their relative location in the various paths. | |
60 ;;; "Early" hierarchies are typically in the user's home directory, | |
61 ;;; "late" hierarchies are typically part of the XEmacs installation, | |
62 ;;; and "last" package hierarchies are for special purposes, such as | |
63 ;;; making the packages of some previous XEmacs version available. | |
428 | 64 |
65 (defvar packages-load-path-depth 1 | |
66 "Depth of load-path search in package hierarchies.") | |
67 | |
68 (defvar packages-data-path-depth 1 | |
69 "Depth of data-path search in package hierarchies.") | |
70 | |
2456 | 71 (defvar early-package-hierarchies nil |
72 "Package hierarchies early in the load path.") | |
428 | 73 |
74 (defvar early-package-load-path nil | |
75 "Load path for packages early in the load path.") | |
76 | |
2456 | 77 (defvar late-package-hierarchies nil |
78 "Package hierarchies late in the load path.") | |
428 | 79 |
80 (defvar late-package-load-path nil | |
81 "Load path for packages late in the load path.") | |
82 | |
2456 | 83 (defvar last-package-hierarchies nil |
84 "Package hierarchies last in the load path.") | |
428 | 85 |
86 (defvar last-package-load-path nil | |
87 "Load path for packages last in the load path.") | |
88 | |
2456 | 89 (defun packages-package-hierarchy-directory-names () |
90 "Returns a list package hierarchy directory names. | |
91 These are the valid immediate directory names of package | |
92 directories, directories with higher priority first" | |
4919
9c6ea1581159
Remove a couple of XEmacs-specific duplicate functions, find-paths.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
4108
diff
changeset
|
93 (delq nil `("site-packages" |
9c6ea1581159
Remove a couple of XEmacs-specific duplicate functions, find-paths.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
4108
diff
changeset
|
94 ,(when (featurep 'mule) "mule-packages") |
9c6ea1581159
Remove a couple of XEmacs-specific duplicate functions, find-paths.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
4108
diff
changeset
|
95 "xemacs-packages"))) |
428 | 96 |
97 (defun package-get-key-1 (info key) | |
98 "Locate keyword `key' in list." | |
99 (cond ((null info) | |
100 nil) | |
101 ((eq (car info) key) | |
102 (nth 1 info)) | |
103 (t (package-get-key-1 (cddr info) key)))) | |
104 | |
105 (defun package-get-key (name key) | |
106 "Get info `key' from package `name'." | |
107 (let ((info (assq name packages-package-list))) | |
108 (when info | |
109 (package-get-key-1 (cdr info) key)))) | |
110 | |
111 (defun package-provide (name &rest attributes) | |
112 (let ((info (if (and attributes (floatp (car attributes))) | |
113 (list :version (car attributes)) | |
114 attributes))) | |
115 (setq packages-package-list | |
116 (cons (cons name info) (remassq name packages-package-list))))) | |
117 | |
2557 | 118 (defun package-suppress (package file form) |
119 "Set up a package-suppress condition FORM for FILE in PACKAGE. | |
120 When XEmacs searches for a file in the load path, it will ignore FILE | |
121 if FORM evaluates to non-nil." | |
122 (setq load-suppress-alist | |
123 (acons (expand-file-name file load-file-name) form | |
124 load-suppress-alist))) | |
125 | |
428 | 126 (defun package-require (name version) |
127 (let ((pkg (assq name packages-package-list))) | |
128 (cond ((null pkg) | |
1410 | 129 (error 'invalid-state |
130 (format "Package %s has not been loaded into this XEmacsen" | |
131 name))) | |
428 | 132 ((< (package-get-key name :version) version) |
1410 | 133 (error 'search-failed |
134 (format "Need version %g of package %s, got version %g" | |
2252 | 135 version name (package-get-key name :version)))) |
428 | 136 (t t)))) |
137 | |
138 (defun package-delete-name (name) | |
139 (let (pkg) | |
140 ;; Delete ALL versions of package. | |
141 ;; This is pretty memory-intensive, as we use copy-alist when deleting | |
142 ;; package entries, to prevent side-effects in functions that call this | |
143 ;; one. | |
144 (while (setq pkg (assq name packages-package-list)) | |
145 (setq packages-package-list (delete pkg (copy-alist | |
1365 | 146 packages-package-list)))))) |
428 | 147 |
148 ;;; Build time stuff | |
149 | |
150 (defvar autoload-file-name "auto-autoloads.el" | |
151 "Filename that autoloads are expected to be found in.") | |
152 | |
1330 | 153 ;; Moved from help.el. |
428 | 154 ;; Unlike the FSF version, our `locate-library' uses the `locate-file' |
155 ;; primitive, which should make it lightning-fast. | |
156 | |
157 (defun locate-library (library &optional nosuffix path interactive-call) | |
158 "Show the precise file name of Emacs library LIBRARY. | |
159 This command searches the directories in `load-path' like `M-x load-library' | |
160 to find the file that `M-x load-library RET LIBRARY RET' would load. | |
161 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el' | |
162 to the specified name LIBRARY. | |
163 | |
164 If the optional third arg PATH is specified, that list of directories | |
165 is used instead of `load-path'." | |
624 | 166 (interactive (list (read-library-name "Locate library: ") |
428 | 167 nil nil |
168 t)) | |
169 (let ((result | |
170 (locate-file | |
171 library | |
172 (or path load-path) | |
173 (cond ((or (rassq 'jka-compr-handler file-name-handler-alist) | |
174 (and (boundp 'find-file-hooks) | |
175 (member 'crypt-find-file-hook find-file-hooks))) | |
176 ;; Compression involved. | |
177 (if nosuffix | |
448 | 178 '("" ".gz" ".Z" ".bz2") |
179 '(".elc" ".elc.gz" "elc.Z" ".elc.bz2" | |
180 ".el" ".el.gz" ".el.Z" ".el.bz2" | |
181 "" ".gz" ".Z" ".bz2"))) | |
428 | 182 (t |
183 ;; No compression. | |
184 (if nosuffix | |
185 "" | |
186 '(".elc" ".el" ""))))))) | |
187 (and interactive-call | |
188 (if result | |
189 (message "Library is file %s" result) | |
190 (message "No library %s in search path" library))) | |
191 result)) | |
192 | |
193 (defun packages-add-suffix (str) | |
194 (if (null (string-match "\\.el\\'" str)) | |
195 (concat str ".elc") | |
196 str)) | |
197 | |
198 (defun packages-list-autoloads-path () | |
199 "List autoloads from precomputed load-path." | |
200 (let ((path load-path) | |
201 autoloads) | |
202 (while path | |
203 (if (file-exists-p (concat (car path) | |
204 autoload-file-name)) | |
205 (setq autoloads (cons (concat (car path) | |
206 autoload-file-name) | |
207 autoloads))) | |
208 (setq path (cdr path))) | |
209 autoloads)) | |
210 | |
211 (defun packages-list-autoloads (source-directory) | |
212 "List autoload files in (what will be) the normal lisp search path. | |
213 This function is used during build to find where the global symbol files so | |
214 they can be perused for their useful information." | |
215 (let ((files (directory-files (file-name-as-directory source-directory) | |
216 t ".*")) | |
217 file autolist) | |
218 ;; (print (prin1-to-string source-directory)) | |
219 ;; (print (prin1-to-string files)) | |
220 (while (setq file (car-safe files)) | |
221 (if (and (file-directory-p file) | |
222 (file-exists-p (concat (file-name-as-directory file) | |
223 autoload-file-name))) | |
224 (setq autolist (cons (concat (file-name-as-directory file) | |
225 autoload-file-name) | |
226 autolist))) | |
227 (setq files (cdr files))) | |
228 autolist)) | |
229 | |
230 ;; The following function cannot be called from a bare temacs | |
231 (defun packages-new-autoloads () | |
232 "Return autoloads files that have been added or modified since XEmacs dump." | |
233 (require 'loadhist) | |
234 (let ((me (concat invocation-directory invocation-name)) | |
235 (path load-path) | |
236 result dir) | |
237 (while path | |
238 (setq dir (file-truename (car path))) | |
239 (let ((autoload-file (file-name-sans-extension (concat | |
240 dir | |
241 autoload-file-name)))) | |
242 ;; Check for: | |
243 ;; 1. An auto-autoload file that hasn't provided a feature (because | |
244 ;; it has been installed since XEmacs was dumped). | |
245 ;; 2. auto-autoload.el being newer than the executable | |
246 ;; 3. auto-autoload.elc being newer than the executable (the .el | |
247 ;; could be missing or compressed) | |
248 (when (or (and (null (file-provides autoload-file)) | |
249 (or (file-exists-p (concat autoload-file ".elc")) | |
250 (file-exists-p (concat autoload-file ".el")))) | |
251 (and (file-newer-than-file-p (concat autoload-file ".el") me) | |
252 (setq autoload-file (concat autoload-file ".el"))) | |
253 (and (file-newer-than-file-p (concat autoload-file | |
254 ".elc") | |
255 me) | |
256 (setq autoload-file (concat autoload-file ".elc")))) | |
257 (push autoload-file result))) | |
258 (setq path (cdr path))) | |
259 result)) | |
260 | |
261 ;; The following function cannot be called from a bare temacs | |
262 (defun packages-reload-autoloads () | |
263 "Reload new or updated auto-autoloads files. | |
264 This is an extremely dangerous function to call after the user-init-files | |
265 is run. Don't call it or you'll be sorry." | |
266 (let ((autoload-list (packages-new-autoloads))) | |
267 (while autoload-list | |
268 (let* ((autoload-file (car autoload-list)) | |
269 (feature (car-safe (file-provides autoload-file)))) | |
270 (when feature | |
271 ;; (message "(unload-feature %S)" feature) | |
272 (unload-feature feature)) | |
273 (condition-case nil | |
274 (load autoload-file) | |
275 (t nil))) | |
276 (setq autoload-list (cdr autoload-list))))) | |
277 | |
278 ;; Data-directory is really a list now. Provide something to search it for | |
279 ;; directories. | |
280 | |
281 (defun locate-data-directory-list (name &optional dir-list) | |
282 "Locate the matching list of directories in a search path DIR-LIST. | |
283 If no DIR-LIST is supplied, it defaults to `data-directory-list'." | |
284 (unless dir-list | |
285 (setq dir-list data-directory-list)) | |
286 (let (found found-dir found-dir-list) | |
287 (while dir-list | |
288 (setq found (file-name-as-directory (concat (car dir-list) name)) | |
289 found-dir (file-directory-p found)) | |
290 (and found-dir | |
291 (setq found-dir-list (cons found found-dir-list))) | |
292 (setq dir-list (cdr dir-list))) | |
293 (nreverse found-dir-list))) | |
294 | |
295 ;; Data-directory is really a list now. Provide something to search it for | |
296 ;; a directory. | |
297 | |
298 (defun locate-data-directory (name &optional dir-list) | |
299 "Locate a directory in a search path DIR-LIST (a list of directories). | |
300 If no DIR-LIST is supplied, it defaults to `data-directory-list'." | |
301 (unless dir-list | |
302 (setq dir-list data-directory-list)) | |
303 (let (found found-dir) | |
304 (while (and (null found-dir) dir-list) | |
305 (setq found (file-name-as-directory (concat (car dir-list) name)) | |
306 found-dir (file-directory-p found)) | |
307 (or found-dir | |
308 (setq found nil)) | |
309 (setq dir-list (cdr dir-list))) | |
310 found)) | |
311 | |
312 ;; Data-directory is really a list now. Provide something to search it for | |
313 ;; files. | |
314 | |
315 (defun locate-data-file (name &optional dir-list) | |
316 "Locate a file in a search path DIR-LIST (a list of directories). | |
317 If no DIR-LIST is supplied, it defaults to `data-directory-list'. | |
318 This function is basically a wrapper over `locate-file'." | |
633 | 319 (locate-file name (or dir-list data-directory-list))) |
428 | 320 |
321 ;; Path setup | |
322 | |
2456 | 323 (defun packages-find-package-hierarchies-named (package-directories base) |
324 "Find a set of package hierarchies within an XEmacs installation. | |
325 PACKAGE-DIRECTORIES is a list of package directories. | |
326 BASE is a subdirectory name for the hierarchy. | |
327 Returns list of hierarchies." | |
328 (paths-directories-which-exist | |
329 (mapcar #'(lambda (package-directory) | |
3179 | 330 (file-name-as-directory |
331 (concat (file-name-as-directory package-directory) | |
332 base))) | |
2456 | 333 package-directories))) |
428 | 334 |
335 (defun packages-split-path (path) | |
336 "Split PATH at \"\", return pair with two components. | |
337 The second component is shared with PATH." | |
338 (let ((reverse-tail '()) | |
339 (rest path)) | |
340 (while (and rest (null (string-equal "" (car rest)))) | |
341 (setq reverse-tail (cons (car rest) reverse-tail)) | |
342 (setq rest (cdr rest))) | |
343 (if (null rest) | |
344 (cons path nil) | |
345 (cons (nreverse reverse-tail) (cdr rest))))) | |
346 | |
347 (defun packages-split-package-path (package-path) | |
348 "Split up PACKAGE-PATH into early, late and last components. | |
349 The separation is by \"\" components. | |
2456 | 350 This returns |
351 (LIST EARLY-PACKAGE-HIERARCHIES LATE-PACKAGE-HIERARCHIES LAST-PACKAGE-HIERARCHIES)." | |
428 | 352 ;; When in doubt, it's late |
353 (let* ((stuff (packages-split-path package-path)) | |
354 (early (and (cdr stuff) (car stuff))) | |
355 (late+last (or (cdr stuff) (car stuff))) | |
356 (stuff (packages-split-path late+last)) | |
357 (late (car stuff)) | |
358 (last (cdr stuff))) | |
2456 | 359 (list (mapcar #'file-name-as-directory early) |
360 (mapcar #'file-name-as-directory late) | |
361 (mapcar #'file-name-as-directory last)))) | |
428 | 362 |
363 (defun packages-deconstruct (list consumer) | |
2456 | 364 "Deconstruct LIST and feed it to CONSUMER. |
365 CONSUMER is a function that accepts the elements of LISTS as separate arguments." | |
428 | 366 (apply consumer list)) |
367 | |
2456 | 368 (defun packages-find-installation-package-directories (roots) |
369 "Find the package directories in the XEmacs installation. | |
370 ROOTS is a list of installation roots." | |
5003
6b6b0f8ab749
#'union doesn't preserve relative order; use #'delete-duplicates instead.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4919
diff
changeset
|
371 (delete-duplicates |
6b6b0f8ab749
#'union doesn't preserve relative order; use #'delete-duplicates instead.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4919
diff
changeset
|
372 (nconc (paths-find-version-directories roots (list "") nil nil nil t) |
6b6b0f8ab749
#'union doesn't preserve relative order; use #'delete-duplicates instead.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4919
diff
changeset
|
373 (paths-find-site-directories roots (list "") nil)) |
6b6b0f8ab749
#'union doesn't preserve relative order; use #'delete-duplicates instead.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4919
diff
changeset
|
374 :test #'equal)) |
428 | 375 |
3179 | 376 (defun packages-find-package-hierarchies (package-directories &optional envvar default) |
2456 | 377 "Find package hierarchies in a list of package directories. |
378 PACKAGE-DIRECTORIES is a list of package directories. | |
3179 | 379 DEFAULT is a default list of package hierarchies. |
380 ENVVAR is the name of an environment variable that may override | |
381 the default." | |
382 (let* ((envvar-value (and envvar (getenv envvar))) | |
383 (package-directories | |
384 (if envvar-value | |
385 (split-path envvar-value) | |
386 package-directories))) | |
387 | |
388 (or (and (not envvar-value) default) | |
389 (let ((package-hierarchies '()) | |
390 (hierarchy-directories (packages-package-hierarchy-directory-names))) | |
391 (while hierarchy-directories | |
392 (setq package-hierarchies | |
393 (nconc package-hierarchies | |
394 (packages-find-package-hierarchies-named | |
395 package-directories | |
396 (car hierarchy-directories)))) | |
397 (setq hierarchy-directories (cdr hierarchy-directories))) | |
398 package-hierarchies)))) | |
2456 | 399 |
400 (defun packages-find-all-package-hierarchies (roots) | |
3179 | 401 "Find the package hierarchies. |
2456 | 402 ROOTS is a list of installation roots. |
403 Returns a list of three directory lists, the first being the list of early | |
404 hierarchies, the second that of the late hierarchies, and the third the | |
405 list of the last hierarchies." | |
3179 | 406 ;; EMACSPACKAGEPATH is a historical kludge |
428 | 407 (let ((envvar-value (getenv "EMACSPACKAGEPATH"))) |
3179 | 408 (cond |
409 (envvar-value | |
3184 | 410 (packages-deconstruct |
411 (packages-split-package-path (paths-decode-directory-path envvar-value)) | |
412 ;; we get package *directories* | |
413 #'(lambda (early late last) | |
414 (list | |
415 (packages-find-package-hierarchies early | |
416 "EMACSEARLYPACKAGES") | |
417 (packages-find-package-hierarchies late | |
418 "EMACSLATEPACKAGES") | |
419 (packages-find-package-hierarchies last | |
420 "EMACSLATEPACKAGES"))))) | |
421 ;; --with-package-path is also a historical kludge | |
3179 | 422 (configure-package-path |
428 | 423 (packages-deconstruct |
424 (packages-split-package-path configure-package-path) | |
3184 | 425 ;; we get package *hierarchies* |
3179 | 426 #'(lambda (early late last) |
2456 | 427 (list |
428 (packages-find-package-hierarchies (list user-init-directory) | |
3179 | 429 "EMACSEARLYPACKAGES" |
430 early) | |
2456 | 431 (packages-find-package-hierarchies (packages-find-installation-package-directories roots) |
3179 | 432 "EMACSLATEPACKAGES" |
433 | |
434 late) | |
2456 | 435 (packages-find-package-hierarchies '() |
3179 | 436 "EMACSLASTPACKAGES" |
437 last))))) | |
438 (t | |
439 (list | |
440 (packages-find-package-hierarchies (or configure-early-package-directories | |
441 (list user-init-directory)) | |
442 "EMACSEARLYPACKAGES") | |
443 (packages-find-package-hierarchies (or configure-late-package-directories | |
444 (packages-find-installation-package-directories roots)) | |
445 "EMACSLATEPACKAGES") | |
446 (packages-find-package-hierarchies configure-last-package-directories | |
447 "EMACSLASTPACKAGES")))))) | |
448 | |
2456 | 449 (defun packages-find-package-library-path (package-hierarchies suffixes) |
428 | 450 "Construct a path into a component of the packages hierarchy. |
2456 | 451 PACKAGE-HIERARCHIES is a list of package hierarchies. |
452 SUFFIXES is a list of names of hierarchy subdirectories to look for." | |
428 | 453 (let ((directories |
5264
0d43872986b6
Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5228
diff
changeset
|
454 (mapcan #'(lambda (hierarchy) |
0d43872986b6
Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5228
diff
changeset
|
455 (mapcar #'(lambda (suffix) |
0d43872986b6
Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5228
diff
changeset
|
456 (file-name-as-directory (concat hierarchy suffix))) |
0d43872986b6
Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5228
diff
changeset
|
457 suffixes)) |
0d43872986b6
Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5228
diff
changeset
|
458 package-hierarchies))) |
428 | 459 (paths-directories-which-exist directories))) |
460 | |
2456 | 461 (defun packages-find-package-load-path (package-hierarchies) |
428 | 462 "Construct the load-path component for packages. |
2456 | 463 PACKAGE-HIERARCHIES is a list of package hierarchies." |
428 | 464 (paths-find-recursive-load-path |
2456 | 465 (packages-find-package-library-path package-hierarchies |
428 | 466 '("lisp")) |
467 packages-load-path-depth)) | |
468 | |
2456 | 469 (defun packages-find-package-exec-path (package-hierarchies) |
428 | 470 "Construct the exec-path component for packages. |
2456 | 471 PACKAGE-HIERARCHIES is a list of package hierarchies." |
472 (packages-find-package-library-path package-hierarchies | |
428 | 473 (list (paths-construct-path |
474 (list "bin" system-configuration)) | |
475 "lib-src"))) | |
476 | |
2456 | 477 (defun packages-find-package-info-path (package-hierarchies) |
428 | 478 "Construct the info-path component for packages. |
2456 | 479 PACKAGE-HIERARCHIES is a list of package directories." |
480 (packages-find-package-library-path package-hierarchies '("info"))) | |
428 | 481 |
2456 | 482 (defun packages-find-package-data-path (package-hierarchies) |
428 | 483 "Construct the data-path component for packages. |
2456 | 484 PACKAGE-HIERARCHIES is a list of package hierachies." |
428 | 485 (paths-find-recursive-load-path |
2456 | 486 (packages-find-package-library-path package-hierarchies |
428 | 487 '("etc")) |
488 packages-data-path-depth)) | |
489 | |
490 ;; Loading package initialization files | |
491 | |
492 (defun packages-load-package-lisps (package-load-path base) | |
493 "Load all Lisp files of a certain name along a load path. | |
494 BASE is the base name of the files." | |
495 (mapcar #'(lambda (dir) | |
793 | 496 (let ((file-name (expand-file-name base dir))) |
497 (with-trapping-errors | |
498 :operation (format "Autoload %s" file-name) | |
499 :class 'packages | |
500 (load file-name t t)))) | |
501 package-load-path)) | |
428 | 502 |
503 (defun packages-load-package-auto-autoloads (package-load-path) | |
504 "Load auto-autoload files along a load path." | |
505 (packages-load-package-lisps package-load-path | |
506 (file-name-sans-extension autoload-file-name))) | |
507 | |
508 (defun packages-handle-package-dumped-lisps (handle package-load-path) | |
509 "Load dumped-lisp.el files along a load path. | |
510 Call HANDLE on each file off definitions of PACKAGE-LISP there." | |
511 (mapcar #'(lambda (dir) | |
512 (let ((file-name (expand-file-name "dumped-lisp.el" dir))) | |
513 (if (file-exists-p file-name) | |
514 (let (package-lisp | |
515 ;; 20.4 packages could set this | |
516 preloaded-file-list) | |
517 (load file-name) | |
518 ;; dumped-lisp.el could have set this ... | |
519 (if package-lisp | |
520 (mapcar #'(lambda (base) | |
521 (funcall handle base)) | |
522 package-lisp)))))) | |
523 package-load-path)) | |
524 | |
525 (defun packages-load-package-dumped-lisps (package-load-path) | |
526 "Load dumped-lisp.el files along a load path. | |
444 | 527 Also load files off PACKAGE-LISP definitions there." |
428 | 528 (packages-handle-package-dumped-lisps #'load package-load-path)) |
529 | |
530 (defun packages-collect-package-dumped-lisps (package-load-path) | |
531 "Load dumped-lisp.el files along a load path. | |
444 | 532 Return list of files off PACKAGE-LISP definitions there." |
428 | 533 (let ((*files* '())) |
534 (packages-handle-package-dumped-lisps | |
535 #'(lambda (file) | |
536 (setq *files* (cons file *files*))) | |
537 package-load-path) | |
538 (reverse *files*))) | |
539 | |
540 (provide 'packages) | |
541 | |
542 ;;; packages.el ends here |