When I change something in a function, I need to move to the last parenthese of a function, and do C-x C-e.
I thought it would be nice if I can devise a keybinding to evaluate the function, while I'm in the middle of the function.
So I came up with the following:
(defun evaluate-sentence ()
(interactive)
(evil-set-marker ?8)
(sp-end-of-sexp)
(eval-last-sexp)
(evil-goto-mark ?8))
The number 8 is just abritrary. You need to have Evil and Smartparens. It sets the mark on the current position of the pointer, then go to the outer parenthese, eval it, and go back to the marked position.
I need to pass the correct arguments for eval-last-sexp
. When looking up the documentation for C-x C-e, it says the following:
C-x C-e runs the command eval-last-sexp (found in global-map), which
is an interactive compiled Lisp function in
‘a:/Dropbox/Emacs/share/emacs/25.0.50/lisp/progmodes/elisp-mode.el’.
It is bound to <menu-bar> <emacs-lisp> <eval-sexp>, C-x C-e.
(eval-last-sexp EVAL-LAST-SEXP-ARG-INTERNAL)
Evaluate sexp before point; print value in the echo area.
Interactively, with prefix argument, print output into current buffer.
Normally, this function truncates long output according to the value
of the variables ‘eval-expression-print-length’ and
‘eval-expression-print-level’. With a prefix argument of zero,
however, there is no such truncation. Such a prefix argument
also causes integers to be printed in several additional formats
(octal, hexadecimal, and character).
If ‘eval-expression-debug-on-error’ is non-nil, which is the default,
this command arranges for all errors to enter the debugger.
I'm not sure what the argument EVAL-LAST-SEXP-ARG-INTERNAL
actually says. When I do an aprpos search with C-h a, he found nothing about what the argument EVAL-LAST-SEXP-ARG-INTERNAL
really means. I would love to solve this myself, instead calling for help. But I'm out of ideas...
Any other suggestion?
C-M-x
iseval-defun
.(setq [..])
, so I need to have a global function that handles other things thaneval-defun
too. Thanks for your suggestion anyway.eval-defun
is not just fordefun
s: it evaluates the top-level form, which could just as easily be asetq
.eval-defun
is somewhat confusing. Aside to that, I really appreciate your help here on Emacs stackexchange.