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

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

Re: How to avoid y-or-n-p in a program?


From: Thorsten Jolitz
Subject: Re: How to avoid y-or-n-p in a program?
Date: Fri, 14 Mar 2014 15:48:03 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Stefan <monnier@iro.umontreal.ca> writes:

>> Is it generally considered a (kind of) bug when a COMMAND (not a
>> function) calls y-or-n-p unconditionally (or enforces user input in
>> other ways)?
>
> Not sure about "generally", but it's a good principle to decompose
> a functionality into a "batch-only" part and an interactive wrapper.

So rather than adding additional function args to the command and using
something like (when (called-interactively-p) ...) the canonical way
would be to split the command into a function (probably with additional
function args) and a command that calls this function (the interactive
wrapper)?

> So we probably wouldn't consider all such cases as bugs, but if
> a particular case is problematic, you should definitely request the
> change (which we may sometimes reject, of course, typically if it would
> require too many/ugly modifications to the code).

This would be more directed towards Org-mode I think ...
What if a command/function is overly verbose wrt to messages when used
in a program? Is it reasonable to ask for including an optional switch
like this

(defun xyz (args &optional quiet)
  (unless quiet
    (message ...)))

to be able to suppress all the messages in the function call?

-- 
cheers,
Thorsten




reply via email to

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