unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history
@ 2017-06-15  8:05 Michael Albinus
  2017-07-17 12:36 ` Michael Albinus
  0 siblings, 1 reply; 13+ messages in thread
From: Michael Albinus @ 2017-06-15  8:05 UTC (permalink / raw)
  To: 27371

1. emacs -Q -l tramp
2. M-x unload-feature <RET> tramp

=> Unexpected element (define-type . tramp-file-name) in load-history

In GNU Emacs 26.0.50 (build 44, x86_64-pc-linux-gnu, GTK+ Version 2.24.30)
 of 2017-03-31 built on detlef
Repository revision: 1da9a207669a3cf5d27ac1dd61543c1492e05360
System Description:	Ubuntu 17.04

Recent messages:
Mark set
uncompressing 23073.gz...done
Deleting article 23073 in default
No more unseen articles
Mark set
Returning to the group buffer
Saving /home/albinus/.newsrc.eld...
Saving file /home/albinus/.newsrc.eld...
Wrote /home/albinus/.newsrc.eld
Saving /home/albinus/.newsrc.eld...done

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND GPM DBUS GCONF GSETTINGS NOTIFY GNUTLS
LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK2 X11

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8

Major mode: Lisp Interaction

Minor modes in effect:
  diff-auto-refine-mode: t
  erc-notify-mode: t
  erc-notifications-mode: t
  erc-list-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-networks-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-match-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-netsplit-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  display-time-mode: t
  shell-dirtrack-mode: t
  icomplete-mode: t
  show-paren-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/albinus/src/elpa/packages/debbugs/debbugs-org hides /home/albinus/.emacs.d/elpa/debbugs-0.14/debbugs-org
/home/albinus/src/elpa/packages/debbugs/debbugs-gnu hides /home/albinus/.emacs.d/elpa/debbugs-0.14/debbugs-gnu
/home/albinus/src/elpa/packages/debbugs/debbugs hides /home/albinus/.emacs.d/elpa/debbugs-0.14/debbugs
/home/albinus/src/elpa/packages/debbugs/debbugs-autoloads hides /home/albinus/.emacs.d/elpa/debbugs-0.14/debbugs-autoloads
/home/albinus/src/elpa/packages/debbugs/debbugs-pkg hides /home/albinus/.emacs.d/elpa/debbugs-0.14/debbugs-pkg
/home/albinus/src/elpa/packages/debbugs/debbugs-browse hides /home/albinus/.emacs.d/elpa/debbugs-0.14/debbugs-browse
/home/albinus/src/elpa/packages/tramp-theme/tramp-theme hides /home/albinus/.emacs.d/elpa/tramp-theme-0.1.1/tramp-theme
/home/albinus/src/elpa/packages/tramp-theme/tramp-theme-autoloads hides /home/albinus/.emacs.d/elpa/tramp-theme-0.1.1/tramp-theme-autoloads
/home/albinus/src/elpa/packages/tramp-theme/tramp-theme-pkg hides /home/albinus/.emacs.d/elpa/tramp-theme-0.1.1/tramp-theme-pkg
/home/albinus/.emacs.d/elpa/telepathy-20131209.458/telepathy hides ~/lisp/telepathy
~/src/tramp/lisp/tramp-smb hides /usr/local/share/emacs/26.0.50/lisp/net/tramp-smb
~/src/tramp/lisp/tramp-uu hides /usr/local/share/emacs/26.0.50/lisp/net/tramp-uu
~/src/tramp/lisp/tramp-adb hides /usr/local/share/emacs/26.0.50/lisp/net/tramp-adb
~/src/tramp/lisp/tramp-compat hides /usr/local/share/emacs/26.0.50/lisp/net/tramp-compat
~/src/tramp/lisp/tramp hides /usr/local/share/emacs/26.0.50/lisp/net/tramp
~/src/tramp/lisp/trampver hides /usr/local/share/emacs/26.0.50/lisp/net/trampver
~/src/tramp/lisp/tramp-ftp hides /usr/local/share/emacs/26.0.50/lisp/net/tramp-ftp
/home/albinus/.emacs.d/elpa/soap-client-3.1.2/soap-client hides /usr/local/share/emacs/26.0.50/lisp/net/soap-client
/home/albinus/.emacs.d/elpa/soap-client-3.1.2/soap-inspect hides /usr/local/share/emacs/26.0.50/lisp/net/soap-inspect
~/src/tramp/lisp/tramp-cmds hides /usr/local/share/emacs/26.0.50/lisp/net/tramp-cmds
~/src/tramp/lisp/tramp-gvfs hides /usr/local/share/emacs/26.0.50/lisp/net/tramp-gvfs
~/src/tramp/lisp/tramp-loaddefs hides /usr/local/share/emacs/26.0.50/lisp/net/tramp-loaddefs
~/lisp/dbus hides /usr/local/share/emacs/26.0.50/lisp/net/dbus
~/src/tramp/lisp/tramp-sh hides /usr/local/share/emacs/26.0.50/lisp/net/tramp-sh
~/src/tramp/lisp/tramp-cache hides /usr/local/share/emacs/26.0.50/lisp/net/tramp-cache

Features:
(shadow warnings emacsbug time-stamp url-http url-gw url-auth url-queue
url-cache url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf diff-mode easy-mmode flow-fill sort gnus-cite
url-util shr-color color shr svg dom browse-url mm-archive mail-extr
gnus-bcklg qp gnus-async gnus-ml pop3 utf-7 nndraft nnmh nnml
network-stream nsm starttls gnus-agent gnus-srvr gnus-score score-mode
nnvirtual gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig
mailcap gnus-cache gnus-sum nnnil smtpmail sendmail gnus-demon nntp
gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail mail-source tls
gnutls utf7 netrc nnoo gnus-spec gnus-int gnus-range message puny rfc822
mml mml-sec epa derived epg mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader gnus-win gnus nnheader gnus-util
rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums mail-utils mm-util
mail-prsvr term/xterm xterm erc-notify erc-desktop-notifications
notifications dbus xml erc-list erc-menu erc-join erc-ring erc-networks
erc-pcomplete erc-track erc-match erc-button wid-edit erc-fill erc-stamp
erc-netsplit erc-goodies erc erc-backend erc-compat thingatpt pp
cperl-mode tramp-theme em-dirs esh-var esh-io esh-cmd esh-opt esh-ext
esh-proc esh-arg esh-groups eshell esh-module esh-mode esh-util
finder-inf rx docker-tramp tramp-cache slime-autoloads vagrant-tramp
dash term disp-table ehelp info package epg-config url-handlers
url-parse url-vars time tramp-sh tramp-cmds tramp tramp-compat
tramp-loaddefs trampver ucs-normalize shell pcomplete comint ansi-color
ring parse-time format-spec advice auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache ido seq byte-opt subr-x gv
bytecomp byte-compile cl-extra help-mode easymenu cconv jka-compr
icomplete time-date paren vc cl-loaddefs pcase cl-lib vc-dispatcher
dired dired-loaddefs mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript case-table epa-hook jka-cmpr-hook help
simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button
faces cus-face macroexp files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote dbusbind inotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 453817 58583)
 (symbols 48 42157 120)
 (miscs 40 69 285)
 (strings 32 100342 15319)
 (string-bytes 1 3099767)
 (vectors 16 60096)
 (vector-slots 8 992964 10665)
 (floats 8 436 632)
 (intervals 56 302 0)
 (buffers 976 23))





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history
  2017-06-15  8:05 bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history Michael Albinus
@ 2017-07-17 12:36 ` Michael Albinus
  2017-07-17 19:43   ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Michael Albinus @ 2017-07-17 12:36 UTC (permalink / raw)
  To: 27371; +Cc: Stefan Monnier

