[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master bf29fc4 4/8: * lisp/so-long.el (so-long-unload-function): Improve
From: |
Phil |
Subject: |
master bf29fc4 4/8: * lisp/so-long.el (so-long-unload-function): Improved feature unload |
Date: |
Thu, 14 Nov 2019 06:48:02 -0500 (EST) |
branch: master
commit bf29fc46c81114909bcfe9c4b60bd419651b49a7
Author: Phil Sainty <address@hidden>
Commit: Phil Sainty <address@hidden>
* lisp/so-long.el (so-long-unload-function): Improved feature unload
---
lisp/so-long.el | 47 +++++++++++++++++++++++++++++++++++++++--------
1 file changed, 39 insertions(+), 8 deletions(-)
diff --git a/lisp/so-long.el b/lisp/so-long.el
index e76ab79..5c9711b 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)
- master updated (75875ca -> 5803558), Phil, 2019/11/14
- master bf29fc4 4/8: * lisp/so-long.el (so-long-unload-function): Improved feature unload,
Phil <=
- master cb7b63d 3/8: ; * lisp/so-long.el (so-long-predicate): Custom type consistency, Phil, 2019/11/14
- master e9dca2b 2/8: Defer triggering `so-long' until the buffer is displayed, Phil, 2019/11/14
- master 77c3bc0 7/8: Make so-long disable flymake, flyspell, flycheck, Phil, 2019/11/14
- master 9029074 1/8: ; Documentation and spelling, Phil, 2019/11/14
- master b28f35a 5/8: Backwards-compatibility function definitions for so-long.el, Phil, 2019/11/14
- master a94f961 6/8: Support loading so-long.el on top of an earlier version, Phil, 2019/11/14
- master 5803558 8/8: Merge branch 'scratch/so-long-updates', Phil, 2019/11/14