[Top][All Lists]

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

Re: [O] inserting a copy of an element at point (timestamps)

From: Rasmus
Subject: Re: [O] inserting a copy of an element at point (timestamps)
Date: Tue, 01 Dec 2015 00:42:36 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)


Matt Price <address@hidden> 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

>       (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


Warning: Everything saved will be lost

reply via email to

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