all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: inserting a copy of an element at point (timestamps)
Date: Tue, 01 Dec 2015 00:42:36 +0100	[thread overview]
Message-ID: <87mvtv2gwj.fsf@gmx.us> (raw)
In-Reply-To: CAN_Dec9gofDn4njKjvi0Ytrm5LTMq2+85mQS0t7yB37O=+6_4w@mail.gmail.com

Hi,

Matt Price <moptop99@gmail.com> 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

      parent reply	other threads:[~2015-11-30 23:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-30 22:59 inserting a copy of an element at point (timestamps) Matt Price
2015-11-30 23:34 ` John Kitchin
2015-11-30 23:42 ` Rasmus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mvtv2gwj.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.