From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: move org line to next superior level
Date: Fri, 30 May 2014 11:16:25 +0200 [thread overview]
Message-ID: <8738frlj86.fsf@gmail.com> (raw)
In-Reply-To: loom.20140529T195340-931@post.gmane.org
Uwe Ziegenhagen <ziegenhagen@gmail.com> writes:
> Thorsten Jolitz <tjolitz <at> gmail.com> writes:
>
>
>> #+begin_src emacs-lisp
>> (defun tj/move-entry-to-next-day ()
>> "Move entry at point to next parent and tag it."
>> (unless (org-on-heading-p)
>> (outline-previous-heading))
>> (org-mark-subtree)
>> (kill-region (region-beginning) (region-end))
>> (org-up-heading-safe)
>> (org-forward-heading-same-level 1)
>> (forward-line)
>> (yank)
>> (outline-previous-heading)
>> (org-mark-subtree)
>> (org-change-tag-in-region
>> (region-beginning) (region-end) "postponed" nil))
>> #+end_src
>>
>> This works with you example Org snippet, but is not tested otherwise.
>>
>
> Hi Thorsten,
>
> your code works fine, I'd like to change it a little in that way that the
> original line should remain but should get the status "POSTPONED"
>
> I tried by inserting a new (yank) line, this didn't work as it sometimes
> moved the entry two headlines away. I am also not sure if org-todo is the
> correct command:
>
> (defun tj/move-entry-to-next-day ()
> "Move entry at point to next parent and tag it."
> (unless (org-on-heading-p)
> (outline-previous-heading))
> (org-mark-subtree)
> (kill-region (region-beginning) (region-end))
> (yank) ;; causes issues
> (org-todo "POSTPONED") ;; is this correct?
> (org-up-heading-safe)
> (org-forward-heading-same-level 2)
> (forward-line)
> (yank)
> (outline-previous-heading)
> (org-mark-subtree)
> (org-change-tag-in-region
> (region-beginning) (region-end) "postponed" nil))
Here is a more robust version of the function, that works for me on your
example snippet
#+begin_src emacs-lisp
(defun tj/copy-entry-to-next-day (state)
"Copy entry at point to next parent and change its STATE."
(interactive "sState: ")
(save-excursion
(save-restriction
(widen)
(unless (org-on-heading-p)
(outline-previous-heading))
(org-copy-subtree)
(org-todo state)
(org-up-heading-safe)
(org-forward-heading-same-level 2)
(forward-line)
(org-yank))))
#+end_src
thus
,---------------------------------------
| M-x tj/copy-entry-to-next-day RET DONE
`---------------------------------------
converts
,-------------
| * aaa
| ** TODO cccc
| * bbb
| ** TODO dddd
`-------------
to
,----------------------------------------------------------------
| * aaa
| ** DONE cccc
| - State "DONE" from "TODO" [2014-05-30 Fr 11:00]
| * bbb
| ** TODO cccc
| ** TODO dddd
`----------------------------------------------------------------
This works, because in my config, C-h v org-todo-keywords shows:
,------------------------------------------------------------------------
| org-todo-keywords is a variable defined in `org.el'.
| Its value is
| ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!/!)")
| (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE"))
|
| Original value was
| ((sequence "TODO" "DONE"))
`------------------------------------------------------------------------
thus DONE is defined. If you want to use "POSTPONED", you need to
,---------------------------------------------
| M-x customize-variable RET org-todo-keywords
`---------------------------------------------
and add it.
But anyway, I still think you complicate your life unnessesary with this
unidiomatic workflow. If you do use this function, the interactive
part could be improve to let you select from the defined
org-todo-keywords.
--
cheers,
Thorsten
next prev parent reply other threads:[~2014-05-30 9:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-29 3:57 move org line to next superior level Uwe Ziegenhagen
2014-05-29 14:28 ` Thorsten Jolitz
2014-05-29 15:12 ` Eric Abrahamsen
2014-05-29 17:16 ` Uwe Ziegenhagen
2014-05-29 18:03 ` Thorsten Jolitz
2014-05-29 18:15 ` Uwe Ziegenhagen
2014-05-30 9:16 ` Thorsten Jolitz [this message]
2014-05-29 17:29 ` Bastien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8738frlj86.fsf@gmail.com \
--to=tjolitz@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).