help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Suppress user-prompting when calling commands in programs


From: Stefan Monnier
Subject: Re: Suppress user-prompting when calling commands in programs
Date: Fri, 13 Jun 2014 10:25:19 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

>> (defun foo (&optional arg)
>>   (interactive "P")
>>   (let ((bar (org-icompleting-read ...)))))
> Yuck!

Indeed, the prompting should normally take place in the `interactive'
spec, but the above is sadly pretty common.

>> Assuming `foo' can't be changed - is there another way to bind `bar'
>> before calling `foo' in a program rather than advising `foo' (with the
>> aim to suppress any user-prompting at all during the execution of
>> `foo')?

Not really, no.  And advising `foo' only won't help: you also need to
advise org-icompleting-read.

> cl-flet org-icompleting-read to 'ignore?

Nope.  That worked with `flet', but `cl-flet' is actually providing
Common-Lisp's `flet' which defines a lexically-scoped function.
Better use an advice here.


        Stefan




reply via email to

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