Ok, this was easier than I initially thought.

Here is a patch. I've tested it with a number of configurations: a few
grouped tags, many grouped tags, grouped tags that fill the last line
entirely, grouped and ungrouped tags. Notice that even ungrouped tags
are indented by two spaces. This is done because some tags may be
grouped while other not. In case no tag is grouped this is adding an
extra initial space but I think removing it is not worth the check "is
everything ungrouped?".

Best regards
--
Carlos
From 4a79d1355ec35c711bddd06be0d99b0af287c182 Mon Sep 17 00:00:00 2001
From: memeplex <carlosjosep...@gmail.com>
Date: Tue, 12 Feb 2019 17:49:40 -0300
Subject: [PATCH] org: Fix fast tag selection menu alignment

* lisp/org.el (org-fast-tag-selection):
  - Avoid lines with just a closing delimiter.
  - Correctly align grouped and ungrouped tags.
---
 lisp/org.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index e2258749b..7f04cee18 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14502,13 +14502,13 @@ Returns the new tags string, or nil to not change the current settings."
 	  			   ((member tg inherited) i-face))))
 	  (when (equal (caar tbl) :grouptags)
 	    (org-add-props tg nil 'face 'org-tag-group))
-	  (when (and (zerop cnt) (not ingroup) (not intaggroup)) (insert " "))
+	  (when (and (zerop cnt) (not ingroup) (not intaggroup)) (insert "  "))
 	  (insert "[" c "] " tg (make-string
 				 (- fwidth 4 (length tg)) ?\ ))
 	  (push (cons tg c) ntable)
 	  (when (= (cl-incf cnt) ncol)
-	    (insert "\n")
-	    (when (or ingroup intaggroup) (insert " "))
+	    (unless (memq (caar tbl) '(:endgroup :endgrouptag)) (insert "\n"))
+	    (when (or ingroup intaggroup) (insert "  "))
 	    (setq cnt 0)))))
       (setq ntable (nreverse ntable))
       (insert "\n")
-- 
2.20.1

Reply via email to