summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Nguyen <james@jojojames.com>2017-11-28 21:55:19 -0800
committerJames Nguyen <james@jojojames.com>2017-11-28 21:55:19 -0800
commitfda63a8547a2668c409f127897af2d84e33962ac (patch)
tree9638a1c733680eaef847b70ff9d3465064cd7b51
parent5cb5ef1e03c2450ccbd34498757d01e5391741c3 (diff)
Slime: Support eval when evil-move-beyond-eol is nil
-rw-r--r--evil-slime.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/evil-slime.el b/evil-slime.el
index b976934..2dbdcfd 100644
--- a/evil-slime.el
+++ b/evil-slime.el
@@ -33,8 +33,24 @@
(defvar sldb-mode-map)
(defvar slime-inspector-mode-map)
+(defun evil-slime-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-slime-setup ()
"Set up `evil' bindings for `slime'."
+ (unless evil-move-beyond-eol
+ (advice-add 'slime-eval-last-expression :around 'evil-slime-last-sexp)
+ (advice-add 'slime-pprint-eval-last-expression :around 'evil-slime-last-sexp)
+ (advice-add 'slime-eval-print-last-expression :around 'evil-slime-last-sexp)
+ (advice-add 'slime-eval-last-expression-in-repl
+ :around 'evil-slime-last-sexp))
+
(evil-collection-util-evilify-map
sldb-mode-map
:mode sldb-mode