[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-surround 641498131a 059/175: Refactor evil-surround-b
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-surround 641498131a 059/175: Refactor evil-surround-block |
Date: |
Mon, 9 Oct 2023 13:01:03 -0400 (EDT) |
branch: elpa/evil-surround
commit 641498131afea83dc612b73569ba61055a648ec8
Author: Henrik Lissner <henrik@lissner.net>
Commit: Henrik Lissner <henrik@lissner.net>
Refactor evil-surround-block
---
evil-surround.el | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/evil-surround.el b/evil-surround.el
index 4a8aaf5aa5..63df8f6c18 100755
--- a/evil-surround.el
+++ b/evil-surround.el
@@ -217,21 +217,19 @@ overlays OUTER and INNER, which are passed to
`evil-surround-delete'."
(define-key evil-operator-shortcut-map "s" 'evil-surround-line)
(define-key evil-operator-shortcut-map "S" 'evil-surround-line))
+(defun evil-surround-column-at (pos)
+ (save-excursion (goto-char pos) (current-column)))
+
(defun evil-surround-block (beg end char)
- "Split a block into regions per line and surround each of them individually."
- (save-excursion
- (goto-char beg)
- (let ((lines (- (1+ (line-number-at-pos end)) (line-number-at-pos beg)))
- (start-col (current-column))
- (end-col (save-excursion (goto-char end) (current-column))))
- (while (> lines 0)
- (move-to-column start-col)
- ;; skip lines that are empty at this column
- (unless (/= start-col (current-column))
- (evil-surround-region (point) (save-excursion (move-to-column
end-col) (point))
- 'inclusive char))
- (setq lines (1- lines))
- (next-line)))))
+ "Split a block into regions per line and surround them individually. Skips
+lines where the columns don't line up."
+ (let* ((beg-col (evil-surround-column-at beg))
+ (end-col (evil-surround-column-at end)))
+ (evil-apply-on-block
+ (lambda (ibeg iend)
+ (unless (< (evil-surround-column-at ibeg) (min beg-col end-col))
+ (evil-surround-region ibeg iend t char)))
+ beg end nil)))
;; Dispatcher function in Operator-Pending state.
;; "cs" calls `evil-surround-change', "ds" calls `evil-surround-delete',
- [nongnu] elpa/evil-surround 282a975bda 154/175: Typo fix, (continued)
- [nongnu] elpa/evil-surround 282a975bda 154/175: Typo fix, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround a3803cfb51 141/175: Add a test for surrounding with a tag in a macro, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 6d37e5c910 115/175: add melpa stable badge, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround f273821f57 165/175: Merge pull request #188 from skangas/nongnu-elpa-fixes, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 2bc8aa6425 160/175: Merge pull request #186 from leungbk/prefix-calls, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 4a21d756b7 168/175: Revert "Enable lexical binding", ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround a3034c284d 049/175: Fix surrounding with invalid chars, like ESC (Fix #51), ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 27eb4112db 050/175: Merge pull request #53 from hlissner/block-surround, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 71f380b6b6 042/175: Merge pull request #35 from Silex/master, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround ce36c8307c 047/175: correct README.md, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 641498131a 059/175: Refactor evil-surround-block,
ELPA Syncer <=
- [nongnu] elpa/evil-surround 0eeef7a3a9 070/175: Merge pull request #68 from hlissner/master, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 8b2ca83b7c 068/175: Fix #52, #39, and #5 (linewise surrounding), ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 78eddc8077 063/175: Merge pull request #50 from yangguang760/master, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 06071c3425 060/175: let* => let, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround a70e34164e 069/175: Don't indent first line on inline linewise surround, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 5c07befaf7 090/175: Merge pull request #89 from LemmingAvalanche/execute-permissions, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 7a0358ce3e 095/175: update readme, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround a4fc4483df 103/175: add credits to Tim C. Harper, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround cb4f0be9b4 119/175: add backquote delimiter test, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 822a0f61c3 111/175: Make `ysw` work like `cw`, not `ce`, ELPA Syncer, 2023/10/09