From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id WJ1fMsudj2KmYQAAbAwnHQ (envelope-from ) for ; Thu, 26 May 2022 17:33:31 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 0JBJMsudj2KOkQAA9RJhRA (envelope-from ) for ; Thu, 26 May 2022 17:33:31 +0200 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 26F163DBF1 for ; Thu, 26 May 2022 17:33:31 +0200 (CEST) Received: from localhost ([::1]:33024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nuFUP-0002po-Uj for larch@yhetil.org; Thu, 26 May 2022 11:33:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuFTQ-0002nY-7S for emacs-orgmode@gnu.org; Thu, 26 May 2022 11:32:30 -0400 Received: from mail-vi1eur04olkn0829.outbound.protection.outlook.com ([2a01:111:f400:fe0e::829]:14599 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuFTN-0006SD-H9 for emacs-orgmode@gnu.org; Thu, 26 May 2022 11:32:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ieFylFN7s50ZF081bfJdBj0y3qtolauR+Y+Ic3W2nCycsKMvBvhzICWIkalPbl6LeZ5/X8pdN2zkC+wlTsZtiJT+fEgFtREifUDqqlzI2zqHRkzIo930b0+pc3rRuHctyTVdHMZxzCsfXqpDoejugw5/DrRcAusIk350/MiSkpc94zcT9w/0r/VoJS8+4xKJ42s+dk5mfO/2X+6vuAdYtuPnYLcgn3QLHme5eAf8nhDTgNbcQm/X4XzrcL8Rw7xADLXJRvsFCk/adGJnVKhohotYLpRcvAAk7NNTXdfIw0QwXaTMdEg4c5hq8LVFmkGPLq4jw/zz071YKGNJrOkh0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/1vnOfHMIJVQSJZDw/uUNSCUD/NdJu2Pxz7BN/iegZ0=; b=jNIN88lojlc6F1ewa9Kxoz+7XdTEgSi7NPZ1FCuw7m86SqOns4pWPJwdeYeazFsgjD3DBpTVKlvtVCsjy4wmQx3motxau5ejTzJZ44bJDFiyxWgCqx6hv+TBLSYI19MgtVQlH5vHLcP996R4ReUU75T8ziLU6UWRuSXSxIms13ks3C85QsoYqqkPnflC69UGas26AsZPa/hPU4bMsE4o1icqDSg0mZFpkbieGwgPM7Eei1dkJ69HF2EJDrrwxBkJagAZuJ2IJ8JyTZqKVgx3XfWchNR9RH/x/VBpXNWeox83I0BqfFSQuoF8s87QEnnBWi0qhV/0kdVN9HXFj5jDBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/1vnOfHMIJVQSJZDw/uUNSCUD/NdJu2Pxz7BN/iegZ0=; b=L3EwwzZvx/JNMzXdHmPD0cjZmu4LahPuS8Y4z3ynNCjwnFi7lFjbjYVWXhEnoAN+Co8wsVrNWJrdHA5/d4Y3GfISMx/ctM9JQNSqPPMQ6RjNMsBCoI9fmXBB9ZLZf9FbgHClWLUmX3tNOkmXbuFstFJoXr9YZgMWvOh+Atw0bTAdqFbyQjfdMSdC+uGGxVDANxH/cXIV6C+Y2Wvtwr6HEWDOX2Hd0ORuoQXdjqfSYcONiUnvWhrnY6P+9JZl2PYlWLtv7U4sI9JJ6Du7zC7/wMMczQzcUljkz+74x44GU8jJWgojkXYNnK7Mzz0lzfM7V4k3deMR2ON/gVkz8OVB1w== Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by AM0PR09MB3441.eurprd09.prod.outlook.com (2603:10a6:208:174::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Thu, 26 May 2022 15:27:22 +0000 Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::48c7:3657:142f:a842]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::48c7:3657:142f:a842%4]) with mapi id 15.20.5293.013; Thu, 26 May 2022 15:27:22 +0000 From: Arthur Miller To: Subject: Proposal: 'executable' org-capture-templaes Date: Thu, 26 May 2022 17:27:20 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Content-Type: multipart/mixed; boundary="=-=-=" X-TMN: [al6uqRrSAsBNoF6LOnunU4ecyEJUnzoh] X-ClientProxiedBy: BE0P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:14::19) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87h75cuxev.fsf@live.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1dbfb755-b9ce-4e47-5432-08da3f2c3a41 X-MS-TrafficTypeDiagnostic: AM0PR09MB3441:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XS2T/6IkyhMBwZsoopGQcdT/l04qsC93R0dRwzAoFJWCojnAmzDngiQsVmvbM0NkAGD33thRQejNailC9FsOtYL4v9S1Dgcwm7PewRf7lP8YB6lZkYBipzbowEPV3vvItR65P+ZMVZOvAltRDhP423ykmEV1kMcfRAUm6LmFr2c4U64z+DImwicpH0k+QHWmv4kcjztbsOXemRHCXB6xFtaJopfxu04Gn7sYVmIiLd8BTSlQ0gcY3j8pLjwf9QRZVYD2tSOg2FyycCEOQJtSfmY8nbx2584vSQ7GFIsWhxxwLgYdL4d5VtAPSBp0sL6p4pNmghDM1h2tVRii59gpP4g+BvO1WO9lBA7OeL6wVSILri6qw9g4yqmuDyB/trQ7/A2LA2Qxx4DFKdY4CUY583Y/HaU7niRhT/Y9yZ5JE3Y0sNmJQNN2T7FiLYJWGCr9pmGCht8mGgFpkrRQpvZBZhbNMqTJj59PVivZl17KMf/VTNu4Ithi4n38+6v+Yw8eBK88vQbGJmhEVKuI8+ZLa06vtEMvLMhh2dtbKlHjaxSvuY8VboQ1hALN7Beh0BPNUUMFVG8dOw0IkdI/yGmsUA== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?LcejmM+2nyyV73xgX8FqDO65iVd7oDrybUV7+5ySCbP9n2Z+UjPOg2LMXBZ4?= =?us-ascii?Q?jf1utdGycP4pzYbtVdF/liMcmdpi5r4gfDmLx8GE98di7Y9pvA9y12Q10Xfn?= =?us-ascii?Q?T8+ZYQpvhdC/btO580GLYn+uqcNgaI/BWRVF34KKc7wFYNfXcptrhN2Z+5yB?= =?us-ascii?Q?MGPV5cnW7OVUE7xBT8VAvM+zOWtI6zfxOQVFahEGjUbN403EkZI7KLooeF6e?= =?us-ascii?Q?JUqygl+eOiFMhy7LOmH3UpwAk309SZWWvN5IDAVDd9Lr5JdVw6tdyGZNDrj1?= =?us-ascii?Q?znaZuqdAFyTxumyh810+Wc941vWpFsLgrpV7iFG+o8KBZZmiIGTEFyBaWpbR?= =?us-ascii?Q?7QN+ARbOv9KfaI+1nlBSNSjungTgSqp7RhNNNckaoG5DdyUi9nMn97v8GTOQ?= =?us-ascii?Q?JY+RIoWlGwa666TwgVgvuiu4Z+0wa1Jym3FtlID61doeupz9DrCBwv2SndVE?= =?us-ascii?Q?YxqNC7+ISdabdBDGdMYcy2GtkZYTCRFJUDxlDClEfcmf1c3QNWd7ATQrPl6b?= =?us-ascii?Q?i/S6SVovxXPz2eDYQFKzK6f0UmkDPvX3oqssWNssGIQARG45m2Z8TOvrW6+m?= =?us-ascii?Q?Ho3nUF2YxlifFixEiWC5UTo0l44VMGK0vnQ2Don7ajiJsJCbiWjBonU4IZnX?= =?us-ascii?Q?h8pja5ez4m6ry/sj3DLEiv9AC3LGap+9lt0dBBbFqLGRkBwFMoMJkgurcbQj?= =?us-ascii?Q?JQAV/i5T8Hs6Fu/lMHbjFJkqLTeQHxif/J2NlP+JPLc231p01xsYsSwGfaDx?= =?us-ascii?Q?Q/3dmeOogUsLc6bLa2Y+CtrkW8fimwiopxfQw4dKnFV+ifMWSK7KVGThGhE2?= =?us-ascii?Q?rWqo3hHTsy83vnovREY8x0F6mn9BOetohvZPsIh3+lfObirA0ZtQRQBqQDP0?= =?us-ascii?Q?Y6GEEPhURg+luBzQ/zvBXqw62NIQC4ltVKodctLroN98uvakwhgL0IcmtnXE?= =?us-ascii?Q?APqqDo4lbvPx8u1gkpDmycXoiEMtsFrFXi4PelM/aUu44zv1YpealfNS27M6?= =?us-ascii?Q?uDbw//9BzhoozU+g1AhjtA5SjAPZQ0HkpBsLpJbufNftosa8++muCkBF1CQP?= =?us-ascii?Q?fQF0u/Mcenjw1lopCk+aFmSqNKTij2SJb14k0Ea2XKYFuDT1JO9hfPZahHs0?= =?us-ascii?Q?jhL59kgzwcxKY2MRd1BAF6MRafmaqwqxQ416Ud3ySVyCibGQpjsuR/o4dfZn?= =?us-ascii?Q?51vZyvDFUyhWrW3rp5paILY74k74lbhfGATLbXXDPXaSeoXX3uHngYHhe3rO?= =?us-ascii?Q?52slTZXdE9hlC8n1azDQyJbRjZrraTq8Vt7o2oxzg6u6pjkEO+VGBBIJ/SZx?= =?us-ascii?Q?wDrHaS6fksoE11/BqKx9behAT14FdZNaHHIiyMp0MD8oHaWRUzlmmiL+vyk6?= =?us-ascii?Q?qGxeiQlZWKvxJmIgJuLKyj789VM/T55OMYbHIFFO2Y7XWOMck/OEVFi8gbKo?= =?us-ascii?Q?IL3AGpK/I0c=3D?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-64da6.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 1dbfb755-b9ce-4e47-5432-08da3f2c3a41 X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2022 15:27:22.2315 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR09MB3441 Received-SPF: pass client-ip=2a01:111:f400:fe0e::829; envelope-from=arthur.miller@live.com; helo=EUR04-VI1-obe.outbound.protection.outlook.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, 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-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" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1653579211; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=/1vnOfHMIJVQSJZDw/uUNSCUD/NdJu2Pxz7BN/iegZ0=; b=B2swy0q4Fn51seh1HKXKn9pV37MeMamLeQe8a3Acc27XMvHQjjb64l/GBNektVS19Qkw5u O8bzjgsZSFVt9xQTA4fagcmAiW+h8ucl/maTUIlqq8kZfHTMx02wEU8Y2aze4Av2K4cRE0 WZzUoq6ssbZboPTLv9wwdhFglCsp5NqJw0Ps8LwwXo9j5E/Asrd1uepWvwsZ10dW81bYqY nuDODa2uvMWo7MObS9IHLK+a8Hcx190YvEFqAxcr2jExHvKSoi9DKJ71e6bJJ9BmCAN2K9 YDidnvitszuSB4dGfH80ehmiggkdri7NAGMbrBI1Kqm03kZUKKQx2WuTdA3TJw== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1653579211; a=rsa-sha256; cv=pass; b=n6KdUrvhbOcKNggE6h2EHFRsjNRBPgG7G9Y46Ea90h/3uWJi/SUI3sw5tT/Oe5m+MyYm2U M++A6hbqDT/Of4zc7IBB9n8bQwSRZ/H4FC5m+Y7feZa5riocLlZHzi6v9L5DXnqsC9WUEF AAtxXDd91f5N2LNp7rEKP7N6zwUTb7Od542GnrF9KmFJ6E0jneOPV/RSfARXE/2CR1gHE9 IU4WgMBDGwi+ZFO9KHq7W9p0rVYSHUjJ9DXBqbJHFq7QWzVx+UMPSdERSWuDWo/TVWS+Co YGR2es3v7ckcRf9A9w2lEiXERlIPj3dDi7+ItlmehsJm/SCzO0Cunh7xqY846w== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=live.com header.s=selector1 header.b=L3EwwzZv; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=live.com; 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" X-Migadu-Spam-Score: -8.84 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=live.com header.s=selector1 header.b=L3EwwzZv; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=live.com; 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" X-Migadu-Queue-Id: 26F163DBF1 X-Spam-Score: -8.84 X-Migadu-Scanner: scn0.migadu.com X-TUID: 3u8GiBTcZhuZ --=-=-= Content-Type: text/plain Hi guys, I was playing with org-capture today, and it strike me that it could be used as a simple and lightweight alternative to create GUIs for user options, somewhat resembling the use of well-known hydra/transient or built-in help macro or easy menu. I would like to propose a small 'feature/change' to org-capture templates, to inlude a new target: 'exec'. It should be followed by a function to be executed. I believe that this is a simple change that does not intrude on anything else in org-capture, you can see the attached patch. The goal is to just circumwent the createion of capture buffer, bookmark and other processing done by org-capture etc. However there might be things I am not aware of, so if someone have more insight, it is welcomed to hear. There is a small illustration in the attached patch as well. The error handling could probably be much better, so I would like to hear opinion and suggestion how can I improve it. best regards /arthur --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Introduce-executable-org-capture-templates.patch >From b8a910235c688d9ea1cb717a186699da489987af Mon Sep 17 00:00:00 2001 From: Arthur Miller Date: Thu, 26 May 2022 17:15:37 +0200 Subject: [PATCH] Introduce 'executable' org-capture-templates * etc/ORG-NEWS: Documented new feature. * doc/misc/org.org: Documented new template target. * lisp/org/org-capture.el: 'org-capture' add handler for 'exec' target. --- doc/misc/org.org | 14 ++++++++++++++ etc/ORG-NEWS | 28 ++++++++++++++++++++++++++++ lisp/org/org-capture.el | 5 +++++ 3 files changed, 47 insertions(+) diff --git a/doc/misc/org.org b/doc/misc/org.org index 3dce83c936..2445c57942 100644 --- a/doc/misc/org.org +++ b/doc/misc/org.org @@ -7629,6 +7629,20 @@ Now lets look at the elements of a template definition. Each entry in the target entry or as a top-level entry. The target file should be an Org file. + - ~exec~ :: + + An executable function. Function will be executed and the result + returned immidiately. No further processing by org-capture will be + performed, no capture buffer will be created, no last capture + bookmark etc, will be created. The eventual other template + parameters are ignored. Use this when you need to execute a Lisp + function for the side effects. Useful if you would like to create + lightweight GUIs for user choices based on org-capture mechanism. + + Simple example: + + '("h" "Say hello" exec (lambda () (message "Hello, World!"))) + - ~item~ :: A plain list item, placed in the first plain list at the target diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 37a39131d9..53ac10ba45 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -108,6 +108,34 @@ If you prefer to keep the keybinding, you can add it back to #+end_src ** New features +*** 'Executable' org-capture-templates + +New target, "exec" is added to templates which provides an easy option +to run a function from within org-capture dialog. It is meant as a +lightweight option to create GUIs for user options based on +org-capture mechanism. + +Exec should be followed by a lisp function, a lambda or a function +object that will be executed and result returned without further +processing by org-capture. As a consequence other template parameters +are not used with this target. + +Illustration: + +#+begin_src emacs-lisp +(defvar my-templates + `(("h" "Hello World" exec + (lambda () + (message "Hello, World"))) + ("f" "Find file" exec ,(function find-file)))) + +(defun simple-menu () + (interactive) + (let ((org-capture-templates my-templates)) + (org-capture))) + +(define-key global-map (kbd "C-S-n") #'simple-menu) +#+end_src *** New citation engine diff --git a/lisp/org/org-capture.el b/lisp/org/org-capture.el index 2fd9a9c74d..1a9b59de2f 100644 --- a/lisp/org/org-capture.el +++ b/lisp/org/org-capture.el @@ -665,6 +665,11 @@ org-capture (remove-text-properties 0 (length annotation) '(read-only t) annotation)) (cond + ((equal (nth 2 entry) 'exec) + (let ((f (plist-get entry 'exec))) + (if (not f) (error "Missing function specification.") + (if (commandp f) (call-interactively f) + (if (functionp f) (funcall f) (error "Invalid function specification.")))))) ((equal entry "C") (customize-variable 'org-capture-templates)) ((equal entry "q") -- 2.36.1 --=-=-=--