diff options
| author | James Nguyen <james@jojojames.com> | 2021-01-14 00:27:12 -0800 |
|---|---|---|
| committer | James N <james@jojojames.com> | 2021-01-14 22:41:03 -0800 |
| commit | a67450ff537b9681a5fed25010ce28d4128e6db2 (patch) | |
| tree | 4091aa8556e192ba4fb6c999f2dca992b7b5d6f9 /modes | |
| parent | 8b1bcd7e49c3fb4ae047d65e22e652a2fb65fa3a (diff) | |
Sly: Advise sly-eval-print-last-expression
Credits to nnoodle for implementation.
For more details:
https://github.com/emacs-evil/evil-collection/pull/441
Diffstat (limited to 'modes')
| -rw-r--r-- | modes/sly/evil-collection-sly.el | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/modes/sly/evil-collection-sly.el b/modes/sly/evil-collection-sly.el index 4e1ebd5..267278f 100644 --- a/modes/sly/evil-collection-sly.el +++ b/modes/sly/evil-collection-sly.el @@ -32,6 +32,9 @@ (require 'evil-collection) (require 'sly nil t) +(declare-function sly-last-expression "sly") +(declare-function sly-eval-print "sly") + (defvar sly-connection-list-mode-map) (defvar sly-db-mode-map) (defvar sly-inspector-mode-map) @@ -62,14 +65,29 @@ (apply command args)) (apply command args))) +(defun evil-collection-sly-eval-print-last-expression (string) + "Evaluate sexp before point; print value into the current buffer. + +Evil version of `sly-eval-print-last-expression' that accounts for +`evil-move-beyond-eol'." + (interactive + (list (progn + (when (and (not evil-move-beyond-eol) + (or (evil-normal-state-p) (evil-motion-state-p))) + (unless (or (eobp) (eolp)) + (forward-char))) + (sly-last-expression)))) + (insert "\n") + (sly-eval-print string)) + ;;;###autoload (defun evil-collection-sly-setup () "Set up `evil' bindings for `sly'." (unless evil-move-beyond-eol (advice-add 'sly-eval-last-expression :around 'evil-collection-sly-last-sexp) (advice-add 'sly-pprint-eval-last-expression :around 'evil-collection-sly-last-sexp) - (advice-add 'sly-eval-print-last-expression :around 'evil-collection-sly-last-sexp) - (advice-add 'sly-mrepl-return :around 'evil-collection-sly-last-sexp)) + (advice-add 'sly-mrepl-return :around 'evil-collection-sly-last-sexp) + (advice-add 'sly-eval-print-last-expression :override 'evil-collection-sly-eval-print-last-expression)) (evil-collection-define-key 'normal 'sly-db-mode-map [follow-link] 'mouse-face |
