From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Making a function than can only be used interactively Date: Fri, 8 Jul 2022 13:08:43 +0700 Message-ID: References: <87pmiljgah.fsf@gnu.org> <875yk8ehp8.fsf@dataswamp.org> 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="37596"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Emanuel Berg , help-gnu-emacs To: carlmarcos@tutanota.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 08 08:09:50 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 1o9hBW-0009ZZ-Mq for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 08 Jul 2022 08:09:50 +0200 Original-Received: from localhost ([::1]:58636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9hBV-0004Rw-3z for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 08 Jul 2022 02:09:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9hAf-0004Rd-M9 for help-gnu-emacs@gnu.org; Fri, 08 Jul 2022 02:08:58 -0400 Original-Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]:39568) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9hAe-0006DO-6x for help-gnu-emacs@gnu.org; Fri, 08 Jul 2022 02:08:57 -0400 Original-Received: by mail-io1-xd2b.google.com with SMTP id 190so2762926iou.6 for ; Thu, 07 Jul 2022 23:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=QH/6VAsbuIB2drsegrDNdfmExLLyl9JhnIKRqs+JaAQ=; b=GMoYrmpNxvyxZzKrK1nnDFRVpaMbLyrpLNLJbmdsEVtDAZb38isKjH/lNrze/V2NpI j9FtlBI5os/iN0S0gxhxA2SvGfJnmJDghX0I7RM/I4VOmi8kH7UhDBDESWTicyurLWLk naSeqEjEfN+DiMlHhDslBJtIalRxxUMtbShCDHo0WXnhI9nqXft23ktNb78uMWUucDOb RRyp3FgOnBNkuE9bDbP1hg9e5wDhL/nUG0bDCnse8jkrQnDV4u+VQtbzoBzDK/nlHLWj 79BDY/KWWyxJVAKH08T6fZkCjG+5hWQBGGs3bQJ6DVMQ7E9ktNTg0VFx5nZItF77c8k0 ox1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=QH/6VAsbuIB2drsegrDNdfmExLLyl9JhnIKRqs+JaAQ=; b=qKXOqYt8NguLV5cUJhwUegrSMAx/LUGqiMU8x4qvFBdB+NrQFhP0NshDLP2yVOkBlD EX4pepdRualRr5vC2ijkauHdaBcSnHfgBpSG5ke7GjlXxmIRptZGYDWup571/rbUOAqY WFn8se3OYrK0E4TOum1c9lJ7mOYU+R8r+UZkCgD/P67k6ndCb8+r8xobNc7GtVxAP2cd NzjKCRGqkxTq5BH93fXmommq3khQ/BagwJjaESSyrnCYHCbcTeWRCGtSEPEkNAERBnou 9Ufr7VCb2Y4t6GZ0tDi+eyhJDSzgScltmJWWvhSTV1bkFMesCxFitxNflWNEBd+bqPgj EXBA== X-Gm-Message-State: AJIora+wxyBi+iPvJ/YJb7k/CZMnAN4T3/Oiy1qUSEXhdLaZ++lsHfLz qT5iAglFY4R90TtAyY2g9pqiw9DQk0bsGk7n7qs= X-Google-Smtp-Source: AGRyM1uyU25syqWZriHidjUmtjZaYlwFsOc2n6I/80dW7ZLy6XP13Y914Nz6lqBkDSVzBsH4YqNMFefgvDR9Z9Bgn1k= X-Received: by 2002:a05:6638:2708:b0:33c:91ae:4c64 with SMTP id m8-20020a056638270800b0033c91ae4c64mr1238081jav.211.1657260534941; Thu, 07 Jul 2022 23:08:54 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::d2b; envelope-from=yurivkhan@gmail.com; helo=mail-io1-xd2b.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:138372 Archived-At: On Fri, 8 Jul 2022 at 05:14, carlmarcos--- via Users list for the GNU Emacs text editor wrote: > I want to know a few specific things. If I want to use the prefix argume= nt, I should include > a variable in the argument list, right? Let us call the variable "prefix= ". Now, should the prefix > be mandatory or optional? Should it always be the first argument? > > (defun funname (prefix arg-a arg-b) > "docstring" > (interactive "P\ns Name:\n s City") > (message "executed funname")) It does not matter for interactive use. Your (interactive) spec, if it were written correctly[see below], would describe three arguments, and Emacs would therefore pass three arguments to your function. =E2=80=98&optional=E2=80=99 comes into play if you use this function non-interactively, from Lisp: (defun funname (prefix arg-a arg-b) nil) (funname 0 1 2) =E2=87=92 nil (funname) =E2=87=92 (wrong-number-of-arguments (lambda (prefix arg-a arg-b) nil) = 0) (defun funname (&optional prefix arg-a arg-b) nil) (funname 0 1 2) =E2=87=92 nil (funname) =E2=87=92 nil Now about (interactive) spec syntax: you have three spaces there. The one immediately after the =E2=80=98\n=E2=80=99 breaks things =E2=80=94 the = first character of an argument specification specifies the way it is produced, and space is not a valid code letter. The other two spaces (after =E2=80=98s=E2=80=99= ) become part of the prompt so the prompt is displayed not at the window edge but one character to the right. Your spec should be: (interactive "P\nsName:\nsCity")