abo-abo / lispy

Short and sweet LISP editing
http://oremacs.com/lispy/
1.2k stars 132 forks source link

How to eval top level form in a single keystroke? #536

Open Andre0991 opened 4 years ago

Andre0991 commented 4 years ago

Hi.

I'm using Ae for evaluating the top level form. This is fine when I don't have to get back to the previous position, otherwise, it's a bit cumbersome.

Evaluating the top level form is super usual, but I haven't found this option in the function reference and I have just lived with that.

Am I missing some command?

If this functionality is not present, would you consider it as a feature request?

abo-abo commented 4 years ago

You can also use C-M-x. But Ae is what I do as well.

When you want it shorter, you mean like a single upper case letter? Because two letters is already quite short.

Andre0991 commented 4 years ago

When you want it shorter, you mean like a single upper case letter? Because two letters is already quite short.

Yeap.

The issue is when you don't want to move the point and getting back to the same place.

For example, say I'm writing a Clojure test. I'd like to change the body of the test, evaluate it, and run the test again with cider-test-run-test.

If I can't eval the top-level sexp, I need to do Ae and then manually get back to where I was.

I can always use of the unbound keys in lispy for doing that, so feel free to close this issue.

Anyway, I'm curious if evaluating the top-level sexp is not as common as I thought.

abo-abo commented 4 years ago

Hi. I've simplified lispy-eval. I think we can now change it like this:

               (looking-at lispy-outline-header))
          (lispy-eval-outline))
         (t
-         (let ((res (lispy--eval nil)))
+         (let ((res (if (eq arg 3)
+                        (save-excursion
+                          (lispy-beginning-of-defun)
+                          (lispy--eval nil))
+                      (lispy--eval nil))))
            (when (member res '(nil ""))

Would 3e be a good binding to eval a top-level expression?

Andre0991 commented 4 years ago

That would work, yeah. Thanks.