Add: (org-ql-find) Add fallback argument

This commit is contained in:
Akira Komamura 2022-07-31 14:02:17 +09:00
parent 06f1e1be6f
commit 65c5fd2556

View file

@ -87,6 +87,7 @@ For an experience like `org-rifle', use a newline."
;;;###autoload ;;;###autoload
(cl-defun org-ql-find (buffers-files &key query-prefix query-filter (cl-defun org-ql-find (buffers-files &key query-prefix query-filter
fallback
(prompt "Find entry: ")) (prompt "Find entry: "))
"Go to an Org entry in BUFFERS-FILES selected by searching entries with `org-ql'. "Go to an Org entry in BUFFERS-FILES selected by searching entries with `org-ql'.
Interactively, with universal prefix, select multiple buffers to Interactively, with universal prefix, select multiple buffers to
@ -100,7 +101,10 @@ QUERY-FILTER may be a function through which the query the user
types is filtered before execution (e.g. it could replace spaces types is filtered before execution (e.g. it could replace spaces
with commas to turn multiple tokens, which would normally be with commas to turn multiple tokens, which would normally be
treated as multiple predicates, into multiple arguments to a treated as multiple predicates, into multiple arguments to a
single predicate)." single predicate).
If no candidate matches the input, FALLBACK function is called on
the input."
(interactive (interactive
(list (if current-prefix-arg (list (if current-prefix-arg
(mapcar #'get-buffer (mapcar #'get-buffer
@ -211,11 +215,13 @@ single predicate)."
(completion-styles-alist (list (list 'org-ql-find #'try #'all "Org QL Find"))) (completion-styles-alist (list (list 'org-ql-find #'try #'all "Org QL Find")))
(selected (completing-read prompt #'collection nil)) (selected (completing-read prompt #'collection nil))
(marker (gethash selected table))) (marker (gethash selected table)))
(if marker
(with-current-buffer (marker-buffer marker) (with-current-buffer (marker-buffer marker)
(goto-char marker) (goto-char marker)
(display-buffer (current-buffer)) (display-buffer (current-buffer))
(select-window (get-buffer-window (current-buffer))) (select-window (get-buffer-window (current-buffer)))
(run-hook-with-args 'org-ql-find-goto-hook)))))) (run-hook-with-args 'org-ql-find-goto-hook))
(funcall fallback selected))))))
;;;###autoload ;;;###autoload
(defun org-ql-find-in-agenda () (defun org-ql-find-in-agenda ()