* 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
This commit is contained in:
Juanma Barranquero 2011-06-25 19:42:18 +02:00
parent c206f5b0f7
commit 519d22cc0e
3 changed files with 38 additions and 0 deletions

View file

@ -1,3 +1,13 @@
2011-06-25 Juanma Barranquero <lekktu@gmail.com>
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 <monnier@iro.umontreal.ca>
* mail/rmail.el (rmail-show-message-1): Use restore-buffer-modified-p.

View file

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

View file

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