Thanks Ihor for the detailed explanation, I updated the patch as you suggested.
On Sun, Feb 6, 2022 at 12:53 PM Ihor Radchenko <yanta...@gmail.com> wrote: > Samim Pezeshki <p.sa...@gmail.com> writes: > > > This commit prevents having extra spaces when the TODO format string is > an > > empty string (""). It was not working properly, with this patch now it > > works correctly. > > Thanks for the patch! > > > (concat > > (substring x 0 (match-end 1)) > > ... > > + (unless (string= org-agenda-todo-keyword-format "") > > + (format org-agenda-todo-keyword-format > > + (match-string 2 x)) > > + ;; Remove `display' property as the icon could leak > > + ;; on the white space. > > + (org-add-props " " (org-plist-delete (text-properties-at 0 x) > > + 'display))) > > (substring x (match-end 3))))))) > > x))) > > Your patch will unconditionally hide todo keywords in agenda even when > org-agenda-todo-keyword-format is not empty. This will happen because > (unless ...) form will only return the last " ", but never the keyword. > > You should better wrap the (org-add-props ...) with another unless > condition. > > Best, > Ihor >
From 2e90cac33c22cf8ea09f7f02e644df983b7ca0d1 Mon Sep 17 00:00:00 2001 From: Samim Pezeshki <psa...@gmail.com> Date: Sat, 5 Feb 2022 20:11:19 +0330 Subject: [PATCH] lisp/org-agenda.el: Fix bug in `org-agenda-highlight-todo' * lisp/org-agenda.el (org-agenda-highlight-todo): Skip formatting the to-do keyword when `org-agenda-todo-keyword-format' is the empty string. TINYCHANGE --- lisp/org-agenda.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 9bc44a56e..3b6397b25 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -7634,14 +7634,15 @@ The optional argument TYPE tells the agenda type." (setq x (concat (substring x 0 (match-end 1)) - (unless (string= org-agenda-todo-keyword-format "") - (format org-agenda-todo-keyword-format - (match-string 2 x))) - ;; Remove `display' property as the icon could leak - ;; on the white space. - (org-add-props " " (org-plist-delete (text-properties-at 0 x) - 'display)) - (substring x (match-end 3))))))) + (unless (string= org-agenda-todo-keyword-format "") + (format org-agenda-todo-keyword-format + (match-string 2 x))) + (unless (string= org-agenda-todo-keyword-format "") + ;; Remove `display' property as the icon could leak + ;; on the white space. + (org-add-props " " (org-plist-delete (text-properties-at 0 x) + 'display))) + (substring x (match-end 3))))))) x))) (defsubst org-cmp-values (a b property) -- 2.35.1