emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Add 'simple option to org-fast-tag-selection-single-key.
@ 2021-04-15  1:25 tumashu
  2021-04-15  7:56 ` tumashu
  0 siblings, 1 reply; 5+ messages in thread
From: tumashu @ 2021-04-15  1:25 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 303 bytes --]

Hello


    I have added  'simple option to org-fast-tag-selection-single-key,  please try and comment :-)


   (setq org-use-fast-tag-selection t)
   (setq org-fast-tag-selection-single-key 'simple)


   ;; better use vertico or selectrum :-)

   ;; (require 'vertico)
   ;; (vertico-mode 1)


thanks!

[-- Attachment #1.2: Type: text/html, Size: 790 bytes --]

[-- Attachment #2: 0001-Add-simple-option-to-org-fast-tag-selection-single-k.patch --]
[-- Type: application/octet-stream, Size: 4799 bytes --]

From 8d87a5e464d4089fc66bb520d3a43c950abea38c Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@163.com>
Date: Thu, 15 Apr 2021 08:59:29 +0800
Subject: [PATCH] Add 'simple option to org-fast-tag-selection-single-key.

* lisp/org.el (org-fast-tag-selection-single-key): Add 'simple option.
(org-fast-tag-selection): Deal with (setq org-fast-tag-selection-single-key 'simple) option.
---
 lisp/org.el | 45 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 36 insertions(+), 9 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 675a614e2..d60d8ce57 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -2844,12 +2844,15 @@ automatically if necessary."
 When nil, you have to press RET to exit it.
 During fast tag selection, you can toggle this flag with `C-c'.
 This variable can also have the value `expert'.  In this case, the window
-displaying the tags menu is not even shown, until you press `C-c' again."
+displaying the tags menu is not even shown, until you press `C-c' again.
+If set this variable to 'simple, the window displaying the tags menu is
+not shown, and edit tab directly (like auto type TAB)."
   :group 'org-tags
   :type '(choice
 	  (const :tag "No" nil)
 	  (const :tag "Yes" t)
-	  (const :tag "Expert" expert)))
+	  (const :tag "Expert" expert)
+          (const :tag "Simple" simple)))
 
 (defvar org-fast-tag-selection-include-todo nil
   "Non-nil means fast tags selection interface will also offer TODO states.
@@ -12159,6 +12162,7 @@ Returns the new tags string, or nil to not change the current settings."
 				  fulltable))))
 	 (buf (current-buffer))
 	 (expert (eq org-fast-tag-selection-single-key 'expert))
+         (simple (eq org-fast-tag-selection-single-key 'simple))
 	 (tab-tags nil)
 	 (fwidth (+ maxlen 3 1 3))
 	 (ncol (/ (- (window-width) 4) fwidth))
@@ -12187,7 +12191,7 @@ Returns the new tags string, or nil to not change the current settings."
     (move-overlay org-tags-overlay ov-start ov-end)
     (save-excursion
       (save-window-excursion
-	(if expert
+	(if (or expert simple)
 	    (set-buffer (get-buffer-create " *Org tags*"))
 	  (delete-other-windows)
 	  (set-window-buffer (split-window-vertically) (get-buffer-create " *Org tags*"))
@@ -12266,10 +12270,12 @@ Returns the new tags string, or nil to not change the current settings."
 	(setq rtn
 	      (catch 'exit
 		(while t
-		  (message "[a-z..]:toggle [SPC]:clear [RET]:accept [TAB]:edit [!] %sgroups%s"
-			   (if (not groups) "no " "")
-			   (if expert " [C-c]:window" (if exit-after-next " [C-c]:single" " [C-c]:multi")))
-		  (setq c (let ((inhibit-quit t)) (read-char-exclusive)))
+                  (if simple
+                      (setq c ?\t)
+		    (message "[a-z..]:toggle [SPC]:clear [RET]:accept [TAB]:edit [!] %sgroups%s"
+			     (if (not groups) "no " "")
+			     (if expert " [C-c]:window" (if exit-after-next " [C-c]:single" " [C-c]:multi")))
+		    (setq c (let ((inhibit-quit t)) (read-char-exclusive))))
 		  (setq org-last-tag-selection-key c)
 		  (cond
 		   ((= c ?\r) (throw 'exit t))
@@ -12306,8 +12312,29 @@ Returns the new tags string, or nil to not change the current settings."
                                                (with-current-buffer buf
                                                  (org-get-buffer-tags))
                                                table))))))
-                    (setq tg (completing-read "Tag: " tab-tags))
-		    (when (string-match "\\S-" tg)
+                    (let* ((max 5)
+                           (n (length current))
+                           (prompt
+                            (if (and simple (> n 0))
+                                (format "Tag (%s%s): "
+                                        (mapconcat #'identity
+                                                   (cl-subseq current 0 (min n max))
+                                                   ", ")
+                                        (if (> n max)
+                                            " ..."
+                                          ""))
+                              "Tag: "))
+
+                           (tab-tags
+                            (if simple
+                                (mapcar (lambda (x)
+                                          (if (member (car x) current)
+                                              (cons (propertize (car x) 'face '(:box t)) (cdr x))
+                                            x))
+                                        tab-tags)
+                              tab-tags)))
+                      (setq tg (completing-read prompt tab-tags)))
+                    (when (string-match "\\S-" tg)
 		      (cl-pushnew (list tg) tab-tags :test #'equal)
 		      (if (member tg current)
 			  (setq current (delete tg current))
-- 
2.20.1


[-- Attachment #3: 截图_2021-04-15_09-20-36.png --]
[-- Type: image/png, Size: 25738 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-08 10:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15  1:25 [PATCH] Add 'simple option to org-fast-tag-selection-single-key tumashu
2021-04-15  7:56 ` tumashu
2021-05-01 15:20   ` [PATCH] " Bastien
2021-05-08  9:50     ` tumashu
2021-05-08 10:00       ` tumashu

Code repositories for project(s) associated with this 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).