diff options
| author | James Nguyen <james@jojojames.com> | 2017-11-28 19:25:07 -0800 |
|---|---|---|
| committer | James Nguyen <james@jojojames.com> | 2017-11-28 19:25:07 -0800 |
| commit | 08cb490f19920e02523aa4182d7b2c40cfe74883 (patch) | |
| tree | 2d876ddc2942890fe9a2ed3eb9ee662a0258d3fe /evil-cider.el | |
| parent | 771dfbea3b1aed7897f0cc15388744500b69777e (diff) | |
Cider: Support eval when evil-move-beyond-eol is nil
https://github.com/syl20bnr/spacemacs/issues/646
Diffstat (limited to 'evil-cider.el')
| -rw-r--r-- | evil-cider.el | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/evil-cider.el b/evil-cider.el index 670f666..fa79ccb 100644 --- a/evil-cider.el +++ b/evil-cider.el @@ -30,8 +30,23 @@ (require 'cider nil t) (require 'evil-collection-util) +(defun evil-cider-last-sexp (command &rest args) + "In normal-state or motion-state, last sexp ends at point." + (if (and (not evil-move-beyond-eol) + (or (evil-normal-state-p) (evil-motion-state-p))) + (save-excursion + (unless (or (eobp) (eolp)) (forward-char)) + (apply command args)) + (apply command args))) + (defun evil-cider-setup () "Set up `evil' bindings for `cider'." + (advice-add 'cider-eval-last-sexp :around 'evil-cider-last-sexp) + (advice-add 'cider-eval-last-sexp-and-replace :around 'evil-cider-last-sexp) + (advice-add 'cider-eval-last-sexp-to-repl :around 'evil-cider-last-sexp) + (with-eval-after-load 'cider-eval-sexp-fu + (advice-add 'cider-esf--bounds-of-last-sexp :around 'evil-cider-last-sexp)) + (evil-define-key '(normal visual) cider-mode-map "gd" 'cider-find-var (kbd "C-t") 'cider-pop-back |
