Skip to content

Commit

Permalink
(org-ql--priority-p) Convert to function
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alphapapa committed May 22, 2018
1 parent 9050b75 commit d1f26ee
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions org-ql.el
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ like one returned by `date-to-day'."
(defsubst org-ql--closed-p (&optional 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.
COMPARATOR-OR-PRIORITY should be either a comparator function,
like `<=', or a priority string, like \"A\" (in which case (\` =)
Expand All @@ -197,19 +197,19 @@ comparator, PRIORITY should be a priority string."
(= '=)
(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))))
(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-ql--habit-p ()
(org-is-habit-p))
Expand Down

0 comments on commit d1f26ee

Please sign in to comment.