summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-04-16 00:06:58 -0400
committerKyle Meyer <kyle@kyleam.com>2014-04-16 00:06:58 -0400
commit9a89e94c4df818d33b572e1c620d3e6b7e22e742 (patch)
tree04c819d5937086378d658acf7767bc8f64ff7855 /lisp
parent7576542b331fa2e8813668221c200b63753b91ba (diff)
downloademacs.d-9a89e94c4df818d33b572e1c620d3e6b7e22e742.tar.gz
Add function to sort on parent heading
Diffstat (limited to 'lisp')
-rw-r--r--lisp/init-org.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/lisp/init-org.el b/lisp/init-org.el
index af5361c..e754bed 100644
--- a/lisp/init-org.el
+++ b/lisp/init-org.el
@@ -118,6 +118,23 @@ Before running `org-tree-to-indirect-buffer',
(let ((org-indirect-buffer-display 'current-window))
(org-tree-to-indirect-buffer arg)))
+(defun km/org-sort-parent (arg)
+ "Sort on parent heading ARG levels up.
+After sorting, the point is returned to its previous location
+under the current heading."
+ (interactive "p")
+ (let ((heading (org-no-properties (org-get-heading t t)))
+ starting-pos
+ chars-after-heading)
+ (setq starting-pos (point))
+ (save-excursion
+ (org-back-to-heading t)
+ (setq chars-after-heading (- starting-pos (point)))
+ (outline-up-heading arg)
+ (call-interactively 'org-sort))
+ (goto-char (+ (org-find-exact-headline-in-buffer heading nil t)
+ chars-after-heading))))
+
;;; Org in other modes
(defun km/load-orgstruct ()
(turn-on-orgstruct++)
@@ -235,6 +252,8 @@ MAXLEVEL (defaults to 2)."
'km/org-refile-to-other-org-buffer)
(local-set-key (kbd "C-c m W")
'km/org-refile-to-other-file)
+ (local-set-key (kbd "C-c m s")
+ 'km/org-sort-parent)
(local-set-key (kbd "C-c m o")
'ace-link-org))))