From 3d44737380569bf9c077d6b55d1800b30f9dfd66 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 15 Oct 2016 21:24:40 -0400 Subject: Add org-sort-all-level-headings command --- lisp/km-org.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lisp/km-org.el b/lisp/km-org.el index 2a00814..9f7c8f8 100644 --- a/lisp/km-org.el +++ b/lisp/km-org.el @@ -150,6 +150,16 @@ current heading." (outline-up-heading arg) (call-interactively #'org-sort))) +(defun km/org-sort-all-level-headings (level) + "Sort all buffer headings that are at LEVEL (default 1)." + (interactive "p") + (org-map-entries (lambda () + (when (and (= (org-current-level) level) + ;; Avoid "Nothing to sort" error. + (save-excursion (org-goto-first-child))) + (org-sort-entries nil ?a)))) + (message "Sorted headings at level %s" level)) + (defun km/org--prop-sort-args () "Return `org-sort-entries' arguments based on \"SORT\" property." (when (save-excursion (org-goto-first-child)) -- cgit v1.2.3