Jump to first open checkbox in currently clocked-in item by default
When no open checkbox is found, just jump to the headline of the item, as before.
This commit is contained in:
parent
69f3f80a6e
commit
64bc1c762b
2
init.el
2
init.el
|
@ -767,7 +767,7 @@
|
||||||
db/org-add-link-to-current-clock
|
db/org-add-link-to-current-clock
|
||||||
hydra-org-linking/body
|
hydra-org-linking/body
|
||||||
org-dblock-write:db/org-backlinks
|
org-dblock-write:db/org-backlinks
|
||||||
db/org-goto-first-open-checkbox-in-subtree))
|
db/org-clock-goto-first-open-checkbox))
|
||||||
|
|
||||||
(use-package org
|
(use-package org
|
||||||
:pin "gnu"
|
:pin "gnu"
|
||||||
|
|
|
@ -145,7 +145,7 @@ in the main agenda view."
|
||||||
("Shell" ?s db/run-or-hide-shell)
|
("Shell" ?s db/run-or-hide-shell)
|
||||||
("EShell" ?e db/run-or-hide-eshell)
|
("EShell" ?e db/run-or-hide-eshell)
|
||||||
("Refile File" ?r #'(lambda () (interactive) (find-file db/org-default-refile-file)))
|
("Refile File" ?r #'(lambda () (interactive) (find-file db/org-default-refile-file)))
|
||||||
("Org Clock Goto" ?c org-clock-goto)
|
("Goto Currnet Clock" ?c db/org-clock-goto-first-open-checkbox)
|
||||||
("Info Lookup" ?I counsel-info-lookup-symbol)
|
("Info Lookup" ?I counsel-info-lookup-symbol)
|
||||||
("Unicode Lookup" ?U counsel-unicode-char)
|
("Unicode Lookup" ?U counsel-unicode-char)
|
||||||
("Timeline of Day" ?T timeline-tools-format-timeline-of-day)
|
("Timeline of Day" ?T timeline-tools-format-timeline-of-day)
|
||||||
|
|
|
@ -1015,32 +1015,55 @@ cache if that's in use."
|
||||||
(when (derived-mode-p 'org-agenda-mode)
|
(when (derived-mode-p 'org-agenda-mode)
|
||||||
(org-agenda-redo)))
|
(org-agenda-redo)))
|
||||||
|
|
||||||
(defun db/org-goto-first-open-checkbox-in-subtree ()
|
(defun db/org-goto-first-open-checkbox-in-subtree (&optional silent)
|
||||||
"Jump to first open checkbox in the current subtree.
|
"Jump to first open checkbox in the current subtree.
|
||||||
|
|
||||||
First search for started checkboxes, i.e. [-], and if those are
|
First search for started checkboxes, i.e. [-], and if those are
|
||||||
not found, go to the first open checkbox, i.e. [ ].
|
not found, go to the first open checkbox, i.e. [ ].
|
||||||
|
|
||||||
If there's no such open checkbox, emit a message and stay put."
|
If there's no such open checkbox, emit a message (unless SILENT
|
||||||
(interactive)
|
is non-nil) and stay put.
|
||||||
|
|
||||||
|
Note: when lists are nested, those are not (yet) descended into
|
||||||
|
to find the logically first open checkbox. This should be fixed
|
||||||
|
somewhen, though."
|
||||||
|
|
||||||
(unless (derived-mode-p 'org-mode)
|
(unless (derived-mode-p 'org-mode)
|
||||||
(user-error "Not in Org buffer, exiting"))
|
(user-error "Not in Org buffer, exiting"))
|
||||||
|
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(let ((original-point (point)))
|
(let ((original-point (point)))
|
||||||
(widen)
|
(widen)
|
||||||
(org-back-to-heading 'invisible-ok)
|
(org-back-to-heading 'invisible-ok)
|
||||||
(org-narrow-to-subtree)
|
(org-narrow-to-subtree)
|
||||||
(unless
|
(unless
|
||||||
;; Yes, progn is not strictly necessary, but it feels cleaner this way.
|
;; Yes, those `progn's are not strictly necessary, but it feels
|
||||||
|
;; cleaner this way.
|
||||||
(or (progn
|
(or (progn
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(re-search-forward " \\[-\\] " nil 'no-error))
|
(re-search-forward " \\[-\\] " nil 'no-error))
|
||||||
(progn
|
(progn
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(re-search-forward " \\[ \\] " nil 'no-error)))
|
(re-search-forward " \\[ \\] " nil 'no-error)))
|
||||||
(message "No open checkbox in subtree")
|
(unless silent
|
||||||
|
(message "No open checkbox in subtree"))
|
||||||
(goto-char original-point)))))
|
(goto-char original-point)))))
|
||||||
|
|
||||||
|
(defun db/org-clock-goto-first-open-checkbox (&optional select)
|
||||||
|
"Go to the currently clocked-in item or most recently clocked item.
|
||||||
|
|
||||||
|
Move point to first open checkbox there, if there's one. See
|
||||||
|
`db/org-goto-first-open-checkbox-in-subtree' for details.
|
||||||
|
|
||||||
|
If SELECT is non-nil, offer a choice of the most recently
|
||||||
|
clocked-in tasks to jump to."
|
||||||
|
(interactive "@P")
|
||||||
|
(org-clock-goto select)
|
||||||
|
;; `org-clock-goto' will barf if there's no currently clocked-in task, so
|
||||||
|
;; there is no need to check this again; just try to find the first checkbox
|
||||||
|
;; now.
|
||||||
|
(db/org-goto-first-open-checkbox-in-subtree :silent))
|
||||||
|
|
||||||
|
|
||||||
;;; Calendar
|
;;; Calendar
|
||||||
|
|
||||||
|
@ -1049,35 +1072,35 @@ If there's no such open checkbox, emit a message and stay put."
|
||||||
This is done only if the value of this variable is not null."
|
This is done only if the value of this variable is not null."
|
||||||
(interactive)
|
(interactive)
|
||||||
(cond
|
(cond
|
||||||
((null org-icalendar-combined-agenda-file)
|
((null org-icalendar-combined-agenda-file)
|
||||||
(message "`org-icalendar-combined-agenda-file’ not set, not exporting diary."))
|
(message "`org-icalendar-combined-agenda-file’ not set, not exporting diary."))
|
||||||
((not (file-name-absolute-p org-icalendar-combined-agenda-file))
|
((not (file-name-absolute-p org-icalendar-combined-agenda-file))
|
||||||
(user-error "`org-icalendar-combined-agenda-file’ not an absolute path, aborting"))
|
(user-error "`org-icalendar-combined-agenda-file’ not an absolute path, aborting"))
|
||||||
(t
|
(t
|
||||||
(progn
|
(progn
|
||||||
(org-save-all-org-buffers)
|
(org-save-all-org-buffers)
|
||||||
(let ((org-agenda-files (cl-remove-if #'null
|
(let ((org-agenda-files (cl-remove-if #'null
|
||||||
(list db/org-default-org-file
|
(list db/org-default-org-file
|
||||||
db/org-default-home-file
|
db/org-default-home-file
|
||||||
db/org-default-work-file)))
|
db/org-default-work-file)))
|
||||||
(org-agenda-new-buffers nil))
|
(org-agenda-new-buffers nil))
|
||||||
;; check whether we need to do something
|
;; check whether we need to do something
|
||||||
(when (cl-some (lambda (org-file)
|
(when (cl-some (lambda (org-file)
|
||||||
(file-newer-than-file-p org-file
|
(file-newer-than-file-p org-file
|
||||||
org-icalendar-combined-agenda-file))
|
org-icalendar-combined-agenda-file))
|
||||||
org-agenda-files)
|
org-agenda-files)
|
||||||
(message "Exporting diary ...")
|
(message "Exporting diary ...")
|
||||||
;; open files manually to avoid polluting `org-agenda-new-buffers’; we
|
;; open files manually to avoid polluting `org-agenda-new-buffers’; we
|
||||||
;; don’t want these buffers to be closed after exporting
|
;; don’t want these buffers to be closed after exporting
|
||||||
(mapc #'find-file-noselect org-agenda-files)
|
(mapc #'find-file-noselect org-agenda-files)
|
||||||
;; actual export; calls `org-release-buffers’ and may thus close
|
;; actual export; calls `org-release-buffers’ and may thus close
|
||||||
;; buffers we want to keep around … which is why we set
|
;; buffers we want to keep around … which is why we set
|
||||||
;; `org-agenda-new-buffers’ to nil
|
;; `org-agenda-new-buffers’ to nil
|
||||||
(when (file-exists-p org-icalendar-combined-agenda-file)
|
(when (file-exists-p org-icalendar-combined-agenda-file)
|
||||||
(delete-file org-icalendar-combined-agenda-file)
|
(delete-file org-icalendar-combined-agenda-file)
|
||||||
(sit-for 3))
|
(sit-for 3))
|
||||||
(org-icalendar-combine-agenda-files)
|
(org-icalendar-combine-agenda-files)
|
||||||
(message "Exporting diary ... done.")))))))
|
(message "Exporting diary ... done.")))))))
|
||||||
|
|
||||||
|
|
||||||
;;; Find items by link to current headline
|
;;; Find items by link to current headline
|
||||||
|
|
Loading…
Reference in New Issue