org-ql icon indicating copy to clipboard operation
org-ql copied to clipboard

Compatibility with org-modern

Open JulienMalka opened this issue 1 year ago • 4 comments

Hello, I know that this has been discussed before, but it looks like org-ql is not compatible with the org-modern package. For some reason, org-agenda-custom-commands using org-ql-block doesn't have the right styling for TODO keywords, although the styling for the tags is correct. I join here a screenshot of the problem and a reproducer.

1733342582-wayshot

(require 'package)
(require 'use-package)

;; Add MELPA for packages
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)

;; Make sure we install updated org from the repositories
(assq-delete-all 'org package--builtins)
(assq-delete-all 'org package--builtin-versions)


(use-package org-ql 
 :ensure t)

(use-package org
  :custom
  ;; Tell Org where to find all my stuff
  (org-directory "~/dev/org")
  (org-agenda-files '("~/dev/todos/test.org"))

  ;; My main custom agenda view
  (org-agenda-custom-commands
   '(("c" "Primary agenda view"
      (
       (org-ql-block '(and
		(todo "TODO")
		(tags "inbox")))

        (tags-todo "inbox"
        	((org-agenda-prefix-format "  %?-12t% s")
                (org-agenda-overriding-header "Inbox"))))))))


(use-package org-modern
  ;;:hook ((org-mode . org-modern-mode)
  ;;       (org-agenda-finalize . org-modern-agenda))
  :ensure t
  :config
  (global-org-modern-mode)
  :custom
  (org-modern-star 'replace)
  ;; Set manually to match leuven-theme
  (org-modern-todo-faces
   `(("TODO" :background "#DBEDFF" :foreground "#333333")
     ("NEXT" :background "#FFC8C8" :foreground "#333333")
     ("HOLD" :background "#F6FECD" :foreground "#333333")
     ("DONE" :background "#D5F1CF" :foreground "#333333"))))
     ```

JulienMalka avatar Dec 04 '24 20:12 JulienMalka

Not knowing exactly who is in a better position to address this, I've opened a sister issue here https://github.com/minad/org-modern/issues/245

JulienMalka avatar Dec 04 '24 20:12 JulienMalka

The issue is probably one of having the appropriate text property on the line. You can see in https://github.com/alphapapa/org-ql/issues/455 where I recently removed text properties from the to-do keyword because it was sometimes picking up other properties from the buffer applied by other modes, which caused incorrect appearance in org-ql-view buffers. So basically, what needs to be done is:

  1. Identify the text property and values used by org-modern to recognize the to-do keyword. This can usually be done with C-u C-x = on the lines in the agenda, comparing the ones that appear as desired and the ones that don't.
  2. Add code in org-ql-view--format-element to set that property and value accordingly.

It should be a relatively simple fix. If you have time to investigate step 1, that would help. My time to work on Emacs stuff lately has been limited.

alphapapa avatar Dec 05 '24 01:12 alphapapa

The properties are org-not-done-regexp and org-todo-regexp. These regexps are used by the Org agenda. See https://github.com/minad/org-modern/blob/87df4997da28cb9335dc4f0224e9bcedb595e425/org-modern.el#L902-L903. Org-modern had an old bug, back then when it didn't use these properties. It tried to use some buffer local variables, but Ihor explained that this quite obviously cannot work if the agenda is aggregated from multiple files with different keywords.

minad avatar Dec 05 '24 09:12 minad

Yes I can confirm that those two properties are indeed not present with org-ql.

JulienMalka avatar Dec 05 '24 09:12 JulienMalka