diff options
author | Juanma Barranquero <lekktu@gmail.com> | 2011-06-25 19:42:18 +0200 |
---|---|---|
committer | Juanma Barranquero <lekktu@gmail.com> | 2011-06-25 19:42:18 +0200 |
commit | 519d22cc0e55fcc5ef7ab7e550af78150f1d1e66 (patch) | |
tree | c809ff2f57f9d65fb800aa43ac1d1c2522a87b5d /lisp/loadhist.el | |
parent | c206f5b0f712f347c37cca49236365e54ff17f63 (diff) | |
download | emacs-519d22cc0e55fcc5ef7ab7e550af78150f1d1e66.tar.gz |
* 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
Diffstat (limited to 'lisp/loadhist.el')
-rw-r--r-- | lisp/loadhist.el | 17 |
1 files changed, 17 insertions, 0 deletions
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) |