Function: org-collect-keywords

org-collect-keywords is a byte-compiled function defined in org.el.gz.

Signature

(org-collect-keywords KEYWORDS &optional UNIQUE DIRECTORY)

Documentation

Return values for KEYWORDS in current buffer, as an alist.

KEYWORDS is a list of strings. Return value is a list of elements with the pattern:

  (NAME . LIST-OF-VALUES)

where NAME is the upcase name of the keyword, and LIST-OF-VALUES is a list of non-empty values, as strings, in order of appearance in the buffer.

When KEYWORD appears in UNIQUE list, LIST-OF-VALUE is its first value, empty or not, appearing in the buffer, as a string.

When KEYWORD appears in DIRECTORIES, each value is a cons cell:

  (VALUE . DIRECTORY)

where VALUE is the regular value, and DIRECTORY is the variable default-directory for the buffer containing the keyword. This is important for values containing relative file names, since the function follows SETUPFILE keywords, and may change its working directory.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-collect-keywords (keywords &optional unique directory)
  "Return values for KEYWORDS in current buffer, as an alist.

KEYWORDS is a list of strings.  Return value is a list of
elements with the pattern:

  (NAME . LIST-OF-VALUES)

where NAME is the upcase name of the keyword, and LIST-OF-VALUES
is a list of non-empty values, as strings, in order of appearance
in the buffer.

When KEYWORD appears in UNIQUE list, LIST-OF-VALUE is its first
value, empty or not, appearing in the buffer, as a string.

When KEYWORD appears in DIRECTORIES, each value is a cons cell:

  (VALUE . DIRECTORY)

where VALUE is the regular value, and DIRECTORY is the variable
`default-directory' for the buffer containing the keyword.  This
is important for values containing relative file names, since the
function follows SETUPFILE keywords, and may change its working
directory."
  (let* ((keywords (cons "SETUPFILE" (mapcar #'upcase keywords)))
	 (unique (mapcar #'upcase unique))
	 (alist (org--collect-keywords-1
		 keywords unique directory
		 (and buffer-file-name (list buffer-file-name))
		 nil)))
    ;; Re-order results.
    (dolist (entry alist)
      (pcase entry
	(`(,_ . ,(and value (pred consp)))
	 (setcdr entry (nreverse value)))))
    (nreverse alist)))