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.
org-cmp-priority
inorg-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))
.