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
This commit is contained in:
Carsten Dominik 2010-10-05 09:51:15 +02:00
parent 093e8cf58e
commit 02357b0c2a
1 changed files with 13 additions and 6 deletions

View File

@ -12769,8 +12769,10 @@ With prefix ARG, realign all tags in headings in the current buffer."
(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 (and
(org-global-tags-completion-table (org-agenda-files)))) 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
@ -12782,19 +12784,24 @@ With prefix ARG, realign all tags in headings in the current buffer."
(delq nil (mapcar 'cdr table)))) (delq nil (mapcar 'cdr table))))
(org-fast-tag-selection (org-fast-tag-selection
current-tags inherited-tags table 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)) (let ((org-add-colon-after-tag-completion t))
(org-trim (org-trim
(org-without-partial-completion (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))))))) nil nil current 'org-tags-history)))))))
(while (string-match "[-+&]+" tags) (while (string-match "[-+&]+" tags)
;; No boolean logic, just a list ;; No boolean logic, just a list
(setq tags (replace-match ":" t t tags)))) (setq tags (replace-match ":" t t tags))))
(setq tags (replace-regexp-in-string "[ ,]" ":" tags))
(if org-tags-sort-function (if org-tags-sort-function
(setq tags (mapconcat 'identity (setq tags (mapconcat 'identity
(sort (org-split-string tags (org-re "[^[:alnum:]_@#%]+")) (sort (org-split-string
tags (org-re "[^[:alnum:]_@#%]+"))
org-tags-sort-function) ":"))) org-tags-sort-function) ":")))
(if (string-match "\\`[\t ]*\\'" tags) (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) (defun org-tags-completion-function (string predicate &optional flag)
(let (s1 s2 rtn (ctable org-last-tags-completion-table) (let (s1 s2 rtn (ctable org-last-tags-completion-table)
(confirm (lambda (x) (stringp (car x))))) (confirm (lambda (x) (stringp (car x)))))
(if (string-match "^\\(.*[-+:&|]\\)\\([^-+:&|]*\\)$" string) (if (string-match "^\\(.*[-+:&,|]\\)\\([^-+:&,|]*\\)$" string)
(setq s1 (match-string 1 string) (setq s1 (match-string 1 string)
s2 (match-string 2 string)) s2 (match-string 2 string))
(setq s1 "" s2 string)) (setq s1 "" s2 string))