[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8781: 24.0.50; unload-feature don't restore default key

From: Juanma Barranquero
Subject: 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


> 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

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


=== 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))

 (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
+  (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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]