Browse Source

Implement tag completion of all tags in all agenda files

Add a variable org-complete-tags-always-offer-all-agenda-tags, which makes org
complete all tags from all agenda files if non-nil.  Usually, setting it
locally to t in org-remember buffers is most convenient.
Tassilo Horn 15 years ago
parent
commit
87fc0b0e2c
4 changed files with 51 additions and 4 deletions
  1. 5 0
      doc/ChangeLog
  2. 20 0
      doc/org.texi
  3. 6 0
      lisp/ChangeLog
  4. 20 4
      lisp/org.el

+ 5 - 0
doc/ChangeLog

@@ -1,3 +1,8 @@
+2009-11-30  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* org.texi (Setting tags): Document variable
+	org-complete-tags-always-offer-all-agenda-tags.
+
 2009-11-18  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-11-18  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org.texi (Column attributes): Cross-reference special
 	* org.texi (Column attributes): Cross-reference special

+ 20 - 0
doc/org.texi

@@ -4234,6 +4234,26 @@ C-c}).  If you set the variable to the value @code{expert}, the special
 window is not even shown for single-key tag selection, it comes up only
 window is not even shown for single-key tag selection, it comes up only
 when you press an extra @kbd{C-c}.
 when you press an extra @kbd{C-c}.
 
 
+@vindex org-complete-tags-always-offer-all-agenda-tags
+As said before, when setting tags and @code{org-tag-alist} is nil, then the
+list of tags in the current buffer is used.  Normally, this behavior is very
+convenient, except in org remember buffers (@pxref{Remember}), because there
+are no tags that can be calculated dynamically.  Here, you most probably want
+to have completion for all tags in all agenda files.  This can be done by
+setting @code{org-complete-tags-always-offer-all-agenda-tags} to non-nil in
+those buffers.
+
+@lisp
+(add-hook 'org-remember-mode-hook
+          (lambda ()
+            (set (make-local-variable
+                  'org-complete-tags-always-offer-all-agenda-tags)
+                 t)))
+@end lisp
+
+Of course, you can also set it to @code{t} globally if you always want to
+have completion of all tags in all agenda files.
+
 @node Tag searches,  , Setting tags, Tags
 @node Tag searches,  , Setting tags, Tags
 @section Tag searches
 @section Tag searches
 @cindex tag searches
 @cindex tag searches

+ 6 - 0
lisp/ChangeLog

@@ -1,3 +1,9 @@
+2009-11-30  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* org.el (org-complete-tags-always-offer-all-agenda-tags): New
+	variable.
+	(org-set-tags): Use it.
+
 2009-11-30  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-11-30  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org-list.el (org-empty-line-terminates-plain-lists): Update
 	* org-list.el (org-empty-line-terminates-plain-lists): Update

+ 20 - 4
lisp/org.el

@@ -2426,6 +2426,20 @@ To disable these tags on a per-file basis, insert anywhere in the file:
 	   (const :tag "End radio group" (:endgroup))
 	   (const :tag "End radio group" (:endgroup))
 	   (const :tag "New line" (:newline)))))
 	   (const :tag "New line" (:newline)))))
 
 
+(defcustom org-complete-tags-always-offer-all-agenda-tags nil
+  "If non-nil, always offer completion for all tags of all agenda files.
+Instead of customizing this variable directly, you might want to
+set it locally for remember buffers, because there no list of
+tags in that file can be created dynamically (there are none).
+
+  (add-hook 'org-remember-mode-hook
+            (lambda ()
+              (set (make-local-variable
+                    'org-complete-tags-always-offer-all-agenda-tags)
+                   t)))"
+  :group 'org-tags
+  :type 'boolean)
+
 (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'
@@ -10509,7 +10523,7 @@ scheduling will use the corresponding date."
 	  (org-add-log-setup 'redeadline nil old-date 'findpos
 	  (org-add-log-setup 'redeadline nil old-date 'findpos
 			     org-log-redeadline))
 			     org-log-redeadline))
 	(message "Deadline on %s" org-last-inserted-timestamp)))))
 	(message "Deadline on %s" org-last-inserted-timestamp)))))
-	
+
 (defun org-schedule (&optional remove time)
 (defun org-schedule (&optional remove time)
   "Insert the SCHEDULED: string with a timestamp to schedule a TODO item.
   "Insert the SCHEDULED: string with a timestamp to schedule a TODO item.
 With argument REMOVE, remove any scheduling date from the item.
 With argument REMOVE, remove any scheduling date from the item.
@@ -11684,7 +11698,9 @@ With prefix ARG, realign all tags in headings in the current buffer."
 	;; Get a new set of tags from the user
 	;; Get a new set of tags from the user
 	(save-excursion
 	(save-excursion
 	  (setq table (append org-tag-persistent-alist
 	  (setq table (append org-tag-persistent-alist
-			      (or org-tag-alist (org-get-buffer-tags)))
+			      (or org-tag-alist (org-get-buffer-tags))
+			      (and org-complete-tags-always-offer-all-agenda-tags
+				   (org-global-tags-completion-table (org-agenda-files))))
 		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
@@ -15040,7 +15056,7 @@ overwritten, and the table is not marked as requiring realignment."
       (setq this-command org-speed-command)
       (setq this-command org-speed-command)
       (call-interactively org-speed-command))
       (call-interactively org-speed-command))
      ((functionp org-speed-command)
      ((functionp org-speed-command)
-      (funcall org-speed-command))     
+      (funcall org-speed-command))
      ((and org-speed-command (listp org-speed-command))
      ((and org-speed-command (listp org-speed-command))
       (eval org-speed-command))
       (eval org-speed-command))
      (t (let (org-use-speed-commands)
      (t (let (org-use-speed-commands)
@@ -16200,7 +16216,7 @@ Your bug report will be posted to the Org-mode mailing list.
     (save-excursion
     (save-excursion
       (if (re-search-backward "^\\(Subject: \\)Org-mode version \\(.*?\\);[ \t]*\\(.*\\)" nil t)
       (if (re-search-backward "^\\(Subject: \\)Org-mode version \\(.*?\\);[ \t]*\\(.*\\)" nil t)
 	  (replace-match "\\1Bug: \\3 [\\2]")))))
 	  (replace-match "\\1Bug: \\3 [\\2]")))))
-    
+
 
 
 (defun org-install-agenda-files-menu ()
 (defun org-install-agenda-files-menu ()
   (let ((bl (buffer-list)))
   (let ((bl (buffer-list)))