Add: Priority selector
This commit is contained in:
parent
94e27fec8a
commit
889a50a3d1
1 changed files with 38 additions and 0 deletions
|
|
@ -85,6 +85,7 @@ NONE-PREDS."
|
|||
(org-agenda-ng--fmap ((category #'org-agenda-ng--category-p)
|
||||
(date #'org-agenda-ng--date-p)
|
||||
(habit #'org-agenda-ng--habit-p)
|
||||
(priority #'org-agenda-ng--priority-p)
|
||||
(todo #'org-agenda-ng--todo-p)
|
||||
(tags #'org-agenda-ng--tags-p))
|
||||
(org-with-wide-buffer
|
||||
|
|
@ -364,5 +365,42 @@ like one returned by `date-to-day'."
|
|||
(error "Unknown date-element type: %s" (org-element-property :type date-element)))))
|
||||
(otherwise (error "COMPARATOR (%s) must be a function, and DATE (%s) must be a string" comparator target-date)))))
|
||||
|
||||
(defmacro org-agenda-ng--priority-p (&optional comparator-or-priority priority)
|
||||
"Return non-nil if current heading has a certain priority.
|
||||
COMPARATOR-OR-PRIORITY should be either a comparator function,
|
||||
like `<=', or a priority string, like \"A\" (in which case (\` =)
|
||||
'will be the comparator). If COMPARATOR-OR-PRIORITY is a
|
||||
comparator, PRIORITY should be a priority string."
|
||||
(let* (comparator)
|
||||
(cond ((null priority)
|
||||
;; No comparator given: compare only given priority with =
|
||||
(setq priority comparator-or-priority
|
||||
comparator '=))
|
||||
(t
|
||||
;; Both comparator and priority given
|
||||
(setq comparator comparator-or-priority)))
|
||||
(setq comparator (cl-case comparator
|
||||
;; Invert comparator because higher priority means lower number
|
||||
(< '>)
|
||||
(> '<)
|
||||
(<= '>=)
|
||||
(>= '<=)
|
||||
(= '=)
|
||||
(otherwise (user-error "Invalid comparator: %s" comparator))))
|
||||
(setq priority (* 1000 (- org-lowest-priority (string-to-char priority))))
|
||||
`(when-let ((item-priority (save-excursion
|
||||
(save-match-data
|
||||
;; FIXME: Is the save-match-data above necessary?
|
||||
(when (and (looking-at org-heading-regexp)
|
||||
(save-match-data
|
||||
(string-match org-priority-regexp (match-string 0))))
|
||||
;; TODO: Items with no priority
|
||||
;; should not be the same as B
|
||||
;; priority. That's not very
|
||||
;; useful IMO. Better to do it
|
||||
;; like in org-super-agenda.
|
||||
(org-get-priority (match-string 0)))))))
|
||||
(funcall ',comparator ,priority item-priority))))
|
||||
|
||||
(defun org-agenda-ng--habit-p ()
|
||||
(org-is-habit-p))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue