Use consult for querying Org refile locations
This commit is contained in:
parent
44fb922b66
commit
1ccc8d927d
10
init.el
10
init.el
@ -703,6 +703,7 @@ split horizontally again, but this extra work should not matter much."
|
||||
db/org-clock-goto-first-open-checkbox)
|
||||
:autoload (db/check-special-org-files-in-agenda
|
||||
db/verify-refile-target
|
||||
db/org-refile-get-location
|
||||
db/find-parent-task
|
||||
db/ensure-running-clock
|
||||
db/save-current-org-task-to-file
|
||||
@ -948,7 +949,14 @@ split horizontally again, but this extra work should not matter much."
|
||||
(org-agenda-redo-all))
|
||||
|
||||
;; Inhibit direct input when point is at the beginning of a headline.
|
||||
(add-to-list 'org-speed-command-hook 'db/org-ignore-insert-on-headline-start)))
|
||||
(add-to-list 'org-speed-command-hook 'db/org-ignore-insert-on-headline-start)
|
||||
|
||||
;; Use consult for querying refile targets
|
||||
(define-advice org-refile-get-location (:around
|
||||
(orig-func prompt default-buffer new-nodes)
|
||||
use-consult-instead)
|
||||
(ignore orig-func)
|
||||
(db/org-refile-get-location prompt default-buffer new-nodes))))
|
||||
|
||||
(use-package org-cycle
|
||||
:autoload (org-cycle-hide-drawers)
|
||||
|
||||
@ -480,6 +480,27 @@ Via %%(with-temp-buffer (db/org-add-link-to-current-clock) (string-trim (buffer-
|
||||
;; any agenda when a super-item is tagged with :HOLD:.
|
||||
(not (member "HOLD" (org-get-tags (point))))))
|
||||
|
||||
(defun db/org-refile-get-location (prompt default-buffer new-nodes)
|
||||
"Replacement function for `org-refile-get-location' using `consult'.
|
||||
|
||||
This function can be used instead of `org-refile-get-location',
|
||||
e.g. using `define-advice'. The parameters PROMPT, DEFAULT-BUFFER, and
|
||||
NEW-NODES have the same meaning. However, setting NEW-NODES to a
|
||||
non-nil value will result in a warning, as creating new headlings is not
|
||||
supported with this function.
|
||||
|
||||
Also note that the usual variables governing the behavior of
|
||||
`org-refile' do not have any effect here. In particular,
|
||||
`org-refile-verify-target-function' is not (yet) considered."
|
||||
(when new-nodes
|
||||
(warn "Cannot create new nodes (yet) with consult interface for `org-refile'"))
|
||||
(let ((pom (with-current-buffer (or default-buffer (current-buffer))
|
||||
(db/org-get-location t nil (concat prompt " "))))) ; TODO: incorporate verify function
|
||||
(list (buffer-name (marker-buffer pom))
|
||||
(buffer-file-name (marker-buffer pom))
|
||||
"" ; some regexp matching the headline?
|
||||
(marker-position pom))))
|
||||
|
||||
|
||||
;;; Helper Functions for Clocking
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user