From 0124957b18d900080bc420512ff55adb4ed391dd Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 28 Sep 2021 16:22:24 -0500 Subject: Add org-narrow-to-task --- init.el | 7 ++++--- lisp/acdw-org.el | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/init.el b/init.el index a0039ac..5f367bb 100644 --- a/init.el +++ b/init.el @@ -1893,7 +1893,8 @@ browser defined in `browse-url-secondary-browser-function'." "C-c C-l" #'org-insert-link-dwim "C-c w" #'chd/do-the-thing "C-c C-n" #'acdw/org-next-heading-widen - "C-c C-p" #'acdw/org-previous-heading-widen) + "C-c C-p" #'acdw/org-previous-heading-widen + "C-x n t" #'org-narrow-to-task) (:unbind "C-'") @@ -1990,8 +1991,8 @@ the default is \"/\"." collect (el-patch-swap (org-add-props - head nil 'face - (nth (% n org-n-level-faces) org-level-faces)) + head nil 'face + (nth (% n org-n-level-faces) org-level-faces)) head)) separator)))) (when (> (length fpath) width) diff --git a/lisp/acdw-org.el b/lisp/acdw-org.el index 96f3f69..8821b28 100644 --- a/lisp/acdw-org.el +++ b/lisp/acdw-org.el @@ -451,6 +451,19 @@ probably abandon it at some point for a better solution (see: (nth day-of-week '("Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat")) "]"))))))) + +;;; Org task stuff + +(defun org-narrow-to-task () + "Narrow buffer to the nearest task and its subtree." + (interactive) + (save-excursion + (save-match-data + (widen) + (while (not (org-entry-is-todo-p)) + ;; TODO: need a better error message + (org-previous-visible-heading 1)) + (org-narrow-to-subtree)))) (provide 'acdw-org) -- cgit 1.4.1-21-gabe81