emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* proposal for enhanced org-get-priority function
@ 2010-10-20 17:14 I.S.
  2010-10-24 19:18 ` David Maus
  0 siblings, 1 reply; 15+ messages in thread
From: I.S. @ 2010-10-20 17:14 UTC (permalink / raw)
  To: emacs-orgmode

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.
"
   (save-match-data
     (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
                     org-default-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))))

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2010-11-17 19:21 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-20 17:14 proposal for enhanced org-get-priority function I.S.
2010-10-24 19:18 ` David Maus
2010-10-24 20:05   ` George Pearson
2010-10-27 12:01   ` I.S.
2010-10-29 11:45     ` I.S.
2010-10-29 11:53       ` I.S.
2010-11-15 10:25         ` Carsten Dominik
2010-11-15 12:07           ` Juan Pechiar
2010-11-15 12:15             ` Carsten Dominik
2010-11-15 18:05             ` I.S.
2010-11-16  0:30               ` Samuel Wales
2010-11-17  8:16               ` Carsten Dominik
2010-11-17 13:11                 ` I.S.
2010-11-17 19:21                 ` Matt Lundin
2010-11-16  1:11           ` Matt Lundin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).