Function: hywiki-org-directory-todo-regexp

hywiki-org-directory-todo-regexp is a byte-compiled function defined in hywiki.el.

Signature

(hywiki-org-directory-todo-regexp DIR)

Documentation

Scan .org files in DIR for #+TODO keyword lines; return a matching regexp.

This includes both standard and custom todo keywords. Does not descend into subdirectories.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hywiki.el
(defun hywiki-org-directory-todo-regexp (dir)
  "Scan .org files in DIR for #+TODO keyword lines; return a matching regexp.
This includes both standard and custom todo keywords.  Does not descend into
subdirectories."
  ;; Use grep, sort and uniq to find all unique #+TODO lines in the directory;
  ;; use -h to omit filenames
  (let ((grep-output
         (shell-command-to-string
          (format "grep -h '^#+TODO:' %s | sort | uniq"
		  (expand-file-name "*.org" dir))))
	keywords)
    ;; Remove #+TODO: markup
    (setq grep-output (replace-regexp-in-string "^#\\+\\(SEQ_\\|TYP_\\)?TODO:[ \t]*" "" grep-output))

    ;; Remove quick keys and other annotations, as well as alternative pipes
    (setq grep-output (replace-regexp-in-string "|\\|([^)]*)" "" grep-output))

    ;; Split into individual todo keywords
    (setq keywords (nconc (with-temp-buffer (org-mode) org-todo-keywords-1)
                          (split-string grep-output "[ \t\n\r]" t)))

    ;; Create the regexp to match to all todo keywords
    (when keywords (format "\\(%s\\)" (regexp-opt keywords)))))