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

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

[elpa] externals/lentic da6ab1268f 104/333: Change locations now use mar


From: ELPA Syncer
Subject: [elpa] externals/lentic da6ab1268f 104/333: Change locations now use markers.
Date: Tue, 27 Feb 2024 13:00:12 -0500 (EST)

branch: externals/lentic
commit da6ab1268f3bebf0e0284008c2469f947d19b304
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>

    Change locations now use markers.
    
    Previously, the begin and end position of changes were stored as
    integers, which became invalid as the buffer is changed. Now use markers
    instead.
---
 linked-buffer-block.el | 43 ++++++++++++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 17 deletions(-)

diff --git a/linked-buffer-block.el b/linked-buffer-block.el
index 11fa488df8..79b589cd64 100644
--- a/linked-buffer-block.el
+++ b/linked-buffer-block.el
@@ -91,7 +91,7 @@ start of line comment-characters in appropriate blocks. 
Changes
 should only have occurred between BEGIN and END in BUFFER."
   (-map
    (lambda (pairs)
-     (let* 
+     (let*
          ((block-begin (car pairs))
           (block-end (cdr pairs))
           (rtn
@@ -105,7 +105,7 @@ should only have occurred between BEGIN and END in BUFFER."
        (set-marker (car pairs) nil)
        (set-marker (cdr pairs) nil)
        rtn))
-   (linked-buffer-blk-marker-boundaries 
+   (linked-buffer-blk-marker-boundaries
     conf buffer)))
 
 (defun linked-buffer-blk-comment-region (conf begin end buffer)
@@ -137,21 +137,30 @@ start of line comment characters beween BEGIN and END in 
BUFFER."
   "Given CONF, a `linked-buffer-configuration' object, add
 start of line comment-characters. Changes should only have occurred
 between BEGIN and END in BUFFER."
-  (-map
-   ;; comment each of these regions
-   (lambda (pairs)
-     (let* ((block-begin (car pairs))
-            (block-end (cdr pairs))
-            (rtn
-             (when
-                 (and (>= end block-begin)
-                      (>= block-end begin))
-               (linked-buffer-blk-comment-region
-                conf (car pairs) (cdr pairs) buffer))))
-       (set-marker (car pairs) nil)
-       (set-marker (cdr pairs) nil)
-       rtn))
-   (linked-buffer-blk-marker-boundaries conf buffer)))
+  ;; we need these as markers because the begin and end position need to
+  ;; move as we change the buffer, in the same way that the marker boundary
+  ;; markers do.
+  (let* ((begin (set-marker (make-marker) begin buffer))
+         (end (set-marker (make-marker) end buffer))
+         (rtn
+          (-map
+           ;; comment each of these regions
+           (lambda (pairs)
+             (let* ((block-begin (car pairs))
+                    (block-end (cdr pairs))
+                    (rtn
+                     (when
+                         (and (>= end block-begin)
+                              (>= block-end begin))
+                       (linked-buffer-blk-comment-region
+                        conf (car pairs) (cdr pairs) buffer))))
+               (set-marker block-begin nil)
+               (set-marker block-end nil)
+               rtn))
+           (linked-buffer-blk-marker-boundaries conf buffer))))
+    (set-marker begin nil)
+    (set-marker end nil)
+    rtn))
 
 (put 'unmatched-delimiter-error
      'error-conditions



reply via email to

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