emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH 2/2] Guard against empty headings when sorting


From: Sebastian Reuße
Subject: [O] [PATCH 2/2] Guard against empty headings when sorting
Date: Tue, 13 Mar 2018 17:51:45 +0100

* 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 | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 76bc60c88..07203c9e1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8756,15 +8756,17 @@ (defun org-sort-entries
          (lambda ()
            (cond
             ((= dcst ?n)
-             (if (looking-at org-complex-heading-regexp)
-                 (string-to-number
-                  (org-sort-remove-invisible (match-string 4)))
-               nil))
+             (let ((heading (and (looking-at org-complex-heading-regexp)
+                                 (match-string 4))))
+               (if heading
+                   (string-to-number (org-sort-remove-invisible heading))
+                 0)))
             ((= dcst ?a)
-             (if (looking-at org-complex-heading-regexp)
-                 (funcall case-func
-                          (org-sort-remove-invisible (match-string 4)))
-               nil))
+             (let ((heading (and (looking-at org-complex-heading-regexp)
+                                 (match-string 4))))
+               (if heading
+                   (funcall case-func (org-sort-remove-invisible heading))
+                 "")))
             ((= dcst ?k)
              (or (get-text-property (point) :org-clock-minutes) 0))
             ((= dcst ?t)
-- 
2.16.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]