GNU bug report logs - #8730
23.2; unload-feature leaves hook

Previous Next

Package: emacs;

Reported by: Andreas Röhler <andreas.roehler <at> easy-emacs.de>

Date: Wed, 25 May 2011 05:54:01 UTC

Severity: minor

Found in version 23.2

Done: Juanma Barranquero <lekktu <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 8730 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: 8781 <at> debbugs.gnu.org, 8730 <at> debbugs.gnu.org
Subject: Re: bug#8781: 24.0.50; unload-feature don't restore default key
Date: Wed, 1 Jun 2011 18:27:55 +0200
> M-x unload-feature python
>
> M-x describe-key <backspace>
>
> sends error:
>
> describe-key: Symbol's function definition is void: python-backspace

and

> M-x python-mode
> M-x unload-feature RET python-mode
> M-x shell
>
> error in process filter: Symbol's function definition is void: python-pdbtrack-track-stack-file
> <<< Press Return to bury the buffer list >>>

unload-feature should surely be smarted, but for the time being, the
only way to fix these is to add a python-unload-function which tries
to undo the changes that unload-feature isn't smart enough to do by
itself.

Try the following patch. It sets [pj]ython-mode buffers to
(default-value 'major-mode), and inferior-python-mode buffers to the
parent of this mode (comint). It also removes the hook that causes
bug#8730, and undoes a couple other changes.

Removing things from after-load-alist is a bit unclean, so I've opted
instead for adding an autoload cookie for `python-after-info-look';
that will avoid an error if the user does

M-x python-mode <RET>
M-x unload-feature <RET> python <RET>
M-x info-look-symbol <RET> ;; etc.

though of course python-mode will be loaded again. Not a common enough
situation to be worth a cleaner fix, I think.  (Though if I'm mistaken
and there's a clean way to remove from after-load-alist, I'm all
ears.)

   Juanma


=== modified file 'lisp/progmodes/python.el'
--- lisp/progmodes/python.el	2011-05-13 12:44:48 +0000
+++ lisp/progmodes/python.el	2011-06-01 16:09:34 +0000
@@ -1915,4 +1915,5 @@
 (declare-function info-lookup-maybe-add-help "info-look" (&rest arg))

+;;;###autoload
 (defun python-after-info-look ()
   "Set up info-look for Python.
@@ -2896,4 +2897,23 @@
   (setq overlay-arrow-position nil))

+(defun python-unload-function ()
+  "Unload the Python library."
+  (let* ((default-mode (default-value 'major-mode))
+         (inferior-mode (or (get 'inferior-python-mode 'derived-mode-parent)
+                            default-mode)))
+    (dolist (buffer (buffer-list))
+      (set-buffer buffer)
+      (cond ((memq major-mode '(python-mode jython-mode))
+             (funcall default-mode))
+            ((eq major-mode 'inferior-python-mode)
+             (funcall inferior-mode)))))
+  (remove-hook 'comint-output-filter-functions
'python-pdbtrack-track-stack-file)
+  (setq minor-mode-alist (assq-delete-all 'python-pdbtrack-is-tracking-p
+                                          minor-mode-alist))
+  (dolist (error '("^No symbol" "^Can't shift all lines enough"))
+    (setq debug-ignored-errors (delete error debug-ignored-errors)))
+  ;; continue standard unloading
+  nil)
+
 (provide 'python)
 (provide 'python-21)




This bug report was last modified 14 years and 25 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.