[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: unload-feature questions and thoughts
From: |
Juanma Barranquero |
Subject: |
Re: unload-feature questions and thoughts |
Date: |
Thu, 18 Oct 2007 01:39:44 +0200 |
On 10/17/07, Richard Stallman <address@hidden> wrote:
> I guess your idea is a good one. Would you like to implement it?
The implementation is trivial (see the attached patch), other than
updating the docstring of `unload-feature', which I'm unable to do.
Juanma
2007-10-17 Juanma Barranquero <address@hidden>
* loadhist.el (unload-function-features-list):
Rename from `unload-hook-features-list'.
(unload-hook-features-list): Add as obsolete alias.
(unload-feature): Use `unload-function-features-list'
and new FEATURE-unload-function.
Index: lisp/loadhist.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/loadhist.el,v
retrieving revision 1.50
diff -c -b -r1.50 loadhist.el
*** lisp/loadhist.el 17 Oct 2007 23:03:55 -0000 1.50
--- lisp/loadhist.el 17 Oct 2007 23:16:28 -0000
***************
*** 137,147 ****
`-hook' or `-hooks', from which `unload-feature' tries to remove
pertinent symbols.")
! (defvar unload-hook-features-list nil
"List of features of the package being unloaded.
! This is meant to be used by FEATURE-unload-hook hooks, see the
documentation of `unload-feature' for details.")
;;;###autoload
(defun unload-feature (feature &optional force)
--- 137,149 ----
`-hook' or `-hooks', from which `unload-feature' tries to remove
pertinent symbols.")
! (defvar unload-function-features-list nil
"List of features of the package being unloaded.
! This is meant to be used by FEATURE-unload-function, see the
documentation of `unload-feature' for details.")
+ (define-obsolete-variable-alias 'unload-hook-features-list
+ 'unload-function-features-list "23.1")
;;;###autoload
(defun unload-feature (feature &optional force)
***************
*** 172,190 ****
(when dependents
(error "Loaded libraries %s depend on %s"
(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
;; places go away. (Some packages install things on
;; `kill-buffer-hook', `activate-menubar-hook' and the like.)
;; First off, provide a clean way for package FOO to arrange
;; this by adding hooks on the variable `FOO-unload-hook'.
! (if unload-hook
(run-hooks unload-hook)
;; Otherwise, do our best. Look through the obarray for symbols
;; which seem to be hook variables or special hook functions and
--- 174,198 ----
(when dependents
(error "Loaded libraries %s depend on %s"
(prin1-to-string dependents) file))))
! (let* ((unload-function-features-list (feature-symbols feature))
! (file (pop unload-function-features-list))
;; If non-nil, this is a symbol for which we should
;; restore a previous autoload if possible.
restore-autoload
! (name (symbol-name feature))
! (unload-hook (intern-soft (concat name "-unload-hook")))
! (unload-func (intern-soft (concat name "-unload-function"))))
! ;; If FEATURE-unload-function is defined and returns non-nil,
! ;; don't try to do anything more; otherwise proceed normally.
! (unless (and (bound-and-true-p unload-func)
! (funcall unload-func))
;; Try to avoid losing badly when hooks installed in critical
;; places go away. (Some packages install things on
;; `kill-buffer-hook', `activate-menubar-hook' and the like.)
+ (if unload-hook
;; First off, provide a clean way for package FOO to arrange
;; this by adding hooks on the variable `FOO-unload-hook'.
! ;; This is obsolete; FEATURE-unload-function should be used now.
(run-hooks unload-hook)
;; Otherwise, do our best. Look through the obarray for symbols
;; which seem to be hook variables or special hook functions and
***************
*** 199,220 ****
(or (and (consp (symbol-value x)) ; Random hooks.
(string-match "-hooks?\\'" (symbol-name x)))
(memq x unload-feature-special-hooks))) ; Known
abnormal hooks etc.
! (dolist (y unload-hook-features-list)
(when (and (eq (car-safe y) 'defun)
(not (get (cdr y) 'autoload)))
(remove-hook x (cdr y)))))))
;; Remove any feature-symbols from auto-mode-alist as well.
! (dolist (y unload-hook-features-list)
(when (and (eq (car-safe y) 'defun)
(not (get (cdr y) 'autoload)))
(setq auto-mode-alist
(rassq-delete-all (cdr y) auto-mode-alist)))))
(when (fboundp 'elp-restore-function) ; remove ELP stuff first
! (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)
;; Remove any feature names that this file provided.
--- 207,228 ----
(or (and (consp (symbol-value x)) ; Random hooks.
(string-match "-hooks?\\'" (symbol-name x)))
(memq x unload-feature-special-hooks))) ; Known
abnormal hooks etc.
! (dolist (y unload-function-features-list)
(when (and (eq (car-safe y) 'defun)
(not (get (cdr y) 'autoload)))
(remove-hook x (cdr y)))))))
;; Remove any feature-symbols from auto-mode-alist as well.
! (dolist (y unload-function-features-list)
(when (and (eq (car-safe y) 'defun)
(not (get (cdr y) 'autoload)))
(setq auto-mode-alist
(rassq-delete-all (cdr y) auto-mode-alist)))))
(when (fboundp 'elp-restore-function) ; remove ELP stuff first
! (dolist (elt unload-function-features-list)
(when (symbolp elt)
(elp-restore-function elt))))
! (dolist (x unload-function-features-list)
(if (consp x)
(case (car x)
;; Remove any feature names that this file provided.
***************
*** 247,253 ****
(unless (local-variable-if-set-p x)
(makunbound x))))
;; Delete the load-history element for this file.
! (setq load-history (delq (assoc file load-history) load-history)))
;; Don't return load-history, it is not useful.
nil)
--- 255,261 ----
(unless (local-variable-if-set-p x)
(makunbound x))))
;; Delete the load-history element for this file.
! (setq load-history (delq (assoc file load-history) load-history))))
;; Don't return load-history, it is not useful.
nil)
- Re: unload-feature questions and thoughts, (continued)
- Re: unload-feature questions and thoughts, Juanma Barranquero, 2007/10/12
- Re: unload-feature questions and thoughts, Richard Stallman, 2007/10/13
- Re: unload-feature questions and thoughts, Juanma Barranquero, 2007/10/13
- Re: unload-feature questions and thoughts, Richard Stallman, 2007/10/14
- Re: unload-feature questions and thoughts, Juanma Barranquero, 2007/10/14
- Re: unload-feature questions and thoughts, Richard Stallman, 2007/10/15
- Re: unload-feature questions and thoughts, Juanma Barranquero, 2007/10/15
- Re: unload-feature questions and thoughts, Richard Stallman, 2007/10/16
- Re: unload-feature questions and thoughts, Juanma Barranquero, 2007/10/16
- Re: unload-feature questions and thoughts, Richard Stallman, 2007/10/17
- Re: unload-feature questions and thoughts,
Juanma Barranquero <=
- Re: unload-feature questions and thoughts, Davis Herring, 2007/10/23
- Re: unload-feature questions and thoughts, Richard Stallman, 2007/10/24
- Re: unload-feature questions and thoughts, Davis Herring, 2007/10/11
- Re: unload-feature questions and thoughts, Richard Stallman, 2007/10/11
- Re: unload-feature questions and thoughts, David Kastrup, 2007/10/25
- Re: unload-feature questions and thoughts, Richard Stallman, 2007/10/28
Re: unload-feature questions and thoughts, Richard Stallman, 2007/10/10