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

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

[elpa] externals/beardbolt 4f4a7f85ac 223/323: Simplify visibility check


From: ELPA Syncer
Subject: [elpa] externals/beardbolt 4f4a7f85ac 223/323: Simplify visibility check logic
Date: Thu, 9 Mar 2023 10:58:33 -0500 (EST)

branch: externals/beardbolt
commit 4f4a7f85ace8dfbeca57ba861eb8655571e245d7
Author: Erik Arvstedt <erik.arvstedt@gmail.com>
Commit: Erik Arvstedt <erik.arvstedt@gmail.com>

    Simplify visibility check logic
    
    - Add variable `scroll-src-buffer-p` (instead of `src-buffer-selected`)
      to explicitly indicate which buffer should be scrolled.
    - Only set `line-visible` at two places:
      Once depending on whether the src buffer is scrolled (i.e. 
scroll-src-buffer-p is
      true) and once depending on whether the output buffer is scrolled.
    - In case that `scroll-src-buffer-p` is true, skip the unneeded line
      visibility calculation for the output-buffer.
---
 rmsbolt.el | 41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/rmsbolt.el b/rmsbolt.el
index 449ddb5963..b578c18ab9 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -1658,15 +1658,17 @@ Are you running two compilations at the same time?"))
                 (save-excursion
                   (rmsbolt--goto-line src-current-line)
                   (cl-values (c-point 'bol) (c-point 'bonl))))))
-        (let ((line-visible (not rmsbolt-goto-match))
-              (src-buffer-selected (eq (current-buffer) src-buffer)))
+        (let*
+            ;; If nil, output-buffer is scrolled instead
+            ((scroll-src-buffer-p (not (eq (current-buffer) src-buffer)))
+             (line-visible (or (not rmsbolt-goto-match)
+                               (when scroll-src-buffer-p
+                                 (with-current-buffer src-buffer
+                                   (rmsbolt--point-visible (cl-first 
src-pts)))))))
           ;; Remove existing overlays
           (rmsbolt--cleanup-overlays)
           (push (rmsbolt--setup-overlay (cl-first src-pts) (cl-second src-pts) 
src-buffer)
                 rmsbolt-overlays)
-          (unless src-buffer-selected
-            (with-current-buffer src-buffer
-              (setq line-visible (rmsbolt--point-visible (cl-first src-pts)))))
           (with-current-buffer output-buffer
             (let ((saved-pt (point)))
               (save-excursion
@@ -1676,29 +1678,28 @@ Are you running two compilations at the same time?"))
                          (start-pt (progn (rmsbolt--goto-line start)
                                           (c-point 'bol)))
                          (end-pt (progn (rmsbolt--goto-line end)
-                                        (c-point 'bonl)))
-                         (visible (or line-visible
-                                      (rmsbolt--point-visible start-pt)
-                                      (rmsbolt--point-visible end-pt)
-                                      (and (> saved-pt start-pt)
-                                           (< saved-pt end-pt)))))
-                    ;; check if line is visible and set line-visible
-                    (unless (or line-visible (not src-buffer-selected))
-                      (setq line-visible visible))
+                                        (c-point 'bonl))))
+                    (when (and (not line-visible)
+                               (not scroll-src-buffer-p))
+                      (setq line-visible (or (rmsbolt--point-visible start-pt)
+                                             (rmsbolt--point-visible end-pt)
+                                             (and (> saved-pt start-pt)
+                                                  (< saved-pt end-pt)))))
                     (push (rmsbolt--setup-overlay start-pt end-pt 
output-buffer)
                           rmsbolt-overlays)))))
             (when (or (not line-visible) force)
               ;; Scroll buffer to first line
-              (when-let ((scroll-buffer (if src-buffer-selected
-                                            output-buffer
-                                          src-buffer))
-                         (line-scroll (if src-buffer-selected
+              (when-let ((scroll-buffer (if scroll-src-buffer-p
+                                            src-buffer
+                                          output-buffer))
+                         (line-scroll (if scroll-src-buffer-p
+                                          src-current-line
+                                        (progn
                                           (car-safe
                                            ;; If forcing, pick the min line 
instead
                                            (if force
                                                (car-safe (last asm-lines))
-                                             (cl-first asm-lines)))
-                                        src-current-line))
+                                             (cl-first asm-lines))))))
                          (window (get-buffer-window scroll-buffer)))
                 (with-selected-window window
                   (rmsbolt--goto-line line-scroll)



reply via email to

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