Make ripgrep flags customisable for org-roam-search

This commit is contained in:
Chris Barrett
2022-10-12 16:05:28 +13:00
parent 954d7c86b7
commit 9e8c08dac0

View File

@@ -63,6 +63,11 @@
:group 'org-roam-search
:type 'string)
(defcustom org-roam-search-ripgrep-flags '("--follow" "--smart-case" "--json")
"The flags to apply when searching via ripgrep."
:group 'org-roam-search
:type '(list string))
(defcustom org-roam-search-ignored-tags nil
"A list of tags for nodes that should never be included in search results.
@@ -161,9 +166,10 @@ would be excluded."
(defun org-roam-search--ripgrep-for-nodes (query)
(let ((reporter (make-progress-reporter "Searching nodes"))
(files (ht-create)))
(files (ht-create))
(ripgrep-args (append org-roam-search-ripgrep-flags (list query org-roam-directory))))
(async-wait
(async-start-process "ripgrep" org-roam-search-ripgrep-program
(apply 'async-start-process "ripgrep" org-roam-search-ripgrep-program
(lambda (_)
(goto-char (point-min))
(while (not (eobp))
@@ -179,9 +185,7 @@ would be excluded."
(file (expand-file-name file org-roam-directory)))
(puthash file file files))
(forward-line)))
"--smart-case"
"--json"
query org-roam-directory))
ripgrep-args))
(progress-reporter-done reporter)
(seq-filter (lambda (node)
(and (ht-get files (org-roam-node-file node))