From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: unload-feature questions and thoughts Date: Mon, 05 Feb 2007 14:10:33 -0500 Message-ID: References: Reply-To: rms@gnu.org NNTP-Posting-Host: lo.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: sea.gmane.org 1170702776 3590 80.91.229.12 (5 Feb 2007 19:12:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 5 Feb 2007 19:12:56 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Juanma Barranquero" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 05 20:12:49 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 1HE9Ge-0006Tz-M7 for ged-emacs-devel@m.gmane.org; Mon, 05 Feb 2007 20:12:44 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HE9Ge-0001cx-4Q for ged-emacs-devel@m.gmane.org; Mon, 05 Feb 2007 14:12:44 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HE9Fe-0000ZP-Uj for emacs-devel@gnu.org; Mon, 05 Feb 2007 14:11:42 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HE9Fe-0000YC-1K for emacs-devel@gnu.org; Mon, 05 Feb 2007 14:11:42 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HE9Fd-0000Xr-QA for emacs-devel@gnu.org; Mon, 05 Feb 2007 14:11:41 -0500 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by monty-python.gnu.org with esmtp (Exim 4.52) id 1HE9Fd-0005af-J0 for emacs-devel@gnu.org; Mon, 05 Feb 2007 14:11:41 -0500 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.60) (envelope-from ) id 1HE9EX-0005d0-BR; Mon, 05 Feb 2007 14:10:33 -0500 In-reply-to: (lekktu@gmail.com) X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) 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:65941 Archived-At: 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))