mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(fix): fix org-roam--list-files elisp fallback (#764)
Always fallback to the elisp implementation, when the shell commands return garbage (possibly from shell configurations).
This commit is contained in:
23
org-roam.el
23
org-roam.el
@ -316,7 +316,11 @@ If FILE is not specified, use the current buffer's file-path."
|
|||||||
|
|
||||||
(defun org-roam--shell-command-files (cmd)
|
(defun org-roam--shell-command-files (cmd)
|
||||||
"Run CMD in the shell and return a list of files. If no files are found, an empty list is returned."
|
"Run CMD in the shell and return a list of files. If no files are found, an empty list is returned."
|
||||||
(seq-filter #'s-present? (split-string (shell-command-to-string cmd) "\n")))
|
(--> cmd
|
||||||
|
(shell-command-to-string it)
|
||||||
|
(ansi-color-filter-apply it)
|
||||||
|
(split-string it "\n")
|
||||||
|
(seq-filter #'s-present? it)))
|
||||||
|
|
||||||
(defun org-roam--list-files-search-globs (exts)
|
(defun org-roam--list-files-search-globs (exts)
|
||||||
"Given EXTS, return a list of search globs.
|
"Given EXTS, return a list of search globs.
|
||||||
@ -424,15 +428,14 @@ Use external shell commands if defined in `org-roam-list-files-commands'."
|
|||||||
`((consp symbolp)
|
`((consp symbolp)
|
||||||
,wrong-type))))
|
,wrong-type))))
|
||||||
(when path (cl-return)))
|
(when path (cl-return)))
|
||||||
(let* ((files (if path
|
(if-let* ((files (when path
|
||||||
(let ((fn (intern (concat "org-roam--list-files-" exe))))
|
(let ((fn (intern (concat "org-roam--list-files-" exe))))
|
||||||
(unless (fboundp fn) (user-error "%s is not an implemented search method" fn))
|
(unless (fboundp fn) (user-error "%s is not an implemented search method" fn))
|
||||||
(funcall fn path (format "\"%s\"" dir)))
|
(funcall fn path (format "\"%s\"" dir)))))
|
||||||
(org-roam--list-files-elisp dir)))
|
(files (seq-filter #'org-roam--org-roam-file-p files))
|
||||||
(files (mapcar #'ansi-color-filter-apply files)) ; strip ansi codes
|
(files (mapcar #'expand-file-name files))) ; canonicalize names
|
||||||
(files (seq-filter #'org-roam--org-roam-file-p files))
|
files
|
||||||
(files (mapcar #'expand-file-name files))) ; canonicalize names
|
(org-roam--list-files-elisp dir))))
|
||||||
files)))
|
|
||||||
|
|
||||||
(defun org-roam--list-all-files ()
|
(defun org-roam--list-all-files ()
|
||||||
"Return a list of all Org-roam files within `org-roam-directory'."
|
"Return a list of all Org-roam files within `org-roam-directory'."
|
||||||
|
Reference in New Issue
Block a user