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: Placement of list within an interactive clause Date: Fri, 15 Jul 2022 12:32:58 +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="18329"; mail-complaints-to="usenet@ciao.gmane.io" Cc: carlmarcos@tutanota.com, Help Gnu Emacs To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 15 12:36:54 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 1oCIgn-0004aa-Qp for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 15 Jul 2022 12:36:53 +0200 Original-Received: from localhost ([::1]:42746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oCIgm-000856-GC for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 15 Jul 2022 06:36:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oCIdb-00084w-QX for help-gnu-emacs@gnu.org; Fri, 15 Jul 2022 06:33:35 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]:33635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oCIdZ-0002Jy-HM for help-gnu-emacs@gnu.org; Fri, 15 Jul 2022 06:33:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657881178; bh=pMbGeU9wwLwT6jb6lqw9UhFsvHzi8/RmKAYe6c2UlnY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=aOITx3RvrAwKZup/iaS8m9NT0n7OPlryNJiTbiLVPZJdpCn1A+WFtSlzjYqoO73tG Cc7/CpSqkRs+HLHDhDRS84a0QUsFMJIIXA9OoMoGDSHbPO3/qBvD+1XJEe9Foi930z O+hf16VTySQKueRzf5yZYK1uR1Sw4GMiAWsmnHFs= 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-bs16.server.lan [172.19.170.184]) (via HTTP); Fri, 15 Jul 2022 12:32:58 +0200 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:KrDH7EtF3fgLq2PNpEAt1ZDaPmaQTb2NfscbijC0EbKhVBN2/Eh5eSP5aH9mFeitVLUnk DcV6MFBMiGSE3R3u76RRl9psVoBhK4ZoVIyxKVSUuElWNUHUZwsjBHO1VTnoLnvbCtoc/Emk4ghV rcid4tKFH/CghRJRZ/O9bV4vpPkdHB1sVy7+5qQupb6QasD19S0KScwCs4eiXYnR9yI6AfMfW/lp f1urBo/0UuT9xDiApDlgb2gRGcX3NAhEWgv6+BjQi1tLjI3bOE87jQGjWpgJEF+Q5rEK8e5t/Z9T 4g= X-UI-Out-Filterresults: notjunk:1;V03:K0:f/c+Njyrr9M=:1giq8CxUbGMhyKzm1dC+QR bDiUCuAcL6/yRBsnOHTFPQOJQbhHM/vuDcsc/+tgXwudAZFkEoSPzlBCIXCsgbn7wslH14yUQ Y0SuzsvN3xITkjDpNlDkSwsRCaK6VRpFB7dfLrWhgri1GYZo/pUIBkZJ2q9nPTE1QqvCiajTK 3PE2pWi0ZfebhheWRQxKDWagbDJQpsoSJIkvVTkR0KTctRD7iZP3SL4IsRCG5CAg4zM8iYYJq ZpilbfGiF6zvF+vTizCxhtHw8Z+aB5eYzrcXEt2jdors6cISjvGgZER0618b4WP3YUktiAeQI 0jQ0hBTj+gojoH1Uz5CwEVtYueTeBu9JjVQapj6UNXiMM/v5LBxXzc4HmdMRH8EhkWdthwbHe Ylu2SPwBkagMZm0h0ypKMTNP3AC1WS1aiTrgbyf88t5BW7Hf8YcGlqiwmTPz6zB4yvJJc/RRQ iLPhrRhm4UOSbJpP6kIXJvMLiGT2zrmhulYKAthuWmZPbDz8N6C8p+ATNv6u0lOpd98c3YEPY MQal6yI31Yf2cD3XxVyNphVINUfsyPZP86iOJIRDYdKovzGP9sn5lNzuR24/GGeoJr1m8/4nX HW1CKOCw8W14epOvq3yFMdd2mbdfF+G6Q+VC5VwxGRnRScJKrJ3jVmXHUxg3BJZ4I7ke1OH1V 2dY76qjDxxHSEG7bkqrn/+DkpISHt5nUqv0rQBqbClDJmnKYQH3/W2saNP8YQAubW+MeDRgr/ 8Re51iq2Dct+xqx1eEG1wIaUNXF52Gd6qfngxbrYI5t84cgjIDb1w2bK/3mlO7t28IUqR2+8 Received-SPF: pass client-ip=212.227.15.19; 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:138488 Archived-At: > Sent: Friday, July 15, 2022 at 10:14 PM > From: "Jean Louis" > To: "Christopher Dimech" > Cc: carlmarcos@tutanota=2Ecom, "Help Gnu Emacs" > Subject: Re: Placement of list within an interactive clause > > * Christopher Dimech [2022-07-15 11:19]: > > > Thus instead of following: > > >=20 > > > (defun my-fun-1 (&optional name) > > > (interactive "MName: ") > > > (message "Hello %s" name)) > > >=20 > > > I am using following: > > >=20 > > > (defun my-fun-2 (&optional name) > > > (interactive) > > > (let ((name (or name (read-from-minibuffer "Name: ")))) > > > (message "Hello %s" name))) > > >=20 > > > as that gives me little more freedom: > > >=20 > > > - if I call (my-fun-1) =E2=87=92 "Hello nil" that result is not what= I > > > really want=2E It makes it difficult to get the wanted result=2E To > > > get the wanted result I need to use: > > >=20 > > > (call-interactively 'my-fun-1) =E2=87=92 "Hello Bob" > > >=20 > > > - but if I call (my-fun-2) and NAME is not supplied, I will be > > > asked for name: (my-fun-2) =E2=87=92 "Hello Bob" and will not get = "NIL" > > > as result=2E In this case I need not complicate the call and use > > > `call-interactively`=2E > > >=20 > > > Additionall, complex `interactive` clauses I find often too > > > difficult to comprehend than reading the body of the function=2E > >=20 > > Yes, but you are forced for interactive commands=2E It is not equival= ent > > to a function that is non-interactive=2E >=20 > You are not forced to supply arguments within (interactive), not at > all=2E Function may not need any arguments=2E But if it has prefix you > should declare (interactive "P")=2E But if it needs some text input you > may say (interactive "MInput: ") >=20 > However, I have explained in the above example of mine that such input > may be provided in the function itself=2E And it looks to me that it is > better handled that way than through `interactive' declaration=2E You can call it within lisp code for sure=2E With interactive to set func= tion=20 arguments, you are also correct=2E In the broader context of considering any input from minibuffer as user interactive, it could make some problems= =2E =20 =20 > So this is the way to go: >=20 > (defun my-fun-2 (&optional name) > (interactive) > (let ((name (or name (read-from-minibuffer "Name: ")))) > (message "Hello %s" name))) >=20 > Function `interactive' DOES NOT make function "interactive" in the > other contexts in English language, there is special meaning in the > Emacs Lisp context=2E Programming meaning is simply not same to English > context=2E >=20 > To call function interactively, it means not to call it exclusively > from Lisp, but from the user interface by using M-x or key=2E=20 >=20 > That means, when there is declaration (interactive), that function > becomes accessible through M-x invokation, and it may be bound to a > key=2E=20 >=20 > It means then you can run the function by pressing a key (that is what > is meant with "interactively") or by invoking the function with M-x > or through menus=2E >=20 > IT DOES NOT EXCLUDE that other functions without the declaration > "(interactive)" are and can be "interactive" in the meaning of English > language=2E >=20 > You may thus have a function that is command and that may be invoked > interactively because of declaration "(interactive)": >=20 > (defun my-fun-2 (&optional name) > (interactive) > (let ((name (or name (read-from-minibuffer "Name: ")))) > (message "Hello %s" name))) >=20 > And you may have interactive function, that interacts with user > without declaration "(interactive)": >=20 > (defun my-fun-3 (&optional name) > (let ((name (or name (read-from-minibuffer "Name: ")))) > (message "Hello %s" name))) >=20 > And that function in the meaning of English language is interactive, > but is not a command in the meaning of Emacs Lisp because it does not > have declaration "(interactive)"=2E >=20 >=20 > ,---- > | Specify a way of parsing arguments for interactive use of a function= =2E > | For example, write > | (defun foo (arg buf) "Doc string" (interactive "P\nbbuffer: ") =2E=2E= =2E=2E ) > | to make ARG be the raw prefix argument, and set BUF to an existing bu= ffer, > | when =E2=80=98foo=E2=80=99 is called as a command=2E > |=20 > | The "call" to =E2=80=98interactive=E2=80=99 is actually a declaration = rather than a > | function; it tells =E2=80=98call-interactively=E2=80=99 how to read a= rguments to pass > | to the function=2E When actually called, =E2=80=98interactive=E2=80= =99 just returns > | nil=2E > |=20 > | Usually the argument of =E2=80=98interactive=E2=80=99 is a string cont= aining a code > | letter followed optionally by a prompt=2E (Some code letters do not > | use I/O to get the argument and do not use prompts=2E) To pass sever= al > | arguments to the command, concatenate the individual strings, > | separating them by newline characters=2E > |=20 > | Prompts are passed to =E2=80=98format=E2=80=99, and may use %s escapes= to print the > | arguments that have already been read=2E > |=20 > | If the argument is not a string, it is evaluated to get a list of > | arguments to pass to the command=2E > |=20 > | Just =E2=80=98(interactive)=E2=80=99 means pass no arguments to the co= mmand when > | calling interactively=2E > `---- >=20 >=20 > --=20 > Jean >=20 > Take action in Free Software Foundation campaigns: > https://www=2Efsf=2Eorg/campaigns >=20 > In support of Richard M=2E Stallman > https://stallmansupport=2Eorg/ >=20 >