From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Juanma Barranquero" Newsgroups: gmane.emacs.devel Subject: Re: unload-feature questions and thoughts Date: Thu, 18 Oct 2007 01:39:44 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1192664506 8890 80.91.229.12 (17 Oct 2007 23:41:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Oct 2007 23:41:46 +0000 (UTC) Cc: emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 18 01:41:46 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IiIWD-0007ME-3r for ged-emacs-devel@m.gmane.org; Thu, 18 Oct 2007 01:41:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IiIVs-00059j-Em for ged-emacs-devel@m.gmane.org; Wed, 17 Oct 2007 19:41:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IiIUk-0004mS-RH for emacs-devel@gnu.org; Wed, 17 Oct 2007 19:40:10 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IiIUg-0004kE-7N for emacs-devel@gnu.org; Wed, 17 Oct 2007 19:40:10 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IiIUf-0004k5-UI for emacs-devel@gnu.org; Wed, 17 Oct 2007 19:40:05 -0400 Original-Received: from py-out-1112.google.com ([64.233.166.183]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IiIUc-000826-Hj for emacs-devel@gnu.org; Wed, 17 Oct 2007 19:40:05 -0400 Original-Received: by py-out-1112.google.com with SMTP id a73so5202829pye for ; Wed, 17 Oct 2007 16:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=2BCOwLTFw/qrdNEjn7j0Dke/w9vQ27SrzgDsx76WiAc=; b=hMTc9E6uacb3YhBdDxphD1oylc0E+rue3C7VevsHRUTXB422V+4Cbu7MH2EHXAMUEewI+zfV9okNgQ7M5DXGlB/3A00r5WywjtbQpJIa3h1P4jph9xQEkbhSRrjSoErJFrqs6uR3tAq6zLIyT7zcH1Jtv9tT9/QFLgxrwufyAbY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=J4XgBT5EwItUmRY85S+SUV1ZzdYeZmhdKLHRjkp9zV5PgG2gcDsSE44h3NYjYCkbWQbhAiTCihS2+M3NvBCYE8tr36dEmlM4VzbFBgkD8FGBF6UPoskLDBGrtvpjHttXnSpexgmCZkKB4m7LW4Ew4hsAwxBbgxvUMguDIRP6YK0= Original-Received: by 10.115.77.1 with SMTP id e1mr150577wal.1192664384705; Wed, 17 Oct 2007 16:39:44 -0700 (PDT) Original-Received: by 10.115.72.13 with HTTP; Wed, 17 Oct 2007 16:39:44 -0700 (PDT) In-Reply-To: Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:81109 Archived-At: On 10/17/07, Richard Stallman 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 * 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)