From: "Christopher M. Miles" <numbchild@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: "Christopher M. Miles" <numbchild@gmail.com>,
Org-mode <emacs-orgmode@gnu.org>
Subject: [PATCH v5] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`
Date: Sat, 01 Jul 2023 18:31:30 +0800 [thread overview]
Message-ID: <64a000ea.170a0220.250a9.7355@mx.google.com> (raw)
In-Reply-To: <87sfa9p0sy.fsf@localhost>
[-- Attachment #1.1: Type: text/plain, Size: 741 bytes --]
Ihor Radchenko <yantar92@posteo.net> writes:
> "Christopher M. Miles" <numbchild@gmail.com> writes:
>
>> I improved the code a little. Can't figure out how to implement upper logic.
>> Can you finish the last part? Thanks
>>
>> #+begin_src emacs-lisp
>> (setq tbl (let* ((tags-grouped (org-tag-alist-to-groups fulltable))
>>...
>
> I tried to improve the code readability in `org-fast-tag-selection'.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=a19654583c6f2070096402bc712591a0a2c80d01
>
> May you look at it again and see if you can manage to implement a full
> patch now?
Ok, I update and re-generated the patch, also add new document and Org NEWS entries.
Review it, if has problem, notify me to modify. Thanks
[-- Attachment #1.2: 0001-org-Improve-the-tags-fast-selection-performance.patch --]
[-- Type: #("text/x-patch" 0 12 (prescient-regexps nil prescient-ignore-case t)), Size: 4459 bytes --]
From 77fdbf8552a0a2ff451bf9071f6646ac016cb262 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Sat, 1 Jul 2023 18:29:02 +0800
Subject: [PATCH] org: Improve the tags fast selection performance
* lisp/org.el (org-fast-tag-selection): Filter out only maximum number
limited tags has fast selection bound when `org-use-fast-tag-selection'
is 'auto and tags has fast select bound keys.
* lisp/org.el (org-fast-tag-selection-maximum-tags): Add new custom
option to set maximum tags number for fast tag selection.
* doc/org-manual.org (org-fast-tag-selection-maximum-tags): Add new
custom option document.
* etc/ORG-NEWS: declare this new custom option.
---
doc/org-manual.org | 10 ++++++++++
etc/ORG-NEWS | 11 +++++++++++
lisp/org.el | 14 +++++++++++++-
3 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/doc/org-manual.org b/doc/org-manual.org
index 3a49917d7..30fcf32dc 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -5073,6 +5073,16 @@ effect: start selection with {{{kbd(C-c C-c C-c)}}} instead of
the special window is not even shown for single-key tag selection, it
comes up only when you press an extra {{{kbd(C-c)}}}.
+#+vindex: org-fast-tag-selection-maximum-tags
+Limit the tags table when you have many tags. You can set the maximum
+tags number for fast tag selection interface. When the variable
+~org-use-fast-tag-selection~ is ~auto~ and
+~org-fast-tag-selection-maximum-tags~ variable value number is smaller
+than single key bound tags number, the fast tag selection will only
+show single key bound tags, in contrary, will show the maximum number
+limited tags. If ~org-use-fast-tag-selection~ is other values, will
+show full tags.
+
** Tag Hierarchy
:PROPERTIES:
:DESCRIPTION: Create a hierarchy of tags.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index cb4bc632b..dfabbfbed 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -322,6 +322,17 @@ special repeaters ~++~ and ~.+~ are skipped.
A capture template can target ~(here)~ which is the equivalent of
invoking a capture template with a zero prefix.
+*** Add new option ~org-fast-tag-selection-maximum-tags~ to limit fast tag selection interface displayed tags
+
+Limit the tags table when you have many tags. You can set the maximum
+tags number for fast tag selection interface. When the variable
+~org-use-fast-tag-selection~ is ~auto~ and
+~org-fast-tag-selection-maximum-tags~ variable value number is smaller
+than single key bound tags number, the fast tag selection will only
+show single key bound tags, in contrary, will show the maximum number
+limited tags. If ~org-use-fast-tag-selection~ is other values, will
+show full tags.
+
** Miscellaneous
*** =org-crypt.el= now applies initial visibility settings to decrypted entries
diff --git a/lisp/org.el b/lisp/org.el
index fdb920864..f077cde12 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -2775,6 +2775,12 @@ displaying the tags menu is not even shown, until you press `C-c' again."
(const :tag "Yes" t)
(const :tag "Expert" expert)))
+(defcustom org-fast-tag-selection-maximum-tags 26
+ "Set the maximum tags number for fast tag selection."
+ :group 'org-tags
+ :type 'number
+ :safe #'numberp)
+
(defvar org-fast-tag-selection-include-todo nil
"Non-nil means fast tags selection interface will also offer TODO states.
This is an undocumented feature, you should not rely on it.")
@@ -11929,7 +11935,13 @@ these have keys assigned to them.
If the keys are nil, a-z are automatically assigned.
Returns the new tags string, or nil to not change the current settings."
(let* (;; Combined alist of all the tags and todo keywords.
- (tag-alist (append tag-table todo-table))
+ (tag-alist (let* ((tags-table (append tag-table todo-table))
+ (binding-tags (seq-filter 'cdr tags-table)))
+ (cl-case org-use-fast-tag-selection
+ (auto (if (length> binding-tags org-fast-tag-selection-maximum-tags)
+ binding-tags
+ (seq-take tags-table org-fast-tag-selection-maximum-tags)))
+ (t tags-table))))
;; Max width occupied by a single tag record in the completion buffer.
(field-width
(+ 3 ; keep space for "[c]" binding.
--
2.39.2 (Apple Git-143)
[-- Attachment #1.3: Type: text/plain, Size: 267 bytes --]
--
[ stardiviner ]
I try to make every word tell the meaning that I want to express without misunderstanding.
Blog: https://stardiviner.github.io/
IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
next prev parent reply other threads:[~2023-07-01 10:33 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-13 4:49 Improve the performance of `org-set-tags-command` on large `org-tag-alist` stardiviner
2023-05-13 7:43 ` Ihor Radchenko
2023-05-13 9:39 ` Christopher M. Miles
2023-05-13 11:13 ` stardiviner
2023-05-13 11:26 ` Ihor Radchenko
2023-05-13 14:24 ` [PATCH] " Christopher M. Miles
2023-05-13 18:43 ` Ihor Radchenko
2023-05-14 1:54 ` Christopher M. Miles
2023-05-14 8:09 ` Ihor Radchenko
2023-05-14 14:27 ` Christopher M. Miles
2023-05-14 14:58 ` Ihor Radchenko
2023-05-14 16:27 ` Christopher M. Miles
2023-05-14 17:38 ` Ihor Radchenko
2023-05-14 18:14 ` [PATCH v2] " Christopher M. Miles
2023-05-15 10:59 ` Ihor Radchenko
2023-05-15 12:43 ` Christopher M. Miles
2023-05-15 13:14 ` Ihor Radchenko
2023-05-15 14:40 ` [PATCH v3] " Christopher M. Miles
2023-05-15 16:12 ` [PATCH v3.1] " Christopher M. Miles
2023-05-16 9:31 ` Ihor Radchenko
2023-05-16 12:12 ` [PATCH v4] " Christopher M. Miles
2023-05-16 18:53 ` Ihor Radchenko
2023-05-17 5:57 ` [PATCH v4.1] " Christopher M. Miles
2023-06-30 12:55 ` Ihor Radchenko
2023-07-01 10:31 ` Christopher M. Miles [this message]
2023-07-01 11:34 ` [PATCH v5] " Ihor Radchenko
2024-01-09 14:12 ` [PATCH v6] " Ihor Radchenko
2024-01-10 3:48 ` Christopher M. Miles
2024-01-12 12:00 ` Ihor Radchenko
2023-05-16 12:12 ` [PATCH v4] " Christopher M. Miles
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=64a000ea.170a0220.250a9.7355@mx.google.com \
--to=numbchild@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).