* Specialized sparse-tree via hook to show specific view in org mode
@ 2023-02-06 1:12 Kevin Layer
2023-02-07 20:28 ` Ihor Radchenko
0 siblings, 1 reply; 2+ messages in thread
From: Kevin Layer @ 2023-02-06 1:12 UTC (permalink / raw)
To: Emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 2518 bytes --]
Hi. I've been using Emacs since the 80's but I'm a new org mode user.
What a fantastic piece of software. I had used my own todo mode, but org
is orders of magnitude better. Thank you!
My main todo file defines various TODO keywords and initial state like this:
#+STARTUP: indent overview
#+TODO: @NOW @NEXT @WIP @PENDING
What I really want is to initially only see items noted with those TODO
keywords and also due items. Everything else should be hidden.
Since I didn't see an out-of-the-box way to do this, I hacked the following
together. The purpose of this email is to see if this is the right way (or
a good way).
The hack starts with this at the end of the org file:
* Local Variables
;; Local Variables:
;; eval: (save-window-excursion (my-org-show-sparse-todo-tree))
;; End:
That function is defined thus:
(defun my-org-show-sparse-todo-tree ()
(interactive)
(message
"%d TODO entries found"
(org-occur (concat "^" org-outline-regexp " *"
"\\("
(mapconcat 'identity org-todo-keywords-1 "\\|")
"\\)\\>")))
;; events due before 2 weeks from now:
(org-check-before-date
(format-time-string "%Y-%m-%d" (time-add nil (* 3600 8 14)))
t))
which relies on the redefined version of org-check-before-date, so
keep-previous is passed to org-occur:
(defun org-check-before-date (d &optional keep-previous)
"Check if there are deadlines or scheduled entries before date D.
Optional argument KEEP-PREVIOUS is passed directly to `org-occur'."
(interactive (list (org-read-date)))
(let* ((case-fold-search nil)
(regexp (org-re-timestamp org-ts-type))
(ts-type org-ts-type)
(callback
(lambda ()
(let ((match (match-string 1)))
(and (if (memq ts-type '(active inactive all))
(eq (org-element-type (save-excursion
(backward-char)
(org-element-context)))
'timestamp)
(org-at-planning-p))
(time-less-p
(org-time-string-to-time match)
(org-time-string-to-time d)))))))
(message "%d entries before %s"
(org-occur regexp keep-previous callback)
d)))
I find this shows me exactly what I want to see when I finish a task and
want to start something new.
If this is the right way and the maintainer wants me to submit a patch, I
would include these functions to get a new optional for keep-previous,
since they could all plausibly be used for the same thing that
org-check-before-date was:
* org-show-todo-tree
* org-check-deadlines
* org-check-before-date
* org-check-after-date
* org-check-dates-range
Thank you.
Kevin
[-- Attachment #2: Type: text/html, Size: 3372 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Specialized sparse-tree via hook to show specific view in org mode
2023-02-06 1:12 Specialized sparse-tree via hook to show specific view in org mode Kevin Layer
@ 2023-02-07 20:28 ` Ihor Radchenko
0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2023-02-07 20:28 UTC (permalink / raw)
To: Kevin Layer; +Cc: Emacs-orgmode
Kevin Layer <layer@known.net> writes:
> My main todo file defines various TODO keywords and initial state like this:
>
> #+STARTUP: indent overview
> #+TODO: @NOW @NEXT @WIP @PENDING
>
> What I really want is to initially only see items noted with those TODO
> keywords and also due items. Everything else should be hidden.
I think you can use `org-match-sparse-tree'. It supports the general
match syntax. See 11.3.3 Matching tags and properties section for the
match syntax.
> If this is the right way and the maintainer wants me to submit a patch, I
> would include these functions to get a new optional for keep-previous,
> since they could all plausibly be used for the same thing that
> org-check-before-date was:
> * org-show-todo-tree
> * org-check-deadlines
> * org-check-before-date
> * org-check-after-date
> * org-check-dates-range
I think that it does make sense to support KEEP-PREVIOUS in these
functions. `org-occur' does support it and there is no reason not to
allow the same toggle in the listed functions.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-07 20:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-06 1:12 Specialized sparse-tree via hook to show specific view in org mode Kevin Layer
2023-02-07 20:28 ` Ihor Radchenko
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).