org-mode: Downgrade in priority all items in current buffer

Is there a way to downgrade all items in the current org-mode buffer?

I guess the relevant function is (org-priority-down) but I'm not sure how to apply it recursively. Unless there is a simpler way

My use case: there's a big org-mode file and I need to adjust all existing priorities while introducing new (higher) priority tasks.


As a temporary workaround I used the following snippet but I'm still looking for more idiomatic solution

(while (re-search-forward "#D" nil t) (replace-match "#E"))
(while (re-search-forward "#C" nil t) (replace-match "#D"))
(while (re-search-forward "#B" nil t) (replace-match "#C"))
(while (re-search-forward "#A" nil t) (replace-match "#B"))


  • Using the Mapping API : Function: org-map-entries

    (org-map-entries #'org-priority-down t 'file)