[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil 04b25f6add 2/2: Add `evil-select-inner-unrestricted-o
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil 04b25f6add 2/2: Add `evil-select-inner-unrestricted-object` |
Date: |
Sat, 30 Apr 2022 17:58:05 -0400 (EDT) |
branch: elpa/evil
commit 04b25f6add374652d5f4aabba9e1eb5cde22df9d
Author: Tom Dalziel <tom_dl@hotmail.com>
Commit: Tom Dalziel <33435574+tomdl89@users.noreply.github.com>
Add `evil-select-inner-unrestricted-object`
---
evil-commands.el | 6 +++---
evil-common.el | 16 +++++++++++++++-
evil-tests.el | 6 +++++-
3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/evil-commands.el b/evil-commands.el
index cdf9aa3227..064873d091 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -1296,7 +1296,7 @@ or line COUNT to the top of the window."
(evil-define-text-object evil-inner-symbol (count &optional beg end type)
"Select inner symbol."
- (evil-select-inner-object 'evil-symbol beg end type count))
+ (evil-select-inner-unrestricted-object 'evil-symbol beg end type count))
(evil-define-text-object evil-a-sentence (count &optional beg end type)
"Select a sentence."
@@ -1304,7 +1304,7 @@ or line COUNT to the top of the window."
(evil-define-text-object evil-inner-sentence (count &optional beg end type)
"Select inner sentence."
- (evil-select-inner-object 'evil-sentence beg end type count))
+ (evil-select-inner-unrestricted-object 'evil-sentence beg end type count))
(evil-define-text-object evil-a-paragraph (count &optional beg end type)
"Select a paragraph."
@@ -1314,7 +1314,7 @@ or line COUNT to the top of the window."
(evil-define-text-object evil-inner-paragraph (count &optional beg end type)
"Select inner paragraph."
:type line
- (evil-select-inner-object 'evil-paragraph beg end type count t))
+ (evil-select-inner-unrestricted-object 'evil-paragraph beg end type count t))
(evil-define-text-object evil-a-paren (count &optional beg end type)
"Select a parenthesis."
diff --git a/evil-common.el b/evil-common.el
index 4c25726a93..e28fc5c7a5 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -3102,7 +3102,7 @@ This can be overridden with TYPE."
(>= (evil-range-end range2)
(evil-range-end range1))))
-(defun evil-select-inner-object (thing beg end type &optional count line)
+(defun evil-select-inner-unrestricted-object (thing beg end type &optional
count line)
"Return an inner text object range of COUNT objects.
If COUNT is positive, return objects following point; if COUNT is
negative, return objects preceding point. If one is unspecified,
@@ -3132,6 +3132,20 @@ linewise, otherwise it is character wise."
(if line 'line type)
:expanded t)))
+(defun evil-select-inner-object (thing beg end type &optional count line)
+ "Return an inner text object range of COUNT objects.
+Selection is restricted to the current line.
+If COUNT is positive, return objects following point; if COUNT is
+negative, return objects preceding point. If one is unspecified,
+the other is used with a negative argument. THING is a symbol
+understood by `thing-at-point'. BEG, END and TYPE specify the
+current selection. If LINE is non-nil, the text object should be
+linewise, otherwise it is character wise."
+ (save-restriction
+ (narrow-to-region (save-excursion (beginning-of-line) (point))
+ (save-excursion (end-of-line) (point)))
+ (evil-select-inner-unrestricted-object thing beg end type count line)))
+
(defun evil-select-an-object (thing beg end type count &optional line)
"Return an outer text object range of COUNT objects.
If COUNT is positive, return objects following point; if COUNT is
diff --git a/evil-tests.el b/evil-tests.el
index 1eaf1e8a48..eb5b131767 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -5955,7 +5955,11 @@ Line 2"))
(evil-test-buffer
"foo\n [ ] bar"
("diW")
- "foo\n[b]ar")))
+ "foo\n[b]ar")
+ (evil-test-buffer
+ "fo[o]\nbar"
+ ("diW")
+ "[\n]bar")))
(ert-deftest evil-test-word-objects-cjk ()
"Test `evil-inner-word' and `evil-a-word' on CJK words"