From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: inserting a copy of an element at point (timestamps) Date: Mon, 30 Nov 2015 18:34:41 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3Xy3-0003PJ-6w for emacs-orgmode@gnu.org; Mon, 30 Nov 2015 18:34:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3Xy0-0002Y1-13 for emacs-orgmode@gnu.org; Mon, 30 Nov 2015 18:34:47 -0500 Received: from mail-qk0-x231.google.com ([2607:f8b0:400d:c09::231]:36690) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3Xxz-0002Xx-T1 for emacs-orgmode@gnu.org; Mon, 30 Nov 2015 18:34:43 -0500 Received: by qkda6 with SMTP id a6so65977540qkd.3 for ; Mon, 30 Nov 2015 15:34:43 -0800 (PST) In-reply-to: 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: Matt Price Cc: Org Mode Try this. You may want use <> intead of [], and you can see org-re-timestamp for other options than all. (defun insert-ts+7 () (interactive) (insert (concat "[" (save-excursion (re-search-backward (org-re-timestamp 'all)) (match-string 0))) "]") (org-timestamp-change 7 'day)) Matt Price writes: > Every time I think I'm starting to learn org Mode, I find I'm actually > really ignorant. > > I want to write a simple function that inserts a timestamp at point for a > date one week after the previous timestamp. I'm sure it's very simple. But > I can't figure out how to do it. > > i have this: > > (defun mwp/one-week-later () > "add a new timestamp a week later than the previous one" > > (interactive) > (save-excursion > (let ((curpos (point))) > (re-search-backward "<[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" ) > (let* ((previous-ts (org-element-context))) > (goto-char curpos) > (INSERT COPY OF PREVIOUS-TS) ;; obviously this is fake. But what to > replace it with? > (org-timestamp-change 7 'dat) ))) > ) > > What's the real solution? Thank you, > Matt -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu