Use Eros for eval last expression

Let's have this as the default for , e e
This commit is contained in:
Howard Abrams 2023-08-14 11:45:54 -07:00
parent e4e800bd70
commit fe6fb9159b
2 changed files with 12 additions and 6 deletions

View file

@ -261,7 +261,7 @@ The [[https://github.com/xiongtx/eros][eros]] package stands for Evaluation Resu
:hook (emacs-lisp-mode . eros-mode))
#+end_src
A feature I enjoyed from Spacemacs is the ability to evaluate the s-expression currently containing the point. Not sure how they made it, but [[help:evil-cp-next-closing ][evil-cp-next-closing]] from cleverparens can help:
A feature I enjoyed from Spacemacs is the ability to evaluate the s-expression currently containing the point. Not sure how they made it, but Lispyville has a =lispyville-next-closing= function to jump to that closing paren (allowing a call to =eval-last=sexp=), and if I save the position using =save-excursion=, I get this feature.
#+begin_src emacs-lisp
(defun ha-eval-current-expression ()
@ -271,15 +271,21 @@ A feature I enjoyed from Spacemacs is the ability to evaluate the s-expression c
finds at that point."
(interactive)
(save-excursion
(if (region-active-p)
(eval-region (region-beginning) (region-end))
(unless (looking-at (rx (any ")" "]")))
(lispyville-next-closing))
(call-interactively 'eval-last-sexp)))
(if (fboundp 'eros-eval-last-sexp)
(call-interactively 'eros-eval-last-sexp)
(call-interactively 'eval-last-sexp)))))
#+end_src
And we just need to bind it.
#+begin_src emacs-lisp
(ha-local-leader :keymaps '(emacs-lisp-mode-map lisp-mode-map)
"e c" '("current" . ha-eval-current-expression))
"e e" '("current" . ha-eval-current-expression))
#+end_src
* Technical Artifacts :noexport:
Let's =provide= a name so we can =require= this file:

View file

@ -696,7 +696,7 @@ Typical keybindings for all programming modes:
"e b" '("buffer" . eval-buffer)
"e f" '("function" . eval-defun)
"e r" '("region" . eval-region)
"e e" '("last s-exp" . eval-last-sexp)
"e e" '("eval exp" . eval-last-sexp)
"e p" '("print s-exp" . ha-eval-print-last-sexp))
#+end_src
** Ligatures