Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some tags not rendering in org-agenda #27

Open
someguynamedmatt opened this issue Mar 17, 2022 · 23 comments
Open

Some tags not rendering in org-agenda #27

someguynamedmatt opened this issue Mar 17, 2022 · 23 comments

Comments

@someguynamedmatt
Copy link

asdfasdf

It might just be a configuration issue on my end, but I'm not sure. You can see that the TODO does render in one case, but not in all others. I can remedy this issue by visiting the file the specific TODO is written in, then when getting back into the org-agenda it's rendered as an expected SVG, but this doesn't seem ideal.

@rougier
Copy link
Owner

rougier commented Mar 28, 2022

Oh, that's weird that some of them are rendered but not the others. How did you implement it with the agenda view? In my case, I use an advice around org-agenda-highlight-todo

@mrvdb
Copy link

mrvdb commented Apr 1, 2022

I have the exact same issue, here's the implementation I use:

(use-package svg-tag-mode
    :after (org base16-theme)
    :commands svg-tag-mode                ; Possibly redundant?
    :hook (org-mode . svg-tag-mode)

    :config
    ;; Readymade svg-tag-tags generator from org keywords
    (defun mrb/gen-svg-tags (kf)
      "Generate a `svg-tag-tags element from a `org-todo-keyword-faces element"
      (let ((k (concat "\\(" (car kf) "\\) ")) ; pass keyword, not the space
            (f (cdr kf)))
        `(,k . ((lambda (tag) (svg-tag-make tag :face ',f :inverse t :margin 0 ))))))

    ;; This gets initialized the first time svg-tag-mode is called, so then it must have
    ;; the proper keywords in org-todo-keyword-faces
    (setq svg-tag-tags (mapcar 'mrb/gen-svg-tags org-todo-keyword-faces)))

So, nothing specific for org-agenda just the hook into org-mode

@someguynamedmatt
Copy link
Author

@rougier Do you have an example of the advice implementation? I can test it.

@rougier
Copy link
Owner

rougier commented Apr 8, 2022

Raw code:

(defun my-org-agenda-highlight-todo (x)
  (let* ((done (string-match-p (regexp-quote ":DONE:") x))
         (canceled (string-match-p (regexp-quote "~") x))
         (x (replace-regexp-in-string ":TODO:" "" x))
         (x (replace-regexp-in-string ":DONE:" "" x))
         (x (replace-regexp-in-string "~" "" x))
;;         (x (replace-regexp-in-string "\\[.+\\]"
;;                                      #'(lambda (text)
;;                                          (propertize text 'face '(nano-salient nano-strong)))
         ;;                                      x))
         (x (if (and (boundp 'org-agenda-dim) org-agenda-dim)
                (propertize x 'face 'nano-faded) x))
         (x (if done (propertize x 'face 'nano-faded) x))
         (x (if canceled (propertize x 'face 'nano-faded) x)))
         ;;(x (if canceled (propertize x 'face '(:strike-through t)) x)))
    x))
(advice-add 'org-agenda-highlight-todo
            :filter-return #'my-org-agenda-highlight-todo)

Some glyph comes from the nerd font, here is how it look on my config:

Screenshot 2022-04-08 at 20 13 27

@someguynamedmatt
Copy link
Author

@rougier To answer your original question: I'm implementing svg-tag-mode in almost the exact same way @mrvdb is implementing theirs. I messed around a bit with your advice-add, but no luck. Same issue.

@rougier
Copy link
Owner

rougier commented Apr 12, 2022

Maybe something is interfering. Can you try with emacs -q

@workcomplete
Copy link

I'm having the same issue on Doom (emacs-mac port). I tried loading a minimal config (https://pastebin.com/rNQ9vpbf) in Doom sandbox with vanilla doom only (doom core, without my personal config, no other modules loaded) and the issue persists. (Apologies for my messy config I don't yet have a great handle on lisp)

@rougier
Copy link
Owner

rougier commented May 8, 2022

Do you see a kind of pattern in missing tags?

@workcomplete
Copy link

Not for me, on a fresh boot of Doom emacs none of the tags shown in org-agenda overview are svg tags until I visit the file and update org-agenda overview.

@rougier
Copy link
Owner

rougier commented May 12, 2022

@workcomplete maybe a force redisplay is needed. Do you also use the advive "trick"?

@workcomplete
Copy link

workcomplete commented Jun 16, 2022

Could this be an issue with org-agenda has with org-mode-hook? I changed the following in my config and svg-tag-mode now loads properly.

...
:hook (text-mode . svg-tag-mode)
...

I was similar issues with org-agenda where packages hooked using :hook (org-mode . some-mode) were not displaying properly in org-agenda. I was able to fix them by hooking to text-mode instead.

@mrvdb
Copy link

mrvdb commented Jun 16, 2022

Do you see a kind of pattern in missing tags?

A partial pattern I am seeing (in org-agenda at least) is that the tags start rendering after the underlying file gets visited.

That is, in my config the agenda items come from different files. If the file gets visited by me, by entering on an item in the agenda, that item gets rendered in the agenda on a refresh.

This seems to vary, sometimes just the item visited gets tagged, sometimes more. Not seeing an obvious pattern there yet.

@workcomplete
Copy link

Could this be an issue with org-agenda has with org-mode-hook? I changed the following in my config and svg-tag-mode now loads properly.

...
:hook (text-mode . svg-tag-mode)
...

I was similar issues with org-agenda where packages hooked using :hook (org-mode . some-mode) were not displaying properly in org-agenda. I was able to fix them by hooking to text-mode instead.

Nevermind, idk why it was working temporarily but changing the hook did not fix this issue for me.

@rougier
Copy link
Owner

rougier commented Jun 21, 2022

I'm a bit out of ideas. At this point, we would nerd to start from a vanilla emacs configuration and only add svg-tag and agenda with minimal configuration such we can try to understand what's going on.

@FieryCod
Copy link

I'm using the Emacs with very simple hand crafted configuration and can confirm I can see the issue as well.

@rougier
Copy link
Owner

rougier commented Jun 24, 2022

Is it also restricted to org-agenda (or does all examples fail)?

@rougier
Copy link
Owner

rougier commented Jun 24, 2022

Just in case, can you try(add-to-list 'font-lock-extra-managed-props 'display)

@someguynamedmatt
Copy link
Author

someguynamedmatt commented Jun 24, 2022

@rougier that didn't seem to have any effect on the issue. I haven't completely had the time to create a minimal config to induce the error, but I'll try to get to that soon. In the meantime, I've experimented with disabling org-super-agenda, just in case that was doing it, but that also didn't seem to remedy it.

@rougier
Copy link
Owner

rougier commented Jun 24, 2022

A minimal example would be nice to test thing and it seems to be specifically org-agenda related. Also, could you test a different transform of tags, I mean, instead of displaying the svt-tag, can you try to display a simple text (using the 'display property) ?

@Elilif
Copy link
Contributor

Elilif commented Sep 14, 2022

@rougier I think the problem is caused by font-lock-mode , which svg-tag-mode uses to show SVG tags. Howerer, org-agenda does not use font-lock-mode, so it only shows rendered SVG tags in visited buffers. One way to solve this problem is to use overly:

  (defun eli-org-agenda-show-svg ()
    (let* ((case-fold-search nil)
           (keywords (mapcar #'svg-tag--build-keywords svg-tag--active-tags))
           (keyword (car keywords)))
      (while keyword
        (save-excursion
          (while (re-search-forward (nth 0 keyword) nil t)
            (overlay-put (make-overlay
                          (match-beginning 0) (match-end 0))
                         'display  (nth 3 (eval (nth 2 keyword)))) ))
        (pop keywords)
        (setq keyword (car keywords)))))
  (add-hook 'org-agenda-finalize-hook #'eli-org-agenda-show-svg)

@rougier
Copy link
Owner

rougier commented Sep 22, 2022

Oh wonderful, well done. Should this be add to the README? Do you want to make a PR?

@Elilif
Copy link
Contributor

Elilif commented Sep 22, 2022

I prefer adding this to the README, because it is not the svg-tag-mode's responsibility to care about somthing out of its function.

@someguynamedmatt
Copy link
Author

Good find, @Elilif! Thanks!

Elilif added a commit to Elilif/svg-tag-mode that referenced this issue Sep 27, 2022
Elilif added a commit to Elilif/svg-tag-mode that referenced this issue Sep 27, 2022
mrvdb added a commit to mrvdb/emacs-config that referenced this issue Oct 4, 2022
rougier added a commit that referenced this issue Oct 17, 2022
fix: update README to solve issue #27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants