emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] move org line to next superior level


From: Thorsten Jolitz
Subject: Re: [O] move org line to next superior level
Date: Fri, 30 May 2014 11:16:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Uwe Ziegenhagen <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]