浏览代码

Tags: Fix implementation of line breaks in fast tag interface

Patch by Christopher Suckling
Carsten Dominik 16 年之前
父节点
当前提交
89e0d3608d
共有 4 个文件被更改,包括 62 次插入5 次删除
  1. 4 0
      doc/ChangeLog
  2. 11 0
      doc/org.texi
  3. 8 0
      lisp/ChangeLog
  4. 39 5
      lisp/org.el

+ 4 - 0
doc/ChangeLog

@@ -1,3 +1,7 @@
+2009-03-01  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.texi (Setting tags): Document `org-tag-persistent-alist'.
+
 2009-02-27  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-02-27  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org.texi (Weekly/daily agenda): New section.
 	* org.texi (Weekly/daily agenda): New section.

+ 11 - 0
doc/org.texi

@@ -3868,6 +3868,17 @@ in a specific file, add an empty TAGS option line to that file:
 #+TAGS:
 #+TAGS:
 @end example
 @end example
 
 
+@vindex org-tag-persistent-alist
+If you have a preferred set of tags that you would like to use in every file,
+in addition to those defined on a per file basis by TAGS option lines, then
+you may specify a list of tags with the variable
+@code{org-tag-persistent-alist}.  You may turn this off on a per file basis
+by adding a STARTUP option line to that file:
+
+@example
+#+STARTUP: noptag
+@end example
+
 By default Org mode uses the standard minibuffer completion facilities for
 By default Org mode uses the standard minibuffer completion facilities for
 entering tags.  However, it also implements another, quicker, tag selection
 entering tags.  However, it also implements another, quicker, tag selection
 method called @emph{fast tag selection}.  This allows you to select and
 method called @emph{fast tag selection}.  This allows you to select and

+ 8 - 0
lisp/ChangeLog

@@ -1,3 +1,11 @@
+2009-03-01  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-tag-persistent-alist): New option.
+	(org-startup-options): Add keyword `noptag'.
+	(org-fast-todo-selection): Handle :newline correctly.
+	(org-set-tags): Handle :newline correctly.
+	(org-fast-tag-selection): Handle :newline correctly.
+
 2009-02-28  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-02-28  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org-exp.el (org-export-as-ascii): Reverse link buffer before
 	* org-exp.el (org-export-as-ascii): Reverse link buffer before

+ 39 - 5
lisp/org.el

@@ -2097,6 +2097,26 @@ See the manual for details."
 	   (const :tag "End radio group" (:endgroup))
 	   (const :tag "End radio group" (:endgroup))
 	   (const :tag "New line" (:newline)))))
 	   (const :tag "New line" (:newline)))))
 
 
+(defcustom org-tag-persistent-alist nil
+  "List of tags that will always appear in all Org-mode files.
+This is 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.
+To disable these tags on a per-file basis, insert anywhere in the file:
+   #+STARTUP: noptag"
+  :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
 (defvar org-file-tags nil
   "List of tags that can be inherited by all entries in the file.
   "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'
 The tags will be inherited if the variable `org-use-tag-inheritance'
@@ -3255,7 +3275,8 @@ After a match, the following groups carry important information:
     ("fnconfirm" org-footnote-auto-label confirm)
     ("fnconfirm" org-footnote-auto-label confirm)
     ("fnplain" org-footnote-auto-label plain)
     ("fnplain" org-footnote-auto-label plain)
     ("constcgs" constants-unit-system cgs)
     ("constcgs" constants-unit-system cgs)
-    ("constSI" constants-unit-system SI))
+    ("constSI" constants-unit-system SI)
+    ("noptag" org-tag-persistent-alist nil))
   "Variable associated with STARTUP options for org-mode.
   "Variable associated with STARTUP options for org-mode.
 Each element is a list of three items: The startup options as written
 Each element is a list of three items: The startup options as written
 in the #+STARTUP line, the corresponding variable, and the value to
 in the #+STARTUP line, the corresponding variable, and the value to
@@ -8976,7 +8997,13 @@ Returns the new TODO keyword, or nil if no state change should occur."
 	    (setq ingroup nil cnt 0)
 	    (setq ingroup nil cnt 0)
 	    (insert "}\n"))
 	    (insert "}\n"))
 	   ((equal e '(:newline))
 	   ((equal e '(:newline))
-	    (insert "\n  "))
+	    (when (not (= cnt 0))
+	      (setq cnt 0)
+	      (insert "\n")
+	      (setq e (car tbl))
+	      (while (equal (car tbl) '(:newline))
+		(insert "\n")
+		(setq tbl (cdr tbl)))))
 	   (t
 	   (t
 	    (setq tg (car e) c (cdr e))
 	    (setq tg (car e) c (cdr e))
 	    (if ingroup (push tg (car groups)))
 	    (if ingroup (push tg (car groups)))
@@ -10226,8 +10253,9 @@ With prefix ARG, realign all tags in headings in the current buffer."
       (if just-align
       (if just-align
 	  (setq tags current)
 	  (setq tags current)
 	;; Get a new set of tags from the user
 	;; Get a new set of tags from the user
-	(save-excursion
-	  (setq table (or org-tag-alist (org-get-buffer-tags))
+	(save-excursion	
+	  (setq table (append org-tag-persistent-alist
+			      (or org-tag-alist (org-get-buffer-tags)))
 		org-last-tags-completion-table table
 		org-last-tags-completion-table table
 		current-tags (org-split-string current ":")
 		current-tags (org-split-string current ":")
 		inherited-tags (nreverse
 		inherited-tags (nreverse
@@ -10434,7 +10462,13 @@ Returns the new tags string, or nil to not change the current settings."
 	  (setq ingroup nil cnt 0)
 	  (setq ingroup nil cnt 0)
 	  (insert "}\n"))
 	  (insert "}\n"))
 	 ((equal e '(:newline))
 	 ((equal e '(:newline))
-	  (insert "\n  "))
+	  (when (not (= cnt 0))
+	    (setq cnt 0)
+	    (insert "\n")
+	    (setq e (car tbl))
+	    (while (equal (car tbl) '(:newline))
+	      (insert "\n")
+	      (setq tbl (cdr tbl)))))
 	 (t
 	 (t
 	  (setq tg (car e) c2 nil)
 	  (setq tg (car e) c2 nil)
 	  (if (cdr e)
 	  (if (cdr e)