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 kC8BK8K7lGJt9gAAbAwnHQ (envelope-from ) for ; Mon, 30 May 2022 14:42:42 +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 iCv0KsK7lGI3agEA9RJhRA (envelope-from ) for ; Mon, 30 May 2022 14:42:42 +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 162D622623 for ; Mon, 30 May 2022 14:42:42 +0200 (CEST) Received: from localhost ([::1]:46352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvejI-00069h-Nc for larch@yhetil.org; Mon, 30 May 2022 08:42:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvehW-00068X-Kf for emacs-orgmode@gnu.org; Mon, 30 May 2022 08:40:50 -0400 Received: from mail-oln040092069040.outbound.protection.outlook.com ([40.92.69.40]:29415 helo=EUR02-VE1-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 1nvehU-0001Vk-94 for emacs-orgmode@gnu.org; Mon, 30 May 2022 08:40:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g4CfRBoiYvDtIT8ytdQ0LjKoZmAHTZ1P/EqCov88o4wZ8TE/vLBvjnWv3Nk4r17YmT2TPUfiGp8YTPdCA1w0/MJYXQDbBBJbTyksDcX+b3mjqurKE8zTUutdXFNiHqwrlYLSgW+WgUgoPmWo750moBeUWIEcUqp4/m7MCKwVaJiSh7oq0LjwBxd0gF6whvhfNibxMdzk4kGha78ZNFuTHErzDChlbg3YM6s7A4HcGtAPv2mXGAlKrk6JnW1VgBW2l/MvV+TyqZ1uymCkFau5SWL5etZTHlb/1pPt9hukzCgWmDHjerJKlZHjgRv9NOgw0/tt0GgNvUXQWmEJMqPQvQ== 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=Qs7l/n3LpPzAEbGoSUnXid2DeR6QJNOWHfPQXWyv1Dg=; b=mbd/HmZnQ6tBldtMtFzcTGS+d8aI+HA4j1RQQoq+spiV8/mmvPL+O0I9E/CRiVEW95UIiqQPS9DFzVTr3tLd+S5+FXy8gyve+lmGi3iuGLY2p5bn72rBH6zdElvryrMuSR05R9sg49tOJPzIL+ai+4kgX2sNhjJX1//M91Sgs3cBRSD85xoohAR7JNCBGKxpBSoi+TGN24VtDD/QGdDEEa3UeHAHN096MM/yzPY63tRqTJp2I82JjnVSXk2wjToLUfD0Y0ILY5ekxrsNC7MDrKQfwju0WL+pgNa43zUc05ESZQ/Rdk4A9Y/mpKP7svU2PoUqbrXR82RkVWLmBMlQ7w== 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=Qs7l/n3LpPzAEbGoSUnXid2DeR6QJNOWHfPQXWyv1Dg=; b=QKs2OBMh8dpF2pTmd2npQS5mb1iRLz7zFWSpb42Vz1vYjXRo6Qb47z5fpy6k5MPIWfJowdUHBTqAjl4WfGz3jOqfCIhAkepWRJ4Pgxu/n3W8Qrd2WoVli7x0mrPJRUnXlcJeO9UBq/HqpeWU26Lzeg3+/IS6o1yGDj6zh5K8EiQJLiJqDpt1x/v4O7hZMkDbcgCCWfWAZoTUP/i9UV1OKsUMVwSaLOzb07NOTuFjeFxcJJcQJOkIeiqjUrFmfJ6vOi7dtLR34XhzgcvSpq0O8oqw+vHvjU7SFGtcQEMU9TlYMYvw8xMlx4lmrJjnM+EGKDloQErgNVdmzC7y+9o5mw== Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by GV1PR09MB5876.eurprd09.prod.outlook.com (2603:10a6:150:97::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.18; Mon, 30 May 2022 12:40:45 +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.019; Mon, 30 May 2022 12:40:45 +0000 From: Arthur Miller To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: Proposal: 'executable' org-capture-templaes References: <87mtf3tui1.fsf@localhost> <87pmjyco0x.fsf@localhost> <87fskrobiw.fsf@localhost> Date: Mon, 30 May 2022 14:40:44 +0200 In-Reply-To: <87fskrobiw.fsf@localhost> (Ihor Radchenko's message of "Mon, 30 May 2022 13:05:43 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Content-Type: text/plain X-TMN: [fgNJoMoOxD6ijR9MNeJmWSIOJH3qhMh9] X-ClientProxiedBy: CWLP123CA0196.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:19c::9) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87v8tnnqgj.fsf@live.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7b55c91a-9e5a-4827-4dde-08da42399d8e X-MS-TrafficTypeDiagnostic: GV1PR09MB5876:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9qm4JutZ6z/CP5PCIsAXtj9q772yIp3gaPqxNcSYQpFgfejh+UfwMrzV5sNlVPNC13HkiNG1Hej/vj6dAxk4zbPtFRriGx94TgUVdp9FGzHsamBJKp+82z/B9TfB+9jdqmQfdcv82fK3a3xLvKdxuN30suP4C0SHRUJk25RXHtjNfLDyTnkuXHLvTimrBGLfdvuEsZOKmn8SEoH9xHmlF/ZXRm5pKJe+km/JqKqv/xGyADA3x6vHNUy4u1EjvjXY4x0q/Baawji2Vj2dHeZzc/I0hsusj9ZWnN0SnJDgxFj8HGYG7xfeC7/uf0vfspWg4lT2rFt3HtOYJJ23x276brY5sPaJE3sxvCRvDO2XeYn99ldw54JCeVNJxG0eiR3MHAmgulihBnl6ry2P6D6clZkMrsN6j4Dlg+9avkY5OT0DczPrUCa4ciz/ppGqh2KAyTCSpfgmq4r53kzwyZjbuYpZlNGMzT1LINyomtgs00nRP6HI4yDs6rSC9JtQejJt37BMS2J/HKS1B80BJ07Yq8VYl1KvSgfysrDVwbhRqP1H0Fe6jgfVvc/iwvq9Rr1AjhqkoYNsS8hkqxshxcyw8g== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?T+eFr6RWlAEj06HWKNSONu0gtJQw51zFOM44n3WrXGUPETH1akUflZBE4iYq?= =?us-ascii?Q?w02yU2mrTSCEOuewZSOEysAsgjiz6nQXbToHW7b2XLAWPj7K3IOn6GGi+g4G?= =?us-ascii?Q?yiP1PBJ44Fe48TfuugSlAM/q8anPAX20/7vy8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uDrueJ8+Cu/1I7BAyKKFClujpSSFsJia9lsRry6+oupIaKRXsAdTlYTlSN8?= =?us-ascii?Q?wjqBGMmW8eUFOPaM9cqAubjmon57/ZQQumIP2bvK5+zdYytpeuImblFflz+Q?= =?us-ascii?Q?LlFvVsJ4R5oyV+buw+R9D6Fhogy7JUvWZ/NoXxxQGpsywQIakF9QZTDXR3Cy?= =?us-ascii?Q?zWzFqInI+FHGV931imvMZg/J2HGUpVB0rmj4NZOvpMG0awVI/qEx6QvLj/Gc?= =?us-ascii?Q?uvAAMI1QpH2stTFqUzFGKaitkZqwkfpt2TMjVyzHj2nC982dTlZASAUhEvYw?= =?us-ascii?Q?BEoHPj6J1oVSnMdvvCwYh7KXm7V7rxqm5O+5uX96B8s9d73/5o9rfnE0z08J?= =?us-ascii?Q?URDsr0wpEDPduxB6nOF21K0SxFgr58HSIkuLjKDTarEtKhvv548MhfwVQiqc?= =?us-ascii?Q?HcBP5hK15F4=3D?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-64da6.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 7b55c91a-9e5a-4827-4dde-08da42399d8e X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2022 12:40:45.5107 (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: GV1PR09MB5876 Received-SPF: pass client-ip=40.92.69.40; envelope-from=arthur.miller@live.com; helo=EUR02-VE1-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, RCVD_IN_DNSWL_NONE=-0.0001, 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=1653914562; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Qs7l/n3LpPzAEbGoSUnXid2DeR6QJNOWHfPQXWyv1Dg=; b=aSFLLGxrSSjpq7oLo8JFoefIY5sx4wTI7PUmfEQZSQGr59OEaV7V4GFeZY9Qdq7sdMQur0 kQnC3wbJRBkvXBDei7RTX9iz4KPt4d5rW5eetq81uGVkq0WLAzGDYdQGdzENJ/fv5DAGDy ESVNbuFpNx3IWebmWcraoyo4yesAO4YdiKdfH1K2rzF9o+RB1a4/4jYlPEnBPjBVTcW4GE Q/aCfhLO/t0GiCbTY+Swzp6vkJN+b9SXMyDZiHwonmu+kFGcCBY/K5y+ltg7TZLhOf6HAG vVKvsV8uRX/0itw55AkdV+rKmoJkzj5s29twvNOITI7WOvkIS3zrnNcJWkCffQ== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1653914562; a=rsa-sha256; cv=pass; b=OVZ350P3uDh9T4W1EiNu3BF3AeLTEu6xR2EalR6tgfacdG149hBIdCJ0BSqTFQw7DKS/DB NeUE2kGZ3rNStkrQZCS9Q5qgxHDV7YRIdzfoGXTXfbA3xd2vtbYS7zXzVCpjjrjU0KeCZO CuL0AokXLDbwzUPmMzczuP9rm4f/bT/XP1HlV6TY1N/DndE/AfHeFnDKIhZZQ8hZdhHybT aG3QA8ZSPetLXIS+LzOWFMCUkHMnDXsK3dsZXQGgMpHxY8kpAzhyv/k8JG1/MshHTF6awY ff/96ona5wuKJ2BFXQuJpXtq8ptUfaz7rQcxVvCfiPm82sRyvNmy8NJV2apSkw== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=live.com header.s=selector1 header.b=QKs2OBMh; 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: -10.33 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=live.com header.s=selector1 header.b=QKs2OBMh; 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: 162D622623 X-Spam-Score: -10.33 X-Migadu-Scanner: scn0.migadu.com X-TUID: ARf9uVSfiJQq Ihor Radchenko writes: > Arthur Miller writes: > >>> By "generic" I did not mean general-purpose all-functional framework. >>> We just need something to remove code duplication in >>> org-export-dispatch, org-agenda, org-capture, org-set-tags-command, etc >>> They all share pretty similar code to generate dialogues. >>> >>> As for familiarity, I understand and it is exactly the reason why I >>> suggested to factor out the menu code from capture templates. >> >> I am not really familiar with those other dialogues but org-capture, so I only >> had that one in the mind. Yes, I agree if the similar code is used/shared in >> several places than it does make sense to refactor it out. > > This refactoring could be a practical way to get something similar to > your proposal into Org core. At least, if the menus are factored out > appropriately. As I see from 'org-capture' function, it does not seem to be terribly hard to factor menu creation out. There seem to be two parts: template selection which is already done by 'org-capture-select-template' function, and then the main work that one has to implement on its own, which is specific to whatever one would like to implement. I just did a quick refactor to test the idea: #+begin_src emacs-lisp (require 'org-capture) (defun org-menu (&optional goto keys) (interactive "P") (let* ((entry (org-capture-select-template keys))) (cond ((equal entry "C") (customize-variable 'org-capture-templates)) ((equal entry "q") (user-error "Abort")) (t (let ((f (nth 2 entry))) (if (not f) (error "Missing function specification.") (if (commandp f) (call-interactively f) (if (functionp f) (funcall f) (error "Invalid function specification."))))))))) (defun org-capture-some-menu () (interactive) (let ((org-capture-templates `(("F" "Functions") ("Fh" "Hello World" (lambda () (message "Hello, World"))) ("Ff" "Find file" ,(function find-file))))) (org-menu))) (define-key global-map (kbd "C-S-m") #'org-capture-some-menu) #+end_src Instead of hardcoding the actual work in the conditional statement, there should be a function to be called, so org-capture would setup its own work, some random "exec" menu like here would setup its own and so on. I haven't look at other parts of org you have mentioned, so I am not yet sure if the approach would work for all the kids in the block. I don't think it would that much harder to refactor this out, but I might be wrong, since I am not that familiar with org code. Factoring this out of Org itself, as suggested by RMS in the link you posted might be much more work though. I haven't looked at that, and question is if that is really worth the effort? I would agree with him that things like org-table and date/time handling would be great to have in entire Emacs, without need to load org, at least bigger parts of it. If I remember well, table mode started outside of org as its own minor mode and got merged into org. > The above statement is a hint that patches are welcome :) As said, I am not that well familiar with org in-depth, and with other places that might need to be factored out, so I don't promise anything. Initially I just got a quick idea while working on a project of mine with org-capture, and hacked the 'org-capture' function to implement my idea :). /a