From 569368aa9b3c7aa5bf1063d3e9c152db5304f4f3 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Sat, 13 May 2023 22:22:25 +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. --- lisp/org.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 542959f73..5d6687b7a 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.") @@ -11935,7 +11941,13 @@ Returns the new tags string, or nil to not change the current settings." (org-fast-tag-insert "Current" current c-face "\n\n") (org-fast-tag-show-exit exit-after-next) (org-set-current-tags-overlay current ov-prefix) - (setq tbl fulltable char ?a cnt 0) + (setq tbl (let ((bound-tags (seq-filter 'cdr fulltable))) + (cl-case org-use-fast-tag-selection + (auto (if (length> bound-tags org-fast-tag-selection-maximum-tags) + bound-tags + (seq-take fulltable org-fast-tag-selection-maximum-tags))) + (t fulltable))) + char ?a cnt 0) (while (setq e (pop tbl)) (cond ((eq (car e) :startgroup) -- 2.39.2 (Apple Git-143)