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, 11 Oct 2007 17:16:14 +0200 Message-ID: References: <861wl5q7al.fsf@lola.quinscape.zz> <54853.128.165.123.18.1192027947.squirrel@webmail.lanl.gov> <55463.128.165.123.18.1192035787.squirrel@webmail.lanl.gov> <55585.128.165.123.18.1192038971.squirrel@webmail.lanl.gov> <858x6atas5.fsf@lola.goethe.zz> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1192115805 18243 80.91.229.12 (11 Oct 2007 15:16:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 11 Oct 2007 15:16:45 +0000 (UTC) Cc: Emacs Devel To: "David Kastrup" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 11 17:16:44 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 1Ifzm3-00088D-OT for ged-emacs-devel@m.gmane.org; Thu, 11 Oct 2007 17:16:32 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ifzlx-0005oJ-88 for ged-emacs-devel@m.gmane.org; Thu, 11 Oct 2007 11:16:25 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ifzlt-0005o4-IS for emacs-devel@gnu.org; Thu, 11 Oct 2007 11:16:21 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ifzlo-0005m5-4C for emacs-devel@gnu.org; Thu, 11 Oct 2007 11:16:20 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ifzln-0005m2-Tv for emacs-devel@gnu.org; Thu, 11 Oct 2007 11:16:15 -0400 Original-Received: from wx-out-0506.google.com ([66.249.82.234]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ifzln-0003cy-4s for emacs-devel@gnu.org; Thu, 11 Oct 2007 11:16:15 -0400 Original-Received: by wx-out-0506.google.com with SMTP id s7so526175wxc for ; Thu, 11 Oct 2007 08:16:14 -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=iwy+9WnlKJenNps54EUTHgDbxCJPlR+Uh8UEtWJK3fI=; b=YuhabMRfrvbmR3gqYHHeBmq6GO+N1zk8FrlI+BHKNu3rl5t4/nCjwZMRfH1ce2Tj9OV8pgFi3CibFjONKz+WISBxtoTFNMXFjwjqWgJ5tz99ABcYCS1prCLqlrRnHLR58maayM4NxfLQORACCCagIJeAFi6QCgyjsNM4Mn1ZQ7Y= 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=osDt38ssY1GSudArbQK0VHK859QCJ4wmuVueCTjKFckk7gl/sdko6VT8F4aV55PemtKm7ts/E7zd9WXdcwgMF2mtUQ/0RTc7IqGXzopI4m2Y1NkbGTIbxcnv8wp1kOYA8Ykm2DYgDufy4SHdgzfGXL02zRL5iHt3VmXpZ6O9Auo= Original-Received: by 10.90.51.17 with SMTP id y17mr3109752agy.1192115774260; Thu, 11 Oct 2007 08:16:14 -0700 (PDT) Original-Received: by 10.90.103.8 with HTTP; Thu, 11 Oct 2007 08:16:14 -0700 (PDT) In-Reply-To: <858x6atas5.fsf@lola.goethe.zz> 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:80626 Archived-At: On 10/11/07, David Kastrup wrote: > While the "no one knows" is somewhat accurate (it was a > combination of reverse engineering and trial and error to make me > understand the implications), it is likely not true that nothing will > break by changes in that area where external packages are concerned. I agree with Davis in believing the breakage would be small, but I'm not necessarily in favor of introducing gratuitous incompatibilities if they can be avoided. So, let's just add something like the following trivial patch, which just adds a new FEATURE-unload-function hook and leaves the old FEATURE-unload-hook untouched (and undocumented). The patch uses diff -b to avoid noise, and most of it is the renaming of `unload-hook-features-list' to `unload-function-features-list' (which not really necessary, but it'd be nice). Other than that, the change is about four lines worth of code, less than ten if you count an obsolescence declaration and a comment... And of course I've not touched the docstring of `unload-feature'; that would be for someone other than me to fix. WDPT? Juanma Index: lisp/loadhist.el =================================================================== RCS file: /sources/emacs/emacs/lisp/loadhist.el,v retrieving revision 1.48 diff -u -b -r1.48 loadhist.el --- lisp/loadhist.el 26 Jul 2007 05:26:27 -0000 1.48 +++ lisp/loadhist.el 11 Oct 2007 11:05:34 -0000 @@ -142,11 +142,13 @@ `-hook' or `-hooks', from which `unload-feature' tries to remove pertinent symbols.") -(defvar unload-hook-features-list nil +(defvar unload-function-features-list nil "List of features of the package being unloaded. -This is meant to be used by FEATURE-unload-hook hooks, see the +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) @@ -175,19 +177,25 @@ (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)) + (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 - (unload-hook (intern-soft (concat (symbol-name feature) - "-unload-hook")))) + (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'. - (if 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 @@ -202,22 +210,22 @@ (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) + (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-hook-features-list) + (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-hook-features-list) + (dolist (elt unload-function-features-list) (when (symbolp elt) (elp-restore-function elt)))) - (dolist (x unload-hook-features-list) + (dolist (x unload-function-features-list) (if (consp x) (case (car x) ;; Remove any feature names that this file provided. @@ -250,7 +258,7 @@ (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))) + (setq load-history (delq (assoc file load-history) load-history)))) ;; Don't return load-history, it is not useful. nil)