1

I want to get the value of the org-mode priority from the heading the cursor is under.

I ideally want a function that, ran under a heading with "[#A]", should return A as a character or string

Any guidance will be appriciated.

9
  • 1
    What are you really trying to do? Whatever it is, turning a number into a string, concatenating it with some other junk, turning that into a symbol and then into a byte is probably the wrong way to do it.
    – db48x
    Commented Feb 22, 2023 at 10:14
  • org-priority-show gets the priority of a heading in OrgMode. It gives the value as 64000 (the 64 is an example, it can be different), I'm dividing it by 1000 to get 64 and if I concatenate 64 to get #o64. If I run #o64 into byte-to-sting, I get the value I wanted. Commented Feb 22, 2023 at 10:40
  • There must be a much better method, probably with a regexp, but I have no idea how to achieve that. Commented Feb 22, 2023 at 10:41
  • All I want is the org-priority value. For a heading with [#A], I want to get A. Commented Feb 22, 2023 at 10:50
  • 1
    Please edit the question, in particular the title, to express what you want to know. It seems that the question is not really about converting a string to a symbol.
    – Drew
    Commented Feb 22, 2023 at 14:40

1 Answer 1

2

You can get the priority letter itself without jumping through any hoops like this:

(defun db48x/org-get-priority-letter ()
  (interactive)
  (let ((pri (cdr (assoc "PRIORITY"
                         (org-entry-properties nil
                                               "PRIORITY")))))
    (message "priority=%s" pri)))
1
  • 4
    Or even simpler: (org-entry-get nil "PRIORITY")
    – orgtre
    Commented Feb 22, 2023 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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