From 87fc0b0e2cfd3aa7ae484226e35d68e34af1e6b4 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Mon, 30 Nov 2009 21:11:28 +0100 Subject: [PATCH] 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. --- doc/ChangeLog | 5 +++++ doc/org.texi | 20 ++++++++++++++++++++ lisp/ChangeLog | 6 ++++++ lisp/org.el | 24 ++++++++++++++++++++---- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 03363fc46..946214595 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2009-11-30 Tassilo Horn + + * org.texi (Setting tags): Document variable + org-complete-tags-always-offer-all-agenda-tags. + 2009-11-18 Carsten Dominik * org.texi (Column attributes): Cross-reference special diff --git a/doc/org.texi b/doc/org.texi index cdadf029b..1ba4352f8 100644 --- a/doc/org.texi +++ b/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 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 @section Tag searches @cindex tag searches diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e56f0ec07..f9beb676c 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2009-11-30 Tassilo Horn + + * org.el (org-complete-tags-always-offer-all-agenda-tags): New + variable. + (org-set-tags): Use it. + 2009-11-30 Carsten Dominik * org-list.el (org-empty-line-terminates-plain-lists): Update diff --git a/lisp/org.el b/lisp/org.el index 5f3040737..664bafc89 100644 --- a/lisp/org.el +++ b/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 "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 "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' @@ -10509,7 +10523,7 @@ scheduling will use the corresponding date." (org-add-log-setup 'redeadline nil old-date 'findpos org-log-redeadline)) (message "Deadline on %s" org-last-inserted-timestamp))))) - + (defun org-schedule (&optional remove time) "Insert the SCHEDULED: string with a timestamp to schedule a TODO 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 (save-excursion (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 current-tags (org-split-string current ":") inherited-tags (nreverse @@ -15040,7 +15056,7 @@ overwritten, and the table is not marked as requiring realignment." (setq this-command org-speed-command) (call-interactively org-speed-command)) ((functionp org-speed-command) - (funcall org-speed-command)) + (funcall org-speed-command)) ((and org-speed-command (listp org-speed-command)) (eval org-speed-command)) (t (let (org-use-speed-commands) @@ -16200,7 +16216,7 @@ Your bug report will be posted to the Org-mode mailing list. (save-excursion (if (re-search-backward "^\\(Subject: \\)Org-mode version \\(.*?\\);[ \t]*\\(.*\\)" nil t) (replace-match "\\1Bug: \\3 [\\2]"))))) - + (defun org-install-agenda-files-menu () (let ((bl (buffer-list)))