From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: carlmarcos--- via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: RE: [External] : Re: Making a function than can only be used interactively Date: Fri, 8 Jul 2022 23:09:57 +0200 (CEST) Message-ID: References: <875yk8ehp8.fsf@dataswamp.org> <87bku0ce1f.fsf@dataswamp.org> Reply-To: carlmarcos@tutanota.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10839"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Christopher Dimech , Yuri Khan , help-gnu-emacs To: Drew Adams Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 08 23:10:59 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 1o9vFb-0002b0-D4 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 08 Jul 2022 23:10:59 +0200 Original-Received: from localhost ([::1]:48134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9vFa-0002uJ-0A for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 08 Jul 2022 17:10:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9vEq-0002uA-Q5 for help-gnu-emacs@gnu.org; Fri, 08 Jul 2022 17:10:13 -0400 Original-Received: from w1.tutanota.de ([81.3.6.162]:39616) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9vEm-0007ae-3m for help-gnu-emacs@gnu.org; Fri, 08 Jul 2022 17:10:11 -0400 Original-Received: from w3.tutanota.de (unknown [192.168.1.164]) by w1.tutanota.de (Postfix) with ESMTP id 918F2FBF767; Fri, 8 Jul 2022 21:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1657314597; s=s1; d=tutanota.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=811tTDEdxiseYKktvSOc9LNejxSPsFq/ULAAlw6VMAA=; b=N/jo/C4wIa7FP6PVKeVxvxEOV2zfUsqLfEZc3/gzbl4g9VT56SggPugOyJcwTTjT u5OP7izoL0kzgmflbbGxDqG8ucbQcSWusP5OSSlBXzQ35GeT1MfCYy2tJzcAwAsxwEr df2QBfSSeQC5z7rFlYwX0lRLuFqZ72IczUxL7jLRTmMp7WFmJ0J4qhXoeVd9+Ac3LYA 5O2jCVgZTQ0ghuGAwWUOdxWrlClspj90y2RLHbzcu1eewREnauO+Jwijbhv/lAjF3Cc +iGU+kvVimspDVWRqzj6V/jn9j/9s8KlO0unWBeklCkU3s3t128HUvN6wZnwZ/qJ7xt UshRbRrjoQ== In-Reply-To: Received-SPF: pass client-ip=81.3.6.162; envelope-from=carlmarcos@tutanota.com; helo=w1.tutanota.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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:138390 Archived-At: Jul 8, 2022, 20:29 by drew.adams@oracle.com: >> It looks as if the easiest understanding of mandatory versus optional >> function arguments occurs when using a function interactively. >> >> For the interactive case, it is quite complicated, depending on whether >> the function uses code characters or a list. >> >> My proposition would be to include the corresponding explanation on >> using in either the "Emacs Lisp Reference Manual" or the "Introduction to >> Programming in Emacs Lisp". >> > > Dunno whether it's a coincidence (I'm guessing no), > but in the past couple of weeks there've been a > boatload of similar questions on emacs.SE. Here > are some of them: > I saw them and got the same kind of problem of how to write interactive function. Quite complicated thing. > What is a raw prefix argument? > > https://emacs.stackexchange.com/q/13886 > > Numeric prefix argument for use with interactive command > > https://emacs.stackexchange.com/q/72365 > > Changing of function arguments > > https://emacs.stackexchange.com/q/72393 > > Using current prefix argument value > > https://emacs.stackexchange.com/q/72425 > > Function arguments and interactive > > https://emacs.stackexchange.com/q/72428 > > Getting prefix as argument > > https://emacs.stackexchange.com/q/72454 > _____ > > (I voted to close some of them as duplicates.) > > Anyway, (I think) I see confusion there similar to > what (I think) I'm seeing here now. > > FWIW, here are some comments I wrote to the last of > those questions. That doesn't seem to have done > much good. But maybe they'll help here. > ____ > > 1. There's no connection between an argument being > optional and it being provided as a prefix > argument - none. > > 2. The only implication of an arg being mandatory or > optional is for calling the function. If it's > mandatory then omitting it raises an error; > otherwise, no error. That's all. > > 3. Using a prefix arg does not necessarily pass an > argument to the function. > > A prefix arg is not necessarily an arg to the > function, and vice versa. > > A prefix arg need not be optional. > > And you can use C-u with M-x. > > I suggest you read the Emacs manual about prefix > args: > > https://www.gnu.org/software/emacs/manual/html_node/elisp/Prefix-Command-Arguments.html > > Start by `C-h k C-u'. > > A prefix arg is used (can be used) by the > following command. It is not necessarily > associated with any argument to that function. > You can think of it as a global variable, if you > like - the function has access to it, but it > need not be one of the function's arguments. > ____ > > Back to this mail thread... > > Instead of looking for some general guideline for > when to use a prefix arg, or when to make this or > that argument optional, my advice is to just learn > what each thingie is/_does_. > > Learn how a prefix arg behaves (raw and numeric). > Learn how an optional arg behaves. Learn some of > the predefined chars for a string arg to > `interactive'. Learn how to give a list arg to > `interactive'. > > Play with those things. Once you know what each > does you'll know what you can do with them. And > you'll know when you might want to use this or > that thingie. Only you know what you want, but > you need to know what the tools in your toolbox > look like and do. > > This whole discussion feels like a quest for > advice about when to use the number one or zero - > or a negative number or a positive number or ... > There is no single "when". There's just knowing > the properties/behaviors of things. > ____ > > tl;dr (too late, I know): > > Don't ask when to use X. Just get to know X. > When and how and why to use it will come to you > when you know it. > > (Just one opinion.) >