From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: inserting a copy of an element at point (timestamps) Date: Tue, 01 Dec 2015 00:42:36 +0100 Message-ID: <87mvtv2gwj.fsf@gmx.us> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3Y66-00074q-4S for emacs-orgmode@gnu.org; Mon, 30 Nov 2015 18:43:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3Y5u-0004wX-Bc for emacs-orgmode@gnu.org; Mon, 30 Nov 2015 18:42:59 -0500 Received: from plane.gmane.org ([80.91.229.3]:32903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3Y5u-0004wT-45 for emacs-orgmode@gnu.org; Mon, 30 Nov 2015 18:42:54 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1a3Y5j-0002OF-LZ for emacs-orgmode@gnu.org; Tue, 01 Dec 2015 00:42:43 +0100 Received: from 46.166.188.217 ([46.166.188.217]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Dec 2015 00:42:43 +0100 Received: from rasmus by 46.166.188.217 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Dec 2015 00:42:43 +0100 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 Hi, 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))) aka save-excursion. Also, you should limit your search to the current heading. > (re-search-backward "<[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" ) org-ts-regexp or maybe org-ts-regexp-both. > (let* ((previous-ts (org-element-context))) > (goto-char curpos) > (INSERT COPY OF PREVIOUS-TS) ;; obviously this is fake. But what to > replace it with? (save-excursion (insert (org-element-interpret-data previous-ts)) (org-timestamp-change 7 'day)) > (org-timestamp-change 7 'dat) ))) You need to use ’day. You probably don’t need org-element in this case, but then again why not... Rasmus -- Warning: Everything saved will be lost