From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: Making a function than can only be used interactively Date: Tue, 5 Jul 2022 20:35:01 +0300 Message-ID: References: <87pmiljgah.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28392"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/+ () (2022-06-11) Cc: Stefan Monnier , Tassilo Horn , carlmarcos@tutanota.com, help-gnu-emacs@gnu.org To: Christopher Dimech Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 06 02:12:56 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 1o8sf1-0007BE-4J for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 06 Jul 2022 02:12:55 +0200 Original-Received: from localhost ([::1]:56160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8sez-00085B-FB for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 05 Jul 2022 20:12:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8sdf-00083N-OZ for help-gnu-emacs@gnu.org; Tue, 05 Jul 2022 20:11:32 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:36613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8sdd-0001J9-P0; Tue, 05 Jul 2022 20:11:31 -0400 Original-Received: from localhost ([::ffff:197.239.6.19]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000087C57.0000000062C4D30F.000004C4; Tue, 05 Jul 2022 17:10:53 -0700 Mail-Followup-To: Christopher Dimech , Stefan Monnier , Tassilo Horn , carlmarcos@tutanota.com, help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_06_12=1.543, RCVD_IN_SBL=0.141, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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:138323 Archived-At: * Christopher Dimech [2022-07-05 00:41]: > (defun foo (a b c) > (interactive ...) > > (if (equal a 1) > (let* (h (read-from-minibuffer ...)) > ... )) > ...) > > Although discouraged, the above could make sense, but completely wrong to use > non-interactively. I think it is OK to use it non-interactively. `interactive' description says "Specify a way of parsing arguments for interactive use of a function." See (info "(elisp) Using Interactive") Here is sample function that I use: (defun cf-hyperscope-assign-tasks-for-many (&optional id) "Assign tasks with information of many contacts" (interactive) (when-tabulated-id "people" (let* ((assignee (cf-people-search-id nil "Assign to which person? ")) (task (rcd-ask "Describe the task to be assigned: ")) (prefix (rcd-ask "Prefix for task: " "Call")) (set (hyperscope-select-set))) (rcd-tabulated-iterate-generic id (lambda (id) (let* ((name (concat prefix " " (cf-full-contact-name id))) (description (concat "⟦ (hyperscope-related-contact-contacts-information hyperscope-current-id) ⟧\n\n" task)) (hyperscope-id (hyperscope-add-generic name "" nil 31 10 set nil description nil id assignee))) (hlink-update-action-status-1 hyperscope-id 2))) "Assign Tasks")))) And I may as well invoke function non-interactively, when there is `interactive`, it means it is a command and accessible through M-x and may be bound to keys. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/