emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: tumashu <tumashu@163.com>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: [PATCH] Add 'simple option to org-fast-tag-selection-single-key.
Date: Thu, 15 Apr 2021 09:25:03 +0800 (CST)	[thread overview]
Message-ID: <7f3a03cb.bec.178d321adcb.Coremail.tumashu@163.com> (raw)


[-- 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 --]

             reply	other threads:[~2021-04-15  1:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-15  1:25 tumashu [this message]
2021-04-15  7:56 ` Re:[PATCH] Add 'simple option to org-fast-tag-selection-single-key tumashu
2021-05-01 15:20   ` [PATCH] " Bastien
2021-05-08  9:50     ` tumashu
2021-05-08 10:00       ` tumashu

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=7f3a03cb.bec.178d321adcb.Coremail.tumashu@163.com \
    --to=tumashu@163.com \
    --cc=emacs-orgmode@gnu.org \
    /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).