summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-10-15 21:24:40 -0400
committerKyle Meyer <kyle@kyleam.com>2016-10-15 21:24:40 -0400
commit3d44737380569bf9c077d6b55d1800b30f9dfd66 (patch)
tree233e873208e64b487839c5dbc12b7066818fa140
parentf2918264af77e47f535db3c62d82c5a974634b13 (diff)
downloademacs.d-3d44737380569bf9c077d6b55d1800b30f9dfd66.tar.gz
Add org-sort-all-level-headings command
-rw-r--r--lisp/km-org.el10
1 files changed, 10 insertions, 0 deletions
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))