Change: (org-ql-find.el) Factor out interactive form
And use in org-ql-find-path.
This commit is contained in:
parent
e885001a2a
commit
72b9934d1f
1 changed files with 42 additions and 34 deletions
|
|
@ -49,7 +49,7 @@
|
||||||
See function `display-buffer'."
|
See function `display-buffer'."
|
||||||
:type 'sexp)
|
:type 'sexp)
|
||||||
|
|
||||||
;;;; Functions
|
;;;; Commands
|
||||||
|
|
||||||
;;;###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
|
||||||
|
|
@ -70,19 +70,7 @@ 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)."
|
||||||
(interactive
|
(interactive (list (org-ql-find--buffers)))
|
||||||
(list (if current-prefix-arg
|
|
||||||
(mapcar #'get-buffer
|
|
||||||
(completing-read-multiple
|
|
||||||
"Buffers: "
|
|
||||||
(cl-loop for buffer in (buffer-list)
|
|
||||||
when (eq 'org-mode (buffer-local-value 'major-mode buffer))
|
|
||||||
collect (buffer-name buffer))
|
|
||||||
nil t))
|
|
||||||
(cond ((derived-mode-p 'org-agenda-mode) (or org-ql-view-buffers-files
|
|
||||||
org-agenda-contributing-files))
|
|
||||||
((derived-mode-p 'org-mode) (current-buffer))
|
|
||||||
(t (user-error "This is not an Org-related buffer: %S" (current-buffer)))))))
|
|
||||||
(let ((marker (org-ql-completing-read buffers-files
|
(let ((marker (org-ql-completing-read buffers-files
|
||||||
:query-prefix query-prefix
|
:query-prefix query-prefix
|
||||||
:query-filter query-filter
|
:query-filter query-filter
|
||||||
|
|
@ -135,12 +123,16 @@ which see (but only the files are used)."
|
||||||
(org-ql-find (org-ql-search-directories-files)))
|
(org-ql-find (org-ql-search-directories-files)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun org-ql-find-path ()
|
(defun org-ql-find-path (buffers-files)
|
||||||
"Call `org-ql-find' to search outline paths in the current buffer."
|
"Call `org-ql-find' to search outline paths in BUFFERS-FILES.
|
||||||
;; TODO: Use same interactive form as `org-ql-find'.
|
Interactively, search the buffers and files relevant to the
|
||||||
(interactive)
|
current buffer (i.e. in `org-agenda-mode', the value of
|
||||||
|
`org-ql-view-buffers-files' or `org-agenda-contributing-files';
|
||||||
|
in `org-mode', that buffer). With universal prefix, select
|
||||||
|
multiple buffers to search with completion and PROMPT."
|
||||||
|
(interactive (list (org-ql-find--buffers)))
|
||||||
(let ((org-ql-default-predicate 'outline-path))
|
(let ((org-ql-default-predicate 'outline-path))
|
||||||
(org-ql-find (current-buffer))))
|
(org-ql-find buffers-files)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(cl-defun org-ql-open-link (buffers-files &key query-prefix query-filter
|
(cl-defun org-ql-open-link (buffers-files &key query-prefix query-filter
|
||||||
|
|
@ -150,21 +142,14 @@ Links found in entries matching the input query are offered as
|
||||||
candidates, and the selected one is opened with
|
candidates, and the selected one is opened with
|
||||||
`org-open-at-point'. Arguments BUFFERS-FILES, QUERY-FILTER,
|
`org-open-at-point'. Arguments BUFFERS-FILES, QUERY-FILTER,
|
||||||
QUERY-PREFIX, and PROMPT are passed to `org-ql-completing-read',
|
QUERY-PREFIX, and PROMPT are passed to `org-ql-completing-read',
|
||||||
which see."
|
which see.
|
||||||
(interactive
|
|
||||||
;; FIXME: Factor this out.
|
Interactively, search the buffers and files relevant to the
|
||||||
(list (if current-prefix-arg
|
current buffer (i.e. in `org-agenda-mode', the value of
|
||||||
(mapcar #'get-buffer
|
`org-ql-view-buffers-files' or `org-agenda-contributing-files';
|
||||||
(completing-read-multiple
|
in `org-mode', that buffer). With universal prefix, select
|
||||||
"Buffers: "
|
multiple buffers to search with completion and PROMPT."
|
||||||
(cl-loop for buffer in (buffer-list)
|
(interactive (list (org-ql-find--buffers)))
|
||||||
when (eq 'org-mode (buffer-local-value 'major-mode buffer))
|
|
||||||
collect (buffer-name buffer))
|
|
||||||
nil t))
|
|
||||||
(progn
|
|
||||||
(unless (eq major-mode 'org-mode)
|
|
||||||
(user-error "This is not an Org buffer: %S" (current-buffer)))
|
|
||||||
(current-buffer)))))
|
|
||||||
(let* ((marker (org-ql-completing-read buffers-files
|
(let* ((marker (org-ql-completing-read buffers-files
|
||||||
:query-prefix query-prefix
|
:query-prefix query-prefix
|
||||||
:query-filter query-filter
|
:query-filter query-filter
|
||||||
|
|
@ -193,6 +178,29 @@ which see."
|
||||||
(org-with-point-at marker
|
(org-with-point-at marker
|
||||||
(org-open-at-point))))
|
(org-open-at-point))))
|
||||||
|
|
||||||
|
;;;; Functions
|
||||||
|
|
||||||
|
(defun org-ql-find--buffers ()
|
||||||
|
"Return list of buffers to search in.
|
||||||
|
In a mode derived from `org-agenda-mode', return the value of
|
||||||
|
`org-ql-view-buffers-files' or `org-agenda-contributing-files'.
|
||||||
|
In a mode derived from `org-mode', return the current buffer.
|
||||||
|
When `current-prefix-arg', read a list of buffers in `org-mode'
|
||||||
|
with completion. To be used in `org-ql-find' commands'
|
||||||
|
interactive forms."
|
||||||
|
(if current-prefix-arg
|
||||||
|
(mapcar #'get-buffer
|
||||||
|
(completing-read-multiple
|
||||||
|
"Buffers: "
|
||||||
|
(cl-loop for buffer in (buffer-list)
|
||||||
|
when (eq 'org-mode (buffer-local-value 'major-mode buffer))
|
||||||
|
collect (buffer-name buffer))
|
||||||
|
nil t))
|
||||||
|
(cond ((derived-mode-p 'org-agenda-mode) (or org-ql-view-buffers-files
|
||||||
|
org-agenda-contributing-files))
|
||||||
|
((derived-mode-p 'org-mode) (current-buffer))
|
||||||
|
(t (user-error "This is not an Org-related buffer: %S" (current-buffer))))))
|
||||||
|
|
||||||
(provide 'org-ql-find)
|
(provide 'org-ql-find)
|
||||||
|
|
||||||
;;; org-ql-find.el ends here
|
;;; org-ql-find.el ends here
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue