[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Wish: switch active time-stamps to inactive when CANCELED
From: |
Memnon Anon |
Subject: |
Re: [O] Wish: switch active time-stamps to inactive when CANCELED |
Date: |
Mon, 21 Jan 2013 10:18:55 +0000 (UTC) |
Nick Dokos <address@hidden> writes:
>> But unfortunately, I know that little of ELISP, that I am not able
>> to implement it by myself :-(
> Time to learn some then - and there is no better way than scratching
> your own itch :-)
Two days later, no reply so far. I'll give it a shot.
Karl, if you are still fiddling to make it work, ignore this posting
and keep trying. :)
>>> [...] accomplish this with org-after-todo-state-change-hook:
>>> Write a function that checks if org-state is "CANCELED"
>>> [...] looks for active timestamps and calls
>>> org-toggle-timestamp-type on them.
Everything there, so...
--8<---------------cut here---------------start------------->8---
(defun my-org-active-to-inactive-ts ()
"Toggle type on active timestamp in current heading if state was changed to
'CNCL'.
This function is supposed to be called by 'org-after-todo-state-change-hook.
This function expects only one active timestamp to be in the headline."
(when (string= org-state "CNCL") ; 1.
(save-excursion ; 2.
(save-restriction
(widen)
(outline-back-to-heading t) ; 3.
(narrow-to-region (point)
(or (outline-next-heading) (point-max)))
(when (re-search-backward (org-re-timestamp 'active) nil t) ; 4.
(org-toggle-timestamp-type))))))
(add-hook 'org-after-todo-state-change-hook 'my-org-active-to-inactive-ts)
--8<---------------cut here---------------end--------------->8---
1.: Only when org-state is CNCL, do the rest.
2.: We are jumping around and narrowing, so let's save the way things are,
first.
3.: Move point to the beginning of the current headline, make sure we
only touch it by narrowing to it. If there is no next headline,
point-max will do.
4.: regex search for (only) one active timestamp. When there is one, point
will end up there and we toggle it.
When there is none, search returns nil, nothing happens.
Memnon
- Re: [O] Wish: switch active time-stamps to inactive when CANCELED, (continued)
- Re: [O] Wish: switch active time-stamps to inactive when CANCELED, Daimrod, 2013/01/18
- Re: [O] Wish: switch active time-stamps to inactive when CANCELED, Karl Voit, 2013/01/20
- Re: [O] Wish: switch active time-stamps to inactive when CANCELED, Bastien, 2013/01/23
- Re: [O] Wish: switch active time-stamps to inactive when CANCELED, Viktor Rosenfeld, 2013/01/23
- Re: [O] Wish: switch active time-stamps to inactive when CANCELED, Bastien, 2013/01/24
Re: [O] Wish: switch active time-stamps to inactive when CANCELED, Nick Dokos, 2013/01/18
- Re: [O] Wish: switch active time-stamps to inactive when CANCELED, Karl Voit, 2013/01/18
- Re: [O] Wish: switch active time-stamps to inactive when CANCELED,
Memnon Anon <=
- [O] OT: Learning ELISP (was: Wish: switch active time-stamps to inactive when CANCELED), Karl Voit, 2013/01/21
- Re: [O] OT: Learning ELISP, Jonathan Arkell, 2013/01/21
- [O] Using Org/babel for Emacs config files (was: OT: Learning ELISP), Karl Voit, 2013/01/23
- Re: [O] Using Org/babel for Emacs config files (was: OT: Learning ELISP), Darlan Cavalcante Moreira, 2013/01/23
- Re: [O] Using Org/babel for Emacs config files (was: OT: Learning ELISP), Kyle Machulis, 2013/01/23
- [O] [OT] open url in emacs was: Re: Using Org/babel for Emacs config files, Andreas Leha, 2013/01/24
- Re: [O] [OT] open url in emacs was: Re: Using Org/babel for Emacs config files, Bastien, 2013/01/24
- Re: [O] [OT] open url in emacs was: Re: Using Org/babel for Emacs config files, Andreas Leha, 2013/01/24
- Re: [O] [OT] open url in emacs was: Re: Using Org/babel for Emacs config files, Bastien, 2013/01/24
- Re: [O] [OT] open url in emacs was: Re: Using Org/babel for Emacs config files, Andreas Leha, 2013/01/24