Hi, Matt Price <mopto...@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