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

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

[nongnu] elpa/evil-surround 88f371a77f 029/175: Use `surround-line' inst


From: ELPA Syncer
Subject: [nongnu] elpa/evil-surround 88f371a77f 029/175: Use `surround-line' instead of `evil-line' for linewise operations
Date: Mon, 9 Oct 2023 13:01:01 -0400 (EDT)

branch: elpa/evil-surround
commit 88f371a77f426ed5fb37c4f1824decf15c726c07
Author: Frank Fischer <frank.fischer@mathematik.tu-chemnitz.de>
Commit: Frank Fischer <frank.fischer@mathematik.tu-chemnitz.de>

    Use `surround-line' instead of `evil-line' for linewise operations
    
    `evil-line' is a motion that covers a number of lines as a line
    range. This causes surround to add additional line breaks before and
    after the text to be wrapped if used with `yss' commands.
    
    The function `surround-line' covers the same characters but this time
    as exclusive character range.
---
 README.md   |  3 +--
 surround.el | 12 +++++++++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 5b01b195a2..868a045cde 100644
--- a/README.md
+++ b/README.md
@@ -95,8 +95,7 @@ space): `cs]{`
 
     { Hello } world!
 
-Now wrap the entire line in parentheses with `yssb` or `yss)` (wrapping the 
line
-is currently broken see [issue 
#5](https://github.com/timcharper/evil-surround/issues/5)).
+Now wrap the entire line in parentheses with `yssb` or `yss)`.
 
     ({ Hello } world!)
 
diff --git a/surround.el b/surround.el
index 72d726df7f..8b931f6619 100644
--- a/surround.el
+++ b/surround.el
@@ -139,6 +139,16 @@ See also `surround-outer-overlay'."
                                   (evil-range-end inner)
                                   nil nil t))))))
 
+(evil-define-motion surround-line (count)
+  "Move COUNT - 1 lines down but return exclusive character motion."
+  :type exclusive
+  (let ((beg (line-beginning-position)))
+    (evil-line count)
+    (end-of-line)
+    (let ((range (evil-range beg (point) 'exclusive)))
+      (evil-expand-range range)
+      range)))
+
 ;;;###autoload
 (defun surround-delete (char &optional outer inner)
   "Delete the surrounding delimiters represented by CHAR.
@@ -205,7 +215,7 @@ Otherwise call `surround-delete'."
    ((eq operation 'delete)
     (call-interactively 'surround-delete))
    (t
-    (define-key evil-operator-shortcut-map "s" 'evil-line)
+    (define-key evil-operator-shortcut-map "s" 'surround-line)
     (call-interactively 'surround-region))))
 
 (evil-define-operator surround-region (beg end type char &optional 
force-new-line)



reply via email to

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