sorting by ancestor priorities
- Lingua principale
- Emacs Lisp
- Stelle
- 1.6k
- Fork
- 120
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
I am using priorities only on PROJ headings but I want the priorities to be reflected on the children headings.
The feature I'd like would be priority inheritance but it seems that org-mode does not support that.
So I tried to get this behavior with org-ql to simply sort the entries by the highest priority up the heading tree.
I managed to get the min prio on the tree but it requires my to have my cursor on the heading or in that buffer because I am traversing with `(org-up-heading-safe)`
I am struggling with elisp so that's the best I could get up with for now.
``` elisp
(defun org-priority-show-ancestors (item)
(let* ((prio-raw (org-element-property :priority item))
(prio (cond (prio-raw prio-raw)
(t (+ 0.5 org-priority-default))))) ;; display empty prio below default
;; move up to the parent
(if (org-up-heading-safe)
(cons prio (org-priority-show-ancestors (org-element-at-point)))
(list prio))))
(defun org-priority-min-ancestors (item)
(org-with-wide-buffer (apply 'min (org-priority-show-ancestors item))))
(defun org-priority-min-ancestors-current ()
(org-priority-min-ancestors (org-element-at-point)))
(defun org-ql--min-ancestor-priority< (a b)
"Return non-nil if A's priority is higher than B's.
A and B are Org headline elements."
(cl-macrolet ((priority (item)
`(org-priority-min-ancestors ,item)))
;; NOTE: Priorities are numbers in Org elements. This might differ from the priority selector logic.
(let ((a-priority (priority a))
(b-priority (priority b)))
(cond ((and a-priority b-priority)
(< a-priority b-priority))
(a-priority t)
(b-priority nil)))))
```
The sorting works but only for the priority of the current element while considering org-priority-default which seems to be ignored in the default prio sorting.
There are most likely better ways to get up to the parent heading based on `item`.
That's actually more of an org-mode question and me asking for help.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.