[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] proposal for enhanced org-get-priority function

From: I.S.
Subject: [Orgmode] proposal for enhanced org-get-priority function
Date: Wed, 20 Oct 2010 13:14:39 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20101013 Thunderbird/3.1.5

Dear Experts,

I'd like to propose a replacement for the org-get-priority function which is backward compatible with the current version but allows the user to add a sub-priority such as [#A]-5 or [#B]+3:

(defun org-get-priority (s)
  "Find priority cookie and return priority.

Priorities of the form [#<letter>]-<number> or
[#<letter>]+<number> are supported with +/-<number> being
optional and modifying the letter priority. The letter priority
is multiplied by 100000 and then the number priority is added
on. Thus a priority string of [#B]+5 is higher than [#B] which is
higher than [#B]-2 and all are lower than [#A].

The number sub-priorities allow finer control of sorting in org agendas.
    (let* ((priority-match (string-match org-priority-regexp s))
       (priority-value (if priority-match
                   (* 100000 (- org-lowest-priority
                      (string-to-char (match-string 2 s))))
                 (* 100000 (- org-lowest-priority
       (sub-priority-match (match-string 3 s))
       (sub-priority-value (if sub-priority-match
                   (string-to-number sub-priority-match) 0)))
      (+ priority-value sub-priority-value))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]