From: "François Pinard" <pinard@iro.umontreal.ca>
To: emacs-orgmode@gnu.org
Subject: Re: Repeaters in plain timestamps
Date: Fri, 15 Nov 2013 20:10:04 -0500 [thread overview]
Message-ID: <87bo1li237.fsf@iro.umontreal.ca> (raw)
In-Reply-To: <8661u1s8oq.fsf@iro.umontreal.ca> ("François Pinard"'s message of "Mon, 16 Sep 2013 00:16:05 -0400")
Hi, Org people.
Merely revisiting the Org mailing list after many days. Gosh! That
list is fairly active! :-)
Quoting an earlier message of mine:
> The manual, section "8.3.2 Repeated tasks", says:
> Some tasks need to be repeated again and again. Org mode helps to
> organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
> or plain timestamp.
> Examples and directions given in the page are related to DEADLINE, and
> a few words suggest that SCHEDULED works the same. But the page does
> not say how one may handle repeaters with plain timestamps. I merely
> would like to update them so they show the date for the next
> iteration, a bit like command "t d" already does on a DEADLINE
> repeater.
For what it may be worth, I kludged this code for bumping the following
repeated timestamps on the current line. I stole most of the code, and
did not write much myself:
(defun fp-org-bump-timestamp ()
;; Adapted from (org.el) org-auto-repeat-maybe.
(interactive)
(save-excursion
(beginning-of-line)
(when (re-search-forward org-ts-regexp (line-end-position) t)
(let ((ts (match-string 1))
(whata '(("h" . hour) ("d" . day) ("m" . month) ("y" . year)))
n time)
(when (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([hdwmy]\\)" ts)
(setq n (string-to-number (match-string 2 ts))
what (match-string 3 ts))
(if (equal what "w") (setq n (* n 7) what "d"))
(if (and (equal what "h")
(not (string-match "[0-9]\\{1,2\\}:[0-9]\\{2\\}" ts)))
(user-error "Cannot repeat in Repeat in %d hour(s) because no hour has been set" n))
;; Preparation, see if we need to modify the start date for the change
(when (match-end 1)
(setq time (save-match-data (org-time-string-to-time ts)))
(cond
((equal (match-string 1 ts) ".")
;; Shift starting date to today
(org-timestamp-change
(- (org-today) (time-to-days time))
'day))
((equal (match-string 1 ts) "+")
(let ((nshiftmax 10) (nshift 0))
(while (or (= nshift 0)
(<= (time-to-days time)
(time-to-days (current-time))))
(when (= (incf nshift) nshiftmax)
(or (y-or-n-p (message "%d repeater intervals were not enough to shift date past today. Continue? " nshift))
(error "Abort")))
(org-timestamp-change n (cdr (assoc what whata)))
(org-at-timestamp-p t)
(setq ts (match-string 1))
(setq time (save-match-data (org-time-string-to-time ts)))))
(org-timestamp-change (- n) (cdr (assoc what whata)))
;; rematch, so that we have everything in place for the real shift
(org-at-timestamp-p t)
(setq ts (match-string 1))
(string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([hdwmy]\\)" ts))))
(org-timestamp-change n (cdr (assoc what whata)) nil t))))))
prev parent reply other threads:[~2013-11-16 1:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-16 4:16 Repeaters in plain timestamps François Pinard
2013-11-16 1:10 ` François Pinard [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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bo1li237.fsf@iro.umontreal.ca \
--to=pinard@iro.umontreal.ca \
--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 public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).