diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-07-19 15:32:13 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-07-20 12:29:44 -0700 |
commit | f68bbf258e0c4726ff2f6da243cebb3856d3199b (patch) | |
tree | ae17bab458133d9b09c6f9d06e9934d9f2cef62b /.emacs.d/init-org.el | |
parent | ea5457ea9ef09ada010a2a058895bc713d344c29 (diff) | |
download | dotfiles-f68bbf258e0c4726ff2f6da243cebb3856d3199b.tar.gz |
bring other macros up to the top & tidy
Diffstat (limited to '.emacs.d/init-org.el')
-rw-r--r-- | .emacs.d/init-org.el | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/.emacs.d/init-org.el b/.emacs.d/init-org.el index ace6504c..ad0e2788 100644 --- a/.emacs.d/init-org.el +++ b/.emacs.d/init-org.el @@ -368,6 +368,30 @@ (setq matches t))))) matches)) +(defmacro spw--skip-when (condition) + "Skip trees where CONDITION is false when evaluated when point is on the headline of the tree." + `(let ((next-headline (save-excursion (outline-next-heading)))) + (when ,condition + (or next-headline + ;; if there is no next headline, skip by going to the end + ;; of the buffer. An alternative would be (save-excursion + ;; (forward-line 1) (point)) + (point-max))))) + +(defmacro spw/org-task-first-line-such-that (&rest forms) + `(when (spw/is-task-or-project-p) + (save-excursion + (outline-show-subtree) + (forward-line 1) + (beginning-of-line-text) + ,@forms))) + +(defun spw/is-task-or-project-p () + ;; ignore errors in case we are before the first headline + (ignore-errors + ;; alternatively: (member (org-get-todo-state) org-todo-keywords-1) + (member (nth 2 (org-heading-components)) org-todo-keywords-1))) + (defun bh--is-project-p () "Any task with a todo keyword subtask" (save-restriction @@ -412,17 +436,6 @@ (setq has-subtask t)))) (and is-a-task (not has-subtask))))) -(defmacro spw--skip-when (&rest condition) - "Skip trees where CONDITION is false when evaluated when point is on the headline of the tree." - `(let ((next-headline (save-excursion (outline-next-heading)))) - (if ,@condition - (or next-headline - ;; if there is no next headline, skip by going to the end - ;; of the buffer. An alternative would be `(save-excursion - ;; (forward-line 1) (point))' - (point-max)) - nil))) - (defun spw--skip-subprojects-and-NOAGENDA () "Skip trees that are subprojects, and trees with (possibly inherited) NOAGENDA tag" @@ -505,17 +518,6 @@ different occasions." ;; # 7 (spw--org-is-scheduled-p))))))))) -(defmacro spw/org-task-first-line-such-that (&rest forms) - `(when ;; ignore errors because we might be before the first headline - (ignore-errors - ;; only consider tasks, not all headlines - (member (nth 2 (org-heading-components)) org-todo-keywords-1)) - (save-excursion - (outline-show-subtree) - (forward-line 1) - (beginning-of-line-text) - ,@forms))) - (defun spw--org-is-scheduled-p () "A task that is scheduled" (spw/org-task-first-line-such-that |