[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/lentic 27b21b2e8f 004/333: Block commenting now operate
From: |
ELPA Syncer |
Subject: |
[elpa] externals/lentic 27b21b2e8f 004/333: Block commenting now operates cleanly with unmatched delimiters. |
Date: |
Tue, 27 Feb 2024 12:59:51 -0500 (EST) |
branch: externals/lentic
commit 27b21b2e8fe34245541dd0bcc98767a54583e4f3
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>
Block commenting now operates cleanly with unmatched delimiters.
---
linked-buffer.el | 65 +++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 43 insertions(+), 22 deletions(-)
diff --git a/linked-buffer.el b/linked-buffer.el
index 7ca3f032b8..c2e9481927 100644
--- a/linked-buffer.el
+++ b/linked-buffer.el
@@ -392,8 +392,8 @@ In practice, this just returns LOCATION."
(defun linked-buffer-blk-uncomment-region (begin end buffer)
"Between BEGIN and END in BUFFER, remove all start of line comment
characters."
- (m-buffer-replace-matches
- (m-buffer-matches-data
+ (m-buffer-replace-match
+ (m-buffer-match-data
buffer
(linked-buffer-blk-line-start-comment)
begin end) ""))
@@ -409,8 +409,8 @@ delimiter regions."
(defun linked-buffer-blk-comment-region (begin end buffer)
"Between BEGIN and END in BUFFER add comment characters"
- (m-buffer-replace-matches
- (m-buffer-matches-data
+ (m-buffer-replace-match
+ (m-buffer-match-data
buffer
;; perhaps we should ignore lines which are already commented,
"\\(^\\).+"
@@ -426,40 +426,61 @@ delimiter regions."
(car pairs) (cdr pairs) buffer))
(linked-buffer-blk-marker-boundaries begin end buffer)))
+(put 'unmatched-delimiter-error
+ 'error-conditions
+ '(error unmatched-delimiter-error))
+
+(put 'unmatched-delimiter-error
+ 'error-message "Unmatched Delimiter in Buffer")
(defun linked-buffer-blk-marker-boundaries (begin end buffer)
"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."
- (-zip
- ;; start comment markers
- ;; plus the start of the region
- (cons
- (set-marker (make-marker) begin buffer)
- (m-buffer-matches-beginning
- buffer
- (linked-buffer-blk-comment-start-regexp)))
- ;; end comment markers
- ;; plus the end of the buffer
- (append
- (m-buffer-matches-end
- buffer
- (linked-buffer-blk-comment-stop-regexp))
- (list (set-marker (make-marker) end buffer)))))
+ (let ((match-start
+ (m-buffer-match-beginning
+ buffer
+ (linked-buffer-blk-comment-start-regexp)))
+ (match-end
+ (m-buffer-match-end
+ buffer
+ (linked-buffer-blk-comment-stop-regexp))))
+ (unless
+ (= (length match-start)
+ (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))))))
(defun linked-buffer-blk-clone-uncomment (from to)
"Update the contents in buffer TO to match FROM and remove comments."
(linked-buffer-log "blk-clone-uncomment (from,to):(%s,%s)" from to)
(linked-buffer-default-clone-contents from to)
;; remove the line comments in the to buffer
- ;; TODO -- this assumes from is current-buffer
- (linked-buffer-blk-uncomment-buffer (point-min) (point-max) to))
+ ;; if the delimitors are unmatched, then we can do nothing other than clone.
+ (condition-case e
+ (linked-buffer-blk-uncomment-buffer (point-min) (point-max) to)
+ (unmatched-delimiter-error
+ nil)))
(defun linked-buffer-blk-clone-comment (from to)
"Update the contents in buffer TO to match FROM and add comments."
(linked-buffer-log "blk-clone-comment (from,to):(%s,%s)" from to)
(linked-buffer-default-clone-contents from to)
- (linked-buffer-blk-comment-buffer (point-min) (point-max) to))
+ (condition-case e
+ (linked-buffer-blk-comment-buffer (point-min) (point-max) to)
+ (unmatched-delimiter-error nil)))
(defun linked-buffer-pabbrev-expansion-length ()
"Returns the length of any text that pabbrev has currently added to the
buffer."
- [elpa] externals/lentic bba710c2f0 100/333: Further tests for incremental updates., (continued)
- [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, 2024/02/27
- [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 <=
- [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
- [elpa] externals/lentic 8cc0df3b4c 022/333: Some batch manipulation functions added., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic a69e98a8c5 025/333: No longer needed., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 2a1f8bb5f5 026/333: Merge branch 'master' of github.com:phillord/linked-buffer, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic fe3efb4ef6 040/333: evm/cask install, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 3528da0a11 032/333: linked-buffer-asciidoc support., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 45d07d6416 034/333: Documentation cleanup., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 3405c13254 033/333: Change fundamental-mode to normal-mode, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic de2450d3e4 043/333: Removed condition-case-no-debug, ELPA Syncer, 2024/02/27