diff options
| author | Phil Sainty | 2019-10-22 00:00:16 +1300 |
|---|---|---|
| committer | Phil Sainty | 2019-11-15 00:39:13 +1300 |
| commit | bf29fc46c81114909bcfe9c4b60bd419651b49a7 (patch) | |
| tree | bf92fd9324792fb8e836dd9ee66ee50f7b1e3bb7 | |
| parent | cb7b63d6e2da14eb92f8f535837fdae04c89dfb2 (diff) | |
| download | emacs-bf29fc46c81114909bcfe9c4b60bd419651b49a7.tar.gz emacs-bf29fc46c81114909bcfe9c4b60bd419651b49a7.zip | |
* lisp/so-long.el (so-long-unload-function): Improved feature unload
| -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'.") | |||
| 1761 | 1761 | ||
| 1762 | (defun so-long-unload-function () | 1762 | (defun so-long-unload-function () |
| 1763 | "Handler for `unload-feature'." | 1763 | "Handler for `unload-feature'." |
| 1764 | (global-so-long-mode 0) | 1764 | (condition-case err |
| 1765 | ;; Remove buffer-local `window-configuration-change-hook' values set by | 1765 | (progn |
| 1766 | ;; `so-long-deferred'. | 1766 | (global-so-long-mode 0) |
| 1767 | (dolist (buf (buffer-list)) | 1767 | ;; Process existing buffers. |
| 1768 | (with-current-buffer buf | 1768 | (dolist (buf (buffer-list)) |
| 1769 | (remove-hook 'window-configuration-change-hook #'so-long :local))) | 1769 | (with-current-buffer buf |
| 1770 | ;; Return nil. Refer to `unload-feature'. | 1770 | ;; Remove buffer-local `window-configuration-change-hook' values set |
| 1771 | nil) | 1771 | ;; by `so-long-deferred'. |
| 1772 | (remove-hook 'window-configuration-change-hook #'so-long :local) | ||
| 1773 | ;; Call `so-long-revert' in all buffers where so-long is active. | ||
| 1774 | (when (bound-and-true-p so-long--active) | ||
| 1775 | (so-long-revert)))) | ||
| 1776 | ;; Un-define our buffer-local variables, as `unload-feature' will not do | ||
| 1777 | ;; this automatically. We remove them from `unload-function-defs-list' | ||
| 1778 | ;; as well, to prevent them being redefined. n.b.: `so-long--active' is | ||
| 1779 | ;; tested (above) using `bound-and-true-p' because that is one of the | ||
| 1780 | ;; variables which we unbind (below); and if something subsequent to | ||
| 1781 | ;; this handler signals an error, the user may need to call this again. | ||
| 1782 | (defvar unload-function-defs-list) | ||
| 1783 | (dolist (var '(so-long--active | ||
| 1784 | so-long--inhibited | ||
| 1785 | so-long-detected-p | ||
| 1786 | so-long-file-local-mode-function | ||
| 1787 | so-long-function | ||
| 1788 | so-long-minor-mode | ||
| 1789 | so-long-mode-abbrev-table | ||
| 1790 | so-long-mode-line-info | ||
| 1791 | so-long-mode-syntax-table | ||
| 1792 | so-long-original-values | ||
| 1793 | so-long-revert-function)) | ||
| 1794 | (makunbound var) | ||
| 1795 | (setq unload-function-defs-list | ||
| 1796 | (delq var unload-function-defs-list))) | ||
| 1797 | ;; Return nil if unloading was successful. Refer to `unload-feature'. | ||
| 1798 | nil) | ||
| 1799 | ;; If any error occurred, return non-nil. | ||
| 1800 | (error (progn | ||
| 1801 | (message "Error unloading so-long: %S %S" (car err) (cdr err)) | ||
| 1802 | t)))) | ||
| 1772 | 1803 | ||
| 1773 | 1804 | ||
| 1774 | (provide 'so-long) | 1805 | (provide 'so-long) |