From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher Dimech Newsgroups: gmane.emacs.help Subject: Re: Making a function than can only be used interactively Date: Tue, 5 Jul 2022 01:33:56 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35383"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , tsdh@gnu.org, help-gnu-emacs@gnu.org To: Christopher Dimech Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 05 01:34:30 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o8VaH-0008vz-Ts for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 05 Jul 2022 01:34:29 +0200 Original-Received: from localhost ([::1]:58084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8VaG-0000FM-JV for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 04 Jul 2022 19:34:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8VZr-0000Ex-Q2 for help-gnu-emacs@gnu.org; Mon, 04 Jul 2022 19:34:03 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]:57853) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8VZp-0004hf-UL; Mon, 04 Jul 2022 19:34:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656977636; bh=oJkit4e2+lZ2EqfA7NwNnrv0aO1iEwvT2sdr6jKJ7Js=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=iDJJhEE1h15+W4VpNjv0MIyEmU/NyTH4C40HzvGGr552gQRg4tfx9phJ31Xci0yUs W7ZYrQ17F3qnuZdBoxvJidM13TMVgncNXZWY0k8TnRnU5RSDk9Jj+o9hQCcN+qSS1q NspnDp8pUod+wlyNzG4tIeVm71+0tFRw5HffEVnQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [92.251.127.164] ([92.251.127.164]) by web-mail.gmx.net (3c-app-mailcom-bs07.server.lan [172.19.170.175]) (via HTTP); Tue, 5 Jul 2022 01:33:56 +0200 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:ruefdj59nqxHWxEjNahVScHPi5a2rzcEkz/ZnMzAn4gusSkcBDc3qMv5DjvVKuwxVuM+l 5qlpaigGFN14Rm/uLEo351AVN34sw5riDaz2GnQTz19c6QQrpIcc+W7gWtUV4EkS/Q1kGuADsrag MITpCHZcFcIT4+4WALWl7UbjlOH9YD/hiNCGX3j6PoDngEdh6hgyZm70OQzw0VSIgNHf+SIVyVo7 eH/5YNaN0Y/n3Jmg6z7Tno7LeShiqInvCIcWPIgaZ72TIUBwcw6U+guu4FOjduWAg4AuKzYmv8N3 DE= X-UI-Out-Filterresults: notjunk:1;V03:K0:OrWUrVzvdig=:5Z8oOdnS2mfnNFIvaLUpWz ICt91Yct0X9XkPwmM3+Asiq0uUq3tXU7zzv10nck3R3aD0Sp1nuoliYSl+CzJpMKeob8pUIAk 1rxPLSnsS5b/2a6NzErQgwGfjVxlo5tT24N38nGwfZTUJiB46Ugoih+D+5Utepow0hUxBGglQ rHFpsSE6++8kb680vUyqIk87GT9A0nR6wK9HAdQ6won1WOxeNLe7tG8ZlOuvOWSt28uTJE6sx MXZruQhAeKiOwlCqQYUfcokUcVdAgAi1tZfprXeWPIs5btu4os7/Gp5Eg4RZsk6n9Zr4LMcAM Nr6ksaxfBv1zXrTKybltRuYc2OEO93iG8yV7YvnpEYw3c6xxSN8HPDEh9hViRoiv6RmRAqDjN aIjKy3KXapcXR+dyUlORexCpPW8DddVi4AjzxSac6JP2I+7ZMkVPUPnYEQAi7hOof++T64SrR zOjVOQhA9AUO9enxAddua8FZvL59P8syo4CML0qX+zCnd1mIN57R9RIgV8tSX3HyRgOYS+qcP USZja6SeiYCtEpNn6rUe4Iqbhk/CwQVOUGPxNlk1PpmjiWcfjbYgH2VHOO15wm7LTrKimHiFs 6LZ5kvghdVdVaSdy9l0Kh+YisctqzzaSmbqU6BmgzPLz580RYldSIDamnIo+xMY8lLWjPcIdd d2RixM1w8o935bgrTLoQKC+ZdX+b5M+ncj/87S8KX0jP2KLFrfDb4oR12JTLHFRTHmiDjPgfl eY1v3xncY9hHRKKZ1MxMXQc/X4j8y7crylICMR+bnIGh/kkbDlCdj0E8foN+V440wyTQmMGT Received-SPF: pass client-ip=212.227.17.20; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:138307 Archived-At: > Sent: Tuesday, July 05, 2022 at 10:05 AM > From: "Christopher Dimech" > To: "Stefan Monnier" > 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" > > To: "Christopher Dimech" > > 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 disc= ussion > > >> you don't care about that because you already have another funct= ion to > > >> use for non-interactive calls. > > > It is indeed incompatible with non-interactive use. A thing that ca= n 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-interact= ively")))) > > ...) > > > > 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 rig= ht > > while you're writing the code. If people don't see the warning becaus= e > > they don't compile their files, then let's fix it by trying to convinc= e > > them to compile their files, which will come with a lot of other benef= its. > > > > > 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`? > >