use-package icon indicating copy to clipboard operation
use-package copied to clipboard

Add :commands* keyword

Open conao3 opened this issue 4 years ago • 8 comments

Add :command* keyword proposed at #851. Special thanks to @aspiers.

This :command* is similar to :command, but it generate autoload statement as no-interactive one.

conao3 avatar Feb 22 '21 18:02 conao3

There should be a less confusing name than :command* for this. IIRC, commands in Emacs terminology are always interactive. maybe :autoload instead?

thomasf avatar Feb 22 '21 19:02 thomasf

Function: commandp object &optional for-call-interactively This function returns t if object is a command. Otherwise, it returns nil.

Commands include strings and vectors (which are treated as keyboard macros), lambda expressions that contain a top-level interactive form (see Using Interactive), byte-code function objects made from such lambda expressions, autoload objects that are declared as interactive (non-nil fourth argument to autoload), and some primitive functions. Also, a symbol is considered a command if it has a non-nil interactive-form property, or if its function definition satisfies commandp.

If for-call-interactively is non-nil, then commandp returns t only for objects that call-interactively could call—thus, not for keyboard macros.

thomasf avatar Feb 22 '21 19:02 thomasf

Completely agree. I renamed :commands* to :autoload.

conao3 avatar Feb 22 '21 19:02 conao3

@conao3 commented on February 22, 2021 7:13 PM:

Completely agree. I renamed :commands* to :autoload.

As suggested in #851 I think :functions is a better choice of symbol here. :autoload is a confusing choice to me because :commands already causes autoloads, so there is an undesirable overlap between the two if this name is used.

aspiers avatar Feb 22 '21 19:02 aspiers

Thanks, @aspiers. Now I think :functions is better. How about @thomasf?

CC: @jwiegley

conao3 avatar Feb 22 '21 19:02 conao3

I don't think that is a clean orthogonal feature regardless of what we name it. :autoload is at least somewhat self explanatory even if :commands also creates autoloads (for commands). I'm not sure if I think that one argument is particularly stronger than the other here.

thomasf avatar Feb 22 '21 19:02 thomasf

@thomasf commented on February 22, 2021 7:21 PM:

I don't think that is a clean orthogonal feature regardl ess of what we name it. :autoload is at least somewhat self explanatory even if :commands also creates autoloads (for commands. I'm not sure if I think that one argument is particularly stronger than the other here.

You are right, my suggestion isn't much better :laughing: Hmmm, I wonder if there is a better word ...

aspiers avatar Feb 22 '21 19:02 aspiers

:functions is already use to satisfy the byte-compiler, but we could easily make that keyword do this as well.

jwiegley avatar Feb 24 '21 17:02 jwiegley

Thank you, I think this is a good and safe addition.

jwiegley avatar Oct 12 '22 17:10 jwiegley