[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/so-long-updates 89157bc 4/6: * lisp/so-long.el (so-long-unload-f
From: |
Phil |
Subject: |
scratch/so-long-updates 89157bc 4/6: * lisp/so-long.el (so-long-unload-function): Improved feature unload |
Date: |
Sat, 2 Nov 2019 08:23:41 -0400 (EDT) |
branch: scratch/so-long-updates
commit 89157bcb9309915bb78b1a48d70346f8f2017c6a
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 c52b3d8..ee6f964 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)
- branch scratch/so-long-updates created (now 781ab5d), Phil, 2019/11/02
- scratch/so-long-updates 0c61fe0 1/6: ; Documentation and spelling, Phil, 2019/11/02
- scratch/so-long-updates 89157bc 4/6: * lisp/so-long.el (so-long-unload-function): Improved feature unload,
Phil <=
- scratch/so-long-updates 6712edc 3/6: ; * lisp/so-long.el (so-long-predicate): Custom type consistency, Phil, 2019/11/02
- scratch/so-long-updates 978f37f 5/6: Backwards-compatibility function definitions for so-long.el, Phil, 2019/11/02
- scratch/so-long-updates 781ab5d 6/6: Support loading so-long.el on top of an earlier version, Phil, 2019/11/02
- scratch/so-long-updates 571b50c 2/6: Defer triggering `so-long' until the buffer is displayed, Phil, 2019/11/02