Run `helm-org-ql--heading' as :filtered-candidate-transformer

This commit is contained in:
Ihor Radchenko 2020-12-07 13:55:18 +08:00
parent 1389ccb46b
commit 7ecb80fca9

View file

@ -178,21 +178,27 @@ Is transformed into this query:
"Return Helm source named NAME that searches BUFFERS-FILES with `helm-org-ql'." "Return Helm source named NAME that searches BUFFERS-FILES with `helm-org-ql'."
;; Expansion of `helm-build-sync-source' macro. ;; Expansion of `helm-build-sync-source' macro.
(helm-make-source name 'helm-source-sync (helm-make-source name 'helm-source-sync
:filtered-candidate-transformer (lambda (candidates _)
(let ((window-width (window-width (helm-window))))
(mapcar (lambda (marker)
(unless (markerp marker) (user-error "Unexpected candidate for `helm-org-ql-source'"))
(org-with-point-at marker
(helm-org-ql--heading window-width)))
candidates)))
:candidates (lambda () :candidates (lambda ()
(let* ((query (org-ql--query-string-to-sexp helm-pattern)) (let* ((query (org-ql--query-string-to-sexp helm-pattern)))
(window-width (window-width (helm-window))))
(when query (when query
(with-current-buffer (helm-buffer-get) (with-current-buffer (helm-buffer-get)
(setq helm-org-ql-buffers-files buffers-files)) (setq helm-org-ql-buffers-files buffers-files))
(ignore-errors (ignore-errors
;; Ignore errors that might be caused by partially typed queries. ;; Ignore errors that might be caused by partially typed queries.
(org-ql-select buffers-files query (org-ql-select buffers-files query
:action `(helm-org-ql--heading ,window-width)))))) :action `(point-marker))))))
:match #'identity :match #'identity
:fuzzy-match nil :fuzzy-match nil
:multimatch nil :multimatch nil
:nohighlight t :nohighlight t
:volatile t :match-dynamic t
:keymap helm-org-ql-map :keymap helm-org-ql-map
:action helm-org-ql-actions)) :action helm-org-ql-actions))