Bug fix in org-find-file

Taken from an update on my website.
This commit is contained in:
Howard Abrams 2023-02-01 08:07:52 -08:00
parent 77facd8668
commit 01b9abdd4c

View file

@ -14,17 +14,18 @@
;; ;;
;;; Code: ;;; Code:
(defun org-find-file (file &optional directory) (defun org-find-file (file)
"Load file from FILE-TUPLE like `find-file'. "Load org-specific file like `find-file'.
If called interactively, first ask for a TAG and then limit the If called interactively, the list of files inclues the Org's
files displayed based on if they have a headline that contains title as well as any headline tags."
that TAG." (interactive (list (org-find-file--choose-file)))
(interactive (list (org-find-file--choose-file directory)))
(find-file file)) (find-file file))
(defun org-find-file--choose-file (&optional directory) (defun org-find-file--choose-file (&optional directory)
"docstring" "Use `completing-read' to present Org files for selection.
Acquires the list of files (and their descriptive text) from
calling `org-find-file--file-choices' (which returns an alist)."
(let* ((default-directory (if (project-current) (let* ((default-directory (if (project-current)
(project-root (project-current)) (project-root (project-current))
(or directory default-directory))) (or directory default-directory)))
@ -47,7 +48,7 @@
(let* ((title-color `(:foreground ,(face-attribute 'org-document-title :foreground))) (let* ((title-color `(:foreground ,(face-attribute 'org-document-title :foreground)))
(title-str (string-trim title)) (title-str (string-trim title))
(title-pretty (propertize title-str 'face title-color)) (title-pretty (propertize title-str 'face title-color))
(tag-str (string-join " "))) (tag-str (string-join tags " ")))
(format "%s : %s %s" file title-pretty tag-str))) (format "%s : %s %s" file title-pretty tag-str)))
(defun org-find-file--gather-titles () (defun org-find-file--gather-titles ()