(org-ql--priority-p) Convert to function

I don't remember why I had made it a macro, but it needs to be a
function so it can be called correctly in org-ql--query.
This commit is contained in:
Adam Porter 2018-05-22 06:27:21 -05:00
parent 9050b756ba
commit d1f26eec2f

View file

@ -174,7 +174,7 @@ like one returned by `date-to-day'."
(defsubst org-ql--closed-p (&optional comparator target-date) (defsubst org-ql--closed-p (&optional comparator target-date)
(org-agenda-ng--date-p :closed comparator target-date)) (org-agenda-ng--date-p :closed comparator target-date))
(defmacro org-ql--priority-p (&optional comparator-or-priority priority) (defun org-ql--priority-p (&optional comparator-or-priority priority)
"Return non-nil if current heading has a certain priority. "Return non-nil if current heading has a certain priority.
COMPARATOR-OR-PRIORITY should be either a comparator function, COMPARATOR-OR-PRIORITY should be either a comparator function,
like `<=', or a priority string, like \"A\" (in which case (\` =) like `<=', or a priority string, like \"A\" (in which case (\` =)
@ -197,7 +197,7 @@ comparator, PRIORITY should be a priority string."
(= '=) (= '=)
(otherwise (user-error "Invalid comparator: %s" comparator)))) (otherwise (user-error "Invalid comparator: %s" comparator))))
(setq priority (* 1000 (- org-lowest-priority (string-to-char priority)))) (setq priority (* 1000 (- org-lowest-priority (string-to-char priority))))
`(when-let ((item-priority (save-excursion (when-let ((item-priority (save-excursion
(save-match-data (save-match-data
;; FIXME: Is the save-match-data above necessary? ;; FIXME: Is the save-match-data above necessary?
(when (and (looking-at org-heading-regexp) (when (and (looking-at org-heading-regexp)
@ -209,7 +209,7 @@ comparator, PRIORITY should be a priority string."
;; useful IMO. Better to do it ;; useful IMO. Better to do it
;; like in org-super-agenda. ;; like in org-super-agenda.
(org-get-priority (match-string 0))))))) (org-get-priority (match-string 0)))))))
(funcall ',comparator ,priority item-priority)))) (funcall comparator priority item-priority))))
(defun org-ql--habit-p () (defun org-ql--habit-p ()
(org-is-habit-p)) (org-is-habit-p))