bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history

Michael Albinus
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))



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history

Michael Albinus
Michael Albinus <[hidden email]> 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.



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history

Stefan Monnier
> 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



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history

Michael Albinus
Stefan Monnier <[hidden email]> 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.



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history

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



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history

Michael Albinus
Stefan Monnier <[hidden email]> 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.



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history

Stefan Monnier
>> 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



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

bug#27371: 26.0.50; Unexpected element (define-type . tramp-file-name) in load-history

Michael Albinus
In reply to this post by Michael Albinus
Michael Albinus <[hidden email]> 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.



Loading...