emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/valign 5b9a086 038/198: Fix edge case


From: Stefan Monnier
Subject: [elpa] externals/valign 5b9a086 038/198: Fix edge case
Date: Tue, 1 Dec 2020 18:19:12 -0500 (EST)

branch: externals/valign
commit 5b9a0864351e0fd7c2c7a0edfa059dd78c0fddeb
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Fix edge case
    
    When we enable valign-mode when a org buffer is in another window.
    
    * valign.el (valign-mode): Add check for visibility.
---
 valign.el | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/valign.el b/valign.el
index 09451dd..9d0faeb 100644
--- a/valign.el
+++ b/valign.el
@@ -533,13 +533,18 @@ When they are fontified next time."
         (advice-add 'org-flag-region :before #'valign--org-flag-region-advice)
         ;; Force jit-lock to refontify (and thus realign) the buffer.
         (dolist (buf (buffer-list))
+          ;; If the buffer is visible, realign immediately, if not,
+          ;; realign when it becomes visible.
           (with-current-buffer buf
             (when (derived-mode-p 'org-mode)
-              (with-silent-modifications
-                (put-text-property
-                 (point-min) (point-max) 'fontified nil)
-                (put-text-property
-                 (point-min) (point-max) 'valign-init nil))))))
+              (if (get-buffer-window buf t)
+                  (with-selected-window (get-buffer-window buf t)
+                    (valign-initial-alignment (point-min) (point-max) t))
+                (with-silent-modifications
+                  (put-text-property
+                   (point-min) (point-max) 'fontified nil)
+                  (put-text-property
+                   (point-min) (point-max) 'valign-init nil)))))))
     (remove-hook 'org-mode-hook #'valign--org-mode-hook)
     (remove-hook 'org-agenda-finalize-hook #'valign--force-align-buffer)
     (advice-remove 'org-toggle-inline-images #'valign--force-align-buffer)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]