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'."
|
||||
:type 'sexp)
|
||||
|
||||
;;;; Functions
|
||||
;;;; Commands
|
||||
|
||||
;;;###autoload
|
||||
(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
|
||||
treated as multiple predicates, into multiple arguments to a
|
||||
single predicate)."
|
||||
(interactive
|
||||
(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)))))))
|
||||
(interactive (list (org-ql-find--buffers)))
|
||||
(let ((marker (org-ql-completing-read buffers-files
|
||||
:query-prefix query-prefix
|
||||
:query-filter query-filter
|
||||
|
|
@ -135,12 +123,16 @@ which see (but only the files are used)."
|
|||
(org-ql-find (org-ql-search-directories-files)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-ql-find-path ()
|
||||
"Call `org-ql-find' to search outline paths in the current buffer."
|
||||
;; TODO: Use same interactive form as `org-ql-find'.
|
||||
(interactive)
|
||||
(defun org-ql-find-path (buffers-files)
|
||||
"Call `org-ql-find' to search outline paths in BUFFERS-FILES.
|
||||
Interactively, search the buffers and files relevant to the
|
||||
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))
|
||||
(org-ql-find (current-buffer))))
|
||||
(org-ql-find buffers-files)))
|
||||
|
||||
;;;###autoload
|
||||
(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
|
||||
`org-open-at-point'. Arguments BUFFERS-FILES, QUERY-FILTER,
|
||||
QUERY-PREFIX, and PROMPT are passed to `org-ql-completing-read',
|
||||
which see."
|
||||
(interactive
|
||||
;; FIXME: Factor this out.
|
||||
(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))
|
||||
(progn
|
||||
(unless (eq major-mode 'org-mode)
|
||||
(user-error "This is not an Org buffer: %S" (current-buffer)))
|
||||
(current-buffer)))))
|
||||
which see.
|
||||
|
||||
Interactively, search the buffers and files relevant to the
|
||||
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* ((marker (org-ql-completing-read buffers-files
|
||||
:query-prefix query-prefix
|
||||
:query-filter query-filter
|
||||
|
|
@ -193,6 +178,29 @@ which see."
|
|||
(org-with-point-at marker
|
||||
(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)
|
||||
|
||||
;;; org-ql-find.el ends here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue