aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Dalziel <tom_dl@hotmail.com>2021-02-20 22:56:00 +0000
committerTom Dalziel <tom_dl@hotmail.com>2021-02-28 15:40:26 +0000
commit22a26d28d50f6ed5180417a9ef614f173c1709ac (patch)
tree8ec45113d327476b6387f8fdce67378afbc6238b
parent881a9ef5b92678c420617bfd60434c99ffb924b6 (diff)
Fix evil-goto-char and add `go` keybinding
-rw-r--r--evil-commands.el3
-rw-r--r--evil-maps.el1
-rw-r--r--evil-tests.el16
-rw-r--r--evil-types.el8
4 files changed, 27 insertions, 1 deletions
diff --git a/evil-commands.el b/evil-commands.el
index 5315fc7..ad96131 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -3859,7 +3859,8 @@ range. The given argument is passed straight to
(evil-define-command evil-goto-char (position)
"Go to POSITION in the buffer.
Default position is the beginning of the buffer."
- (interactive "p")
+ :jump t
+ (interactive "<N>Goto position: ")
(let ((position (evil-normalize-position
(or position (point-min)))))
(goto-char position)))
diff --git a/evil-maps.el b/evil-maps.el
index 8820215..70bf25f 100644
--- a/evil-maps.el
+++ b/evil-maps.el
@@ -212,6 +212,7 @@
(define-key evil-motion-state-map "g_" 'evil-last-non-blank)
(define-key evil-motion-state-map "g^" 'evil-first-non-blank-of-visual-line)
(define-key evil-motion-state-map "gm" 'evil-middle-of-visual-line)
+(define-key evil-motion-state-map "go" 'evil-goto-char)
(define-key evil-motion-state-map "g$" 'evil-end-of-visual-line)
(define-key evil-motion-state-map "g\C-]" 'evil-jump-to-tag)
(define-key evil-motion-state-map "{" 'evil-backward-paragraph)
diff --git a/evil-tests.el b/evil-tests.el
index 4af6fcb..5bb0ce2 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -3048,6 +3048,22 @@ Below some empty line")))
return EXIT_SUCCESS;
\[}]"))
+(ert-deftest evil-test-goto-char ()
+ "Test `evil-goto-char' motion and ex command."
+ :tags '(evil motion ex)
+ (evil-test-buffer
+ "[W]e only need a short buffer for this test"
+ (":goto 9")
+ "We only [n]eed a short buffer for this test"
+ (":goto")
+ "[W]e only need a short buffer for this test"
+ ("16go")
+ "We only need a [s]hort buffer for this test"
+ ("go18")
+ "We only need a sh[o]rt buffer for this test"
+ (evil-goto-char 24)
+ "We only need a short bu[f]fer for this test"))
+
(ert-deftest evil-test-operator-0 ()
"Test motion \"0\" with an operator."
:tags '(evil motion)
diff --git a/evil-types.el b/evil-types.el
index d72466e..fe4972b 100644
--- a/evil-types.el
+++ b/evil-types.el
@@ -342,6 +342,14 @@ If visual state is inactive then those values are nil."
:ex-arg t
(list (when (evil-ex-p) evil-ex-argument)))
+(evil-define-interactive-code "<N>" (prompt)
+ "Prefix argument, ex-arg or minibuffer input, converted to number"
+ (list (cond
+ (current-prefix-arg (prefix-numeric-value current-prefix-arg))
+ ((and evil-ex-argument (evil-ex-p)) (string-to-number evil-ex-argument))
+ ((evil-ex-p) nil)
+ (t (string-to-number (read-string prompt))))))
+
(evil-define-interactive-code "<f>"
"Ex file argument."
:ex-arg file