diff --git a/README.org b/README.org index 10d6e07..9c9d734 100644 --- a/README.org +++ b/README.org @@ -117,6 +117,10 @@ These commands jump to a heading selected using Emacs's built-in completion faci [[images/org-ql-find.png]] +*** org-ql-refile + +This command refiles the current Org entry to one selected by searching with Org QL completion. It searches files listed in ~org-refile-targets~ as well as the current buffer. + *** org-ql-search /Note: This command supports both sexp queries and [[#non-sexp-query-syntax][non-sexp queries]]./ @@ -542,6 +546,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *Added* + Commands ~org-ql-find~, ~org-ql-find-heading~, and ~org-ql-find-path~, which jump to entries selected using Emacs's built-in completion facilities and Org QL queries (like ~helm-org-ql~, but doesn't require Helm.). ++ Command ~org-ql-refile~, which refiles the entry at point to one selected using Org QL completion. + Predicate ~rifle~, which matches an entry if each of the given arguments is found in either the entry's contents or its outline path. This provides very intuitive results, mimicing the behavior of [[https://github.com/alphapapa/org-rifle][=org-rifle=]]. In fact, the results are so useful that it's now the default predicate for plain-string query tokens. (It is also aliased to ~smart~, since it's so "smart," and not all users have used =org-rifle=.) + Option ~org-ql-default-predicate~, applied to plain-string query tokens (before, the ~regexp~ predicate was always used, but now it may be customized). diff --git a/org-ql-find.el b/org-ql-find.el index a85b937..5a482f7 100644 --- a/org-ql-find.el +++ b/org-ql-find.el @@ -84,6 +84,35 @@ single predicate)." (select-window (get-buffer-window (current-buffer))) (run-hook-with-args 'org-ql-find-goto-hook)))) +;;;###autoload +(defun org-ql-refile (marker) + "Refile current entry to MARKER (interactively, one selected with `org-ql'). +Interactive completion uses files listed in `org-refile-targets', +which see (but only the files are used)." + (interactive (let ((buffers-files (delete-dups + ;; Always include the current buffer. + (cons (current-buffer) + (cl-loop for (files-spec . _candidate-spec) in org-refile-targets + append (cl-typecase files-spec + (null (list (current-buffer))) + (symbol (pcase (funcall files-spec) + ((and (pred stringp) file) (list file)) + ((and (pred listp) files) files))) + (list files-spec))))))) + (list (org-ql-completing-read buffers-files :prompt "Refile to: ")))) + (org-refile nil nil + ;; The RFLOC argument: + (list + ;; Name + (org-with-point-at marker + (nth 4 (org-heading-components))) + ;; File + (buffer-file-name (marker-buffer marker)) + ;; nil + nil + ;; Position + marker))) + ;;;###autoload (defun org-ql-find-in-agenda () "Call `org-ql-find' on `org-agenda-files'." diff --git a/org-ql.info b/org-ql.info index cfb9896..96fb8e4 100644 --- a/org-ql.info +++ b/org-ql.info @@ -48,6 +48,7 @@ Usage Commands * org-ql-find:: +* org-ql-refile:: * org-ql-search:: * helm-org-ql:: * org-ql-view:: @@ -201,6 +202,7 @@ File: README.info, Node: Commands, Next: Queries, Up: Usage * Menu: * org-ql-find:: +* org-ql-refile:: * org-ql-search:: * helm-org-ql:: * org-ql-view:: @@ -209,7 +211,7 @@ File: README.info, Node: Commands, Next: Queries, Up: Usage * org-ql-sparse-tree::  -File: README.info, Node: org-ql-find, Next: org-ql-search, Up: Commands +File: README.info, Node: org-ql-find, Next: org-ql-refile, Up: Commands 4.1.1 org-ql-find ----------------- @@ -224,9 +226,19 @@ completion facilities with an Org QL query: • ‘org-ql-find-in-org-directory’ searches in ‘org-directory’.  -File: README.info, Node: org-ql-search, Next: helm-org-ql, Prev: org-ql-find, Up: Commands +File: README.info, Node: org-ql-refile, Next: org-ql-search, Prev: org-ql-find, Up: Commands -4.1.2 org-ql-search +4.1.2 org-ql-refile +------------------- + +This command refiles the current Org entry to one selected by searching +with Org QL completion. It searches files listed in +‘org-refile-targets’ as well as the current buffer. + + +File: README.info, Node: org-ql-search, Next: helm-org-ql, Prev: org-ql-refile, Up: Commands + +4.1.3 org-ql-search ------------------- _Note: This command supports both sexp queries and ._ @@ -269,7 +281,7 @@ text properties are placed on each item, imitating an Agenda buffer.)  File: README.info, Node: helm-org-ql, Next: org-ql-view, Prev: org-ql-search, Up: Commands -4.1.3 helm-org-ql +4.1.4 helm-org-ql ----------------- _Note: This command uses . It is available separately in the package @@ -283,7 +295,7 @@ _Note: This command uses . It is available separately in the package  File: README.info, Node: org-ql-view, Next: org-ql-view-sidebar, Prev: helm-org-ql, Up: Commands -4.1.4 org-ql-view +4.1.5 org-ql-view ----------------- Choose and display a view stored in ‘org-ql-views’. @@ -298,7 +310,7 @@ Choose and display a view stored in ‘org-ql-views’.  File: README.info, Node: org-ql-view-sidebar, Next: org-ql-view-recent-items, Prev: org-ql-view, Up: Commands -4.1.5 org-ql-view-sidebar +4.1.6 org-ql-view-sidebar ------------------------- Show a sidebar window listing views stored in ‘org-ql-views’ for easy @@ -308,7 +320,7 @@ point, and press ‘c’ to customize the view at point.  File: README.info, Node: org-ql-view-recent-items, Next: org-ql-sparse-tree, Prev: org-ql-view-sidebar, Up: Commands -4.1.6 org-ql-view-recent-items +4.1.7 org-ql-view-recent-items ------------------------------ Show items in ‘FILES’ from last ‘DAYS’ days with timestamps of ‘TYPE’. @@ -319,7 +331,7 @@ returned by the function ‘org-agenda-files’.  File: README.info, Node: org-ql-sparse-tree, Prev: org-ql-view-recent-items, Up: Commands -4.1.7 org-ql-sparse-tree +4.1.8 org-ql-sparse-tree ------------------------ Arguments: ‘(query &key keep-previous (buffer (current-buffer)))’ @@ -1009,6 +1021,8 @@ File: README.info, Node: 07-pre, Next: 062, Up: Changelog ‘org-ql-find-path’, which jump to entries selected using Emacs’s built-in completion facilities and Org QL queries (like ‘helm-org-ql’, but doesn’t require Helm.). + • Command ‘org-ql-refile’, which refiles the entry at point to one + selected using Org QL completion. • Predicate ‘rifle’, which matches an entry if each of the given arguments is found in either the entry’s contents or its outline path. This provides very intuitive results, mimicing the behavior @@ -1639,68 +1653,69 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1764 -Node: Screenshots1887 -Node: Installation2005 -Node: Quelpa2519 -Node: Helm support3047 -Node: Usage3450 -Node: Commands3848 -Node: org-ql-find4274 -Node: org-ql-search4740 -Node: helm-org-ql6434 -Node: org-ql-view6812 -Node: org-ql-view-sidebar7342 -Node: org-ql-view-recent-items7722 -Node: org-ql-sparse-tree8218 -Node: Queries9018 -Node: Non-sexp query syntax10135 -Node: General predicates11894 -Node: Ancestor/descendant predicates18636 -Node: Date/time predicates19764 -Node: Functions / Macros22888 -Node: Agenda-like views23186 -Ref: Function ‘org-ql-block’23348 -Node: Listing / acting-on results24609 -Ref: Caching24817 -Ref: Function ‘org-ql-select’25730 -Ref: Function ‘org-ql-query’28156 -Ref: Macro ‘org-ql’ (deprecated)29930 -Node: Custom predicates30245 -Ref: Macro ‘org-ql-defpred’30469 -Node: Dynamic block33910 -Node: Links36634 -Node: Tips37321 -Node: Changelog37645 -Node: 07-pre38413 -Node: 06239820 -Node: 06140128 -Node: 0640696 -Node: 05243750 -Node: 05144050 -Node: 0544473 -Node: 04946002 -Node: 04846282 -Node: 04746629 -Node: 04647038 -Node: 04547446 -Node: 04447807 -Node: 04348166 -Node: 04248369 -Node: 04148530 -Node: 0448777 -Node: 03252878 -Node: 03153281 -Node: 0353478 -Node: 02356778 -Node: 02257012 -Node: 02157292 -Node: 0257497 -Node: 0161575 -Node: Notes61676 -Node: Comparison with Org Agenda searches61838 -Node: org-sidebar62727 -Node: License63006 +Node: Contents1782 +Node: Screenshots1905 +Node: Installation2023 +Node: Quelpa2537 +Node: Helm support3065 +Node: Usage3468 +Node: Commands3866 +Node: org-ql-find4310 +Node: org-ql-refile4776 +Node: org-ql-search5099 +Node: helm-org-ql6795 +Node: org-ql-view7173 +Node: org-ql-view-sidebar7703 +Node: org-ql-view-recent-items8083 +Node: org-ql-sparse-tree8579 +Node: Queries9379 +Node: Non-sexp query syntax10496 +Node: General predicates12255 +Node: Ancestor/descendant predicates18997 +Node: Date/time predicates20125 +Node: Functions / Macros23249 +Node: Agenda-like views23547 +Ref: Function ‘org-ql-block’23709 +Node: Listing / acting-on results24970 +Ref: Caching25178 +Ref: Function ‘org-ql-select’26091 +Ref: Function ‘org-ql-query’28517 +Ref: Macro ‘org-ql’ (deprecated)30291 +Node: Custom predicates30606 +Ref: Macro ‘org-ql-defpred’30830 +Node: Dynamic block34271 +Node: Links36995 +Node: Tips37682 +Node: Changelog38006 +Node: 07-pre38774 +Node: 06240296 +Node: 06140604 +Node: 0641172 +Node: 05244226 +Node: 05144526 +Node: 0544949 +Node: 04946478 +Node: 04846758 +Node: 04747105 +Node: 04647514 +Node: 04547922 +Node: 04448283 +Node: 04348642 +Node: 04248845 +Node: 04149006 +Node: 0449253 +Node: 03253354 +Node: 03153757 +Node: 0353954 +Node: 02357254 +Node: 02257488 +Node: 02157768 +Node: 0257973 +Node: 0162051 +Node: Notes62152 +Node: Comparison with Org Agenda searches62314 +Node: org-sidebar63203 +Node: License63482  End Tag Table