From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Sebastian=20Reu=C3=9Fe?= Subject: [PATCH] Fix alphabetic sorting for headlines, tags Date: Tue, 6 Feb 2018 09:57:16 +0100 Message-ID: <20180206085716.16913-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]:51005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiz4m-0007vH-Or for emacs-orgmode@gnu.org; Tue, 06 Feb 2018 03:58:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiz4j-0000nw-NX for emacs-orgmode@gnu.org; Tue, 06 Feb 2018 03:58:04 -0500 Received: from wirrsal.net ([188.68.36.149]:51736 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 1eiz4j-0000mm-Ca for emacs-orgmode@gnu.org; Tue, 06 Feb 2018 03:58:01 -0500 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): Use collated sorting. (org-tags-sort-function): Use collated sorting. (org-string-collate-greaterp): Add helper-function to use as defcustom option, since there is no =E2=80=98string-collate-greaterp=E2=80=99 in Em= acs. =E2=80=98org-sort-entries=E2=80=99 and =E2=80=98org-tags-sort-function=E2= =80=99 advertise alphabetic sorting, but actually sort based only on character code. This produces non-alphabetic orderings of strings in non-ASCII locales. E.=E2=80=AFg., German Umlauts =E2=80=9C=C3=84 =C3=9C =C3=96=E2=80=9D are = alphabetically sorted as if they were =E2=80=9CA U O=E2=80=9D, whereas sorting based on character-code wil= l place them after =E2=80=9CZ=E2=80=9D, which is unexpected. --- lisp/org.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 688e48bcc..d54c410b0 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3558,8 +3558,8 @@ (defcustom org-tags-sort-function nil :group 'org-tags :type '(choice (const :tag "No sorting" nil) - (const :tag "Alphabetical" string<) - (const :tag "Reverse alphabetical" string>) + (const :tag "Alphabetical" string-collate-lessp) + (const :tag "Reverse alphabetical" org-string-collate-greaterp) (function :tag "Custom function" nil))) =20 (defvar org-tags-history nil @@ -8803,7 +8803,7 @@ (defun org-sort-entries (t (error "Invalid sorting type `%c'" sorting-type)))) nil (cond - ((=3D dcst ?a) 'string<) + ((=3D dcst ?a) 'string-collate-lessp) ((=3D dcst ?f) (or compare-func (and interactive? @@ -8913,6 +8913,12 @@ (defun org-context-p (&rest contexts) (org-in-item-p))) (goto-char pos)))) =20 +(defun org-string-collate-greaterp (s1 s2 &optional locale ignore-case) + "Return t if S1 is greater than S2 in collation order. + +LOCALE and IGNORE-CASE are handled as in `string-collate-lessp'." + (not (string-collate-lessp s1 s2))) + ;;;###autoload (defun org-run-like-in-org-mode (cmd) "Run a command, pretending that the current buffer is in Org mode. --=20 2.16.1