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

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

[elpa] externals/lentic 779c2d05e3 120/333: Treat start of line properly


From: ELPA Syncer
Subject: [elpa] externals/lentic 779c2d05e3 120/333: Treat start of line properly in blocks.
Date: Tue, 27 Feb 2024 13:00:15 -0500 (EST)

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

    Treat start of line properly in blocks.
    
    Previously, deleting the uncommented buffer to the beginning of the line
    would leave the comments around. We now expand any change at the
    beginning of the line in the uncommented buffer to the beginning of the
    line in the commented buffer (i.e. affecting comments).
---
 linked-buffer-block.el     | 64 +++++++++++++++++++++++++++++-----------------
 test/linked-buffer-test.el | 11 +++-----
 2 files changed, 44 insertions(+), 31 deletions(-)

diff --git a/linked-buffer-block.el b/linked-buffer-block.el
index c88dba2096..d766d113ad 100644
--- a/linked-buffer-block.el
+++ b/linked-buffer-block.el
@@ -361,30 +361,46 @@ between the two buffers; we don't care which one has 
comments."
    &optional start stop length-before start-converted stop-converted)
   "Update the contents in the linked-buffer with comments."
   ;;(linked-buffer-log "blk-clone-comment conf):(%s)" conf)
-  (call-next-method conf start stop length-before
-                    start-converted stop-converted)
-  (condition-case e
-      (linked-buffer-blk-comment-buffer
-       conf
-       ;; the buffer at this point has been copied over, but is in an
-       ;; inconsistent state (because it may have comments that it should
-       ;; not). Still, the convertor should still work because it counts from
-       ;; the end
-       (linked-buffer-convert
-        conf
-        ;; point-min if we know nothing else
-        (or start (point-min)))
-       (linked-buffer-convert
-        conf
-        ;; if we have a stop
-        (if stop
-            ;; take stop (if we have got longer) or
-            ;; start length before (if we have got shorter)
-            (max stop
-                 (+ start length-before))
-          (point-max)))
-       (linked-buffer-that conf))
-    (unmatched-delimiter-error nil)))
+  (let*
+      ((start-at-bolp
+        (when
+            (and start
+                 (linked-buffer-bolp
+                  (oref conf :this-buffer)
+                  start))
+          (m-buffer-with-current-location
+              (oref conf :that-buffer)
+              start-converted
+            (line-beginning-position))))
+       (start-converted (or start-at-bolp start-converted)))
+    (if (or start-at-bolp)
+        (linked-buffer-log "In comment: %s"
+                           (when start-at-bolp
+                             "start")))
+    (call-next-method conf start stop length-before
+                      start-converted stop-converted)
+    (condition-case e
+        (linked-buffer-blk-comment-buffer
+         conf
+         ;; the buffer at this point has been copied over, but is in an
+         ;; inconsistent state (because it may have comments that it should
+         ;; not). Still, the convertor should still work because it counts from
+         ;; the end
+         (linked-buffer-convert
+          conf
+          ;; point-min if we know nothing else
+          (or start (point-min)))
+         (linked-buffer-convert
+          conf
+          ;; if we have a stop
+          (if stop
+              ;; take stop (if we have got longer) or
+              ;; start length before (if we have got shorter)
+              (max stop
+                   (+ start length-before))
+            (point-max)))
+         (linked-buffer-that conf))
+      (unmatched-delimiter-error nil))))
 
 (defmethod linked-buffer-invert
   ((conf linked-buffer-uncommented-block-configuration))
diff --git a/test/linked-buffer-test.el b/test/linked-buffer-test.el
index 369b447bd6..0a61abd27f 100644
--- a/test/linked-buffer-test.el
+++ b/test/linked-buffer-test.el
@@ -21,7 +21,7 @@
 (defun linked-buffer-test-equal-loudly (a b)
   "Actually, this just tests equality and shouts if not."
   ;; change this to t to disable noisy printout
-  (if t
+  (if nil
       (string= a b)
     (if (string= a b)
         t
@@ -163,7 +163,7 @@ results."
               (setq this
                     (find-file-noselect filename))
             (setq linked-buffer-init init)
-            (progn 
+            (progn
               (setq that
                     (linked-buffer-init-create))
               (funcall f-this)
@@ -183,7 +183,7 @@ results."
                      (point-max))))
             (set-buffer-modified-p nil)
             retn)
-        
+
         ;; unwind forms
         (when this (kill-buffer this))
         (when that (kill-buffer that))))
@@ -316,12 +316,9 @@ This mostly checks my test machinary."
     "orgel-org.el" "orgel-org.el"
     nil
     (lambda ()
+      (show-all)
       (goto-char (point-min))
       (forward-line)
       (insert "a")
       (delete-char -1))
     t)))
-
-
-
-    



reply via email to

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