From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Sebastian=20Reu=C3=9Fe?= Subject: [PATCH 2/2] Guard against empty headings when sorting Date: Tue, 13 Mar 2018 17:51:45 +0100 Message-ID: <20180313165145.27160-3-seb@wirrsal.net> References: <20180313165145.27160-1-seb@wirrsal.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evnAB-000600-Qe for emacs-orgmode@gnu.org; Tue, 13 Mar 2018 12:52:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evnA6-0002x5-SA for emacs-orgmode@gnu.org; Tue, 13 Mar 2018 12:52:35 -0400 Received: from wirrsal.net ([188.68.36.149]:50328 helo=mail.wirrsal.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1evnA6-0002we-L2 for emacs-orgmode@gnu.org; Tue, 13 Mar 2018 12:52:30 -0400 In-Reply-To: <20180313165145.27160-1-seb@wirrsal.net> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Cc: =?UTF-8?q?Sebastian=20Reu=C3=9Fe?= * org.el (org-sort-entries): Guard against empty headings when sorting alphabetically, numerically. Due to how =E2=80=98org-complex-heading-regexp=E2=80=99 is defined, the t= itle capture group currently returns nil in empty headings, which we don=E2=80=99t want to p= ass on to =E2=80=98org-sort-remove-invisible=E2=80=99. --- 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 ((=3D 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))) ((=3D 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)) + ""))) ((=3D dcst ?k) (or (get-text-property (point) :org-clock-minutes) 0)) ((=3D dcst ?t) --=20 2.16.2