From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 iGgQNu5lsGJyRgEAbAwnHQ (envelope-from ) for ; Mon, 20 Jun 2022 14:19:58 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id iGTnNe5lsGI3kwAAauVa8A (envelope-from ) for ; Mon, 20 Jun 2022 14:19:58 +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 8057B2213C for ; Mon, 20 Jun 2022 14:19:58 +0200 (CEST) Received: from localhost ([::1]:43804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3GNp-0000n8-AM for larch@yhetil.org; Mon, 20 Jun 2022 08:19:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3GE6-00056L-Iu for emacs-orgmode@gnu.org; Mon, 20 Jun 2022 08:09:54 -0400 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:42628) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o3GE0-0005Hy-EP for emacs-orgmode@gnu.org; Mon, 20 Jun 2022 08:09:49 -0400 Received: by mail-qk1-x735.google.com with SMTP id 68so7612751qkk.9 for ; Mon, 20 Jun 2022 05:09:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=uhYNpN+pVFReVybx9HrH/yrt9th6s/KW5P41EZyaj0E=; b=N2jvVQEDtb22ycIUOH19PlCyqEBAI01jYgzcYBGS8Yprv3Gn/o1BKnTFA+G4/Hf5za LxCoqxuEGLg7k0WIIowSTdy5KKRHien2z0MY1PlsxiSTi0jsvEgBP8LmEcL71aE7Xrj+ hcHGBnfNwFPIxX64veU/1xTq0ChQx5QbVzYs9DAgvobOrTgy+7Vmc8IFn/PBVa3KB2yD UwZGG9b3I8M4kcy2zK2zlcwTOrpVVnlzMO+irvGRKRJh2sHRGXoP06wpOV0ND/vJLx98 xrkGpiNS5l/T/dwmBUXAOqi676wia0SqYeDPDuOAB54npcmL/50kRAM5U4eLXDw2LFsO RIhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=uhYNpN+pVFReVybx9HrH/yrt9th6s/KW5P41EZyaj0E=; b=EOZjp9LPBxeQoYADHLxuwLsVm2a76UDbf0SAWi6cyNslyTyCEPILGLZxtbRrzI7dI5 V5Woh9WVYaZakeSpyURS/r8oVrYmMApnLDm/vQPIRLmSc76FzydKdWcU5zYSkvxrMCqa 8L5HyhH0O/0JcMpQDfa6V28B5ZfxVXHkf3iO+g2jxZIYuv5Q6YPbnefXlwx25WJei5UB z7NPt71ng+jUmHn7RvzkR2Uci8WcSQG0c3/jq1pGI+q24NxSWGPdkbpgn+cIHIhkUT2q 8dWCeVmz2g1B93jPXxxroQBXLG2tXju3IEquHS3csK8Fp7+btdt0O7LpAZxU1VZrmROS LDvg== X-Gm-Message-State: AJIora/E+AINpLrImjnR57GUzEe9TaP+wkhP029CdvkIDs2zX5W4ufuR BFDEU6wx/CGlzzq3v1tDMQQ= X-Google-Smtp-Source: AGRyM1sMGVqMwGe4kY7NFHEf5Tsq/KiiAiClfYesYqvFLFC2ymwM8kLxYuyS7ysZM0WKlfFiq8G4KQ== X-Received: by 2002:a05:620a:1218:b0:6a7:3ade:277a with SMTP id u24-20020a05620a121800b006a73ade277amr15673002qkj.724.1655726987359; Mon, 20 Jun 2022 05:09:47 -0700 (PDT) Received: from localhost ([66.150.196.58]) by smtp.gmail.com with ESMTPSA id v7-20020ac87487000000b00304febfc2ddsm10130014qtq.56.2022.06.20.05.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 05:09:46 -0700 (PDT) From: Ihor Radchenko To: Max Nikulin Cc: emacs-orgmode@gnu.org Subject: Re: Proposal: 'executable' org-capture-templaes In-Reply-To: References: <87mtf3tui1.fsf@localhost> <87pmjyco0x.fsf@localhost> <87fskrobiw.fsf@localhost> <87a6ay1enh.fsf@localhost> <87edzvdb44.fsf@localhost> <878rpu5qf4.fsf@localhost> Date: Mon, 20 Jun 2022 20:10:57 +0800 Message-ID: <87zgi7357y.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::735; envelope-from=yantar92@gmail.com; helo=mail-qk1-x735.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, 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: 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=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1655727598; 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=uhYNpN+pVFReVybx9HrH/yrt9th6s/KW5P41EZyaj0E=; b=loE+RbZYAoKg0ltjthgdW6rhuGEKbvRSOv2ieyM2PmcW48CEf+BxhTs/O7HUxcCM4Cqny9 rdja/pZhvO6+mWybohbBPecz6CRffF93EyAqiNVNLNjxzt7+4qBNUQzLZ83emplp9nFYDJ mTY/C3FOUBO8gQAAEn/781aVGjjHlSMCcImFTZQ5XxEkE+Y3akLOLbOCvmpgv1mUKBO7yA PtYPKCE/IzsN7byWALoNuUtFHA43s2sVL6H/CFUoWBHqb/hCNohBOyKTwbykBYwwGX6HU3 zaVE8ggjezYNfb0uTBRZHc5EppeNq7pECKcp1d4rl/d8bnfGBT/bdKIrkAYJFQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655727598; a=rsa-sha256; cv=none; b=KuFiU4yrmtpk3df6GAuLwbCNKi2NwbYy++hmSsuFv/0HrdU+M3sel16e/krO0y6adZD777 GNXmyd2qimUyfIWdlQiflJSUaDRsFGSAwraDUg3IC8tL6/QptEmOsB0ZANkog3Z32PtqPP x2kdaKJe/3aPEXZEphiCffaWalSE8z9kCHoTsdg33nklCZtPuTwp0ot7QmprbtpWFu9gYC 4cYVvvq3UAGj5LInT9rIvov9MYd5tZcIuDOcplgL5rQujZDE3+IdruAcPUWN1BP9eXk+Wt NnZIkFYxYRdfZvH5/9B4a2dnWKr8tMcxJuNBdJVnHdrzX1TxfG7P41JOM+lydA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=N2jvVQED; dmarc=pass (policy=none) header.from=gmail.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: -6.97 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=N2jvVQED; dmarc=pass (policy=none) header.from=gmail.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: 8057B2213C X-Spam-Score: -6.97 X-Migadu-Scanner: scn0.migadu.com X-TUID: TaFr/LuDvFha Max Nikulin writes: >>> Ihor, magic is impossible. If several captures may be requested in >>> parallel then snapshot of data required to fill capture template should >>> be stored somewhere at the moment when capture is initiated. Otherwise >>> the user may kill the buffer she is going to capture before selecting >>> particular template. >> >> Sure. That somewhere can be buffer-local variable inside the capture >> menu buffer. Or global variable. Or closure. How is it relevant to the >> capture menu? > > Before menu buffer is created, caller can not assign a buffer-local > variable. So to be transparent for snapshot of capture data, menu should > support such variable and should pass it further when template is > chosen. Otherwise the capture data may be lost with temporary buffer. > The function calling menu should gather values from all variables > necessary for capture to build some state passed to menu implementation. Sure. I was hinting about such functionality in the new library we are discussing. Multiple capture menus are not possible now anyway, so it will be a new feature if we decide that we need it (I am not 100% sure if having multiple menus is not going to be confusing). >> Of course, using global variables will limit things to a single capture, >> but it just means that if a user starts capture, leaves the capture menu >> buffer, and then starts another capture, only the last capture will be >> handled. Just like we have now. > > Now user may leave capture menu by either selection of a template or by > aborting menu. In the case of keymap-based menu there is no such > restriction, so org-capture and menu implementation should be adjusted > in some way to avoid bad surprises for users. > > Currently several capture menu instances may be requested though > org-protocol (or calling org-capture from emacsclient). The behavior is > rather confusing. New menu may help to fix the issue, that is why I > raised the question about parallel captures. I am not sure which behavior you have in mind. What I was thinking as a conservative implementation that would not introduce any new features is replacing the old menu with the new one every time the same menu is called. So, every time the user calls menu (e.g. capture menu), only the last capture environment is preserved. The previous, potentially unfinished, capture menus will be destroyed. Best, Ihor