[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/valign 841925f 189/198: Remove all advice when they are
From: |
Stefan Monnier |
Subject: |
[elpa] externals/valign 841925f 189/198: Remove all advice when they are not needed |
Date: |
Tue, 1 Dec 2020 18:19:46 -0500 (EST) |
branch: externals/valign
commit 841925f7e72613515f0ae60a5e2071c5ccc65f0d
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Remove all advice when they are not needed
* valign.el (valign-remove-advice): Add missing advices.
(valign--maybe-clean-advice): New function.
(valign-mode): Add 'valign--maybe-clean-advice' to 'kill-buffer-hook'.
Remove misplaced advice code.
---
valign.el | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/valign.el b/valign.el
index b140c74..247a102 100644
--- a/valign.el
+++ b/valign.el
@@ -977,10 +977,23 @@ FLAG is the same as in ‘org-flag-region’."
markdown-cycle))
(advice-remove fn #'valign--tab-advice))
(dolist (fn '(text-scale-increase
- text-scale-decrease))
+ text-scale-decrease
+ org-toggle-inline-images))
(advice-remove fn #'valign--buffer-advice))
(dolist (fn '(org-flag-region outline-flag-region))
- (advice-remove fn #'valign--flag-region-advice)))
+ (advice-remove fn #'valign--flag-region-advice))
+ (when (featurep 'org-indent)
+ (advice-remove 'org-indent-initialize-agent
+ #'valign--org-indent-advice)))
+
+(defun valign--maybe-clean-advice ()
+ "Remove advices if there is no buffer with valign-mode enabled.
+This runs in `kill-buffer-hook'."
+ (when (eq 1 (cl-count-if
+ (lambda (buf)
+ (buffer-local-value 'valign-mode buf))
+ (buffer-list)))
+ (valign-remove-advice)))
;;; Userland
@@ -1019,18 +1032,18 @@ FLAG is the same as in ‘org-flag-region’."
(advice-add fn :after #'valign--buffer-advice))
(dolist (fn '(org-flag-region outline-flag-region))
(advice-add fn :after #'valign--flag-region-advice))
- (with-eval-after-load 'org-indent
+ (when (featurep 'org-indent)
(advice-add 'org-indent-initialize-agent
:after #'valign--org-indent-advice))
(add-hook 'org-indent-mode-hook #'valign--buffer-advice 0 t)
+ (add-hook 'kill-buffer-hook #'valign--maybe-clean-advice 0 t)
(if valign-fancy-bar (cursor-sensor-mode))
(jit-lock-refontify))
- (with-eval-after-load 'org-indent
- (advice-remove 'org-indent-initialize-agent
- #'valign--org-indent-advice))
(remove-hook 'jit-lock-functions #'valign-region t)
+ (remove-hook 'kill-buffer-hook #'valign--maybe-clean-advice t)
(valign-reset-buffer)
- (cursor-sensor-mode -1))))
+ (cursor-sensor-mode -1)
+ (valign--maybe-clean-advice))))
(provide 'valign)
- [elpa] externals/valign 9fc0c11 149/198: Use new function to calculate space and bar width, (continued)
- [elpa] externals/valign 9fc0c11 149/198: Use new function to calculate space and bar width, Stefan Monnier, 2020/12/01
- [elpa] externals/valign d18aea8 183/198: Improve error handling, Stefan Monnier, 2020/12/01
- [elpa] externals/valign 62766e7 184/198: Add custom group, Stefan Monnier, 2020/12/01
- [elpa] externals/valign bf68d39 171/198: Remove single-column style, Stefan Monnier, 2020/12/01
- [elpa] externals/valign ce1a53c 188/198: ; * test.org: Update., Stefan Monnier, 2020/12/01
- [elpa] externals/valign 82be45d 198/198: Bug fix, Stefan Monnier, 2020/12/01
- [elpa] externals/valign cf3a794 099/198: Fix: cursor disappears on bars when fancy-bar is t, Stefan Monnier, 2020/12/01
- [elpa] externals/valign 0e77a02 164/198: Add some commands that suppresses auto alignment, Stefan Monnier, 2020/12/01
- [elpa] externals/valign 7afe578 182/198: Improve documentation, Stefan Monnier, 2020/12/01
- [elpa] externals/valign e0362c0 156/198: * valign.el (valign-region): Report to jit-lock the actual end of fontified region., Stefan Monnier, 2020/12/01
- [elpa] externals/valign 841925f 189/198: Remove all advice when they are not needed,
Stefan Monnier <=
- [elpa] externals/valign e438083 103/198: Change text property to overlay, Stefan Monnier, 2020/12/01
- [elpa] externals/valign cd2b563 191/198: * valign.el: Bump version to 3.0.0., Stefan Monnier, 2020/12/01