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 00:05:38 +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="38894"; mail-complaints-to="usenet@ciao.gmane.io" Cc: tsdh@gnu.org, help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 05 00:06:12 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 1o8UCq-0009vV-Iu for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 05 Jul 2022 00:06:12 +0200 Original-Received: from localhost ([::1]:60454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8UCp-0002aJ-GC for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 04 Jul 2022 18:06:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8UCO-0002a3-0W for help-gnu-emacs@gnu.org; Mon, 04 Jul 2022 18:05:44 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:54371) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8UCM-0001iy-3L; Mon, 04 Jul 2022 18:05:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656972338; bh=uRKVmnvkPVPkGZ88ELb5HHlSoSngRATZ4vxlhjy0X1Y=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=KkVHErMoGHyvymKJyqrQtsA/hCXxegc5IgEbW1SbF4ZOPRouSKu6qAfdd2MPX6f0F 1Ae4rZJyVFSVZrM0DgODWWkcpvaNossmF7PdquT0EM92iVOoN+UTD6JM0DHHt7S0k1 /gpmQBKbFN27KtMPwi3BGIaYYn16yYKz4isTHQdE= 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 00:05:38 +0200 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:/ye7fTOb6VJOuXxeIHUUziF2KP9yrmwJOx5ec+8I6UFKRM2VVOMOBj06O6B1sA2ODvmOM gwlcFu18csyp4P2Zr4kiVpnXgvH8L7mSxiQspW9z3uL4V3x09Ly+uBxif6GL1Gf6O51Fo/zG8AZ/ oT7Uow817TBl/GeTFuIUPWTRjUt6eicPHN8AlmnLVxQ0SXO39JR31uBP5ArGzx3+2scN/Q8rYinL GyVKZ1ejw3Zcj3LFiTambL724LSg1E1j5b2CbNVg9o2dXMED/rJ5Q6YxvrISeGFMGadrqxXBmuFj ag= X-UI-Out-Filterresults: notjunk:1;V03:K0:qoboIvpya5U=:bCF6cJiKHG9WfpUiDVPYbc 6JoRhLdroyCR/0QV2hMq2lU2qfG8jz37RPhJLgC5Kso/L3Fry99XyilIJc7OgI7lkeNY4/Q4f ylQkyMN28xbcaBlCVHOB2oefxwt3Zj42bKNoGrPbTFS6D04F9tKti0RKotbjSy2+vIZhByQqX dqKwyRoarzrD2IQ4hQf/cIZiETEkh4lioJT0kCOdLNcnOccTeoA+fKHbDsY/i6J5EkTIq2ti4 eyYoXUTO+0Ox0zxOhRJJaJT9SiDRCdJurHbDH1fAG5ErfqtxLjlh1vRn4x+p3JwZS9hxnktAk SC9REipny77LJRmzeXj+3Bkzrm+5Bi/U+m9AufkqE7yXGaU/fK/0Fa3lFUZVMYhP1P2e8oYc5 SCBqVjXCWd4JzdJPpFtxIqOjP4SRvh8wMP5xohSYAgQzsU0dV7tgh3VaLmSLbzgToGTXmdFCY Etk9CSxq+h0sctasHC/k2QH20aXx+2OOq6uSVjslgE3PVdXgFfkkKPhK0RhIcre0TLZqVmmAY FJdU5jTJ3XUDzT3J/JQINEPCWoyrmjmJfAdqG/WRZCNFj3DX/HI1nJ4cqYEzP2+KyZAETzaON VbsYkfCXxG1fz+djxoh6tZYG3BH6LMVq5qv9efAwYsKxyowlxF44/Uek2wlPqH5YsPvqbjDZt Raeo5KmGA0pjBtY9XYtqWrmMNsXgjOWVw1dsJIW5Bh5jeZXcikqcOMEn8xKAG6S8SKaSm2Ksq MfnjGQqXTiY3M2ahXdERDD37cx1mw0T8pmNR1A0Byc1iEO8oTPDncM+vbGFcZVko6Nb3qzvS Received-SPF: pass client-ip=212.227.15.18; 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:138305 Archived-At: > 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 discus= sion > >> you don't care about that because you already have another functio= n 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-c= ode. > > 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-interactiv= ely")))) > ...) > > Not sure what's the benefit, still. > > > Although byte compilation in recommended, I wonder how often people ac= tually > > 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 benefit= s. > > > 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`?