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

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

[elpa] externals/beardbolt e97b71e808 171/323: Re-work method to replace


From: ELPA Syncer
Subject: [elpa] externals/beardbolt e97b71e808 171/323: Re-work method to replace asm contents
Date: Thu, 9 Mar 2023 10:58:28 -0500 (EST)

branch: externals/beardbolt
commit e97b71e8087eb3da61598b8719dcd6e1ab38a3dd
Author: Jay Kamat <jaygkamat@gmail.com>
Commit: Jay Kamat <jaygkamat@gmail.com>

    Re-work method to replace asm contents
    
    The old method of replacing asm contents was buggy and slow on Emacs
    26, causing many hangs when doing large replaces. This method is more
    crude, but is much faster and less prone to subtle issues. With small
    edits, the point may end up in the wrong place (as it is relying on
    position rather than contents), but I think that's an acceptable loss.
    
    Please file an issue if this causes issues for you. On Emacs 25, this
    should strictly be better than the previous solution
---
 rmsbolt.el | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/rmsbolt.el b/rmsbolt.el
index 42dcd46262..332f3c8c60 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -1231,18 +1231,15 @@ Argument OVERRIDE-BUFFER use this buffer instead of 
reading from the output file
 
                  (with-current-buffer src-buffer
                    (setq-local rmsbolt-line-mapping ht))
-                 ;; Replace buffer contents non-destructively if possible
-                 (if (functionp #'replace-buffer-contents)
-                     (with-temp-buffer
-                       (insert (mapconcat #'identity lines "\n"))
-                       (let ((tmp-buffer (current-buffer)))
-                         (with-current-buffer output-buffer
-                           (replace-buffer-contents tmp-buffer))))
-                   (with-current-buffer output-buffer
-                     (let ((old-point (point)))
-                       (erase-buffer)
-                       (insert (mapconcat #'identity lines "\n"))
-                       (goto-char old-point))))
+
+                 ;; Replace buffer contents but save point and scroll
+                 (let* ((window (get-buffer-window output-buffer))
+                        (old-point (window-point window))
+                        (old-window-start (window-start window)))
+                   (erase-buffer)
+                   (insert (mapconcat #'identity lines "\n"))
+                   (set-window-start window old-window-start)
+                   (set-window-point window old-point))
                  (asm-mode)
                  (rmsbolt-mode 1)
                  (setq-local rmsbolt-src-buffer src-buffer)



reply via email to

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