Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evil-integration: add compatibility with tempo.el #1153

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions evil-integration.el
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,38 @@ Based on `evil-enclose-ace-jump-for-motion'."
'(when (fboundp 'eldoc-add-command-completions)
(eldoc-add-command-completions "evil-window-")))

;;; Tempo
(declare-function tempo-forward-mark "tempo" ())
(declare-function tempo-backward-mark "tempo" ())
(eval-after-load 'tempo
'(progn
(defadvice tempo-forward-mark (before evil activate)
(when (and (not evil-move-beyond-eol)
(cl-notany (apply-partially #'= (point))
tempo-marks)
(= (point)
(1-
(save-excursion
(evil-move-end-of-line)
(point)))))
(forward-char 1)))

(evil-declare-motion 'tempo-forward-mark)
(evil-declare-motion 'tempo-backward-mark)

;; The original tempo commands don't accept a count argument.
(evil-define-motion evil-tempo-forward-mark (count)
"Move the cursor to the COUNT-th next mark in `tempo-marks'."
:jump t
(evil-motion-loop (_ count)
(tempo-forward-mark)))

(evil-define-motion evil-tempo-backward-mark (count)
"Move the cursor to the COUNT-th previous mark in `tempo-marks'."
:jump t
(evil-motion-loop (_ count)
(tempo-backward-mark)))))

(provide 'evil-integration)

;;; evil-integration.el ends here
55 changes: 55 additions & 0 deletions evil-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -8055,6 +8055,61 @@ maybe we need one line more with some text\n")
((kbd "C-z") (kbd "C-u") (kbd "C-x C-e"))
"(+ 1 (+ 2 33[)])")))

(ert-deftest evil-test-tempo ()
"Test advised `tempo-forward-mark'"
:tags '(evil advice tempo)
(require 'tempo)
;; evil-mode is not turned on when running "make tests" so we have to make
;; sure the advice we're testing is actually active.
(ad-enable-advice 'tempo-forward-mark 'before 'evil)
(ad-activate 'tempo-forward-mark)
(tempo-define-template "evil--test"
'("Line 1" n
"Line 2" p n
"Line 3" p " Line 3"))
(ert-info ("Test if advised `tempo-forward-mark' works in normal mode")
(evil-test-buffer
"
"
("\M-xtempo-template-evil--test" [return])
"Line 1
Line [2]
Line 3 Line 3"
("\M-xtempo-forward-mark" [return])
"Line 1
Line 2
Line 3[ ]Line 3"
("\M-xtempo-forward-mark" [return])
"Line 1
Line 2
Line 3 Line [3]"
("\M-xtempo-backward-mark" [return] "\M-xtempo-backward-mark" [return])
"Line 1
Line [2]
Line 3 Line 3"
))
(ert-info ("Test if advised `tempo-forward-mark' works in insert mode")
(evil-test-buffer
:state insert
"
"
("\M-xtempo-template-evil--test" [return])
"Line 1
Line 2[]
Line 3 Line 3"
("\M-xtempo-forward-mark" [return])
"Line 1
Line 2
Line 3[ ]Line 3"
("\M-xtempo-forward-mark" [return])
"Line 1
Line 2
Line 3 Line 3[]"
("\M-xtempo-backward-mark" [return] "\M-xtempo-backward-mark" [return])
"Line 1
Line 2[]
Line 3 Line 3")))

;;; ESC

(ert-deftest evil-test-esc-count ()
Expand Down