emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] [PATCH] fast tag selection interface


From: Christopher Suckling
Subject: Re: [Orgmode] [PATCH] fast tag selection interface
Date: Fri, 27 Feb 2009 18:40:58 +0000


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)







reply via email to

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