all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: Making a function than can only be used interactively
@ 2022-07-04 21:07 Christopher Dimech
  2022-07-04 21:45 ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Christopher Dimech @ 2022-07-04 21:07 UTC (permalink / raw)
  To: monnier, tsdh, help-gnu-emacs

> Jul 4, 2022, 20:45 by monnier@iro.umontreal.ca:

>>>>>            More seriously, what are you trying to gain by "mak[ing] a function
>>>>>            interactive only"?

>>>        For instance, writing an interactive wrapper function calling a non-interactive
>>>        mother function.


>    A common enough case, which you can do just fine without having to
>    prevent non-interactive calls to the interactive wrapper.

>>>        Technically, you can use `completing-read` and `read-from-minibuffer` if you'd also
>>>        like to set values interactively, while calling the function non-interactively.


>    You mean you can turn

>    (defun foo (a b c)
>    (interactive ...)
>    ...)

>    into

>    (defun foo ()
>    (interactive)
>    (let ((a ...)
>    (b ...)
>    (c ...))
>    ...))

Yes, that is what I had in mind.

>    Indeed. It's usually discouraged because it's incompatible with
>    non-interactive uses of the function, but in the case under discussion
>    you don't care about that because you already have another function to
>    use for non-interactive calls.

It is indeed incompatible with non-interactive use.  A thing that can be done
is fire the warning even when Lisp Code in not transformed into byte-code.

Although byte compilation in recommended, I wonder how often people actually
byte-compile every file.  Byte compiling will often tell you errors or warning
in your elisp code that you normally wouldn't know, but I think that running
an interactive-only function non-interactively is serious enough to insert the
warning in the warnings buffer anyway.


>>>        I am not sure if in practice that is ever desired.


>    It's done occasionally, typically in cases where it's difficult to
>    cleanly separate the part of the code that prompts the user from the
>    part that actually performs the desired operation.

>    Stefan







^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-07-05 23:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-04 21:07 Making a function than can only be used interactively Christopher Dimech
2022-07-04 21:45 ` Stefan Monnier
2022-07-04 22:05   ` Christopher Dimech
2022-07-04 22:35     ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-07-05 14:02       ` [External] : " Drew Adams
2022-07-05 15:35         ` RE: [External] : " Christopher Dimech
2022-07-05 16:34           ` Drew Adams
     [not found]             ` <trinity-568779dc-3120-4001-a48b-df09d38f19a1-1657055684424@3c-app-mailcom-bs14>
2022-07-05 22:40               ` FW: " Drew Adams
2022-07-05 23:05                 ` Christopher Dimech
2022-07-04 23:33     ` Christopher Dimech

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.