Change/Fix: (org-ql-select) Warn instead of erroring on bad files

This helps prevent unexpected errors from making it impossible to
search, and displaying the messages in the warnings buffer makes them
more noticeable and readable for the user.
This commit is contained in:
Adam Porter 2022-06-25 10:54:38 -05:00
parent 5768c685ad
commit bbd164c6ae

View file

@ -371,7 +371,7 @@ each priority the newest items would appear first."
;; It feels unintuitive that `find-file-noselect' returns ;; It feels unintuitive that `find-file-noselect' returns
;; a buffer if the filename doesn't exist. ;; a buffer if the filename doesn't exist.
(find-file-noselect it)) (find-file-noselect it))
(user-error "Can't open file: %s" it))))) (display-warning 'org-ql-select (format "Can't open file: %s" it) :error)))))
;; Ignore special/hidden buffers. ;; Ignore special/hidden buffers.
(--remove (string-prefix-p " " (buffer-name it))))) (--remove (string-prefix-p " " (buffer-name it)))))
(query (org-ql--normalize-query query)) (query (org-ql--normalize-query query))
@ -411,7 +411,7 @@ each priority the newest items would appear first."
(->> buffers (->> buffers
(--map (with-current-buffer it (--map (with-current-buffer it
(unless (derived-mode-p 'org-mode) (unless (derived-mode-p 'org-mode)
(user-error "Not an Org buffer: %s" (buffer-name))) (display-warning 'org-ql-select (format "Not an Org buffer: %s" (buffer-name)) :error))
(org-ql--select-cached :query query :preamble preamble :preamble-case-fold preamble-case-fold (org-ql--select-cached :query query :preamble preamble :preamble-case-fold preamble-case-fold
:predicate predicate :action action :narrow narrow))) :predicate predicate :action action :narrow narrow)))
(-flatten-n 1))) (-flatten-n 1)))