all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Juanma Barranquero" <lekktu@gmail.com>
To: "David Kastrup" <dak@gnu.org>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: unload-feature questions and thoughts
Date: Thu, 11 Oct 2007 17:16:14 +0200	[thread overview]
Message-ID: <f7ccd24b0710110816icc17b2fp24f9e3d6abdb41b@mail.gmail.com> (raw)
In-Reply-To: <858x6atas5.fsf@lola.goethe.zz>

On 10/11/07, David Kastrup <dak@gnu.org> 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)

  reply	other threads:[~2007-10-11 15:16 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-04 18:03 unload-feature questions and thoughts Juanma Barranquero
2007-02-04 18:32 ` David Kastrup
2007-02-04 19:07   ` Juanma Barranquero
2007-02-04 19:14     ` David Kastrup
2007-02-05  0:10       ` Juanma Barranquero
2007-02-05  7:21         ` David Kastrup
2007-02-05  9:21           ` Juanma Barranquero
2007-02-05  9:32             ` David Kastrup
2007-02-05 11:08               ` Juanma Barranquero
2007-02-05 11:16                 ` David Kastrup
2007-02-05 11:40                   ` Juanma Barranquero
2007-02-06  0:16                 ` Richard Stallman
2007-10-10 11:04                 ` Juanma Barranquero
2007-10-10 14:52                   ` Davis Herring
2007-10-10 16:08                     ` Juanma Barranquero
2007-10-10 17:03                       ` Davis Herring
2007-10-10 17:07                         ` Juanma Barranquero
2007-10-10 17:56                           ` Davis Herring
2007-10-11  5:20                             ` Richard Stallman
2007-10-11  6:39                             ` David Kastrup
2007-10-11 15:16                               ` Juanma Barranquero [this message]
2007-10-12 15:59                                 ` Richard Stallman
2007-10-12 17:01                                   ` Juanma Barranquero
2007-10-13  6:41                                     ` Richard Stallman
2007-10-13 10:03                                       ` Juanma Barranquero
2007-10-14 16:28                                         ` Richard Stallman
2007-10-14 22:34                                           ` Juanma Barranquero
2007-10-15 16:03                                             ` Richard Stallman
2007-10-15 16:22                                               ` Juanma Barranquero
2007-10-16  4:10                                                 ` Richard Stallman
2007-10-16  8:15                                                   ` Juanma Barranquero
2007-10-17  5:02                                                     ` Richard Stallman
2007-10-17 23:39                                                       ` Juanma Barranquero
2007-10-23 19:27                                           ` Davis Herring
2007-10-24  8:32                                             ` Richard Stallman
2007-10-11 16:41                               ` Davis Herring
2007-10-12  2:46                               ` Richard Stallman
2007-10-25 21:24                                 ` David Kastrup
2007-10-28 13:51                                   ` Richard Stallman
2007-10-10 21:03                   ` Richard Stallman
2007-10-10 21:42                     ` Juanma Barranquero
2007-02-05 19:10 ` Richard Stallman
2007-02-05 23:27   ` Juanma Barranquero
2007-02-06 17:09     ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7ccd24b0710110816icc17b2fp24f9e3d6abdb41b@mail.gmail.com \
    --to=lekktu@gmail.com \
    --cc=dak@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.