From 121af5c5d5d2ba10f1a4494dfb6538ae7d93c3d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Antol=C3=ADn=20Camarena?= Date: Fri, 8 Sep 2023 14:42:30 -0600 Subject: [PATCH 1/5] Add C-c C-e key binding to save an org-ql-find session --- org-ql-completing-read.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 9c4c044..4109557 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -322,7 +322,23 @@ single predicate)." (mapc #'org-ql--ensure-buffer buffers-files) (let* ((completion-styles '(org-ql-completing-read)) (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 () + (let ((map (make-sparse-keymap))) + (define-key + map (kbd "C-c C-e") + (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)))) + (use-local-map (make-composed-keymap map (current-local-map))))) + (completing-read prompt #'collection nil t)))) ;; (debug-message "SELECTED:%S KEYS:%S" selected (hash-table-keys table)) (or (gethash selected table) ;; If there are completions in the table, but none of them exactly match the user input From 0552aa8b93c3b8278742d0cf63c7d49878e0172d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Antol=C3=ADn?= Date: Mon, 18 Dec 2023 13:35:04 -0600 Subject: [PATCH 2/5] Use a keymap for the org-ql-view export functionality --- org-ql-completing-read.el | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 4109557..b290ed9 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -114,6 +114,17 @@ value, or nil." ;;;;; Completing read +(defun org-ql-export-view () + "Create `org-ql-view' buffer from current minibuffer org-ql search." + (interactive) + (user-error "Must be run from within an `org-ql-completing-read' session")) + +(defvar org-ql-completing-read-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c C-e") #'org-ql-export-view) + map) + "Keymap active during `org-ql-completing-read' minibuffer sessions.") + ;;;###autoload (cl-defun org-ql-completing-read (buffers-files &key query-prefix query-filter @@ -325,20 +336,20 @@ single predicate)." (selected (minibuffer-with-setup-hook (lambda () - (let ((map (make-sparse-keymap))) - (define-key - map (kbd "C-c C-e") - (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)))) - (use-local-map (make-composed-keymap map (current-local-map))))) - (completing-read prompt #'collection nil t)))) + (use-local-map (make-composed-keymap org-ql-completing-read-map (current-local-map)))) + (cl-letf* (((symbol-function 'org-ql-export-view) + (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-export-view))) + (completing-read prompt #'collection nil t))))) ;; (debug-message "SELECTED:%S KEYS:%S" selected (hash-table-keys table)) (or (gethash selected table) ;; If there are completions in the table, but none of them exactly match the user input From 2644f53fe2a69006a442a60e0e156fed061bb7e2 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 21 Dec 2023 16:35:25 -0600 Subject: [PATCH 3/5] Tidy, rename --- org-ql-completing-read.el | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index b290ed9..4c3e0f3 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -26,6 +26,12 @@ (require 'org-ql) +;;;; Variables + +(defvar-keymap org-ql-completing-read-map + :doc "Active during `org-ql-completing-read' sessions." + (kbd "C-c C-e") #'org-ql-completing-read-export) + ;;;; Customization (defgroup org-ql-completing-read nil @@ -114,16 +120,10 @@ value, or nil." ;;;;; Completing read -(defun org-ql-export-view () - "Create `org-ql-view' buffer from current minibuffer org-ql search." +(defun org-ql-completing-read-export () + "Show `org-ql-view' buffer for current `org-ql-completing-read'-based search." (interactive) - (user-error "Must be run from within an `org-ql-completing-read' session")) - -(defvar org-ql-completing-read-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "C-c C-e") #'org-ql-export-view) - map) - "Keymap active during `org-ql-completing-read' minibuffer sessions.") + (user-error "Not in an `org-ql-completing-read' session")) ;;;###autoload (cl-defun org-ql-completing-read @@ -337,7 +337,7 @@ single predicate)." (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-export-view) + (cl-letf* (((symbol-function 'org-ql-completing-read-export) (lambda () (interactive) (run-at-time 0 nil @@ -348,7 +348,7 @@ single predicate)." (minibuffer-quit-recursive-edit) (abort-recursive-edit)))) ((symbol-function 'embark-export) - (symbol-function 'org-ql-export-view))) + (symbol-function 'org-ql-completing-read-export))) (completing-read prompt #'collection nil t))))) ;; (debug-message "SELECTED:%S KEYS:%S" selected (hash-table-keys table)) (or (gethash selected table) From f4b006ffb956d7503d8072d9c3b76c9f77485113 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 21 Dec 2023 16:38:11 -0600 Subject: [PATCH 4/5] Remap embark-collect to embark-export --- org-ql-completing-read.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 4c3e0f3..a8053af 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -30,7 +30,11 @@ (defvar-keymap org-ql-completing-read-map :doc "Active during `org-ql-completing-read' sessions." - (kbd "C-c C-e") #'org-ql-completing-read-export) + "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 From f98dee54c8d73a6951a051a4e43afaf0048cbf0d Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 21 Dec 2023 16:48:52 -0600 Subject: [PATCH 5/5] Docs: Update changelog and usage --- README.org | 3 +- org-ql.info | 132 +++++++++++++++++++++++++++------------------------- 2 files changed, 71 insertions(+), 64 deletions(-) diff --git a/README.org b/README.org index 3d2f75e..bd34ecf 100644 --- a/README.org +++ b/README.org @@ -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-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]] @@ -558,6 +558,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *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]].) + - 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-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.) diff --git a/org-ql.info b/org-ql.info index ecc4d75..430d5a9 100644 --- a/org-ql.info +++ b/org-ql.info @@ -237,7 +237,9 @@ completion facilities with an Org QL query: Note that these commands are compatible with Embark (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 -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 @@ -1076,6 +1078,10 @@ File: README.info, Node: 08-pre, Next: 074, Up: Changelog Thanks to Omar Antolín Camarena (https://github.com/oantolin), Daniel Mendler (https://github.com/minad), and Akira Komamura (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 ‘org-ql-view’ buffer to search the buffers which contributed to the agenda/view buffer. @@ -1872,68 +1878,68 @@ Node: Helm support3142 Node: Usage3545 Node: Commands3943 Node: org-ql-find4408 -Node: org-ql-open-link5226 -Node: org-ql-refile6081 -Node: org-ql-search6409 -Node: helm-org-ql8340 -Node: org-ql-view8718 -Node: org-ql-view-sidebar9248 -Node: org-ql-view-recent-items9628 -Node: org-ql-sparse-tree10124 -Node: Queries10924 -Node: Non-sexp query syntax12041 -Node: General predicates13800 -Node: Ancestor/descendant predicates20725 -Node: Date/time predicates21853 -Node: Functions / Macros24977 -Node: Agenda-like views25275 -Ref: Function org-ql-block25437 -Node: Listing / acting-on results26698 -Ref: Caching26906 -Ref: Function org-ql-select27819 -Ref: Function org-ql-query30245 -Ref: Macro org-ql (deprecated)32019 -Node: Custom predicates32334 -Ref: Macro org-ql-defpred32558 -Node: Dynamic block35999 -Node: Links38723 -Node: Tips39410 -Node: Changelog39734 -Node: 08-pre40558 -Node: 07443031 -Node: 07343258 -Node: 07243990 -Node: 07144909 -Node: 0745718 -Node: 06348642 -Node: 06249173 -Node: 06149478 -Node: 0650046 -Node: 05253102 -Node: 05153404 -Node: 0553829 -Node: 04955360 -Node: 04855642 -Node: 04755991 -Node: 04656400 -Node: 04556808 -Node: 04457169 -Node: 04357528 -Node: 04257731 -Node: 04157892 -Node: 0458139 -Node: 03262240 -Node: 03162643 -Node: 0362840 -Node: 02366140 -Node: 02266374 -Node: 02166654 -Node: 0266859 -Node: 0170937 -Node: Notes71038 -Node: Comparison with Org Agenda searches71200 -Node: org-sidebar72089 -Node: License72368 +Node: org-ql-open-link5316 +Node: org-ql-refile6171 +Node: org-ql-search6499 +Node: helm-org-ql8430 +Node: org-ql-view8808 +Node: org-ql-view-sidebar9338 +Node: org-ql-view-recent-items9718 +Node: org-ql-sparse-tree10214 +Node: Queries11014 +Node: Non-sexp query syntax12131 +Node: General predicates13890 +Node: Ancestor/descendant predicates20815 +Node: Date/time predicates21943 +Node: Functions / Macros25067 +Node: Agenda-like views25365 +Ref: Function org-ql-block25527 +Node: Listing / acting-on results26788 +Ref: Caching26996 +Ref: Function org-ql-select27909 +Ref: Function org-ql-query30335 +Ref: Macro org-ql (deprecated)32109 +Node: Custom predicates32424 +Ref: Macro org-ql-defpred32648 +Node: Dynamic block36089 +Node: Links38813 +Node: Tips39500 +Node: Changelog39824 +Node: 08-pre40648 +Node: 07443372 +Node: 07343599 +Node: 07244331 +Node: 07145250 +Node: 0746059 +Node: 06348983 +Node: 06249514 +Node: 06149819 +Node: 0650387 +Node: 05253443 +Node: 05153745 +Node: 0554170 +Node: 04955701 +Node: 04855983 +Node: 04756332 +Node: 04656741 +Node: 04557149 +Node: 04457510 +Node: 04357869 +Node: 04258072 +Node: 04158233 +Node: 0458480 +Node: 03262581 +Node: 03162984 +Node: 0363181 +Node: 02366481 +Node: 02266715 +Node: 02166995 +Node: 0267200 +Node: 0171278 +Node: Notes71379 +Node: Comparison with Org Agenda searches71541 +Node: org-sidebar72430 +Node: License72709  End Tag Table