diff options
author | Phil Sainty <psainty@orcon.net.nz> | 2019-10-22 00:00:16 +1300 |
---|---|---|
committer | Phil Sainty <psainty@orcon.net.nz> | 2019-11-15 00:39:13 +1300 |
commit | bf29fc46c81114909bcfe9c4b60bd419651b49a7 (patch) | |
tree | bf92fd9324792fb8e836dd9ee66ee50f7b1e3bb7 /lisp/so-long.el | |
parent | cb7b63d6e2da14eb92f8f535837fdae04c89dfb2 (diff) | |
download | emacs-bf29fc46c81114909bcfe9c4b60bd419651b49a7.tar.gz emacs-bf29fc46c81114909bcfe9c4b60bd419651b49a7.tar.bz2 emacs-bf29fc46c81114909bcfe9c4b60bd419651b49a7.zip |
* lisp/so-long.el (so-long-unload-function): Improved feature unload
Diffstat (limited to 'lisp/so-long.el')
-rw-r--r-- | lisp/so-long.el | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/lisp/so-long.el b/lisp/so-long.el index e76ab791fcd..5c9711b0bb0 100644 --- a/lisp/so-long.el +++ b/lisp/so-long.el @@ -1761,14 +1761,45 @@ or call the function `global-so-long-mode'.") (defun so-long-unload-function () "Handler for `unload-feature'." - (global-so-long-mode 0) - ;; Remove buffer-local `window-configuration-change-hook' values set by - ;; `so-long-deferred'. - (dolist (buf (buffer-list)) - (with-current-buffer buf - (remove-hook 'window-configuration-change-hook #'so-long :local))) - ;; Return nil. Refer to `unload-feature'. - nil) + (condition-case err + (progn + (global-so-long-mode 0) + ;; Process existing buffers. + (dolist (buf (buffer-list)) + (with-current-buffer buf + ;; Remove buffer-local `window-configuration-change-hook' values set + ;; by `so-long-deferred'. + (remove-hook 'window-configuration-change-hook #'so-long :local) + ;; Call `so-long-revert' in all buffers where so-long is active. + (when (bound-and-true-p so-long--active) + (so-long-revert)))) + ;; Un-define our buffer-local variables, as `unload-feature' will not do + ;; this automatically. We remove them from `unload-function-defs-list' + ;; as well, to prevent them being redefined. n.b.: `so-long--active' is + ;; tested (above) using `bound-and-true-p' because that is one of the + ;; variables which we unbind (below); and if something subsequent to + ;; this handler signals an error, the user may need to call this again. + (defvar unload-function-defs-list) + (dolist (var '(so-long--active + so-long--inhibited + so-long-detected-p + so-long-file-local-mode-function + so-long-function + so-long-minor-mode + so-long-mode-abbrev-table + so-long-mode-line-info + so-long-mode-syntax-table + so-long-original-values + so-long-revert-function)) + (makunbound var) + (setq unload-function-defs-list + (delq var unload-function-defs-list))) + ;; Return nil if unloading was successful. Refer to `unload-feature'. + nil) + ;; If any error occurred, return non-nil. + (error (progn + (message "Error unloading so-long: %S %S" (car err) (cdr err)) + t)))) (provide 'so-long) |