all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
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
Date: Mon, 04 Jul 2022 17:45:11 -0400	[thread overview]
Message-ID: <jwvsfngftmb.fsf-monnier+Inbox@gnu.org> (raw)
In-Reply-To: <trinity-df671afe-f541-4864-b868-e48795a15df7-1656968847982@3c-app-mailcom-bs07> (Christopher Dimech's message of "Mon, 4 Jul 2022 23:07:28 +0200")

>>    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.

> 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




  reply	other threads:[~2022-07-04 21:45 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04 21:07 Making a function than can only be used interactively Christopher Dimech
2022-07-04 21:45 ` Stefan Monnier [this message]
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
  -- strict thread matches above, loose matches on Subject: below --
2022-07-04 23:42 Christopher Dimech
2022-07-04 20:10 Christopher Dimech
2022-07-04 20:35 ` Stefan Monnier
2022-07-04 20:46   ` Christopher Dimech
2022-07-04 21:18     ` Stefan Monnier
2022-07-04 21:59       ` Christopher Dimech
2022-07-05 22:34       ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-04 19:32 Christopher Dimech
2022-07-03 19:16 carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-03 19:28 ` Bruno Barbier
     [not found] ` <N64WnlX--3-2@missing-mail-id>
2022-07-03 19:36   ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-03 19:53     ` Tassilo Horn
2022-07-03 20:17       ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-04  4:51         ` Tassilo Horn
2022-07-05 23:13       ` Emanuel Berg
2022-07-03 20:14     ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-07-03 20:27       ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-03 20:51       ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-03 21:18         ` Stefan Monnier
2022-07-03 21:29       ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-03 22:01         ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-07-03 22:45           ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-04  1:13             ` Stefan Monnier
     [not found]             ` <jwvczelllyq.fsf-monnier+emacs@gnu.org-N65lQ2m----2>
2022-07-04 10:36               ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-04 10:55                 ` Tassilo Horn
2022-07-04 11:43                   ` Christopher Dimech
2022-07-04 13:21                     ` Stefan Monnier
2022-07-04 14:08                       ` Robert Pluim
2022-07-04 21:40                       ` Christopher Dimech
2022-07-05 17:35                         ` Jean Louis
2022-07-04 19:17                   ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-04 19:40                     ` Stefan Monnier
2022-07-04 19:50                       ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-04 20:45                         ` Stefan Monnier
2022-07-06  0:07                         ` Jean Louis
2022-07-06 20:00                           ` Christopher Dimech
2022-07-06 20:29                             ` Jean Louis
2022-07-07 11:03                               ` Christopher Dimech
2022-07-07 21:06                               ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-07 21:28                                 ` Emanuel Berg
2022-07-07 22:14                                   ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-08  3:40                                     ` Emanuel Berg
2022-07-08  6:08                                     ` Yuri Khan
2022-07-08  6:30                                       ` Emanuel Berg
2022-07-08  6:55                                         ` Yuri Khan
2022-07-08 11:44                                           ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-09  2:05                                             ` Emanuel Berg
2022-07-10  4:33                                             ` Emanuel Berg
2022-07-08 12:06                                           ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-08 12:11                                           ` Christopher Dimech
     [not found]                                           ` <N6Sh4jm--3-2@tutanota.com-N6ShCt5----2>
2022-07-08 12:18                                             ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-08 16:14                                           ` Christopher Dimech
2022-07-04  1:06     ` Po Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvsfngftmb.fsf-monnier+Inbox@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=dimech@gmx.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=tsdh@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.