Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determining arguments to interactive functions #51

Open
vermiculus opened this issue Sep 21, 2018 · 2 comments
Open

Determining arguments to interactive functions #51

vermiculus opened this issue Sep 21, 2018 · 2 comments

Comments

@vermiculus
Copy link

Is there any prevailing wisdom on when to use the (interactive (list ...)) form over the body code (setq arg-1 (or arg-1 (get-default))? Personally I prefer (and more often see) the former, but I've realized I have no good reasoning either way.

@Fuco1
Copy link
Collaborator

Fuco1 commented Sep 21, 2018

If the mandatory argument can be worked out with the interactive code letters I prefer that and set the optional args in the body. So if I have (beg end &optional flag) then I would use (interactive "r") because that's probably the intended semantics.

I would never set optional args in the interactive form if they are not for interactive use. If they are some flags which can be determined during interactive use I would prefer the list spec except when it would be overly complicated (then I would prefer simple code letters/prompts and the logic in the body).

I understand my answer is pretty vague :D But a definitive rule for me is: never use the interactive list spec if non-interactive use-case can run through it.

@bbatsov
Copy link
Owner

bbatsov commented Sep 22, 2018

@Fuco1 Seems to me you want to write the rule about this in the guide. ;-)

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

No branches or pull requests

3 participants