diff options
| author | Tom Dalziel <tom_dl@hotmail.com> | 2022-04-30 22:05:47 +0100 |
|---|---|---|
| committer | Tom Dalziel <tom_dl@hotmail.com> | 2022-04-30 22:43:52 +0100 |
| commit | 8baa566fc23864da78b46a28c064ee9f937b7cf2 (patch) | |
| tree | 5d179994086df9bac8d6fd11c7c17ce0d25f7ba6 | |
| parent | 03278456c300eb053ecf9652d98beada03589722 (diff) | |
Add `evil-select-inner-unrestricted-object`
| -rw-r--r-- | evil-commands.el | 6 | ||||
| -rw-r--r-- | evil-common.el | 16 | ||||
| -rw-r--r-- | evil-tests.el | 6 |
3 files changed, 23 insertions, 5 deletions
diff --git a/evil-commands.el b/evil-commands.el index 34389a1..0eff012 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -1293,7 +1293,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." @@ -1301,7 +1301,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." @@ -1311,7 +1311,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 1518a4a..6b09cea 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 e66f7d1..e01043e 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -5945,7 +5945,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" |
