4

I'm trying to setup priorities other than A, B, C. (I want to do U, I, O; short for Urgent, Important, Other). Previously, I had set up custom agenda commands that sorted priority-down.

I configured my priorities like this:

(setq org-highest-priority ?U)
(setq org-default-priority ?I)
(setq org-lowest-priority ?O)

Then when I viewed my agendas I noticed that rather than sorting in priority order, it seems to be using alphabetical order.

What am I doing wrong here?

  • Most people are not interested in substantially modifying anything in Emacs (with perhaps me being the only exception to that rule). In the event you are anyone is interested, the priorities are turned into raw character values and the numbers are compared with org-cmp-priority in org-agenda.el -- e.g., (string-to-char "A") is 65. To see a glimpse at what these hidden properties look like, on a heading in an *Org-Agenda*, evaluate (text-properties-at (point)). – lawlist Jun 7 '16 at 23:28
2

Just looked at the source for org.el, and found this frustrating snippet:

(defcustom org-highest-priority ?A
  "The highest priority of TODO items.  A character like ?A, ?B etc.
   Must have a smaller ASCII number than `org-lowest-priority'."
  :group 'org-priorities
  :type 'character)

It would appear that org-mode wants the custom priorities to also be alphabetically ordered.

I thought you might've been able to use org-get-priority-function to work around this, but the source code appears to be simply calling the priority fn with no args, instead of taking the string as an arg.

My attempted work-around was to use these priorities:

(setq org-highest-priority ?U)
(setq org-default-priority ?i)
(setq org-lowest-priority ?o)

But this didn't work because of this pesky regex in org.el:

(defvar org-priority-regexp ".*?\\(\\[#\\([A-Z0-9]\\)\\] ?\\)"
  "Regular expression matching the priority indicator.")

So what I've finally come up with is to use these priorities:

(setq org-highest-priority ?G) ;; UrGent
(setq org-default-priority ?I) ;; Important
(setq org-lowest-priority ?O) ;; Other
1

I have also been trying to get org-mode to integrate properly with the idea of urgent vs important tasks. Considering that they are actually supposed to be independent dimensions, I think the more natural way to represent these concepts is to map level of importance to Org's priority, and to map level of urgency to the amount of time remaining before an Org deadline arrives.

I'm still figuring out how to make use of such a setup by creating a custom use of Org's mapping API (http://orgmode.org/manual/Using-the-mapping-API.html) which collects tasks tagged in an appropriate way, and represents them in a table sorted first by TODO status, then by PRIORITY, then by DEADLINE.

(Quite possibly Org's agenda functionality is capable of doing what i'm trying to do manually, but I've always been a bit leery of agenda seeming to "lose" tasks whose deadline has passed, where i actually still want to see them.)

0

The docs tell you to

please make sure that the highest priority is earlier in the alphabet than the lowest priority

Apart from that, @Roger Mateer's suggestion to use deadlines and scheduling for urgency and priorities for importance seems to ring a bell. That is how Stephen Covey differentiates it, for example: with two scales; one from important to unimportant. One from urgent to non-urgent.

A possibility would be to expand to

#+PRIORITIES: A F D

at the top of your file, with A-C as important and D-F as unimportant.

0

Please tend a close attention to what docs say:

org-get-priority-function is a variable defined in ‘org.el’.
Its value is nil

Documentation:
Function to extract the priority from a string.
The string is normally the headline.  If this is nil Org computes the
priority from the priority cookie like [#A] in the headline.  It returns
an integer, increasing by 1000 for each priority level.
The user can set a different function here, which should take a string
as an argument and return the numeric priority.

So, this is the variable that should contain the name of a function. This function should get a string (headline) as an argument, and return a number.

In other words - it is what you, & I, are searching for. Just write the global function any way you like and provide the name for it.

In Org-mode the source code block that processes a priority:

org.el:

(defun org-get-priority (s)
  "Find priority cookie and return priority."
  (save-match-data
    (if (functionp org-get-priority-function)
    (funcall org-get-priority-function)
      (if (not (string-match org-priority-regexp s))
      (* 1000 (- org-lowest-priority org-default-priority))
    (* 1000 (- org-lowest-priority
           (string-to-char (match-string 2 s))))))))

So first if separates the true case - usage of custom function, and in else - provides the default implementation.

So we have default implementation and the regex that selects the priority from the header:

(defvar org-priority-regexp ".*?\\(\\[#\\([A-Z0-9]\\)\\] ?\\)"
  "Regular expression matching the priority indicator.")

So now you have everything to create your implementation.

You are also right that function call does not gives the headline as arg.

You can just overload org-get-priority with your definition.

Thou that does not fully works (faces, modify functions) since there is some hard-code processing priorities as chars, and a magic (* 1000 ...) numbering around.

I've send a patch fixing the call for function in org-get-priority-function and some other patches around that.

Since you gone already so far - you can also get in, there is a lot of easy fixes to do regarding priorities.

  • Nitpick: it doesn't have to be the name of a function; it can also be an actual function. – Stefan Sep 28 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.