From acd28edf7129eb32b95ae0ab8b83276bf3721360 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 27 Sep 2021 18:21:03 -0500 Subject: Add consult-org-clock ... or whatever it's called. --- init.el | 118 ++++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 77 insertions(+), 41 deletions(-) diff --git a/init.el b/init.el index 6620f45..f24f1c7 100644 --- a/init.el +++ b/init.el @@ -1838,47 +1838,46 @@ browser defined in `browse-url-secondary-browser-function'." org-contrib) (:also-load acdw-org) (require 'chd nil 'noerror) - (:option - org-adapt-indentation nil - org-agenda-files nil ; only until I set this up - org-catch-invisible-edits 'show-and-error - org-clock-clocked-in-display 'frame-title - org-clock-frame-title-format (cons '(t org-mode-line-string) - (cons " --- " frame-title-format)) - ;;org-clock-string-limit 7 ; gives time and not title - org-confirm-babel-evaluate nil - org-cycle-separator-lines 0 - org-directory "~/org" - org-ellipsis " …" - org-export-coding-system 'utf-8-unix - org-export-headline-levels 8 - org-export-with-section-numbers nil - org-export-with-smart-quotes t - org-export-with-sub-superscripts t - org-export-with-toc nil - org-fontify-done-headline t - org-fontify-quote-and-verse-blocks t - org-fontify-whole-heading-line t - org-hide-emphasis-markers t - org-html-coding-system 'utf-8-unix - org-image-actual-width '(300) - org-imenu-depth 3 - org-list-demote-modify-bullet '(("-" . "+") - ("+" . "*") - ("*" . "-")) - org-log-into-drawer t - org-outline-path-complete-in-steps nil - org-pretty-entities t - org-refile-use-outline-path 'file - org-special-ctrl-a/e t - org-special-ctrl-k t - org-src-fontify-natively t - org-src-tab-acts-natively t - org-src-window-setup 'current-window - org-startup-truncated nil - org-startup-with-inline-images t - org-tags-column 0 ; (- 0 fill-column -3) - ) + (:option org-adapt-indentation nil + org-agenda-files nil ; only until I set this up + org-catch-invisible-edits 'show-and-error + org-clock-clocked-in-display 'frame-title + org-clock-frame-title-format (cons '(t org-mode-line-string) + (cons " --- " frame-title-format)) + ;;org-clock-string-limit 7 ; gives time and not title + org-clock-persist t + org-confirm-babel-evaluate nil + org-cycle-separator-lines 0 + org-directory "~/org" + org-ellipsis " …" + org-export-coding-system 'utf-8-unix + org-export-headline-levels 8 + org-export-with-section-numbers nil + org-export-with-smart-quotes t + org-export-with-sub-superscripts t + org-export-with-toc nil + org-fontify-done-headline t + org-fontify-quote-and-verse-blocks t + org-fontify-whole-heading-line t + org-hide-emphasis-markers t + org-html-coding-system 'utf-8-unix + org-image-actual-width '(300) + org-imenu-depth 3 + org-list-demote-modify-bullet '(("-" . "+") + ("+" . "*") + ("*" . "-")) + org-log-into-drawer t + org-outline-path-complete-in-steps nil + org-pretty-entities t + org-refile-use-outline-path 'file + org-special-ctrl-a/e t + org-special-ctrl-k t + org-src-fontify-natively t + org-src-tab-acts-natively t + org-src-window-setup 'current-window + org-startup-truncated nil + org-startup-with-inline-images t + org-tags-column 0) (:bind "RET" #'acdw-org/return-dwim "" #'acdw-org/org-table-copy-down @@ -1916,6 +1915,43 @@ browser defined in `browse-url-secondary-browser-function'." (acdw-org/count-words-stupidly start end 999))))) + + (with-eval-after-load 'org + (org-clock-persistence-insinuate)) + + (with-eval-after-load 'consult + (defun consult-clock-in (&optional match scope resolve) + "Clock into an Org heading." + (interactive (list nil nil current-prefix-arg)) + (require 'org-clock) + (org-clock-load) + (save-window-excursion + (consult-org-heading + match + (or scope + (thread-last org-clock-history + (mapcar 'marker-buffer) + (mapcar 'buffer-file-name) + (delete-dups) + (delq nil)) + (user-error "No recent clocked tasks"))) + (org-clock-in nil (when resolve + (org-resolve-clocks) + (org-read-date t t))))) + + (consult-customize consult-clock-in + :prompt "Clock in: " + :preview-key (kbd "M-.") + :group + (lambda (cand transform) + (if transform + (substring + cand + (next-single-property-change 0 'consult-org--buffer cand)) + (let ((m (car (get-text-property 0 'consult-org--heading cand)))) + (if (member m org-clock-history) + "*Recent*" + (buffer-name (marker-buffer m)))))))) (:advise org-delete-backward-char :override #'acdw-org/delete-backward-char) -- cgit 1.4.1-21-gabe81