[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suppress user-prompting when calling commands in programs

From: Thorsten Jolitz
Subject: Re: Suppress user-prompting when calling commands in programs
Date: Fri, 13 Jun 2014 20:14:00 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Drew Adams <address@hidden> writes:

>> I tried convincing upstream before and never made it!
> Try again.

hmmm ...

>> And I actually understand the authors of code like that and even copied
>> that technique sometimes, because it might be harder to write the
>> interactive spec for both interactive and programmatical use than to
>> write the function itself, and then there is no need for a wrapper
>> command or interactive (lambda ...) expression when it comes to define
>> a key for that command.
> Huh?  Instead of:
> (defun foo (&optional arg)
>   (interactive "P")
>   (let ((bar  (org-icompleting-read ...)))
>     ...))
> What's wrong with them pushing the read into the interactive spec?
> (defun foo (&optional arg bar)
>   (interactive (list current-prefix-arg
>                      (org-icompleting-read ...))))
>   ...)

probably nothing ...

> That's the recommended approach, in general.
> Or if the (org-icompleting-read ...) code itself uses the prefix
> arg as the variable ARG, then rename such occurrences of ARG to,
> say, PREF), and bind PREF before invoking `org-icompleting-read':
> (defun foo (&optional arg bar)
>   (interactive
>     (let ((pref  current-prefix-arg))
>       (list pref (org-icompleting-read ...))))
>   ...)
> Or if they really want to leave the beginning of the code the
> same for some reason, they could at least factor out the body
> (the second "..."), so you can invoke that code directly:
> (defun foo (&optional arg)
>   (interactive "P")
>   (let ((bar (org-icompleting-read ...)))
>     (foo-guts arg bar))) ; <== Just a wrapper for the body.
>                          ;     No other code changes needed.
> Then your code would just call `foo-guts'.

yes, does not look too complicated ...

>> But OTOH its a shame that many commands are hard/impossible to reuse in
>> programs because of this 'trick'.
> A shame and unnecessary.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]