-
Notifications
You must be signed in to change notification settings - Fork 113
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
Agenda format function #44
base: master
Are you sure you want to change the base?
Conversation
Hi Akira, Thanks, this is very interesting. Passing the alist of values from the other function is a nice way to save the other function the trouble of extracting them itself. On one hand, that seems simpler, but on the other, it would seem simpler to just pass the element plist. So I'm not sure what the best solution is. If you're interested, please take a look at this branch: https://github.com/alphapapa/org-ql/tree/wip/view-section Specifically, look at The idea is to make sorting and grouping easier, and in the long run, to aid with making the magit-section-like view in that branch (I posted a demo here: https://www.reddit.com/r/orgmode/comments/d11zfj/wip_magitlike_sections_for_orgql_views/). Anyway, I think I will see how that struct idea works out before changing the formatter. Afterward, I'll take another look at P.S. |
c4e82b6
to
37ba30c
Compare
718aa1e
to
e1c55b5
Compare
492ed77
to
c4f9a58
Compare
1359cbb
to
b3601cf
Compare
af2582f
to
8baeeea
Compare
Yes. |
e441d88
to
4194456
Compare
f52bef0
to
ec0f8c7
Compare
ae83de1
to
890c247
Compare
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. |
4f5fbc4
to
d0acc8c
Compare
Real world context/anecdote: I'm writing an org-ql version of Task management with org-roam and this feature would be needed to implement their category display improvement. |
Per the advice shared in #23, these functions which I've adapted should meet your needs (defun dl/org-roam-get-keyword (name)
(let ((key (intern (upcase name)))
(keyword-alist (org-collect-keywords (list name))))
(car (alist-get key keyword-alist nil nil #'string-equal))))
(defun dl/org-ql-view--format-element-a (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))
(buffer (marker-buffer (plist-get properties :org-marker)))
(category (with-current-buffer buffer (dl/org-roam-get-keyword "title"))))
(org-add-props
(format "%s %s"
(s-pad-right dl-org-ql-view-format-length " "
(s-truncate dl-org-ql-view-format-length category))
result)
(text-properties-at 0 result)))))
(advice-add 'org-ql-view--format-element :around #'dl/org-ql-view--format-element-a) |
@dstrr You should probably use |
059b10c
to
77b4c2b
Compare
Hi,
I want to customize the entry format of
org-ql-block
. In particular, I want to prepend the category to each entry. In the builtin agenda, this is the default and can be customizable by customizingorg-agenda-prefix-format
variable, but it doesn't work for org-ql, sinceorg-ql-block
uses its own function for formatting entries. I want a way to customize the formats inorg-ql-block
blocks.In the source code of
org-ql-agenda.el
, I found your todo comment on adding support fororg-agenda
-like formats in the future, but it sounds really hard to re-implementorg-agenda-prefix-format
, and I would like to customize the format soon (or even now), I implemented an alternative solution.It allows the user to change the format through
org-ql-agenda-format-function
, which takes as arguments a map (currently alist) and an element returned by org-element. In addition, I've added category to the map, since it would be more efficient to get the data inside the function.I am not sure if this is an ideal API, so I don't expect you to merge this PR. It sufficies for my purpose, but there can be a better way.
What is your current plan on supporting custom formats, and what do you think of this solution?
Thanks.