From 0ea9f73242d0139aaca58695c059e31748a002f9 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Wed, 10 Dec 2014 01:14:17 -0500 Subject: Clean up and comment org-sort-parent --- lisp/init-org.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lisp') diff --git a/lisp/init-org.el b/lisp/init-org.el index e1fa33f..35a39cb 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -190,14 +190,16 @@ 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 + (starting-pos (point)) 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)) + (org-back-to-heading t) + (setq chars-after-heading (- starting-pos (point))) + (outline-up-heading arg) + (call-interactively #'org-sort) + ;; Sorting doesn't play well with `save-restriction' or markers, + ;; so just put the point where it was relative to original + ;; heading. This may not actually be the same tree if there are + ;; redundant headings. (goto-char (+ (org-find-exact-headline-in-buffer heading nil t) chars-after-heading)))) -- cgit v1.2.3