From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: Making a function than can only be used interactively Date: Sun, 03 Jul 2022 21:53:43 +0200 Message-ID: <87v8sekls5.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="633"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.8.3; emacs 29.0.50 Cc: Bruno Barbier , help-gnu-emacs@gnu.org To: carlmarcos@tutanota.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 03 22:03:08 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 1o85oB-000AWZ-8J for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 03 Jul 2022 22:03:07 +0200 Original-Received: from localhost ([::1]:48254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o85o9-00024r-Nn for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 03 Jul 2022 16:03:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o85nC-00024j-DV for help-gnu-emacs@gnu.org; Sun, 03 Jul 2022 16:02:06 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:41482) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o85nC-0003ri-26; Sun, 03 Jul 2022 16:02:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-reply-to:Date:Subject:To:From: References; bh=KYTTSEvI/PlCHir+Z6ZCfOmT+3blWPENeeyshWeeBXI=; b=Fh7XPI4gfrmV92 A7nSVdvtw5i/G+eWdb12o6Pw6Y+REgwLdpsWehOVhB55pQGIdS+ZbyOVyC1wmQZtaBTeEDEIYLbQX IN0TGfcwinAg5DF8aArTkjYKrxkynKX8gAlUSUj3DG++sseXrNlJTBKGsU6BcH7x7bfriyDvvJm1i oVaxx01mU4p0r7EXEZP0LEhKp41LGkCJG42hWJIyoO3zlViJXm5SZANSokFnq5zC/UGSOWGeW+iEB EfLHw4vfciSW9H2L5Bg91Xk+0n2c2Lk97RE5HC/F4fF+PtlM0tm2UOQ+/KbxJkuJs7RnRiXc9vyxA HSsjYLqUrEV/A485rMfw==; Original-Received: from auth1-smtp.messagingengine.com ([66.111.4.227]:42305) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o85nB-0005zg-RX; Sun, 03 Jul 2022 16:02:05 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 9846A27C005B; Sun, 3 Jul 2022 16:02:04 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 03 Jul 2022 16:02:04 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudehjedgudegkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfhgfhffvvefuffgjkfggtgesth dtredttdertdenucfhrhhomhepvfgrshhsihhlohcujfhorhhnuceothhsughhsehgnhhu rdhorhhgqeenucggtffrrghtthgvrhhnpedujedtheduvdelffejkeetgedvheelhedvue efhfeukeekkeehvdfggeegffevgfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehthhhorhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlh hithihqdekieejfeekjeekgedqieefhedvleekqdhtshguhheppehgnhhurdhorhhgsehf rghsthhmrghilhdrfhhm X-ME-Proxy: Feedback-ID: ib2b94485:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 3 Jul 2022 16:02:03 -0400 (EDT) In-reply-to: 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:138273 Archived-At: carlmarcos--- via Users list for the GNU Emacs text editor writes: >>> Is it possible to make an interactive function than can only be used >>> interactively? >> >> I'm not sure I understand your question. A function, that may be >> called interactively, is called a "command" in Emacs. And a command >> can definitely be called interactively, either by using it's name >> (using M-x) or binding it to a key. >> > I do not want people to use the function non-interactively. How restrictive is that! :-) --8<---------------cut here---------------start------------->8--- (defun only-interactive () (interactive) (if (called-interactively-p 'interactive) 42 (error "You may not call me"))) (only-interactive) ;;=> Debugger entered--Lisp error: (error "You may not call me") (call-interactively 'only-interactive) ;;=> 42 (cl-letf (((symbol-function 'called-interactively-p) (lambda (&rest _args) t))) (only-interactive)) ;;=> 42 --8<---------------cut here---------------end--------------->8--- So as you see, there are many ways around it. Bye, Tassilo