Add: (org-ql-refile)

This commit is contained in:
Adam Porter 2022-08-19 03:18:14 -05:00
parent cfa3b307ec
commit 7f4faff27b
3 changed files with 119 additions and 70 deletions

View file

@ -117,6 +117,10 @@ These commands jump to a heading selected using Emacs's built-in completion faci
[[images/org-ql-find.png]] [[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 *** org-ql-search
/Note: This command supports both sexp queries and [[#non-sexp-query-syntax][non-sexp queries]]./ /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* *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.). + 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=.) + 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). + Option ~org-ql-default-predicate~, applied to plain-string query tokens (before, the ~regexp~ predicate was always used, but now it may be customized).

View file

@ -84,6 +84,35 @@ single predicate)."
(select-window (get-buffer-window (current-buffer))) (select-window (get-buffer-window (current-buffer)))
(run-hook-with-args 'org-ql-find-goto-hook)))) (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 ;;;###autoload
(defun org-ql-find-in-agenda () (defun org-ql-find-in-agenda ()
"Call `org-ql-find' on `org-agenda-files'." "Call `org-ql-find' on `org-agenda-files'."

View file

@ -48,6 +48,7 @@ Usage
Commands Commands
* org-ql-find:: * org-ql-find::
* org-ql-refile::
* org-ql-search:: * org-ql-search::
* helm-org-ql:: * helm-org-ql::
* org-ql-view:: * org-ql-view::
@ -201,6 +202,7 @@ File: README.info, Node: Commands, Next: Queries, Up: Usage
* Menu: * Menu:
* org-ql-find:: * org-ql-find::
* org-ql-refile::
* org-ql-search:: * org-ql-search::
* helm-org-ql:: * helm-org-ql::
* org-ql-view:: * org-ql-view::
@ -209,7 +211,7 @@ File: README.info, Node: Commands, Next: Queries, Up: Usage
* org-ql-sparse-tree:: * 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 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. 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 ._ _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 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 _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 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. 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 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 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 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. 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 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))) 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 Emacss org-ql-find-path, which jump to entries selected using Emacss
built-in completion facilities and Org QL queries (like built-in completion facilities and Org QL queries (like
helm-org-ql, but doesnt require Helm.). helm-org-ql, but doesnt 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 • Predicate rifle, which matches an entry if each of the given
arguments is found in either the entrys contents or its outline arguments is found in either the entrys contents or its outline
path. This provides very intuitive results, mimicing the behavior path. This provides very intuitive results, mimicing the behavior
@ -1639,68 +1653,69 @@ GPLv3
 
Tag Table: Tag Table:
Node: Top225 Node: Top225
Node: Contents1764 Node: Contents1782
Node: Screenshots1887 Node: Screenshots1905
Node: Installation2005 Node: Installation2023
Node: Quelpa2519 Node: Quelpa2537
Node: Helm support3047 Node: Helm support3065
Node: Usage3450 Node: Usage3468
Node: Commands3848 Node: Commands3866
Node: org-ql-find4274 Node: org-ql-find4310
Node: org-ql-search4740 Node: org-ql-refile4776
Node: helm-org-ql6434 Node: org-ql-search5099
Node: org-ql-view6812 Node: helm-org-ql6795
Node: org-ql-view-sidebar7342 Node: org-ql-view7173
Node: org-ql-view-recent-items7722 Node: org-ql-view-sidebar7703
Node: org-ql-sparse-tree8218 Node: org-ql-view-recent-items8083
Node: Queries9018 Node: org-ql-sparse-tree8579
Node: Non-sexp query syntax10135 Node: Queries9379
Node: General predicates11894 Node: Non-sexp query syntax10496
Node: Ancestor/descendant predicates18636 Node: General predicates12255
Node: Date/time predicates19764 Node: Ancestor/descendant predicates18997
Node: Functions / Macros22888 Node: Date/time predicates20125
Node: Agenda-like views23186 Node: Functions / Macros23249
Ref: Function org-ql-block23348 Node: Agenda-like views23547
Node: Listing / acting-on results24609 Ref: Function org-ql-block23709
Ref: Caching24817 Node: Listing / acting-on results24970
Ref: Function org-ql-select25730 Ref: Caching25178
Ref: Function org-ql-query28156 Ref: Function org-ql-select26091
Ref: Macro org-ql (deprecated)29930 Ref: Function org-ql-query28517
Node: Custom predicates30245 Ref: Macro org-ql (deprecated)30291
Ref: Macro org-ql-defpred30469 Node: Custom predicates30606
Node: Dynamic block33910 Ref: Macro org-ql-defpred30830
Node: Links36634 Node: Dynamic block34271
Node: Tips37321 Node: Links36995
Node: Changelog37645 Node: Tips37682
Node: 07-pre38413 Node: Changelog38006
Node: 06239820 Node: 07-pre38774
Node: 06140128 Node: 06240296
Node: 0640696 Node: 06140604
Node: 05243750 Node: 0641172
Node: 05144050 Node: 05244226
Node: 0544473 Node: 05144526
Node: 04946002 Node: 0544949
Node: 04846282 Node: 04946478
Node: 04746629 Node: 04846758
Node: 04647038 Node: 04747105
Node: 04547446 Node: 04647514
Node: 04447807 Node: 04547922
Node: 04348166 Node: 04448283
Node: 04248369 Node: 04348642
Node: 04148530 Node: 04248845
Node: 0448777 Node: 04149006
Node: 03252878 Node: 0449253
Node: 03153281 Node: 03253354
Node: 0353478 Node: 03153757
Node: 02356778 Node: 0353954
Node: 02257012 Node: 02357254
Node: 02157292 Node: 02257488
Node: 0257497 Node: 02157768
Node: 0161575 Node: 0257973
Node: Notes61676 Node: 0162051
Node: Comparison with Org Agenda searches61838 Node: Notes62152
Node: org-sidebar62727 Node: Comparison with Org Agenda searches62314
Node: License63006 Node: org-sidebar63203
Node: License63482
 
End Tag Table End Tag Table