-
Notifications
You must be signed in to change notification settings - Fork 108
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
org-ql-agenda: Custom formatter support #23
Comments
You could modify the formatter to do so. |
By this do you mean modifying this function to show the buffer source? |
Yes. You can see a comment at the bottom that mentions adding the proper prefix, which refers to imitating Alternatively, you could use simple |
I probably won't work on this soon, but it's a good idea. |
Isn't this already supported with the use of "select" in org-ql-query? There one can provide a custom sexp to format the output. Same with the action argument to org-ql-select, no? Is there a reason for not using the same functionality in the org-ql views? |
@Whil- If you want to override the formatting function used in |
Got it, thanks. Though providing the select functionality also for the view function should hardly be considered minor. Thinking of org mode documents as a database of entities is very powerful and org-ql is very helpful with this. And allowing the output from the query on the database to be customized by for example adding attributes from the nodes etc. makes a lot of sense. This ofc already is possible using org-ql-select and org-ql-query. So I'll just finish with a thumbs up for that! 👍 |
What I mean is, since I plan to implement a new view library, I don't want to spend much effort on implementing formatting changes that would be obsoleted by the future plans. In the meantime, you can use However, since this has taken a while, it might be worth adding an argument and/or a variable to let users more easily change the formatting function. |
Let's pick one place or the other to have this conversation. I'll reply on Reddit again. |
For completeness I'll repost the solution via adding an advice here as well, if you don't mind?
|
Minor tweak to @pragmat1c1 code. In case someone wants to add category instead of filename.
|
Since it's been so long since the last 0.x release, I'm going to defer this to 0.7 in an effort to reduce the scope of 0.6 and release it sooner. |
I'm using this version of org-ql:
and the function from the comment above returns an empty category. Here's the fixed version: (defun zdo/org-ql-view--format-element (orig-fun &rest args)
"This function will intercept the original function and
add the category to the result.
ARGS is `element' in `org-ql-view--format-element'"
(if (not args)
""
(let* ((element args)
(properties (cadar element))
(result (apply orig-fun element))
(category (org-entry-get (plist-get properties :org-marker) "CATEGORY")))
(org-add-props
(format " %-8s %s" (concat category ":") result)
(text-properties-at 0 result)))))
(advice-add 'org-ql-view--format-element :around #'zdo/org-ql-view--format-element) with nice indentation 🙂 |
For future reference, this issue will generally be addressed by the branch mentioned here: #331 |
Thanks @dmitri-zganiaiko. I added some modifications to make sure the indentation will work too if the file or buffer name are too long. (defun salih/org-ql-view--format-element (orig-fun &rest args)
"This function will intercept the original function and
add the category to the result.
ARGS is `element' in `org-ql-view--format-element'"
(if (not args)
""
(let* ((element args)
(properties (cadar element))
(result (apply orig-fun element))
(smt "")
(category (org-entry-get (plist-get properties :org-marker) "CATEGORY")))
(if (> (length category) 11)
(setq category (substring category 0 10)))
(if (< (length category) 11)
(setq smt (make-string (- 11 (length category)) ?\s)))
(org-add-props
(format " %-8s %s" (concat category ":" smt) result)
(text-properties-at 0 result))))) |
Is there a way to force
org-ql-agenda
to show the name of the buffer from which each task is derived? I tried adding:auto-category t
to:super-groups
but it didn't work (i.e., it probably groups by category but still doesn't show the name of the category).The text was updated successfully, but these errors were encountered: