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

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

[elpa] externals/lentic 370ebf12a9 268/333: Widening was inconsistent in


From: ELPA Syncer
Subject: [elpa] externals/lentic 370ebf12a9 268/333: Widening was inconsistent in hooks.
Date: Tue, 27 Feb 2024 13:00:43 -0500 (EST)

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

    Widening was inconsistent in hooks.
    
    Lentic was widen buffers inconsistently in hooks, in particular the
    before-command-function was not widened. This has been fixed a new macro
    introduced which widens both buffers in a conf cleanly.
    
    In this process of fixing this bug, I found that the orgel-org
    configuration was dependent on the global current-buffer, rather than
    obeying its own state; this was caused by a bug in m-buffer, hence the
    dependency for this has been updated.
    
    This also addresses a problem with "comment-region", in clojure buffers.
    This uses narrowing to limit the effect of the commenting function. The
    before-command-function was running with narrowing in place, which mean
    that the location of the change was incorrectly calculated.
    
    Closes #27
---
 Cask            |  2 +-
 lentic-block.el |  1 -
 lentic.el       | 64 +++++++++++++++++++++++++++++++++++----------------------
 3 files changed, 41 insertions(+), 26 deletions(-)

diff --git a/Cask b/Cask
index f3a67c6a06..8080df17e9 100644
--- a/Cask
+++ b/Cask
@@ -1,7 +1,7 @@
 ;; -*- emacs-lisp -*-
 (source gnu)
 (source marmalade)
-(source melpa-stable)
+(source melpa)
 
 (package-file "lentic.el")
 
diff --git a/lentic-block.el b/lentic-block.el
index e94065b31c..ba50a28486 100644
--- a/lentic-block.el
+++ b/lentic-block.el
@@ -141,7 +141,6 @@ should only have occurred between BEGIN and END in BUFFER."
 (defun lentic-blk-comment-region (conf begin end buffer)
   "Given CONF, a `lentic-configuration' object, add
 start of line comment characters beween BEGIN and END in BUFFER."
-  (lentic-log "comment-region (%s,%s,%s)" begin end buffer)
   (m-buffer-with-markers
       ((line-match
         (m-buffer-match
diff --git a/lentic.el b/lentic.el
index 465ba37a86..20e7a670e5 100644
--- a/lentic.el
+++ b/lentic.el
@@ -7,7 +7,7 @@
 ;; Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
 ;; Maintainer: Phillip Lord <phillip.lord@newcastle.ac.uk>
 ;; Version: 0.10
-;; Package-Requires: ((emacs "24.4")(m-buffer "0.10")(dash "2.5.0")(f 
"0.17.2"))
+;; Package-Requires: ((emacs "24.4")(m-buffer "0.13")(dash "2.5.0")(f 
"0.17.2"))
 
 ;; The contents of this file are subject to the GPL License, Version 3.0.
 
@@ -534,6 +534,7 @@ in the new."
                  (stop (or stop (point-max))))
             (with-current-buffer that-b
               (save-restriction
+                (widen)
                 ;; get the start location that we converted before the change.
                 ;; lentic-convert is not reliable now, because the two
                 ;; buffers do not share state until we have percolated it
@@ -545,8 +546,6 @@ in the new."
                        (min (point-max)
                             (or stop-converted
                                 (point-max)))))
-                  ;; does this widen do anything?
-                  (widen)
                   (delete-region converted-start
                                  converted-stop)
                   (save-excursion
@@ -650,6 +649,19 @@ Emacs crashes with backtraces in batch." )
          ,bodyform
        ,@handlers)))
 
+(defmacro lentic-widen (conf &rest body)
+  "Widen both buffers in CONF, then evaluate BODY."
+  (declare (debug t)
+           (indent 1))
+  `(with-current-buffer
+       (lentic-that ,conf)
+     (save-restriction
+       (widen)
+       (with-current-buffer
+           (lentic-this ,conf)
+         (save-restriction
+           (widen)
+           ,@body)))))
 ;; #+end_src
 
 ;; Recurse down the lentic tree to all lentic views.
@@ -1102,23 +1114,25 @@ SEEN-BUFFER is a list of buffers to which the change 
has been percolated."
            (or (-contains? seen-buffer (lentic-that config))
                ;; convert uses that buffer
                (not (buffer-live-p (lentic-that config))))
-         (oset config :last-change-start start)
-         (oset config
-               :last-change-start-converted
-               (lentic-convert
-                config
-                start))
-         (oset config :last-change-stop stop)
-         (oset config
-               :last-change-stop-converted
-               (lentic-convert
-                config
-                stop))
-         (lentic-before-change-function-1
-          (lentic-that config)
-          (oref config :last-change-start-converted)
-          (oref config :last-change-stop-converted)
-          seen-buffer)))
+         (lentic-widen
+             config
+           (oset config :last-change-start start)
+           (oset config
+                 :last-change-start-converted
+                 (lentic-convert
+                  config
+                  start))
+           (oset config :last-change-stop stop)
+           (oset config
+                 :last-change-stop-converted
+                 (lentic-convert
+                  config
+                  stop))
+           (lentic-before-change-function-1
+            (lentic-that config)
+            (oref config :last-change-start-converted)
+            (oref config :last-change-stop-converted)
+            seen-buffer))))
      lentic-config)))
 ;; #+end_src
 
@@ -1190,10 +1204,12 @@ LENGTH-BEFORE is the length of area before the change."
         (oset conf :last-change-start-converted nil)
         (oset conf :last-change-stop nil)
         (oset conf :last-change-stop-converted nil)
-        (if skewed
-            (lentic-clone conf)
-          (lentic-clone conf start stop length-before
-                        start-converted stop-converted))))))
+        (lentic-widen
+            conf
+          (if skewed
+              (lentic-clone conf)
+            (lentic-clone conf start stop length-before
+                          start-converted stop-converted)))))))
 
 (defun lentic-update-point (conf)
   "Update the location of point in that-buffer to reflect this-buffer.



reply via email to

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