I want child org items to inherit priority from their parent.

I tried setting org-use-property-inheritance '("PRIORITY"), but it did not have any apparent effect.

Use case: I often have high priority projects whose tasks are mostly equally important. I don't want to waste time setting priorities for each individual child task unless it differs from the parent (e.g., an optional subtask may have lower priority).

Update: I e-mailed the org mailing list. Will report back if I get a useful response.

  • The mailing-list thread referenced: lists.gnu.org/archive/html/emacs-orgmode/2018-01/msg00075.html Unresolved as of 12-03-2018. – Matthew Piziak Mar 13 '18 at 0:18
  • 1
    FWIW, I wrote a semi-working implementation in org-mode. Need to finish it and submit a patch. – holocronweaver Mar 13 '18 at 18:17
  • Wow, looking forward do it! – Matthew Piziak Mar 13 '18 at 21:36
  • 1
    Update: went back and fleshed out my implementation of priority inheritance so it both sorts correctly in various agenda views and is visible in both agenda and colview. Preparing to submit a patch. – holocronweaver Apr 22 '18 at 20:46
  • That's exciting! Thanks for the updates. :D – Matthew Piziak Apr 23 '18 at 17:29

The mailing list referenced in the first comment of the question states the following:

Note that you can already achieve inheritance by setting `org-get-priority-function' to a function that searches priority cookies among ancestors of the current headline.

I went ahead and implemented that suggestion (note that org-get-priority-function is just an alias for org-priority-get-priority-function):

(defun my/org-inherited-priority (s)

   ;; Priority cookie in this heading
   ((string-match org-priority-regexp s)
    (* 1000 (- org-priority-lowest
               (org-priority-to-value (match-string 2 s)))))

   ;; No priority cookie, but already at highest level
   ((not (org-up-heading-safe))
    (* 1000 (- org-priority-lowest org-priority-default)))

   ;; Look for the parent's priority
    (my/org-inherited-priority (org-get-heading)))))

(setq org-priority-get-priority-function #'my/org-inherited-priority)

Along with adding %l to org-agenda-prefix-format, this bit of code gives me an Org Agenda with indented subtasks that immediately follow their parent tasks (why I went down this rabbit hole in the first place).


In the absence of a genuine answer to this at the moment, I'm going to post this partial solution to the problem, if not to the literal question. The second pair of functions here raise and lower the priority of all items in the selected region:

(defun my/org-priority-up ()
  (org-priority 'up))

(defun my/org-priority-down ()
  (org-priority 'down))

(defun my/org-priority-up-region ()
  (org-map-entries #'my/org-priority-up nil 'region)
  (setq deactivate-mark nil))

(defun my/org-priority-down-region ()
  (org-map-entries #'my/org-priority-down nil 'region)
  (setq deactivate-mark nil))

You can just bind those last two to keys in the normal way.

For spacemacs users, here's a fancier way (,r. puts you in a transient state which lets you raise and lower the priorities on all items in the selected region using just the up and down arrow keys -- q to escape the transient state):

(spacemacs|define-transient-state my/org-region
  :title "Org region transient state"
  ("<up>" my/org-priority-up-region "up")
  ("<down>" my/org-priority-down-region "down")
  ("q" (lambda () (interactive) (setq deactivate-mark t)) "quit" :exit t))

(with-eval-after-load 'org
  (spacemacs/set-leader-keys-for-major-mode 'org-mode
    "r." 'spacemacs/my/org-region-transient-state/body))

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.