drym-org / symex.el

An intuitive way to edit Lisp symbolic expressions ("symexes") structurally in Emacs
Other
271 stars 22 forks source link

Support universal arg for debugging in clojure and elisp #56

Open markgdawson opened 1 year ago

markgdawson commented 1 year ago

Summary of Changes

In elisp and clojure, the universal arg evaluates an expression in a debug mode. These are pretty handy and universal arg isn't currently used for these commands in symex. So I've added it here in the hope that we think it's a good idea.

Public Domain Dedication

(Why: The freely released, copyright-free work in this repository represents an investment in a better way of doing things called attribution-based economics. Attribution-based economics is based on the simple idea that we gain more by giving more, not by holding on to things that, truly, we could only create because we, in our turn, received from others. As it turns out, an economic system based on attribution -- where those who give more are more empowered -- is significantly more efficient than capitalism while also being stable and fair (unlike capitalism, on both counts), giving it transformative power to elevate the human condition and address the problems that face us today along with a host of others that have been intractable since the beginning. You can help make this a reality by releasing your work in the same way -- freely into the public domain in the simple hope of providing value. Learn more about attribution-based economics at drym.org, tell your friends, do your part.)

countvajhula commented 1 year ago

That does sound useful. One thing to consider though is that in Evil, typically the universal argument is expected to be a count. While Symex adopts this convention for many interfaces (like symex-evaluate, e.g. 3e evaluates three expressions), it doesn't at present adopt it universally. In principle, 3d in Symex is analogous to 3diw in Evil/Vim, which, I'm not sure if you're familiar with Vim, but this is a command to essentially delete 3 words, but which, unlike 3dw, can be run from within a word and doesn't require you to be at the beginning of the word (in practice though, because this command treats spaces as words, it undercounts what we consider to be words and isn't that useful!).

So it's not inconceivable that we'd want to support 3d to mean "evaluate the next 3 definitions, including the current one," and this usage would be in conflict with the use of the universal argument for debugging.

How about using a distinct keybinding for this, e.g. gd, which would correspond to a new symex-eval-for-debug?

tommy-mor commented 1 year ago

not related to symex, but what is "universal arg", i've never heard this term

markgdawson commented 1 year ago

This explains it better then I could: https://www.emacswiki.org/emacs/PrefixArgument#universal_argument

markgdawson commented 1 year ago

i wasn't aware of that count and prefix used the same function argument. In that case the gd option sounds like a good way forward. I won't be able to take a look at this for a week or so at least, but I'll take a look at this when I get back.