Merge: org-ql-completing-read-export

This commit is contained in:
Adam Porter 2023-12-21 16:49:13 -06:00
commit 08497a1648
3 changed files with 103 additions and 65 deletions

View file

@ -115,7 +115,7 @@ These commands jump to a heading selected using Emacs's built-in completion faci
- ~org-ql-find-in-agenda~ searches in ~(org-agenda-files)~. - ~org-ql-find-in-agenda~ searches in ~(org-agenda-files)~.
- ~org-ql-find-in-org-directory~ searches in ~org-directory~. - ~org-ql-find-in-org-directory~ searches in ~org-directory~.
Note that these commands are compatible with [[https://github.com/oantolin/embark][Embark]]: the ~embark-act~ command can be called on a completion candidate (i.e. a search result) to act on it immediately, without having to visit the entry in its source Org buffer. Note that these commands are compatible with [[https://github.com/oantolin/embark][Embark]]: the ~embark-act~ command can be called on a completion candidate (i.e. a search result) to act on it immediately, without having to visit the entry in its source Org buffer, and ~embark-export~ may be called to show the results in an ~org-ql-view~ buffer.
[[images/org-ql-find.png]] [[images/org-ql-find.png]]
@ -558,6 +558,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
*Additions* *Additions*
+ Function ~org-ql-completing-read~, used by command ~org-ql-find~, now specifies the completion category as ~org-heading~, providing compatibility with [[https://github.com/oantolin/embark][Embark]]. (This is a powerful feature, as it means any ~org-ql-find~ result can be acted on from inside the search results with Embark, which provides common actions from Org Agenda and Org speed keys bindings.) ([[https://github.com/alphapapa/org-ql/issues/299][#299]]. Thanks to [[https://github.com/oantolin][Omar Antolín Camarena]], [[https://github.com/minad][Daniel Mendler]], and [[https://github.com/akirak][Akira Komamura]].) + Function ~org-ql-completing-read~, used by command ~org-ql-find~, now specifies the completion category as ~org-heading~, providing compatibility with [[https://github.com/oantolin/embark][Embark]]. (This is a powerful feature, as it means any ~org-ql-find~ result can be acted on from inside the search results with Embark, which provides common actions from Org Agenda and Org speed keys bindings.) ([[https://github.com/alphapapa/org-ql/issues/299][#299]]. Thanks to [[https://github.com/oantolin][Omar Antolín Camarena]], [[https://github.com/minad][Daniel Mendler]], and [[https://github.com/akirak][Akira Komamura]].)
- Command ~org-ql-completing-read-export~, bound to ~C-c C-e~ or ~embark-export~ while in an ~org-ql-completing-read~ session, exits and shows an ~org-ql-view~ buffer for the current search.
+ Command ~org-ql-find~ may be called in an ~org-agenda~ or ~org-ql-view~ buffer to search the buffers which contributed to the agenda/view buffer. + Command ~org-ql-find~ may be called in an ~org-agenda~ or ~org-ql-view~ buffer to search the buffers which contributed to the agenda/view buffer.
+ Command ~org-ql-find-path~, which searches outline paths in the current buffer. + Command ~org-ql-find-path~, which searches outline paths in the current buffer.
+ Command ~org-ql-open-link~, which finds links in entries matching the given query, and opens the selected one with ~org-open-at-point~. (This is helpful when a collection of links are kept in Org files: rather than having to first visit the entry containing the desired link, then locate it within the entry, and then open it, the user can simply select the link and open it directly.) + Command ~org-ql-open-link~, which finds links in entries matching the given query, and opens the selected one with ~org-open-at-point~. (This is helpful when a collection of links are kept in Org files: rather than having to first visit the entry containing the desired link, then locate it within the entry, and then open it, the user can simply select the link and open it directly.)

View file

@ -26,6 +26,16 @@
(require 'org-ql) (require 'org-ql)
;;;; Variables
(defvar-keymap org-ql-completing-read-map
:doc "Active during `org-ql-completing-read' sessions."
"C-c C-e" #'org-ql-completing-read-export)
;; `embark-collect' doesn't work for `org-ql-completing-read', so remap
;; it to `embark-export' (which `keymap-set', et al doesn't allow).
(define-key org-ql-completing-read-map [remap embark-collect] 'embark-export)
;;;; Customization ;;;; Customization
(defgroup org-ql-completing-read nil (defgroup org-ql-completing-read nil
@ -114,6 +124,11 @@ value, or nil."
;;;;; Completing read ;;;;; Completing read
(defun org-ql-completing-read-export ()
"Show `org-ql-view' buffer for current `org-ql-completing-read'-based search."
(interactive)
(user-error "Not in an `org-ql-completing-read' session"))
;;;###autoload ;;;###autoload
(cl-defun org-ql-completing-read (cl-defun org-ql-completing-read
(buffers-files &key query-prefix query-filter (buffers-files &key query-prefix query-filter
@ -322,7 +337,23 @@ single predicate)."
(mapc #'org-ql--ensure-buffer buffers-files) (mapc #'org-ql--ensure-buffer buffers-files)
(let* ((completion-styles '(org-ql-completing-read)) (let* ((completion-styles '(org-ql-completing-read))
(completion-styles-alist (list (list 'org-ql-completing-read #'try #'all "Org QL Find"))) (completion-styles-alist (list (list 'org-ql-completing-read #'try #'all "Org QL Find")))
(selected (completing-read prompt #'collection nil t))) (selected
(minibuffer-with-setup-hook
(lambda ()
(use-local-map (make-composed-keymap org-ql-completing-read-map (current-local-map))))
(cl-letf* (((symbol-function 'org-ql-completing-read-export)
(lambda ()
(interactive)
(run-at-time 0 nil
#'org-ql-search
buffers-files
(minibuffer-contents-no-properties))
(if (fboundp 'minibuffer-quit-recursive-edit)
(minibuffer-quit-recursive-edit)
(abort-recursive-edit))))
((symbol-function 'embark-export)
(symbol-function 'org-ql-completing-read-export)))
(completing-read prompt #'collection nil t)))))
;; (debug-message "SELECTED:%S KEYS:%S" selected (hash-table-keys table)) ;; (debug-message "SELECTED:%S KEYS:%S" selected (hash-table-keys table))
(or (gethash selected table) (or (gethash selected table)
;; If there are completions in the table, but none of them exactly match the user input ;; If there are completions in the table, but none of them exactly match the user input

View file

@ -237,7 +237,9 @@ completion facilities with an Org QL query:
Note that these commands are compatible with Embark Note that these commands are compatible with Embark
(https://github.com/oantolin/embark): the embark-act command can be (https://github.com/oantolin/embark): the embark-act command can be
called on a completion candidate (i.e. a search result) to act on it called on a completion candidate (i.e. a search result) to act on it
immediately, without having to visit the entry in its source Org buffer. immediately, without having to visit the entry in its source Org buffer,
and embark-export may be called to show the results in an
org-ql-view buffer.
 
File: README.info, Node: org-ql-open-link, Next: org-ql-refile, Prev: org-ql-find, Up: Commands File: README.info, Node: org-ql-open-link, Next: org-ql-refile, Prev: org-ql-find, Up: Commands
@ -1076,6 +1078,10 @@ File: README.info, Node: 08-pre, Next: 074, Up: Changelog
Thanks to Omar Antolín Camarena (https://github.com/oantolin), Thanks to Omar Antolín Camarena (https://github.com/oantolin),
Daniel Mendler (https://github.com/minad), and Akira Komamura Daniel Mendler (https://github.com/minad), and Akira Komamura
(https://github.com/akirak).) (https://github.com/akirak).)
• Command org-ql-completing-read-export, bound to C-c C-e or
embark-export while in an org-ql-completing-read session,
exits and shows an org-ql-view buffer for the current
search.
• Command org-ql-find may be called in an org-agenda or • Command org-ql-find may be called in an org-agenda or
org-ql-view buffer to search the buffers which contributed to the org-ql-view buffer to search the buffers which contributed to the
agenda/view buffer. agenda/view buffer.
@ -1872,68 +1878,68 @@ Node: Helm support3142
Node: Usage3545 Node: Usage3545
Node: Commands3943 Node: Commands3943
Node: org-ql-find4408 Node: org-ql-find4408
Node: org-ql-open-link5226 Node: org-ql-open-link5316
Node: org-ql-refile6081 Node: org-ql-refile6171
Node: org-ql-search6409 Node: org-ql-search6499
Node: helm-org-ql8340 Node: helm-org-ql8430
Node: org-ql-view8718 Node: org-ql-view8808
Node: org-ql-view-sidebar9248 Node: org-ql-view-sidebar9338
Node: org-ql-view-recent-items9628 Node: org-ql-view-recent-items9718
Node: org-ql-sparse-tree10124 Node: org-ql-sparse-tree10214
Node: Queries10924 Node: Queries11014
Node: Non-sexp query syntax12041 Node: Non-sexp query syntax12131
Node: General predicates13800 Node: General predicates13890
Node: Ancestor/descendant predicates20725 Node: Ancestor/descendant predicates20815
Node: Date/time predicates21853 Node: Date/time predicates21943
Node: Functions / Macros24977 Node: Functions / Macros25067
Node: Agenda-like views25275 Node: Agenda-like views25365
Ref: Function org-ql-block25437 Ref: Function org-ql-block25527
Node: Listing / acting-on results26698 Node: Listing / acting-on results26788
Ref: Caching26906 Ref: Caching26996
Ref: Function org-ql-select27819 Ref: Function org-ql-select27909
Ref: Function org-ql-query30245 Ref: Function org-ql-query30335
Ref: Macro org-ql (deprecated)32019 Ref: Macro org-ql (deprecated)32109
Node: Custom predicates32334 Node: Custom predicates32424
Ref: Macro org-ql-defpred32558 Ref: Macro org-ql-defpred32648
Node: Dynamic block35999 Node: Dynamic block36089
Node: Links38723 Node: Links38813
Node: Tips39410 Node: Tips39500
Node: Changelog39734 Node: Changelog39824
Node: 08-pre40558 Node: 08-pre40648
Node: 07443031 Node: 07443372
Node: 07343258 Node: 07343599
Node: 07243990 Node: 07244331
Node: 07144909 Node: 07145250
Node: 0745718 Node: 0746059
Node: 06348642 Node: 06348983
Node: 06249173 Node: 06249514
Node: 06149478 Node: 06149819
Node: 0650046 Node: 0650387
Node: 05253102 Node: 05253443
Node: 05153404 Node: 05153745
Node: 0553829 Node: 0554170
Node: 04955360 Node: 04955701
Node: 04855642 Node: 04855983
Node: 04755991 Node: 04756332
Node: 04656400 Node: 04656741
Node: 04556808 Node: 04557149
Node: 04457169 Node: 04457510
Node: 04357528 Node: 04357869
Node: 04257731 Node: 04258072
Node: 04157892 Node: 04158233
Node: 0458139 Node: 0458480
Node: 03262240 Node: 03262581
Node: 03162643 Node: 03162984
Node: 0362840 Node: 0363181
Node: 02366140 Node: 02366481
Node: 02266374 Node: 02266715
Node: 02166654 Node: 02166995
Node: 0266859 Node: 0267200
Node: 0170937 Node: 0171278
Node: Notes71038 Node: Notes71379
Node: Comparison with Org Agenda searches71200 Node: Comparison with Org Agenda searches71541
Node: org-sidebar72089 Node: org-sidebar72430
Node: License72368 Node: License72709
 
End Tag Table End Tag Table