2

I am very confused by the definitions of define-skeleton and skeleton-proxy-new in skeleton.el in the emacs source (version 28.1).

The command generated by the define-skeleton macro has the interactive spec "*P\nP". Whatever can that mean? Two prefix args? The usual one prefix arg used twice? but str which corresponds to the 1st line of the spec should clearly be a string !

Maybe this is just a bug ? Please help me grok this :-)

2 Answers 2

3

There are no multiple prefix arguments. The interactive specification (interactive "*P\nP") means that the one-and-only raw prefix argument is used twice for the command arguments.

In the case of skeleton-proxy-new it means that the STR argument is just ignored in interactive commands since it is tested with stringp and the raw prefix argument cannot be a string.

BTW, (interactive "*i\nP") would be more clear.

2
  • I think you're right about the effect of the code. But is that what the programmer intended? After all, there is the "i" interactive code for "always nil". At the very least using it would have been cleaner? -- Update: you beat me to it
    – q.undertow
    Commented Jun 14, 2022 at 6:39
  • @q.undertow I've added that (interactive "*i\nP") would better express the intent. It might even be worth a code improvement request.
    – Tobias
    Commented Jun 14, 2022 at 6:44
2

@Tobias has answered the question, but just in case you've found this Q&A because you want to be able to supply multiple different prefix arguments to a command, take a look at the transient library which is included in Emacs 28+ and available in GNU ELPA for earlier versions of Emacs.

If you're a Magit user, Transient is the library which drives its menus, and you already know how it works. If not...


A transient menu is essentially a fancy visual keymap.

It provides visual (but keyboard-⁠driven) menus for invoking commands; and also provides an interface for interactively specifying arguments to pass to those commands, all from within the same menu.

The first aspect is like prefix key bindings, but with all of the keys under the prefix being presented visually in a friendly format, with descriptive labels, so that you can see at a glance what the possible commands are, and which keys invoke them.

The second aspect is like a much fancier notion of prefix arguments, where you can interactively (but optionally) specify the arguments you wish to pass to the command you are about to select (and they are again all labelled clearly, to help you understand what each one does).

It's useful because it's a very efficient and user-⁠friendly interface for invoking complex commands with arbitrary interactive arguments.

1
  • Thanks. I am a magit user, in fact, but I asked this because I am writing my own generic skeleton wrangler and trying to understand the existing code in that area in general, not particularly because of the interactive spec.
    – q.undertow
    Commented Jun 14, 2022 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.