From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id kPgUCsOX1l+4UAAA0tVLHw (envelope-from ) for ; Sun, 13 Dec 2020 22:37:55 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id iF98BcOX1l9LfgAA1q6Kng (envelope-from ) for ; Sun, 13 Dec 2020 22:37:55 +0000 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 B3EEA9404CE for ; Sun, 13 Dec 2020 22:37:54 +0000 (UTC) Received: from localhost ([::1]:36072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koa01-0001Yb-1g for larch@yhetil.org; Sun, 13 Dec 2020 17:37:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koZz2-0001Y8-Og for emacs-orgmode@gnu.org; Sun, 13 Dec 2020 17:36:53 -0500 Received: from stw1.rcdrun.com ([217.170.207.13]:37623) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koZyy-0005aT-6s for emacs-orgmode@gnu.org; Sun, 13 Dec 2020 17:36:51 -0500 Received: from localhost ([::ffff:197.157.34.185]) (AUTH: PLAIN securesender, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 00000000000308F3.000000005FD6977B.00006CEC; Sun, 13 Dec 2020 15:36:43 -0700 Date: Mon, 14 Dec 2020 01:34:01 +0300 From: Jean Louis To: Tim Cross Subject: Re: Org Capture Menu cannot be fully viewed Message-ID: References: <87y2i2ttl7.fsf@gmail.com> <87wnxlig9m.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <87wnxlig9m.fsf@gmail.com> User-Agent: Mutt/2.0 (3d08634) (2020-11-07) 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.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pietru@caramail.com, emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.80 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: B3EEA9404CE X-Spam-Score: -1.80 X-Migadu-Scanner: scn1.migadu.com X-TUID: pRorAhlyeNX+ * Tim Cross [2020-12-13 23:49]: > > That is very right. I have 1140+ "Sets" which are equivalent to > > capture templates. Imagine if I would be "defining it" by using Emacs > > custom, forget it, I would rather break my computer down and switch to > > paper. > > I have no clue as to why your dragging Emacs custom into this > discussion. The issue being discussed here is making it easier to > select from a larger list of capture templates, not defining custom > templates. It is double work: - user already has files which is accessing and using, those are most probably files where captured notes need to go - org agenda already indexed most of files including headings - org capture defeats its purpose with more then few templates, then it could be better sorting it right away in proper file. If that is right for user like me - defining custom templates is double work and left to user, instead to computer, to calculate it for user. The more templates there are the more hand work user does for computer. It is definitely related to the speed and efficiency. The discussion is brainstorming. It may lead to useful selection of templates where to store notes. Definition of those templates allows for many various selections by ID, file+heading, file+regexp etc. Now any enhancement is rather type of a glue than well designed solution. It looks to me most logical to use the key and the description to choose the template, as that is what each template alreadu has: (defvar my-capture-template-history nil) (defun my-capture-choice () (interactive) (let* ((collection '()) (collection (dolist (item org-capture-templates collection) (let* ((key (elt item 0)) (description (elt item 1)) (headline (car (elt item 3))) (headline (if (string-match "headline" (symbol-name headline)) (concat " > " (elt (elt item 3) 2)) "")) (item (concat description " " headline " [" key "]"))) (push item collection))))) (completing-read "Capture to: " collection nil t nil 'my-capture-template-history))) That function can already choose one among many templates by using completion. But it shows collection in some peculiar way with keys being within [] so that by using completion such as ivy, user would need to enter: [KEY instead of just key. In standard completion user would need to enter *[KEY and press TAB to reach to heading/template by using a key. Key could be used within [KEY] to find the actual org capture template programmatically from the selection. The selection would look like: Protocol Link > Inbox [L] Following function must programmatically understand what is the key L within the selected string: "Protocol Link > Inbox [L]" (defun string-cut-right-square-bracket-reference (s) "Returns the reference within square brackets on the end of S." (let* ((space (string-match " " (reverse s)))) (if space (let* ((id (substring (reverse s) 0 space))) (if (and (string-match "\\[" id) (string-match "\\]" id)) (replace-regexp-in-string "\\[\\\|\\]" "" (reverse id)) nil)) nil))) (string-cut-right-square-bracket-reference "Protocol Link > Inbox [L]") "L" So it can find the key L from the selection of Org templates. Then `org-capture' function already allows for the key to be selected, thus running it as (org-capture nil "L") leads user by the selected key to the proper template. Putting it together is this: (defvar my-capture-template-history nil) (defun my-capture-choice () (let* ((collection '()) (collection (dolist (item org-capture-templates collection) (let* ((key (elt item 0)) (description (elt item 1)) (headline (car (elt item 3))) (headline (if (string-match "headline" (symbol-name headline)) (concat " > " (elt (elt item 3) 2)) "")) (item (concat description " " headline " [" key "]"))) (push item collection))))) (completing-read "Capture to: " collection nil t nil 'my-capture-template-history))) (defun string-cut-right-square-bracket-reference (s) "Returns the reference within square brackets on the end of S." (let* ((space (string-match " " (reverse s)))) (if space (let* ((id (substring (reverse s) 0 space))) (if (and (string-match "\\[" id) (string-match "\\]" id)) (replace-regexp-in-string "\\[\\\|\\]" "" (reverse id)) nil)) nil))) (defun my-completing-org-capture () (interactive) (let* ((my-capture-choice (my-capture-choice)) (my-key (string-cut-right-square-bracket-reference my-capture-choice))) (when my-key (org-capture nil my-key)))) Then user can bind `my-completing-org-capture' to some key to quickly capture items by using completion. So Pietrum, you can try using this solution. Or run M-x my-completing-org-capture This is not perfect function but I just guess it should work well for people who have many templates with headlines. Jean