[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

unload-feature questions and thoughts

From: Juanma Barranquero
Subject: unload-feature questions and thoughts
Date: Sun, 4 Feb 2007 19:03:35 +0100

1.- Currently, `unload-feature' (from loadhist.el) does not expect
entries on `load-history' of the form (autoload . SYMBOL) or (defface
. SYMBOL). Unloading a package which defines either one produces
messages like

 Unexpected element (defface . myface) in load-history

which should be reserved, I think, to really unexpected items in the
load-history, not perfectly usual ones like those above.

AFAICS, there's no way to delete an existing face, so ignoring the
item is the best option (or, alternatively, giving a more significant
warning, like "Face MYFACE can not be unloaded"). Autoload entries,
OTOH, can be unloaded like a function; so I propose to commit the
attached patch.

2.- `unload-feature' returns `load-history', but this is not
documented, and a PITA when you're using `unload-feature' in a context
that evaluates its result, like IELM. Should we document what it does
now, or (preferred) just force it to return nil?

3.- A weirdness of load vs. autoload. Let's suppose we have a package
test.el, with:

 ;;;;; test.el ;;;;;
 (defun test-fun () (interactive) t)
 (provide 'test)

and we create an autoload for it:

 (autoload 'test-fun "test" nil t)

Now, if we do load test.el by using the autoload mechanism, i.e.,

 M-x test-fun RET

then the autoload is recorded:

 (get 'test-fun 'autoload) => ("test" nil t nil)

However, if we load test.el with `load' or `require', the autoload is
not recorded:

 (require 'test)
 (get 'test-fun 'autoload) => nil

Which is not very important, but affects the ability of
`unload-feature' to do its work: it cannot restore an autoload if it
is not recorded in the property list.


Index: lisp/ChangeLog
RCS file: /cvsroot/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.10649
diff -u -2 -r1.10649 ChangeLog
--- lisp/ChangeLog      4 Feb 2007 17:29:50 -0000       1.10649
+++ lisp/ChangeLog      4 Feb 2007 17:50:33 -0000
@@ -1,2 +1,8 @@
+2007-02-04  Juanma Barranquero  <address@hidden>
+       * loadhist.el (unload-feature): Process also `load-history'
+       entries of the form `(autoload . SYMBOL)' (by treating them like
+       `defun'), and `(defface . SYMBOL)' (by ignoring them).
2007-02-04  David Kastrup  <address@hidden>

Index: lisp/loadhist.el
RCS file: /cvsroot/emacs/emacs/lisp/loadhist.el,v
retrieving revision 1.43
diff -u -2 -r1.43 loadhist.el
--- lisp/loadhist.el    21 Jan 2007 03:53:11 -0000      1.43
+++ lisp/loadhist.el    4 Feb 2007 16:59:22 -0000
@@ -216,5 +216,5 @@
            (setq features (delq (cdr x) features)))
-          (defun
+          ((defun autoload)
            (let ((fun (cdr x)))
              (when (fboundp fun)
@@ -225,5 +225,5 @@
                      (fset fun (cons 'autoload aload))
                    (fmakunbound fun))))))
-           ((t require) nil)
+           ((t require defface) nil)
           (t (message "Unexpected element %s in load-history" x)))
        ;; Kill local values as much as possible.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]