emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Sacha Chua <sacha@sachachua.com>
To: emacs list <emacs-orgmode@gnu.org>
Subject: [PATCH] Change relative weekday specifications (ex: fri or -tue) to exclude today
Date: Fri, 12 Apr 2013 19:29:55 -0400	[thread overview]
Message-ID: <CAJGZZeLGdeWN4-gxDDuvw3mb7+Q5T-FSgf6DA+misDz1WQeOPQ@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 889 bytes --]

I use the weekday specifiers for org-read-date a lot when scheduling tasks.
For example, I frequently use things like "+sat" - the + isn't needed for
this, but I still do it out of habit ("sat" works just as well). Sometimes
I want to postpone tasks to the same day next week. I think of "fri" as
"the next upcoming Friday", so I tend to use that to postpone things.

Then I get thoroughly confused, because it ends up on the same day, and
then I grumble and reschedule it to either "2fri" or "+w". You see, if
today is Friday, "fri" gets you today, even if org-read-date-prefer-future
is true. It's the correct behaviour according to the documentation, but it
was driving me a little crazy, so I propose the attached change. It makes
"fri" and "-fri" exclude today, so if today is Friday, "fri" means next
Friday (procrastinate away!) and "-fri" means last Friday.

What do people think?

[-- Attachment #1.2: Type: text/html, Size: 1171 bytes --]

[-- Attachment #2: 0001-Change-relative-weekday-specifications-ex-fri-or-tue.patch --]
[-- Type: application/octet-stream, Size: 2865 bytes --]

From 90dcd9f63351d346fb65b10897d61b7300dddffa Mon Sep 17 00:00:00 2001
From: Sacha Chua <sacha@sachachua.com>
Date: Fri, 12 Apr 2013 19:19:16 -0400
Subject: [PATCH] Change relative weekday specifications (ex: fri or -tue) to
 exclude today

* lisp/org.el (org-read-date-get-relative): Handle positive and
negative weekday specifications so that they don't return today.
If today is Friday, "fri" should mean next Friday. This changes
the previous behavior, which required you to specify "+2fri" in
order to mean next Friday if today was Friday. If you want to
schedule something for today, you can use ".".

* doc/org.texi (The date/time prompt): Update the documentation
to reflect the new way `org-read-date-get-relative' handles
weekdays.

TINYCHANGE
---
 doc/org.texi |  5 +++--
 lisp/org.el  | 10 ++++++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index ac66b79..7ecd057 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -5881,7 +5881,7 @@ in @b{bold}.
 14            @result{} @b{2006}-@b{06}-14
 12            @result{} @b{2006}-@b{07}-12
 2/5           @result{} @b{2007}-02-05
-Fri           @result{} nearest Friday (default date or later)
+Fri           @result{} nearest Friday after the default date
 sep 15        @result{} @b{2006}-09-15
 feb 15        @result{} @b{2007}-02-15
 sep 12 9      @result{} 2009-09-12
@@ -5906,7 +5906,8 @@ the abbreviation of day name, the date will be the Nth such day, e.g.:
 +4            @result{} same as above
 +2w           @result{} two weeks from today
 ++5           @result{} five days from default date
-+2tue         @result{} second Tuesday from now.
++2tue         @result{} second Tuesday from now
+-wed          @result{} last Wednesday
 @end example
 
 @vindex parse-time-months
diff --git a/lisp/org.el b/lisp/org.el
index bbbeb7a..cf5c9a9 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16141,7 +16141,8 @@ mean next year.  For details, see the manual.  A few examples:
   12:45         --> today 12:45
   22 sept 0:34  --> currentyear-09-22 0:34
   12            --> currentyear-currentmonth-12
-  Fri           --> nearest Friday (today or later)
+  Fri           --> nearest Friday after today
+  -Tue          --> last Tuesday
   etc.
 
 Furthermore you can specify a relative date by giving, as the *first* thing
@@ -16529,7 +16530,12 @@ DEF-FLAG   is t when a double ++ or -- indicates shift relative to
       (if wday1
 	  (progn
 	    (setq delta (mod (+ 7 (- wday1 wday)) 7))
-	    (if (= dir ?-) (setq delta (- delta 7)))
+	    (if (= delta 0) (setq delta 7))
+	    (if (= dir ?-)
+		(progn
+		  (setq delta (- delta 7))
+		  (if (= delta 0) (setq delta -7))
+		  ))
 	    (if (> n 1) (setq delta (+ delta (* (1- n) (if (= dir ?-) -7 7)))))
 	    (list delta "d" rel))
 	(list (* n (if (= dir ?-) -1 1)) what rel)))))
-- 
1.8.1.msysgit.1


             reply	other threads:[~2013-04-12 23:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-12 23:29 Sacha Chua [this message]
2013-04-13  0:11 ` [PATCH] Change relative weekday specifications (ex: fri or -tue) to exclude today Bastien
2013-04-13  5:27   ` Carsten Dominik

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=CAJGZZeLGdeWN4-gxDDuvw3mb7+Q5T-FSgf6DA+misDz1WQeOPQ@mail.gmail.com \
    --to=sacha@sachachua.com \
    --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).