[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/lentic dea9f03ab8 103/333: Only update regions which ov
From: |
ELPA Syncer |
Subject: |
[elpa] externals/lentic dea9f03ab8 103/333: Only update regions which overlap the change. |
Date: |
Tue, 27 Feb 2024 13:00:12 -0500 (EST) |
branch: externals/lentic
commit dea9f03ab85a15adeeb6e9dbb5bfa82c7da03c63
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>
Only update regions which overlap the change.
Previously, all regions were updated even if they were outside the
change region. While this had no functional changes, it was
computationally expensive.
---
dev-resources/block-comment-changed-first-line.tex | 8 ++
linked-buffer-block.el | 88 +++++++++++++---------
test/linked-buffer-test.el | 5 +-
3 files changed, 64 insertions(+), 37 deletions(-)
diff --git a/dev-resources/block-comment-changed-first-line.tex
b/dev-resources/block-comment-changed-first-line.tex
new file mode 100644
index 0000000000..95a9e72e60
--- /dev/null
+++ b/dev-resources/block-comment-changed-first-line.tex
@@ -0,0 +1,8 @@
+inserted
+Commented Code
+
+\begin{code}
+(comment "code")
+\end{code}
+
+Commented Code
diff --git a/linked-buffer-block.el b/linked-buffer-block.el
index 6ce4343880..11fa488df8 100644
--- a/linked-buffer-block.el
+++ b/linked-buffer-block.el
@@ -87,22 +87,31 @@ function `linked-buffer-configuration' object."
(defun linked-buffer-blk-uncomment-buffer (conf begin end buffer)
"Given CONF, a `linked-buffer-configuration' object, remove all
-start of line comment-characters in appropriate blocks between
-BEGIN and END in BUFFER."
+start of line comment-characters in appropriate blocks. Changes
+should only have occurred between BEGIN and END in BUFFER."
(-map
(lambda (pairs)
- (prog1
- (linked-buffer-blk-uncomment-region
- conf
- (car pairs) (cdr pairs) buffer)
+ (let*
+ ((block-begin (car pairs))
+ (block-end (cdr pairs))
+ (rtn
+ (when
+ (and (>= end block-begin)
+ (>= block-end begin))
+ (linked-buffer-blk-uncomment-region
+ conf
+ block-begin block-end buffer))))
;; remove markers as we go
(set-marker (car pairs) nil)
- (set-marker (cdr pairs) nil)))
- (linked-buffer-blk-marker-boundaries conf begin end buffer)))
+ (set-marker (cdr pairs) nil)
+ rtn))
+ (linked-buffer-blk-marker-boundaries
+ conf buffer)))
(defun linked-buffer-blk-comment-region (conf begin end buffer)
"Given CONF, a `linked-buffer-configuration' object, add
start of line comment characters beween BEGIN and END in BUFFER."
+ (linked-buffer-log "comment-region (%s,%s,%s)" begin end buffer)
(let ((line-match
(m-buffer-match
buffer
@@ -126,17 +135,23 @@ start of line comment characters beween BEGIN and END in
BUFFER."
(defun linked-buffer-blk-comment-buffer (conf begin end buffer)
"Given CONF, a `linked-buffer-configuration' object, add
-start of line comment-characters in appropriate blocks between
-BEGIN and END in BUFFER."
+start of line comment-characters. Changes should only have occurred
+between BEGIN and END in BUFFER."
(-map
;; comment each of these regions
(lambda (pairs)
- (prog1
- (linked-buffer-blk-comment-region
- conf (car pairs) (cdr pairs) buffer)
+ (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)))
- (linked-buffer-blk-marker-boundaries conf begin end buffer)))
+ (set-marker (cdr pairs) nil)
+ rtn))
+ (linked-buffer-blk-marker-boundaries conf buffer)))
(put 'unmatched-delimiter-error
'error-conditions
@@ -145,11 +160,11 @@ BEGIN and END in BUFFER."
(put 'unmatched-delimiter-error
'error-message "Unmatched Delimiter in Buffer")
-(defun linked-buffer-blk-marker-boundaries (conf begin end buffer)
+(defun linked-buffer-blk-marker-boundaries (conf buffer)
"Given CONF, a `linked-buffer-configuration' object, find
-demarcation markers between BEGIN and END in BUFFER. Returns a
-list of start end cons pairs. BEGIN is considered to be an
-implicit start and END an implicit stop."
+demarcation markers. Returns a list of start end cons pairs.
+`point-min' is considered to be an implicit start and `point-max'
+an implicit stop."
(let* ((match-block
(linked-buffer-block-match
conf buffer))
@@ -162,18 +177,19 @@ implicit start and END an implicit stop."
(length match-end))
(linked-buffer-log "delimiters do not match")
(signal 'unmatched-delimiter-error
- (list begin end buffer)))
- (-zip
- ;; start comment markers
- ;; plus the start of the region
- (cons
- (set-marker (make-marker) begin buffer)
- match-start)
- ;; end comment markers
- ;; plus the end of the buffer
- (append
- match-end
- (list (set-marker (make-marker) end buffer))))))
+ (list buffer)))
+ (with-current-buffer buffer
+ (-zip
+ ;; start comment markers
+ ;; plus the start of the region
+ (cons
+ (set-marker (make-marker) (point-min) buffer)
+ match-start)
+ ;; end comment markers
+ ;; plus the end of the buffer
+ (append
+ match-end
+ (list (set-marker (make-marker) (point-max) buffer)))))))
(defmethod linked-buffer-block-match ((conf linked-buffer-block-configuration)
buffer)
@@ -277,13 +293,15 @@ between the two buffers; we don't care which one has
comments."
(defmethod linked-buffer-block-comment-start-regexp
((conf linked-buffer-commented-block-configuration))
- (concat (regexp-quote (oref conf :comment))
- (oref conf :comment-start)))
+ (concat
+ "\\(" (regexp-quote (oref conf :comment)) "\\)?"
+ (oref conf :comment-start)))
(defmethod linked-buffer-block-comment-stop-regexp
((conf linked-buffer-commented-block-configuration))
- (concat (regexp-quote (oref conf :comment))
- (oref conf :comment-stop)))
+ (concat
+ "\\(" (regexp-quote (oref conf :comment)) "\\)?"
+ (oref conf :comment-stop)))
(defmethod linked-buffer-clone
((conf linked-buffer-uncommented-block-configuration)
diff --git a/test/linked-buffer-test.el b/test/linked-buffer-test.el
index 3f97bb9bda..bd50e9e11d 100644
--- a/test/linked-buffer-test.el
+++ b/test/linked-buffer-test.el
@@ -51,7 +51,8 @@
"-c"
a-file
b-file)
- (buffer-string))))))
+ (buffer-string))))
+ nil))
(defun linked-buffer-test-clone-equal (init file cloned-file)
(let ((cloned-file
@@ -259,7 +260,7 @@ This mostly checks my test machinary."
(ert-deftest clojure-latex-first-line ()
"Tests for a bug after introduction of incremental blocks."
- :expected-result :fail
+ :expected-result :failed
(should
(linked-buffer-test-clone-and-change-equal
'linked-buffer-clojure-latex-init
- [elpa] externals/lentic b0c705c488 093/333: Removed :numeric option., (continued)
- [elpa] externals/lentic b0c705c488 093/333: Removed :numeric option., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 8ee4c01fe5 086/333: Fixed some errant blocks., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic b2e4d953f1 053/333: Support for Org to Elisp transformation., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic e9369029fe 055/333: Having this in git is a pain!, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic c88b7ccbe2 057/333: Update to add emacs temp files., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 8b7966fd4e 066/333: Test files added for org-orgel, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 95feec5f21 075/333: Move to MELPA, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 4f5f1bb96a 092/333: Add support for logging non-matching buffers., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic bba710c2f0 100/333: Further tests for incremental updates., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic a85fe6d8d5 101/333: Merge branch 'feature/incremental-update' into feature/incremental-blocks-update, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic dea9f03ab8 103/333: Only update regions which overlap the change.,
ELPA Syncer <=
- [elpa] externals/lentic 4c277411c6 107/333: Edebug Spec for Macro., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 9529b25c69 109/333: Moved with-markers functionality to m-buffer., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 3535011e66 112/333: Refactored to use with-current-location., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 2a4cdabdee 114/333: test-after-change-hooks now works on incremental., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 06510f56a5 013/333: 0.2 release, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 2cb03e9056 002/333: First release version., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic c3822600d5 008/333: Beginning -> begin to reflect changes in m-buffer., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 27b21b2e8f 004/333: Block commenting now operates cleanly with unmatched delimiters., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 021995daf2 010/333: Condition-case form was malformed., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 0db978a409 017/333: Version number bump., ELPA Syncer, 2024/02/27