From 1af7f303d5351c2fb9e3fea94438a399a88ea9a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Reu=C3=9Fe?= Date: Tue, 13 Mar 2018 17:51:45 +0100 Subject: [PATCH] Guard against empty headings when sorting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * org.el (org-sort-entries): Guard against empty headings when sorting alphabetically, numerically. Due to how ‘org-complex-heading-regexp’ is defined, the title capture group currently returns nil in empty headings, which we don’t want to pass on to ‘org-sort-remove-invisible’. --- lisp/org.el | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 73ab32aa0..15bc0e83a 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8734,15 +8734,11 @@ function is being called interactively." (lambda () (cond ((= dcst ?n) - (if (looking-at org-complex-heading-regexp) - (string-to-number - (org-sort-remove-invisible (match-string 4))) - nil)) + (string-to-number + (org-sort-remove-invisible (org-get-heading t t t t)))) ((= dcst ?a) - (if (looking-at org-complex-heading-regexp) - (funcall case-func - (org-sort-remove-invisible (match-string 4))) - nil)) + (funcall case-func + (org-sort-remove-invisible (org-get-heading t t t t)))) ((= dcst ?k) (or (get-text-property (point) :org-clock-minutes) 0)) ((= dcst ?t)