From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 CN+QLQdVrWJodAAAbAwnHQ (envelope-from ) for ; Sat, 18 Jun 2022 06:31:03 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id YNacLAdVrWKI3AAAG6o9tA (envelope-from ) for ; Sat, 18 Jun 2022 06:31:03 +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 345E4AE66 for ; Sat, 18 Jun 2022 06:31:03 +0200 (CEST) Received: from localhost ([::1]:35020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2Pgi-0007Q8-VY for larch@yhetil.org; Sat, 18 Jun 2022 00:03:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2Pfj-0007Q0-Es for emacs-orgmode@gnu.org; Sat, 18 Jun 2022 00:02:55 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:45658) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2Pfh-0005tX-El for emacs-orgmode@gnu.org; Sat, 18 Jun 2022 00:02:55 -0400 Received: by mail-pg1-x531.google.com with SMTP id 184so5565811pga.12 for ; Fri, 17 Jun 2022 21:02:49 -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=s2w/RUywMHogGkKy3Ze5PR+VTn9o2yYVr2zlfkvl0OQ=; b=lwJSoJah6bQoGJCvYZ60JsYv/c7kHe0NFn817sFUP07LxjVfLQXDJuxZNHOlvbu5AY b8bMDupbmTtjUjJ3YdEsJt8pjH8up4M1XeENMfyYMKWRqKJPQp8n+1JWM6Hp2U6VgC8J OvSeyBNM6f4OMVVB6A7918DUo6YlnLIcAUgW5fCplIUUvQ/1NteKMEqODvk6fOjIAeUU 1fJzEkQt77QEYJ1ZOgj6AM75+h96wADkwnQWBJ8R6bB8HJlIQv36IudMxRUdqHsNfNdT AngQDi5Ikm9hfLiERNI5Ygr7zvRvL5R7M+E6KxcaGoR38yDjsIXkGzD2twn+/wQ2efbj fdSA== 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=s2w/RUywMHogGkKy3Ze5PR+VTn9o2yYVr2zlfkvl0OQ=; b=I9meNHOhwi6ycmuM+jNANpZxAmuVE65H/UYHOklfao9exQI3lLWrxzNQEXCnXxopfp EoJYCKr+CnPwJs/5ADrDtldtoyFIsuztLORBxUvEqG3iTejnoPy887xGMi/pKnwKhKSe N2qlmFSEhbywzSBWp2Okk2e98QNuAdzKwRr7H125x8Vt8trojezp/Hhnkh8mmQQeMfpA fNjtmcufydHHZQt0w0h3c3G/qkjwucOIV/xls/tAbyldvLn2lrfiIoa4BCFf+mbIvnRT MXotZ8vxraq0V+1nOVGfeyrYFL02Z7WScv/STk/KAQ4s8U46ioEdDZ4wAJaL+G2lbxwd JulA== X-Gm-Message-State: AJIora/HO/z3LawbR286PDUoRibruSM3NX9tDZ+PK3AYMrMICmpXDrzH AI7WOQ1GM9XJIlSOn4bBlx0= X-Google-Smtp-Source: AGRyM1vNZo/9GUoQ1c9slnC8mYmh+tVgh2FmRXvfyjVsOl0qetlWQbOkJGoLCc9lzsP1As0rNHOPkg== X-Received: by 2002:a63:9142:0:b0:3fc:c021:e237 with SMTP id l63-20020a639142000000b003fcc021e237mr12037744pge.279.1655524968420; Fri, 17 Jun 2022 21:02:48 -0700 (PDT) Received: from localhost ([204.44.110.111]) by smtp.gmail.com with ESMTPSA id ja6-20020a170902efc600b00161a40b2135sm4283379plb.104.2022.06.17.21.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 21:02:47 -0700 (PDT) From: Ihor Radchenko To: Arthur Miller Cc: Tim Cross , 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> <87zgisvuu5.fsf@localhost> <87sfoi1xde.fsf@gmail.com> <87ilpbs4tw.fsf@localhost> Date: Sat, 18 Jun 2022 12:03:51 +0800 Message-ID: <87mteawrbs.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=yantar92@gmail.com; helo=mail-pg1-x531.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=1655526663; 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=FVkGZ7kgJrA4q0W5vKdptayNcT9q48m/EcSVoxF29qI=; b=ef5B6fPR/HnOYszMPEvtQUyMnLOYOwF+vla43WRq9neR72QafLSH8eKbdyjPeSdU8bXUSp z/Bg/d0JWpZgJ/tsGyk1rLbrnxy0QY/81t0+uoF15mO8zoP6SUsLeZKVL0zGrPVQILkIMc 6+4/YD9ws/flY1eQYzVVWzr1eEbCx4cPfLVXyXmjUhoH5PgprzdhpiMMZJ8+ijW0bSBu+q ZfkfSa+Lx2Uq4LYldwOiV3zNcjBUXwSdNLFNMU1XWQA+oFLnRCKbcb3PdcgJ+B+0iskynh cR1s7k6LtnVdjlJuKnIcRX5rOhkPU/vA5mRnd9/sjdQ6nRn68bdDtl3uNW+bHA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655526663; a=rsa-sha256; cv=none; b=ttmV7gKzcm+6HVMrUYKsMZEeVZvPhGhH+5ts9avOgvmO8WPcoEGeuhRO1IMtxtZJ3wwUIV 3XElV2Ava05UTsxwd2XABYgv4suwzOfHlWGH7VnQA+AXyvCUfflPCgiODnL5oJ+mf4d1Cn 0Np0DQmaFedLHRnPDnZ/oSQ3OGXeKqZ1l36xoxAOHYVMOy7dLIPxSniqeT2QPFltqIeNrn QRdEIwDvo66YsqBHUkV4Arv1jYG8Y/iL+0kwlTZc4z15nKQkTD7ZwNbgEPNhTOrza0bQQU 6CWoTI7++2Mxzol+/opetzEhbR5YoIYKBkxWc+ZPqTa35eFtLlGUJ57EH4fheA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=lwJSoJah; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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" X-Migadu-Spam-Score: 7.71 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=lwJSoJah; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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" X-Migadu-Queue-Id: 345E4AE66 X-Spam-Score: 7.71 X-Migadu-Scanner: scn0.migadu.com X-TUID: pSVsufGr966L Arthur Miller writes: > Anyway, I have been playing and testing a bit, and didn't want to prolong > discussion untill I have something to show. So here is a small prototype. It is > just a rough sketch of the idea. Thanks! I will not comment on Elisp part just yet. Let's first settle down the design. > this example the mode map approach seems slightly more convenient. I don't know, > in org-agenda-test, I haven't implemented all of org-agenda, restrictions, > prefixes and some other stuff, mostly because I don't really understand the > implementation. In the nutshell, agenda restrictions will execute some elisp that sets certain global variables affecting other agenda commands. selecting the restriction should not leave the agenda menu. Also, unlike other selections being echoed literally upon selection, restriction echo must depend on the global state. If you press "<" in the menu, the menu prompt should change between "Press key for agenda command (unrestricted):", Press key for agenda command (restricted to buffer):, ... etc Note that there is not much point echoing the selection. Tim, do I understand correctly that changed minibuffer prompt will be also spoken out by emacspeak? > About the name: org-select; i really have no idea what to call it, so better > name would be nice. Sorry for the bugs, I am aware of many, but it still > displays the idea I think. It does not matter at this point. We can discuss it at the very end. It is not like M-x replace-regexp is difficult to run later. > (defun osl--make-mode-map () > (let ((map (make-sparse-keymap))) > (define-key map [?q] #'org-select-quit) > (define-key map [?\C-g] #'org-select-abort) > (define-key map [left] #'osl--back) > (define-key map [?\C-p] #'osl--back) binding left and C-p is unexpected. C-n and C-p are usually dedicated to moving around. A very conservative alternative could be creating a new buffer for sub-menus and letting the user use the usual previous-buffer command. > ;;; API > > (defun org-select (tables &rest args) > "Select a member of an alist with multiple keys. > > TABLE is an alist which should contain entries where the car is a string. > There should be two types of entries. This is confusing because there is no TABLE argument in the command. I it not immediately clear that you can use multiple tables to build a single menu. > ARGS is a property list containing following members: Does it apply to individual menu entries? I am a bit confused here. > :text a string placed over the selection in the buffer. > :label a string used for the selections buffer name. :label name is confusing. Why not directly :buffer-name? > :always when `t', this menu is shown; even descended into submenus > :transient when `t', the menu is dissmised after user perform an > action Does it apply to the whole table? Individual entries? > TABLES are additional menus in the same format as TABLE. If there are more > than one menus, they will be separated by a separator line rendered with > character as specified in `org-select-horizontal-separator'" > (defun org-capture-test (&optional goto keys) > (defun org-capture--handle (entry) > (org-select-quit "") > (cond > ((or (equal "C" (car entry)) (equal "q" (car entry))) > (eval (nth 2 entry))) > (t > (let* ((orig-buf (current-buffer)) This looks fragile. It is hard to know what is the value of (current-buffer) after exiting the manu. It is not guaranteed to be the buffer where the menu was called initially. A more proper alternative could be allowing the menu to setup some variables _before_ running the menu. For example, org-select can store some setting as buffer-local variables in the menu buffer. This way, the caller can fill some initial settings at the calling time. The settings will then be available at the time user actually select the menu option. > (defvar org-agenda--menu > '((("a" "Agenda for current week or day" (org-agenda--exec > 'org-agenda-list)) It's nice that I can instead do `((("a" ,(propertize "Agenda for current week or day" 'face 'highlight) (org-agenda--exec 'org-agenda-list)) and the face is actually preserved (: Best, Ihor