Skip to content

Support universal arg for debugging in clojure and elisp#56

Open
markgdawson wants to merge 1 commit intodrym-org:mainfrom
markgdawson:support-universal-arg-for-eval-definition
Open

Support universal arg for debugging in clojure and elisp#56
markgdawson wants to merge 1 commit intodrym-org:mainfrom
markgdawson:support-universal-arg-for-eval-definition

Conversation

@markgdawson
Copy link
Copy Markdown
Contributor

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

  • In contributing, I relinquish any copyright claims on my contribution and freely release it into the public domain in the simple hope that it will provide value.

(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
Copy link
Copy Markdown
Collaborator

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
Copy link
Copy Markdown
Collaborator

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

@markgdawson
Copy link
Copy Markdown
Contributor Author

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

@markgdawson
Copy link
Copy Markdown
Contributor Author

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.

@yuki-tsubaki
Copy link
Copy Markdown
Collaborator

yuki-tsubaki commented Sep 5, 2025

@countvajhula This might not matter at this point, but you can actually handle both count and prefix arguments in the same function separately.

Here is a little function that illustrates that (I use it to remind myself sometimes which is which lol):

(defun display-prefix (arg)
  "Display the value of the raw prefix arg."
  (interactive "P")
  (message "%s" arg))

When you call C-u M-x display-prefix you will get (4) displayed in the message area. When you call <normal-state> 4 M-x display-prefix or C-4 M-x display-prefix (or the other ways) you will get 4 in the message area.

In other words, you can distinguish the universal prefix argument (even without funky methods) by checking the type of the raw prefix (interactive "P") instead of (interactive "p").

Thus, you can support both types of functionality.


Edit: though not that I actually looked at the diffs for this PR, I can definitely say that we would want to redo it (in addition to adapting it to 2.0) so that it is clear the prefix arg is generic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants