From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: [misc-new-features 3/5] Add an option to sort tags automatically. Date: Fri, 17 Jul 2009 18:38:58 +0200 Message-ID: <87skgv44sf.fsf@bzg.ath.cx> References: <1247473682-23338-1-git-send-email-ahktenzero@mohorovi.cc> <1247473682-23338-2-git-send-email-ahktenzero@mohorovi.cc> <1247473682-23338-3-git-send-email-ahktenzero@mohorovi.cc> <1247473682-23338-4-git-send-email-ahktenzero@mohorovi.cc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MRqu6-0008R7-2t for emacs-orgmode@gnu.org; Fri, 17 Jul 2009 13:07:26 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MRqu0-0008Oo-Oy for emacs-orgmode@gnu.org; Fri, 17 Jul 2009 13:07:25 -0400 Received: from [199.232.76.173] (port=46109 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MRqu0-0008Oe-AB for emacs-orgmode@gnu.org; Fri, 17 Jul 2009 13:07:20 -0400 Received: from rv-out-0708.google.com ([209.85.198.246]:8847) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MRqty-0004Hg-RU for emacs-orgmode@gnu.org; Fri, 17 Jul 2009 13:07:19 -0400 Received: by rv-out-0708.google.com with SMTP id f25so362120rvb.6 for ; Fri, 17 Jul 2009 10:07:18 -0700 (PDT) In-Reply-To: <1247473682-23338-4-git-send-email-ahktenzero@mohorovi.cc> (James TD Smith's message of "Mon, 13 Jul 2009 09:28:00 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: James TD Smith Cc: emacs-orgmode@gnu.org I applied this patch, thanks a lot. James TD Smith writes: > --- > lisp/ChangeLog | 3 +++ > lisp/org.el | 17 ++++++++++++++++- > 2 files changed, 19 insertions(+), 1 deletions(-) > > diff --git a/lisp/ChangeLog b/lisp/ChangeLog > index 348ade3..9ce7a17 100755 > --- a/lisp/ChangeLog > +++ b/lisp/ChangeLog > @@ -11,6 +11,9 @@ > SINCE_IA. These give the time since any active or inactive > timestamp in an entry. > (org-special-properties): Add SINCE, SINCE_IA. > + (org-tags-sort-function): Add custom declaration for tags > + sorting function. > + (org-set-tags): Sort tags if org-tags-sort-function is set > > 2009-07-08 Carsten Dominik > > diff --git a/lisp/org.el b/lisp/org.el > index d08155a..854d09c 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -2337,6 +2337,15 @@ is better to limit inheritance to certain tags using the variables > (const :tag "Yes, do list them" t) > (const :tag "List them, indented with leading dots" indented))) > > +(defcustom org-tags-sort-function nil > + "When set, tags are sorted using this function as a comparator" > + :group 'org-tags > + :type '(choice > + (const :tag "No sorting" nil) > + (const :tag "Alphabetical" string<) > + (const :tag "Reverse alphabetical" string>) > + (function :tag "Custom function" nil))) > + > (defvar org-tags-history nil > "History of minibuffer reads for tags.") > (defvar org-last-tags-completion-table nil > @@ -10840,11 +10849,17 @@ With prefix ARG, realign all tags in headings in the current buffer." > ;; No boolean logic, just a list > (setq tags (replace-match ":" t t tags)))) > > + (if org-tags-sort-function > + (setq tags (mapconcat 'identity > + (sort (org-split-string tags (org-re "[^[:alnum:]_@]+")) > + org-tags-sort-function) ":"))) > + > (if (string-match "\\`[\t ]*\\'" tags) > - (setq tags "") > + (setq tags "") > (unless (string-match ":$" tags) (setq tags (concat tags ":"))) > (unless (string-match "^:" tags) (setq tags (concat ":" tags)))) > > + > ;; Insert new tags at the correct column > (beginning-of-line 1) > (cond -- Bastien