summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-04-03 01:08:04 -0400
committerKyle Meyer <kyle@kyleam.com>2015-04-03 01:08:04 -0400
commitee9efe4a885db42bf87f21736213796c4bb0ef95 (patch)
tree5203c1a1c6ffd47de96c4047a5b48d05e7677d11
parenta4d627b752ba66838781283bc35cefcdb2ad5f71 (diff)
downloademacs.d-ee9efe4a885db42bf87f21736213796c4bb0ef95.tar.gz
Rewrite org-sort-parent
Search for whole heading line instead of using org-find-exact-headline-in-buffer.
-rw-r--r--lisp/init-org.el25
1 files changed, 13 insertions, 12 deletions
diff --git a/lisp/init-org.el b/lisp/init-org.el
index 76b00ec..be79d25 100644
--- a/lisp/init-org.el
+++ b/lisp/init-org.el
@@ -174,19 +174,20 @@ heading."
After sorting, return point to its previous location under the
current heading."
(interactive "p")
- (let ((heading (org-no-properties (org-get-heading t t)))
- (starting-pos (point))
- chars-after-heading)
+ (let ((starting-pos (point)))
(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 the 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))))
+ (let ((heading-line (buffer-substring-no-properties
+ (point-at-bol) (point-at-eol)))
+ (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 the original
+ ;; heading. This may not actually be the same tree if there are
+ ;; redundant headings.
+ (re-search-forward heading-line)
+ (beginning-of-line)
+ (goto-char (+ (point) chars-after-heading)))))
(defun km/org-sort-heading-ignoring-articles ()
"Sort alphabetically, but ignore any leading articles."