branch: elpa/evil-numbers
commit 1bf577af5c6622741aca0f92a629d6dfad172917
Author: Campbell Barton <[email protected]>
Commit: Campbell Barton <[email protected]>
Fix #26: Optionally match characters directly before the cursor
---
CHANGELOG.org | 7 +++++++
README.org | 5 +++++
evil-numbers.el | 23 +++++++++++++++++------
3 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG.org b/CHANGELOG.org
index 1805b9be51..5603599136 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -1,5 +1,12 @@
#+TITLE: Evil Numbers CHANGELOG
+* in development
+
+** Additions
+
+ + =evil-numbers-use-cursor-at-end-of-number= option to match numbers
directly before the cursor
+ (diverging from VIM's default behavior).
+
* 0.6
** Additions
diff --git a/README.org b/README.org
index 65878c7062..aa7675e15c 100644
--- a/README.org
+++ b/README.org
@@ -47,6 +47,11 @@
- '=upcase= Always upper case.
- '=downcase= Always lower case.
+ - =evil-numbers-use-cursor-at-end-of-number= ::
+ Support matching numbers directly before the cursor.
+
+ This is off by default this is not done as it doesn't match VIM's default
behavior.
+
** Key Bindings
Example key bindings:
diff --git a/evil-numbers.el b/evil-numbers.el
index 94ac8225dd..6997b6789d 100644
--- a/evil-numbers.el
+++ b/evil-numbers.el
@@ -99,6 +99,13 @@ Otherwise nil will disable this functionality."
(const :tag "Upper Case" upcase)
(const :tag "Lower Case" downcase)))
+(defcustom evil-numbers-use-cursor-at-end-of-number nil
+ "When non-nil, recognize numbers directly before the cursor.
+
+This doesn't match VIM's behavior."
+ :group 'evil-numbers
+ :type 'boolean
+ :options '(nil t))
;; ---------------------------------------------------------------------------
;; Internal Variables
@@ -601,12 +608,16 @@ result in a number with a + sign."
(t
(let ((point-next
(save-excursion
- ;; `forward-char' so that we do not match the number
- ;; directly behind us.
- ;;
- ;; Check the range to avoid end-of-buffer warning or skipping to
the next line.
- (unless (>= (1+ (point)) (point-at-eol))
- (forward-char))
+ ;; While the default (nil) is VIM's default behavior,
+ ;; users may want to change this, see: #26.
+ (unless evil-numbers-use-cursor-at-end-of-number
+ ;; `forward-char' so that we do not match the number
+ ;; directly behind us.
+ ;;
+ ;; Check the range to avoid end-of-buffer warning
+ ;; or skipping to the next line.
+ (unless (>= (1+ (point)) (point-at-eol))
+ (forward-char)))
(when (evil-numbers--inc-at-pt-impl-with-search
amount (point-at-bol) (point-at-eol) padded)
(point)))))