From mboxrd@z Thu Jan 1 00:00:00 1970 From: "I.S." Subject: proposal for enhanced org-get-priority function Date: Wed, 20 Oct 2010 13:14:39 -0400 Message-ID: <4CBF237F.1080602@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=33400 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8cFU-00042Y-Ly for emacs-orgmode@gnu.org; Wed, 20 Oct 2010 13:14:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8cFT-0005mQ-3P for emacs-orgmode@gnu.org; Wed, 20 Oct 2010 13:14:48 -0400 Received: from mail-yw0-f41.google.com ([209.85.213.41]:53142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8cFT-0005m9-0q for emacs-orgmode@gnu.org; Wed, 20 Oct 2010 13:14:47 -0400 Received: by ywi4 with SMTP id 4so724021ywi.0 for ; Wed, 20 Oct 2010 10:14:46 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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 [#]- or [#]+ are supported with +/- 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))))