emacs-devel
[Top][All Lists]
Advanced

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

Re: unload-feature questions and thoughts


From: Richard Stallman
Subject: Re: unload-feature questions and thoughts
Date: Mon, 05 Feb 2007 14:10:33 -0500

     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.

Since the presence of such entries is normal, `unload-feature' ought
to handle such entries in a useful way.

Would someone like to implement this?

    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").

Of these two, it would definitely be better to do nothing.
Signaling an error in circumstances that are normal is perverse.

It should not be hard to add a way to delete a face, but let's leave
that for later.

                                                      Autoload entries,
    OTOH, can be unloaded like a function; so I propose to commit the
    attached patch.

Your patch to handle an `autoload' entry like an `defun' entry seems
correct.

Meanwhile, I think another change is needed to handle `(t . SYMBOL)'
elements correctly.  See below.  Does anyone else see a problem in it?

     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?

It is ok to make it return nil.



*** loadhist.el 21 Jan 2007 01:36:08 -0500      1.43
--- loadhist.el 05 Feb 2007 13:30:24 -0500      
***************
*** 173,178 ****
--- 173,181 ----
               (prin1-to-string dependents) file))))
    (let* ((unload-hook-features-list (feature-symbols feature))
           (file (pop unload-hook-features-list))
+        ;; If non-nil, this is a symbol for which we should
+        ;; restore a previous autoload if possible.
+        restore-autoload
           (unload-hook (intern-soft (concat (symbol-name feature)
                                             "-unload-hook"))))
      ;; Try to avoid losing badly when hooks installed in critical
***************
*** 209,214 ****
--- 212,218 ----
        (dolist (elt unload-hook-features-list)
        (when (symbolp elt)
          (elp-restore-function elt))))
+ 
      (dolist (x unload-hook-features-list)
        (if (consp x)
          (case (car x)
***************
*** 221,230 ****
                (when (fboundp 'ad-unadvise)
                  (ad-unadvise fun))
                (let ((aload (get fun 'autoload)))
!                 (if aload
                        (fset fun (cons 'autoload aload))
                      (fmakunbound fun))))))
!            ((t require) nil)
           (t (message "Unexpected element %s in load-history" x)))
        ;; Kill local values as much as possible.
        (dolist (buf (buffer-list))
--- 225,238 ----
                (when (fboundp 'ad-unadvise)
                  (ad-unadvise fun))
                (let ((aload (get fun 'autoload)))
!                 (if (and aload (eq fun restore-autoload))
                        (fset fun (cons 'autoload aload))
                      (fmakunbound fun))))))
!          ;; (t . SYMBOL) comes before (defun . SYMBOL)
!          ;; and says we should restore SYMBOL's autoload
!          ;; when we undefine it.
!          (t (setq restore-autoload (cdr x)))
!            (require nil)
           (t (message "Unexpected element %s in load-history" x)))
        ;; Kill local values as much as possible.
        (dolist (buf (buffer-list))




reply via email to

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