Michael Albinus <michael.albinus@gmx.de> writes:

> 1. emacs -Q -l tramp
> 2. M-x unload-feature <RET> tramp
>
> => Unexpected element (define-type . tramp-file-name) in load-history

The following patch fixes this for me:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/loadhist.el b/lisp/loadhist.el
index 28d0b18c81..34200ab40e 100644
--- a/lisp/loadhist.el
+++ b/lisp/loadhist.el
@@ -269,7 +269,7 @@ unload-feature
 	      ;; and says we should restore SYMBOL's autoload
 	      ;; when we undefine it.
 	      (`t (setq restore-autoload (cdr x)))
-	      ((or `require `defface) nil)
+	      ((or `require `defface `define-type) nil)
 	      (_ (message "Unexpected element %s in load-history" x)))
 	  ;; Kill local values as much as possible.
 	  (dolist (buf (buffer-list))
--8<---------------cut here---------------end--------------->8---

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?

Stefan?

Beswt regards, Michael.





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history
  2017-07-17 12:36 ` Michael Albinus
@ 2017-07-17 19:43   ` Stefan Monnier
  2017-07-18  7:09     ` Michael Albinus
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2017-07-17 19:43 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 27371

> 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.


        Stefan





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history
  2017-07-17 19:43   ` Stefan Monnier
@ 2017-07-18  7:09     ` Michael Albinus
  2017-07-18 14:25       ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Michael Albinus @ 2017-07-18  7:09 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 27371

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> 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.

>         Stefan

Best regards, Michael.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history
  2017-07-18  7:09     ` Michael Albinus
@ 2017-07-18 14:25       ` Stefan Monnier
  2017-07-18 15:19         ` Michael Albinus
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2017-07-18 14:25 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 27371

>>> 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.





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history
  2017-07-18 14:25       ` Stefan Monnier
@ 2017-07-18 15:19         ` Michael Albinus
  2017-07-18 15:56           ` Stefan Monnier
  2017-07-18 16:08           ` Michael Albinus
  0 siblings, 2 replies; 13+ messages in thread
From: Michael Albinus @ 2017-07-18 15:19 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 27371

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

Hi Stefan,

> The hook shouldn't be specific to cl.  Maybe something like the patch
> below would make sense?

There is an error in the patch:

In toplevel form:
loadhist.el:192:40:Error: Invalid read syntax: ")"

After fixing this, `tramp-test39-unload' still passes the test. You
might push the patch.

> Then we can add support for define-type, ert-deftest, cl-defmethod, ...

That's my original question: what does it take to unload a `define-type'
entry?

>         Stefan

Best regards, Michael.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history
  2017-07-18 15:19         ` Michael Albinus
@ 2017-07-18 15:56           ` Stefan Monnier
  2017-07-24 15:01             ` Michael Albinus
  2017-07-18 16:08           ` Michael Albinus
  1 sibling, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2017-07-18 15:56 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 27371

>> Then we can add support for define-type, ert-deftest, cl-defmethod, ...
> That's my original question: what does it take to unload a `define-type'
> entry?

Presumably it should undo what cl-struct-define does.
The main part would be (setf (cl--find-class name) nil), I guess.


        Stefan





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history
  2017-07-18 15:19         ` Michael Albinus
  2017-07-18 15:56           ` Stefan Monnier
@ 2017-07-18 16:08           ` Michael Albinus
  1 sibling, 0 replies; 13+ messages in thread
From: Michael Albinus @ 2017-07-18 16:08 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 27371

Michael Albinus <michael.albinus@gmx.de> writes:

Hi Stefan,

> After fixing this, `tramp-test39-unload' still passes the test. You
> might push the patch.

Too hasty. Further runs of tramp-tests.el fail for this. I'll check
what's up.

>>         Stefan

Best regards, Michael.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history
  2017-07-18 15:56           ` Stefan Monnier
@ 2017-07-24 15:01             ` Michael Albinus
  2017-07-24 15:33               ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Michael Albinus @ 2017-07-24 15:01 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 27371

[-- Attachment #1: Type: text/plain, Size: 579 bytes --]

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

Hi Stefan,

>>> Then we can add support for define-type, ert-deftest, cl-defmethod, ...
>> That's my original question: what does it take to unload a `define-type'
>> entry?
>
> Presumably it should undo what cl-struct-define does.
> The main part would be (setf (cl--find-class name) nil), I guess.

I've ended up with the appended patch. Would this be OK? More precise,
would the implementation of

(cl-defmethod loadhist-unload-element ((x (head define-type)))

be the right thing?

>         Stefan

Best regards, Michael.


[-- Attachment #2: Type: text/plain, Size: 5462 bytes --]

diff --git a/lisp/loadhist.el b/lisp/loadhist.el
index 28d0b18c81..59b1688857 100644
--- a/lisp/loadhist.el
+++ b/lisp/loadhist.el
@@ -162,6 +162,83 @@ 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)
+;; The following two might require more actions.
+(cl-defmethod loadhist-unload-element ((x (head ert-deftest))) nil)
+(cl-defmethod loadhist-unload-element ((x (head cl-defmethod))) 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)))
+
+(cl-defmethod loadhist-unload-element ((x (head define-type)))
+  (let* ((name (cdr x))
+         (slots (mapcar 'car (cdr (cl-struct-slot-info name)))))
+    ;; Remove the struct.
+    (setf (cl--find-class name) nil)
+    ;; Remove internal functions.
+    (dolist (fun
+	     (append
+	      ;; constructor, copier, predicate, tag-symbol.
+	      `(,(format "make-%s" name)
+	        ,(format "copy-%s" name)
+	        ,(format "%s-p" name)
+	        ,(format "cl-struct-%s-tags" name))
+	      ;; accessors.
+	      (mapcar #'(lambda (y) (format "%s-%s" name y)) slots)))
+      (dolist
+          (symbol
+           `(,fun ,(format "%s--cmacro" fun) ,(format "--cl-block-%s--" fun)))
+        (unintern symbol obarray)))))
+
 ;;;###autoload
 (defun unload-feature (feature &optional force)
   "Unload the library that provided FEATURE.
@@ -200,9 +277,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 +324,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.

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history
  2017-07-24 15:01             ` Michael Albinus
@ 2017-07-24 15:33               ` Stefan Monnier
  2017-07-24 16:13                 ` Michael Albinus
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2017-07-24 15:33 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 27371

> +    ;; Remove internal functions.
> +    (dolist (fun
> +	     (append
> +	      ;; constructor, copier, predicate, tag-symbol.
> +	      `(,(format "make-%s" name)
> +	        ,(format "copy-%s" name)
> +	        ,(format "%s-p" name)
> +	        ,(format "cl-struct-%s-tags" name))
> +	      ;; accessors.
> +	      (mapcar #'(lambda (y) (format "%s-%s" name y)) slots)))

AFAIK all these functions are defined with `defalias', so they should
already be handled by their own entry in load-history.


        Stefan





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history
  2017-07-24 15:33               ` Stefan Monnier
@ 2017-07-24 16:13                 ` Michael Albinus
  2017-07-24 16:31                   ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Michael Albinus @ 2017-07-24 16:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 27371

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> +    ;; Remove internal functions.
>> +    (dolist (fun
>> +	     (append
>> +	      ;; constructor, copier, predicate, tag-symbol.
>> +	      `(,(format "make-%s" name)
>> +	        ,(format "copy-%s" name)
>> +	        ,(format "%s-p" name)
>> +	        ,(format "cl-struct-%s-tags" name))
>> +	      ;; accessors.
>> +	      (mapcar #'(lambda (y) (format "%s-%s" name y)) slots)))
>
> AFAIK all these functions are defined with `defalias', so they should
> already be handled by their own entry in load-history.

You're right. So what's left to do is

    (setf (cl--find-class name) nil)))

If you don't object I would commit the patch then ('tho it's rather your patch).

>         Stefan

Best regards, Michael.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history
  2017-07-24 16:13                 ` Michael Albinus
@ 2017-07-24 16:31                   ` Stefan Monnier
  2017-07-24 17:39                     ` Michael Albinus
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2017-07-24 16:31 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 27371

> If you don't object I would commit the patch then ('tho it's rather
> your patch).

Please do,


        Stefan





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history
  2017-07-24 16:31                   ` Stefan Monnier
@ 2017-07-24 17:39                     ` Michael Albinus
  0 siblings, 0 replies; 13+ messages in thread
From: Michael Albinus @ 2017-07-24 17:39 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 27371-done

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> If you don't object I would commit the patch then ('tho it's rather
>> your patch).
>
> Please do,

Done. Closing the bug.

>         Stefan

Best regards, Michael.





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-07-24 17:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-15  8:05 bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history Michael Albinus
2017-07-17 12:36 ` Michael Albinus
2017-07-17 19:43   ` Stefan Monnier
2017-07-18  7:09     ` Michael Albinus
2017-07-18 14:25       ` Stefan Monnier
2017-07-18 15:19         ` Michael Albinus
2017-07-18 15:56           ` Stefan Monnier
2017-07-24 15:01             ` Michael Albinus
2017-07-24 15:33               ` Stefan Monnier
2017-07-24 16:13                 ` Michael Albinus
2017-07-24 16:31                   ` Stefan Monnier
2017-07-24 17:39                     ` Michael Albinus
2017-07-18 16:08           ` Michael Albinus

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).