From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Suckling Subject: Re: [PATCH] fast tag selection interface Date: Fri, 27 Feb 2009 18:40:58 +0000 Message-ID: <521CAEF3-952B-4086-9BCD-DC6120B1DB24@gmail.com> References: <181D70D7-85EC-4010-ABD5-8F18C785337E@gmail.com> Mime-Version: 1.0 (Apple Message framework v930.3) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ld7e6-0007dF-1x for emacs-orgmode@gnu.org; Fri, 27 Feb 2009 13:41:14 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ld7e4-0007cL-Fa for emacs-orgmode@gnu.org; Fri, 27 Feb 2009 13:41:13 -0500 Received: from [199.232.76.173] (port=39941 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ld7e4-0007c5-1v for emacs-orgmode@gnu.org; Fri, 27 Feb 2009 13:41:12 -0500 Received: from mail-gx0-f160.google.com ([209.85.217.160]:44094) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ld7e3-0003HK-L0 for emacs-orgmode@gnu.org; Fri, 27 Feb 2009 13:41:11 -0500 Received: by gxk4 with SMTP id 4so2898637gxk.18 for ; Fri, 27 Feb 2009 10:41:09 -0800 (PST) In-Reply-To: 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: Carsten Dominik Cc: org-mode mailing list On 19 Feb 2009, at 09:22, Carsten Dominik wrote: > Hi Christopher, > > ok, I have applied your patch, with one addition: > > When you write > > #+TAGS: a b c > #+TAGS: d e f > > instead of > > #+TAGS: a b c d e f > > then a newline is implied after "c". > > Also, I noticed, that you can do > > #+TAGS: a b c \n \n d e f > > and it will nicely give you an empty line. > > Thanks! > > - Carsten Hi Carsten, Unfortunately, my patch was a bit crude and caused some rather unpredictable formatting. Here's an improvement which fixes that; I had forgotten to reset cnt to 0 whenever a new line occurred, so all sorts of strange line breaks were happening. I've also added a new variable, org-tag-persistent-alist, which is a list of tags that will always appear in all Org-mode files, in addition to any in buffer settings or customizations of org-tag-alist. As with line breaks, this may be a tiny personal convenience (I store all my GTD contexts in them so I don't have to re-enter them in every new org file), but in case anyone else finds it useful... Best wishes, Christopher ----- Modified lisp/org.el diff --git a/lisp/org.el b/lisp/org.el index abb9395..66654f5 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -2097,6 +2097,22 @@ See the manual for details." (const :tag "End radio group" (:endgroup)) (const :tag "New line" (:newline))))) +(defcustom org-tag-persistent-alist nil + "List of tags that will always appear in all Org-mode files, in addition to any in buffer settings or customizations of org-tag-alist. +When this list is nil, Org-mode will base TAG input on org-tag-alist. +The value of this variable is an alist, the car of each entry must be a +keyword as a string, the cdr may be a character that is used to select +that tag through the fast-tag-selection interface. +See the manual for details." + :group 'org-tags + :type '(repeat + (choice + (cons (string :tag "Tag name") + (character :tag "Access char")) + (const :tag "Start radio group" (:startgroup)) + (const :tag "End radio group" (:endgroup)) + (const :tag "New line" (:newline))))) + (defvar org-file-tags nil "List of tags that can be inherited by all entries in the file. The tags will be inherited if the variable `org-use-tag-inheritance' @@ -8976,7 +8992,13 @@ Returns the new TODO keyword, or nil if no state change should occur." (setq ingroup nil cnt 0) (insert "}\n")) ((equal e '(:newline)) - (insert "\n ")) + (when (not (= cnt 0)) + (setq cnt 0) + (insert "\n") + (setq e (car tbl)) + (cond + ((equal e '(:newline)) + (insert "\n"))))) (t (setq tg (car e) c (cdr e)) (if ingroup (push tg (car groups))) @@ -10227,7 +10249,7 @@ With prefix ARG, realign all tags in headings in the current buffer." (setq tags current) ;; Get a new set of tags from the user (save-excursion - (setq table (or org-tag-alist (org-get-buffer-tags)) + (setq table (append org-tag-persistent-alist (or org-tag-alist (org-get-buffer-tags))) org-last-tags-completion-table table current-tags (org-split-string current ":") inherited-tags (nreverse @@ -10434,7 +10456,13 @@ Returns the new tags string, or nil to not change the current settings." (setq ingroup nil cnt 0) (insert "}\n")) ((equal e '(:newline)) - (insert "\n ")) + (when (not (= cnt 0)) + (setq cnt 0) + (insert "\n") + (setq e (car tbl)) + (cond + ((equal e '(:newline)) + (insert "\n"))))) (t (setq tg (car e) c2 nil) (if (cdr e)