summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Nguyen <james@jojojames.com>2017-12-04 18:20:26 -0800
committerJames Nguyen <james@jojojames.com>2017-12-04 18:20:26 -0800
commit7d24430b68e21a76c54c4d1f2e3a6f0110a926c4 (patch)
treee74abb0f8ecafc3a2dfc1c1884168c3eecc693cd
parent701d127bcde4d7b7b25e40142e9f9bcaa34febfb (diff)
Elisp: Support eval-print-last-sexp when evil-move-beyond-eol is nil
-rw-r--r--evil-elisp-mode.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/evil-elisp-mode.el b/evil-elisp-mode.el
index 82d332a..b788633 100644
--- a/evil-elisp-mode.el
+++ b/evil-elisp-mode.el
@@ -57,8 +57,19 @@ alternative printed representations that can be displayed."
(lookup-key (current-global-map) (kbd "C-m")))
(call-interactively 'elisp-last-sexp-toggle-display)))
+(defun evil-elisp-mode-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-elisp-mode-setup ()
"Set up `evil' bindings for `elisp-mode'."
+ (unless evil-move-beyond-eol
+ (advice-add 'eval-print-last-sexp :around 'evil-elisp-mode-last-sexp))
(advice-add 'last-sexp-setup-props
:override 'evil-elisp-mode-last-sexp-setup-props))