From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history Date: Tue, 18 Jul 2017 10:25:56 -0400 Message-ID: References: <87mv99n0ac.fsf@detlef> <87o9sjme8n.fsf@detlef> <87y3rm2pbw.fsf@detlef> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1500388951 31857 195.159.176.226 (18 Jul 2017 14:42:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 18 Jul 2017 14:42:31 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 27371@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jul 18 16:42:23 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXThb-0007h9-Fq for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Jul 2017 16:42:19 +0200 Original-Received: from localhost ([::1]:56927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXThh-00065t-4Y for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Jul 2017 10:42:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58921) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXTSr-0000SA-9K for bug-gnu-emacs@gnu.org; Tue, 18 Jul 2017 10:27:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXTSo-0005lR-Kq for bug-gnu-emacs@gnu.org; Tue, 18 Jul 2017 10:27:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44014) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dXTSo-0005lI-H3 for bug-gnu-emacs@gnu.org; Tue, 18 Jul 2017 10:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dXTSo-0005aA-4h for bug-gnu-emacs@gnu.org; Tue, 18 Jul 2017 10:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Jul 2017 14:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27371 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27371-submit@debbugs.gnu.org id=B27371.150038796321379 (code B ref 27371); Tue, 18 Jul 2017 14:27:02 +0000 Original-Received: (at 27371) by debbugs.gnu.org; 18 Jul 2017 14:26:03 +0000 Original-Received: from localhost ([127.0.0.1]:46687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXTRq-0005Yk-DN for submit@debbugs.gnu.org; Tue, 18 Jul 2017 10:26:03 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:43758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXTRn-0005YJ-La for 27371@debbugs.gnu.org; Tue, 18 Jul 2017 10:26:01 -0400 Original-Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id v6IEPvNC032084; Tue, 18 Jul 2017 10:25:57 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id E83D9660CC; Tue, 18 Jul 2017 10:25:56 -0400 (EDT) In-Reply-To: <87y3rm2pbw.fsf@detlef> (Michael Albinus's message of "Tue, 18 Jul 2017 09:09:55 +0200") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6074=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6074> : inlines <5979> : streams <1754727> : uri <2465302> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:134715 Archived-At: >>> However, it just skips the entry. Wouldn't it be better to remove the >>> defstruct itself, and all inherited symbols? And where could I find >>> information how to destroy a defstruct? >> Better would be to add some hook so cl-lib can add support for >> define-type. > Likely yes. But I'm not familiar with cl*; I have no idea how such a > hook should look like. And how it shall be implemented. The hook shouldn't be specific to cl. Maybe something like the patch below would make sense? Then we can add support for define-type, ert-deftest, cl-defmethod, ... Stefan diff --git a/lisp/loadhist.el b/lisp/loadhist.el index 28d0b18c81..bf15399c11 100644 --- a/lisp/loadhist.el +++ b/lisp/loadhist.el @@ -162,6 +162,60 @@ unload--set-major-mode ;; mode, or proposed is not nil and not major-mode, and so we use it. (funcall (or proposed 'fundamental-mode))))))) +(cl-defgeneric loadhist-unload-element (x) + "Unload an element from the `load-history'." + (message "Unexpected element %S in load-history" x)) + +;; In `load-history', the definition of a previously autoloaded +;; function is represented by 2 entries: (t . SYMBOL) comes before +;; (defun . SYMBOL) and says we should restore SYMBOL's autoload when +;; we undefine it. +;; So we use this auxiliary variable to keep track of the last (t . SYMBOL) +;; that occurred. +(defvar loadhist--restore-autoload + "If non-nil, this is a symbol for which we should +restore a previous autoload if possible.") + +(cl-defmethod loadhist-unload-element ((x (head t))) + (setq loadhist--restore-autoload (cdr x))) + +(defun loadhist--unload-function (x) + (let ((fun (cdr x))) + (when (fboundp fun) + (when (fboundp 'ad-unadvise) + (ad-unadvise fun)) + (let ((aload (get fun 'autoload))) + (defalias fun + (if (and aload (eq fun loadhist--restore-autoload)) + (cons 'autoload aload) + nil)))))) + (setq loadhist--restore-autoload nil)) + +(cl-defmethod loadhist-unload-element ((x (head defun))) + (loadhist--unload-function x)) +(cl-defmethod loadhist-unload-element ((x (head autoload))) + (loadhist--unload-function x)) + +(cl-defmethod loadhist-unload-element ((x (head require))) nil) +(cl-defmethod loadhist-unload-element ((x (head defface))) nil) + +(cl-defmethod loadhist-unload-element ((x (head provide))) + ;; Remove any feature names that this file provided. + (setq features (delq (cdr x) features))) + +(cl-defmethod loadhist-unload-element ((x symbol)) + ;; Kill local values as much as possible. + (dolist (buf (buffer-list)) + (with-current-buffer buf + (if (and (boundp x) (timerp (symbol-value x))) + (cancel-timer (symbol-value x))) + (kill-local-variable x))) + (if (and (boundp x) (timerp (symbol-value x))) + (cancel-timer (symbol-value x))) + ;; Get rid of the default binding if we can. + (unless (local-variable-if-set-p x) + (makunbound x))) + ;;;###autoload (defun unload-feature (feature &optional force) "Unload the library that provided FEATURE. @@ -200,9 +254,6 @@ unload-feature (prin1-to-string dependents) file)))) (let* ((unload-function-defs-list (feature-symbols feature)) (file (pop unload-function-defs-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")))) @@ -250,38 +301,7 @@ unload-feature (when (symbolp elt) (elp-restore-function elt)))) - (dolist (x unload-function-defs-list) - (if (consp x) - (pcase (car x) - ;; Remove any feature names that this file provided. - (`provide - (setq features (delq (cdr x) features))) - ((or `defun `autoload) - (let ((fun (cdr x))) - (when (fboundp fun) - (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))) - ((or `require `defface) nil) - (_ (message "Unexpected element %s in load-history" x))) - ;; Kill local values as much as possible. - (dolist (buf (buffer-list)) - (with-current-buffer buf - (if (and (boundp x) (timerp (symbol-value x))) - (cancel-timer (symbol-value x))) - (kill-local-variable x))) - (if (and (boundp x) (timerp (symbol-value x))) - (cancel-timer (symbol-value x))) - ;; Get rid of the default binding if we can. - (unless (local-variable-if-set-p x) - (makunbound x)))) + (mapc #'loadhist-unload-element unload-function-defs-list) ;; 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.