Hi Ihor, Ihor Radchenko <yanta...@gmail.com> writes:
> William Xu <william....@gmail.com> writes: > >> Now I try to test it extensively. Even with all your changes, I find >> when I use org-agenda-todo to change the todo-state inside the agenda >> buffer, the new state isn't always prettified. >> >> Do you see the same behaviour? > > Oops. Yes, I do see the same behaviour. I only did light testing on > master and I had some unrelated changes nullifying the problem you > observe on my testing branch. Thank you very much for the patch. Could it slow down agenda generation for some configurations? > See the updated patch. > > From 06a2d8ab328721835866bf97f0344cce15cd1dee Mon Sep 17 00:00:00 2001 > Message-Id: > <06a2d8ab328721835866bf97f0344cce15cd1dee.1619960107.git.yanta...@gmail.com> > From: Ihor Radchenko <yanta...@gmail.com> > Date: Sat, 1 May 2021 20:09:10 +0800 > Subject: [PATCH] Make sure that fontification is preserved in agenda > > Preserve fontification and composition of headlines and tags in > agenda. If the headlines/tags are not yet fontified when building > agenda, make sure that they are fontified in the original Org mode > buffers first. > > In addition, tags alignment is now done pixelwise to avoid alignment > issues with variable-pitch symbols that may appear in fontified Org > mode buffers. The alignment is utilising :align-to specification, > which means that the alignment will be automatically updated as the > agenda buffer is resized. Please move the comments after the change log themselves. > * lisp/org-macs.el (org-string-width): Refactor old code and add > optional argument to return pixel width. The old code used manual > parsing of text proerpties to find which parts of string are visible. > The new code defers this work to Emacs display engine via > `window-text-pixel-size'. The visibility settings of current buffer > are taken into account. > > (org-buffer-substring-fontified): New function getting fontified > substring from current buffer. > > * lisp/org-agenda.el (org-agenda-get-todos, org-agenda-get-progress, > org-agenda-get-deadlines, org-agenda-get-scheduled): Use > org-buffer-substring-fontified to get fontified heading. > > (org-agenda-fix-displayed-tags): Fontify tags. > > (org-agenda-highlight-todo): Preserve composition property used, > i.e. by `prettify-symbols-mode'. The composition is usually set to be > removed on text change, so we do the changes inside > `with-silent-modifications'. > > (org-agenda-align-tags): Use pixel width and (space . :align-to) > 'display property to align tags in agenda. > > * lisp/org.el (org-get-heading): Make sure that heading is fontified. > --- > lisp/org-agenda.el | 63 ++++++++++++++++---------- > lisp/org-macs.el | 108 ++++++++++++++++++--------------------------- > lisp/org.el | 2 + > 3 files changed, 85 insertions(+), 88 deletions(-) > > diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el > index bd9d466a6..5add0e092 100644 > --- a/lisp/org-agenda.el > +++ b/lisp/org-agenda.el > @@ -5562,7 +5562,7 @@ (defun org-agenda-get-todos () > ts-date-pair (org-agenda-entry-get-agenda-timestamp (point)) > ts-date (car ts-date-pair) > ts-date-type (cdr ts-date-pair) > - txt (org-trim (buffer-substring (match-beginning 2) (match-end > 0))) > + txt (org-trim (org-buffer-substring-fontified (match-beginning 2) > (match-end 0))) Here and for the rest of the patch: please try to keep lines below 80 characters. I'm aware this is not always feasible, especially given long functions with many nested s-exps, but let's try to come as close as possible to 80. Thanks! -- Bastien