diff --git a/org-roam.el b/org-roam.el index 676cbc2..49f5424 100644 --- a/org-roam.el +++ b/org-roam.el @@ -174,22 +174,11 @@ If FILE is not specified, use the current buffer's file-path." (defun org-roam--list-files (dir) "Return all Org-roam files located within DIR, at any nesting level. Ignores hidden files and directories." - (if (file-exists-p dir) - (let ((files (directory-files dir t "." t)) - (dir-ignore-regexp (concat "\\(?:" - "\\." - "\\|\\.\\." - "\\)$")) - result) - (dolist (file files) - (cond - ((file-directory-p file) - (unless (string-match dir-ignore-regexp file) - (setq result (append (org-roam--list-files file) result)))) - ((and (file-readable-p file) - (org-roam--org-file-p file)) - (setq result (cons (file-truename file) result))))) - result))) + (let ((regex (concat "\\.\\(?:"(mapconcat #'regexp-quote org-roam-file-extensions "\\|" )"\\)\\(?:\\.gpg\\)?\\'")) + result) + (dolist (file (directory-files-recursively dir regex) result) + (when (and (file-readable-p file) (org-roam--org-file-p file)) + (push file result))))) (defun org-roam--list-all-files () "Return a list of all Org-roam files within `org-roam-directory'."