Compare commits

..

2 Commits

2 changed files with 33 additions and 4 deletions

10
init.el
View File

@ -703,6 +703,7 @@ split horizontally again, but this extra work should not matter much."
db/org-clock-goto-first-open-checkbox) db/org-clock-goto-first-open-checkbox)
:autoload (db/check-special-org-files-in-agenda :autoload (db/check-special-org-files-in-agenda
db/verify-refile-target db/verify-refile-target
db/org-refile-get-location
db/find-parent-task db/find-parent-task
db/ensure-running-clock db/ensure-running-clock
db/save-current-org-task-to-file 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)) (org-agenda-redo-all))
;; Inhibit direct input when point is at the beginning of a headline. ;; 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 (use-package org-cycle
:autoload (org-cycle-hide-drawers) :autoload (org-cycle-hide-drawers)

View File

@ -478,6 +478,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:. ;; any agenda when a super-item is tagged with :HOLD:.
(not (member "HOLD" (org-get-tags (point)))))) (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
(error "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 ;;; Helper Functions for Clocking
@ -1861,11 +1882,11 @@ not."
(t (user-error "Neither ID nor CUSTOM_ID given"))))) (t (user-error "Neither ID nor CUSTOM_ID given")))))
(org-search-view nil query))) (org-search-view nil query)))
(defun db/org-get-location (&optional use-all-org-files initial-input) (defun db/org-get-location (&optional use-all-org-files initial-input prompt)
"Interactively query for location and return mark. "Interactively query for location and return mark.
Use INITIAL-INPUT as initial input when filtering available Use INITIAL-INPUT as initial input when filtering available
locations. locations. Use PROMPT as prompt when given.
When USE-ALL-ORG-FILES is nil, this functions by default searches When USE-ALL-ORG-FILES is nil, this functions by default searches
through the current buffer if that one is an Org buffer and is through the current buffer if that one is an Org buffer and is
@ -1910,7 +1931,7 @@ linking to any item."
(consult--read (consult--slow-operation "Collecting headings..." (consult--read (consult--slow-operation "Collecting headings..."
(or (consult-org--headings t nil scope) (or (consult-org--headings t nil scope)
(user-error "No headings"))) (user-error "No headings")))
:prompt "Choose heading: " :prompt (or prompt "Choose heading: ")
:category 'org-heading :category 'org-heading
:sort nil :sort nil
:initial initial-input :initial initial-input