From 02357b0c2a88077b95e182ba19c3e457774c0ff8 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 5 Oct 2010 09:51:15 +0200 Subject: [PATCH] Allow comma as a separator when specifying tags * lisp/org.el (org-set-tags): Allow comma as a separator when specifying tags at the completion interface. (org-tags-completion-function): Allow comma as a separator when specifying tags at the completion interface. Patch by Richard Riley, extended by Carsten --- lisp/org.el | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 642d106d5..f4c7a3e0a 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -12769,8 +12769,10 @@ With prefix ARG, realign all tags in headings in the current buffer." (save-excursion (setq table (append org-tag-persistent-alist (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)))) + (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 @@ -12782,19 +12784,24 @@ With prefix ARG, realign all tags in headings in the current buffer." (delq nil (mapcar 'cdr table)))) (org-fast-tag-selection current-tags inherited-tags table - (if org-fast-tag-selection-include-todo org-todo-key-alist)) + (if org-fast-tag-selection-include-todo + org-todo-key-alist)) (let ((org-add-colon-after-tag-completion t)) (org-trim (org-without-partial-completion - (org-icompleting-read "Tags: " 'org-tags-completion-function + (org-icompleting-read "Tags: " + 'org-tags-completion-function nil nil current 'org-tags-history))))))) (while (string-match "[-+&]+" tags) ;; No boolean logic, just a list (setq tags (replace-match ":" t t tags)))) + (setq tags (replace-regexp-in-string "[ ,]" ":" tags)) + (if org-tags-sort-function (setq tags (mapconcat 'identity - (sort (org-split-string tags (org-re "[^[:alnum:]_@#%]+")) + (sort (org-split-string + tags (org-re "[^[:alnum:]_@#%]+")) org-tags-sort-function) ":"))) (if (string-match "\\`[\t ]*\\'" tags) @@ -12874,7 +12881,7 @@ This works in the agenda, and also in an org-mode buffer." (defun org-tags-completion-function (string predicate &optional flag) (let (s1 s2 rtn (ctable org-last-tags-completion-table) (confirm (lambda (x) (stringp (car x))))) - (if (string-match "^\\(.*[-+:&|]\\)\\([^-+:&|]*\\)$" string) + (if (string-match "^\\(.*[-+:&,|]\\)\\([^-+:&,|]*\\)$" string) (setq s1 (match-string 1 string) s2 (match-string 2 string)) (setq s1 "" s2 string))