[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Making a function than can only be used interactively
From: |
Christopher Dimech |
Subject: |
Re: Making a function than can only be used interactively |
Date: |
Tue, 5 Jul 2022 01:33:56 +0200 |
> Sent: Tuesday, July 05, 2022 at 10:05 AM
> From: "Christopher Dimech" <dimech@gmx.com>
> To: "Stefan Monnier" <monnier@iro.umontreal.ca>
> Cc: tsdh@gnu.org, help-gnu-emacs@gnu.org
> Subject: Re: Making a function than can only be used interactively
>
>
>
> > Sent: Tuesday, July 05, 2022 at 9:45 AM
> > From: "Stefan Monnier" <monnier@iro.umontreal.ca>
> > To: "Christopher Dimech" <dimech@gmx.com>
> > Cc: tsdh@gnu.org, help-gnu-emacs@gnu.org
> > Subject: Re: Making a function than can only be used interactively
> >
> > >> 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.
> >
> > You could emit the warning/error during macro-expansion, indeed.
> > Something like:
> >
> > (defun foo (a b c)
> > (interactive ...)
> > (declare (compiler-macro (lambda (_) (error "Called
> > non-interactively"))))
> > ...)
> >
> > Not sure what's the benefit, still.
I am not confident the declare command will always work.
Not for
(defun foo ()
(interactive)
(let ((a ...)
(b ...)
(c ...))
...))
> > > Although byte compilation in recommended, I wonder how often people
> > > actually
> > > byte-compile every file.
> >
> > `flymake-mode` will run the compiler for you to get those warnings right
> > while you're writing the code. If people don't see the warning because
> > they don't compile their files, then let's fix it by trying to convince
> > them to compile their files, which will come with a lot of other benefits.
> >
> > > 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.
> >
> > Usually calling an interactive-only function non-interactively is not
> > serious *at all* and very often it's The Right Thing to do.
> >
> > Stefan
>
> Depends whether the person coding that function thinks it is. What can he
> do then? Issue warning as you suggested with `declare`?
>
>
- Re: Making a function than can only be used interactively, (continued)
- Re: Making a function than can only be used interactively, Christopher Dimech, 2022/07/04
- Re: Making a function than can only be used interactively, Stefan Monnier, 2022/07/04
- Re: Making a function than can only be used interactively, Christopher Dimech, 2022/07/04
- Re: Making a function than can only be used interactively, Stefan Monnier, 2022/07/04
- RE: [External] : Re: Making a function than can only be used interactively, Drew Adams, 2022/07/05
- Re: RE: [External] : Making a function than can only be used interactively, Christopher Dimech, 2022/07/05
- RE: RE: [External] : Making a function than can only be used interactively, Drew Adams, 2022/07/05
- Message not available
- FW: RE: RE: [External] : Making a function than can only be used interactively, Drew Adams, 2022/07/05
- Re: FW: RE: RE: [External] : Making a function than can only be used interactively, Christopher Dimech, 2022/07/05
- Re: Making a function than can only be used interactively,
Christopher Dimech <=
Re: Making a function than can only be used interactively, Christopher Dimech, 2022/07/04