From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: move org line to next superior level Date: Fri, 30 May 2014 11:16:25 +0200 Message-ID: <8738frlj86.fsf@gmail.com> References: <874n08zmjf.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqIvg-0002yG-Bk for emacs-orgmode@gnu.org; Fri, 30 May 2014 05:16:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WqIvY-0003Kx-TE for emacs-orgmode@gnu.org; Fri, 30 May 2014 05:16:48 -0400 Received: from plane.gmane.org ([80.91.229.3]:39527) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqIvY-0003Km-MK for emacs-orgmode@gnu.org; Fri, 30 May 2014 05:16:40 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WqIvW-0003PJ-UW for emacs-orgmode@gnu.org; Fri, 30 May 2014 11:16:38 +0200 Received: from g231234225.adsl.alicedsl.de ([92.231.234.225]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 May 2014 11:16:38 +0200 Received: from tjolitz by g231234225.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 May 2014 11:16:38 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Uwe Ziegenhagen writes: > Thorsten Jolitz 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