From: Juanma Barranquero Date: Sat, 25 Jun 2011 17:42:18 +0000 (+0200) Subject: * loadhist.el (unload--set-major-mode): New function. X-Git-Tag: emacs-pretest-24.0.90~104^2~152^2~414^2~5 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=519d22cc0e55fcc5ef7ab7e550af78150f1d1e66;p=emacs.git * loadhist.el (unload--set-major-mode): New function. (unload-feature): Use it. * progmodes/python.el (python-after-info-look): Add autoload cookie. (python-unload-function): New function. Fixes: debbugs:8781 debbugs:8730 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5370471bcc3..4fec617954a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2011-06-25 Juanma Barranquero + + Fix bug#8730, bug#8781. + + * loadhist.el (unload--set-major-mode): New function. + (unload-feature): Use it. + + * progmodes/python.el (python-after-info-look): Add autoload cookie. + (python-unload-function): New function. + 2011-06-25 Stefan Monnier * mail/rmail.el (rmail-show-message-1): Use restore-buffer-modified-p. diff --git a/lisp/loadhist.el b/lisp/loadhist.el index 8e00c33cd81..943eac42b02 100644 --- a/lisp/loadhist.el +++ b/lisp/loadhist.el @@ -143,6 +143,19 @@ documentation of `unload-feature' for details.") (define-obsolete-variable-alias 'unload-hook-features-list 'unload-function-defs-list "22.2") +(defun unload--set-major-mode () + (save-current-buffer + (dolist (buffer (buffer-list)) + (set-buffer buffer) + (let ((proposed major-mode)) + ;; Look for an antecessor mode not defined in the feature we're processing + (while (and proposed (rassq proposed unload-function-defs-list)) + (setq proposed (get proposed 'derived-mode-parent))) + (unless (eq proposed major-mode) + ;; Two cases: either proposed is nil, and we want to switch to fundamental + ;; mode, or proposed is not nil and not major-mode, and so we use it. + (funcall (or proposed 'fundamental-mode))))))) + ;;;###autoload (defun unload-feature (feature &optional force) "Unload the library that provided FEATURE. @@ -222,6 +235,10 @@ something strange, such as redefining an Emacs function." (not (get (cdr y) 'autoload))) (setq auto-mode-alist (rassq-delete-all (cdr y) auto-mode-alist))))) + + ;; Change major mode in all buffers using one defined in the feature being unloaded. + (unload--set-major-mode) + (when (fboundp 'elp-restore-function) ; remove ELP stuff first (dolist (elt unload-function-defs-list) (when (symbolp elt) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 3d243f14f07..4d2f15c69d8 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1868,6 +1868,7 @@ instance. Assumes an inferior Python is running." (declare-function info-lookup-maybe-add-help "info-look" (&rest arg)) +;;;###autoload (defun python-after-info-look () "Set up info-look for Python. Used with `eval-after-load'." @@ -2731,6 +2732,16 @@ comint believe the user typed this string so that (defun python-sentinel (_proc _msg) (setq overlay-arrow-position nil)) +(defun python-unload-function () + "Unload the Python library." + (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)