Function: org-tag-string-to-alist
org-tag-string-to-alist is a byte-compiled function defined in
org.el.gz.
Signature
(org-tag-string-to-alist S)
Documentation
Return tag alist associated to string S.
S is a value for TAGS keyword or produced with
org-tag-alist-to-string. Return value is an alist suitable for
org-tag-alist or org-tag-persistent-alist.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-tag-string-to-alist (s)
"Return tag alist associated to string S.
S is a value for TAGS keyword or produced with
`org-tag-alist-to-string'. Return value is an alist suitable for
`org-tag-alist' or `org-tag-persistent-alist'."
(let ((lines (mapcar #'split-string (split-string s "\n" t)))
(tag-re (concat "\\`\\(" org-tag-re "\\|{.+?}\\)" ; regular expression
"\\(?:(\\(.\\))\\)?\\'"))
alist group-flag)
(dolist (tokens lines (cdr (nreverse alist)))
(push '(:newline) alist)
(while tokens
(let ((token (pop tokens)))
(pcase token
("{"
(push '(:startgroup) alist)
(when (equal (nth 1 tokens) ":") (setq group-flag t)))
("}"
(push '(:endgroup) alist)
(setq group-flag nil))
("["
(push '(:startgrouptag) alist)
(when (equal (nth 1 tokens) ":") (setq group-flag t)))
("]"
(push '(:endgrouptag) alist)
(setq group-flag nil))
(":"
(push '(:grouptags) alist))
((guard (string-match tag-re token))
(let ((tag (match-string 1 token))
(key (and (match-beginning 2)
(string-to-char (match-string 2 token)))))
;; Push all tags in groups, no matter if they already
;; appear somewhere else in the list.
(when (or group-flag (not (assoc tag alist)))
(push (cons tag key) alist))))))))))