简体   繁体   中英

Refile existing entry to different location in Org Mode date-tree

I use the Org-Mode diary to keep a record of my upcoming appointments.

In my diary.org file I could have an entry that looks something like the following:

*** 2014-10-31 Friday
**** 9:30 Take dog to vet
     <2014-10-31 Fri>

Now imagine I need to reschedule my vet appointment. Is there a quick way (ie some Org-Mode command) to refile the appropriate heading within the same file but under a different date?

Use org-refile with Cc Cw. This will allow you to refile it to the rescheduled date. Also be sure to check out the variables org-refile-use-outline-path (nil by default) and org-outline-path-complete-in-steps.

I would also recommend using the full power of org-mode dates so they show up in the agenda (Ca) appropriately. For example:

* Take Dog to Vet
  <2014-10-31 Fri 09:30>--<2014-10-31 Fri 10:30>

I don't see a builtin function that does this, but it sounds pretty useful. This function is really just a simplification of the code in org-archive.el that archives to datetrees. If you instead want to refile based on SCHEDULED , DEADLINE or some other property, just change "TIMESTAMP" to the property you want.

(defun org-refile-to-datetree ()
  "Refile a subtree to a datetree corresponding to it's timestamp."
  (interactive)
  (let* ((datetree-date (org-entry-get nil "TIMESTAMP" t))
         (date (org-date-to-gregorian datetree-date)))
    (when date
      (save-excursion
        (org-cut-subtree)
        (org-datetree-find-date-create date)
        (org-narrow-to-subtree)
        (show-subtree)
        (org-end-of-subtree t)
        (newline)
        (goto-char (point-max))
        (org-paste-subtree 4)
        (widen)
        )
      )
    ))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM