From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id WOCrIG/XuWNHsgAAbAwnHQ (envelope-from ) for ; Sat, 07 Jan 2023 21:34:55 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id EB9lIG/XuWPnPQAAauVa8A (envelope-from ) for ; Sat, 07 Jan 2023 21:34:55 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2C53ADC15 for ; Sat, 7 Jan 2023 21:34:55 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEFtR-0000cr-AP; Sat, 07 Jan 2023 15:34:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEFtP-0000cg-SY for emacs-orgmode@gnu.org; Sat, 07 Jan 2023 15:34:15 -0500 Received: from stw1.rcdrun.com ([217.170.207.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEFtN-0003ts-4z for emacs-orgmode@gnu.org; Sat, 07 Jan 2023 15:34:15 -0500 Received: from localhost ([::ffff:197.239.14.179]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000055DA4.0000000063B9D741.00003DBD; Sat, 07 Jan 2023 13:34:09 -0700 Date: Sat, 7 Jan 2023 23:33:09 +0300 From: Jean Louis To: Alain.Cochard@unistra.fr Cc: emacs-orgmode@gnu.org Subject: Re: When is a function an interactive function? [was Re: Is function 'org-insert-property-drawer' usable?] Message-ID: Mail-Followup-To: Alain.Cochard@unistra.fr, emacs-orgmode@gnu.org References: <25520.25134.831330.318368@gargle.gargle.HOWL> <87v8lq75id.fsf@localhost> <25527.22953.318527.300303@gargle.gargle.HOWL> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <25527.22953.318527.300303@gargle.gargle.HOWL> User-Agent: Mutt/2.2.9+54 (af2080d) (2022-11-21) Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1673123695; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7+l/xqRpLCP8jbxHvdsTZXG+qBYHblWSJhNCRrhURrg=; b=T1f3gP3agmaoTOsQoJzBGTDrsJks+BUA1h3SNtAvAK4cAzMJm+izERE1o0lTmO0YmoMjpX /thQjfbRVKS23KgCZaIa4irIXVfOEoCQqkS20MvvDmo8pTnG5ue24M/MnyEWDYu/hKhCC7 63G8EMUKTSaLrgGbdlsCujxmNRqQNlC/2o2wymMLQrJGqnc3t98B4nbkSLSPmqbIv7Wcqj 5TqZ1ne9RiYc5o8aS7ScEfOIPm2yH0OcAsRsutKHCnmc8sdoYaGbF869I+wFvNlzW5fghH awr9K0SLBFgRgLdaxm0fiRrfuL/fFsldl7MmdY/QhBhZDENBI51ETl2DMPmZoA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1673123695; a=rsa-sha256; cv=none; b=NYlSbNWUxENDf7Og57xTc/kN/BDcEMLnHDFV8AW75PqD0iWUxWrMHOSxCSU0gTw5uWJoye d1/scYgGzd67alX8dXR5k8QjO9GHPtMVrZmRMQfdcO3+41agj+aNq2Tchou0/FRvJCyVu9 ZX5dU+UbXeeI2bTNKn9VFR+7iY+rQhCb64SCIVkJz0hY9YQXxjLqKLfefk0Xlvua2qFSr3 4E9h735GYM/V+f0HlZ/yoAURWrjLrutE31H1qu1IImFTAm75pwrIjJMQCs33YP7hL39ERe EOjwcA0F6e0/M0uyay5PNDqBvE7je+h5Xqa6lmLTWa0/ZVw2BFAKvFLwGWmkzA== X-Spam-Score: -2.87 X-Migadu-Queue-Id: 2C53ADC15 Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=none X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -2.87 X-TUID: /EM+pbrWXKJs * Alain.Cochard@unistra.fr [2023-01-06 02:16]: :ATTACH: :PROPERTIES: :ID: 51b2af8b-b2b1-45a7-ab74-1d8e7d8fce7e :END: > so I was trying to understand if there is a way to deduce whether or > not a particular function is a command. Based on several examples > such as > > ‘M-’ (‘org-do-demote’) Function is considered command when it has declaration (interactive) See: (info "(elisp) Defining Commands") 22.2 Defining Commands ====================== The special form ‘interactive’ turns a Lisp function into a command. The ‘interactive’ form must be located at top-level in the function body, usually as the first form in the body; this applies to both lambda expressions (*note Lambda Expressions::) and ‘defun’ forms (*note Defining Functions::). This form does nothing during the actual execution of the function; its presence serves as a flag, telling the Emacs command loop that the function can be called interactively. The argument of the ‘interactive’ form specifies how the arguments for an interactive call should be read. Please note ----------- The word "interactive" is used in context of Emacs Lisp, and not in the context of English language. In the context of the English language any Emacs Lisp function may be interactive, even if it is not a command. And to note is that only commands, which are functions with (interactive) declaration, may be bound to keys. > I conjectured that, when an interactive function does correspond to a > command, Function with (interactive) declaraion IS a command. But in English language ordinary context in computing, a function may be interactive but not a command, because it does not have (interactive) declaration. > it is just mentioned between parentheses, right after its > corresponding key combination. I tried to check this in an as much > systematic way as I could and investigated 330 such instances (based > on the manual of version 9.5). > - that even if a function is _not_ mentioned in that conventional > form, it be explicitly stated in the manual that it is > non-interactive (just as was recently proposed for > 'org-insert-property-drawer' by Ihor+Bastien). When programmer wish to find out if function is interactive, one can use C-h f function-name-here to see if it is interactive, or one may jump to it's definition: (find-function 'org-insert-property-drawer) and see if there is declaration to be command, or to use the test like this: (commandp 'org-insert-property-drawer) ➜ nil IMHO, mentioning for each function if it is interactive or non-interactive in Emacs manual is waste. And programmers shall observe that commands should appear only in corresponding modes: If MODES is present, it should be a list of mode names (symbols) that this command is applicable for. The main effect of this is that ‘M-x TAB’ (by default) won’t list this command if the current buffer’s mode doesn’t match the list. That is, if either the major mode isn’t derived from them, or (when it’s a minor mode) the mode isn’t in effect. > (interactive &optional ARG-DESCRIPTOR &rest MODES) > If MODES is present, it should be a list of mode names (symbols) that > this command is applicable for. The main effect of this is that > ‘M-x TAB’ (by default) won’t list this command if the current buffer’s > mode doesn’t match the list. That is, if either the major mode isn’t > derived from them, or (when it’s a minor mode) the mode isn’t in > effect. And sharp programmers should make sure that their functions that may be invoked interactively in other modes, recognize what is going on and don't disturb user's work or data. > For example, with the cursor on 'org-capture-finalize' in the manual, > 'C-h f ' gives nothing right away; 'C-h f org-capture' does > not offer 'org-capture-finalize' as a completion; 'C-h f > org-capture-fin' does complete and says that > 'org-capture-finalize' is interactive; and then it becomes possible to > use it with 'M-x'. > > Similarly, as far I as can see, 'M-x org-attach-attach' fails right > away, but works after having been used once with the standard (menu) > way. Good inspection! I find it not right that I can even invoke `M-x og-attach-attach' in this mail mode. And I find it out of control that directory was created in ~/data without asking me or telling me, by using `org-attach'. We have too many expectations. > I can understand why it is like that, but still find it disconcerting. > If it is to stay this way, perhaps things could be made more explicit > in the manual. Thanks for observation. > List (of non interactive functions that might be thought interactive > to the ignorant): > > - ‘C-u C-u ’ (‘org-set-startup-visibility’) Any function without (interactive) declaration may be made a "command" by adding declaration by using `lambda' like this: (lambda () (interactive) (org-set-startup-visibility)) and that `lambda' may be bound to key. > - ‘C-c C-e’ (‘org-export’) > > Shouldn't this one be 'org-export-dispatch'? Right. > - ‘C-c '’ (‘org-edit~sbpecial’) > > This must be a typo, right? Good observation. > - ‘C-c C-e o o’ (‘org-export-to-odt’) > > Shouldn't it be 'org-odt-export-to-odt'? That is right. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/