emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Eric S Fraga <e.fraga@ucl.ac.uk>
Cc: Tassilo Horn <tassilo@member.fsf.org>, emacs-orgmode@gnu.org
Subject: Re: bug#9695: allowed date range
Date: Thu, 13 Oct 2011 10:27:12 +0200	[thread overview]
Message-ID: <D5DADA52-90E0-4513-A501-E845169000D2@gmail.com> (raw)
In-Reply-To: <87lisp9vsm.fsf@pinto.chemeng.ucl.ac.uk>

[-- Attachment #1: Type: text/plain, Size: 1763 bytes --]


On 13.10.2011, at 09:48, Eric S Fraga wrote:

> Tassilo Horn <tassilo@member.fsf.org> writes:
> 
>> Ivan Kanis <ivan.kanis@googlemail.com> writes:
>> 
>> Hi!
>> 
>>> After investigating further <2011-10-17 >--<2011-10-30 > works but not
>>> <2011-10-17>--<2011-10-30>. The regexp for a timestamp is defined in
>>> org-ts-regexp :
>>> 
>>> "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^\r\n>]*?\\)>"
>>> 
>>> Shouldn't the trailing space be optional?
>> 
>> In your regex, there is no trailing whitespace, but are right that it is
>> in the original definition.
>> 
>> ,----[ C-h v org-ts-regexp RET ]
>> | org-ts-regexp is a variable defined in `org.el'.
>> | Its value is
>> | "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^\r\n>]*?\\)>"
>> |                                            ^
>> `----
>> 
>> Strangely, that timestamp regex didn't change for 3 years...
>> 
>> Oh, now I see what's wrong.  All time stamps consist of the date and
>> then the day's name abbreviation, which is missing with your example.
>> Correct would be
>> 
>>  <2011-10-17 Mon>--<2011-10-30 Sun>
>> 
>> Bye,
>> Tassilo
> 
> Although the day is optional according to the regexp.  I would
> definitely like to have the regexp with the space optional as well as
> there are cases where I want to type the date in directly (not in org
> mode for whatever reason).

I am attaching a patch which will make time stamps without a day name
like <2011-10-12> work correctly.  Furthermore, pressing C-c C-c on
a time stamp will fill in or fix the day name.

However, I am not sure if this patch is complete, or if it
has side effects.  So it would be good if a few people could
apply it and test it during their daily work for a few weeks,
and then report problems in this thread.

- Carsten


[-- Attachment #2: time-stamp-no-space.patch --]
[-- Type: application/octet-stream, Size: 3415 bytes --]

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index e026d93..5dbe4dc 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1117,7 +1117,7 @@ the clocking selection, associated with the letter `d'."
 		   (looking-at
 		    (concat "^[ \t]* " org-clock-string
 			    " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
-			    " +\\sw+\.? +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")))
+			    " *\\sw+\.? +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")))
 	      (message "Matched %s" (match-string 1))
 	      (setq ts (concat "[" (match-string 1) "]"))
 	      (goto-char (match-end 1))
@@ -1249,7 +1249,7 @@ line and position cursor in that line."
 		 (re-search-forward
 		  (concat "^[ \t]* " org-clock-string
 			  " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
-			  " +\\sw+ +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")
+			  " *\\sw+ +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")
 		  end t))
 	(beginning-of-line 1)
 	(throw 'exit t))
diff --git a/lisp/org.el b/lisp/org.el
index b26e1a3..83cf4c3 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4645,7 +4645,7 @@ means to push this value onto the list in the variable.")
 		    "\\|" org-deadline-string
 		    "\\|" org-closed-string
 		    "\\|" org-clock-string "\\)\\)?"
-		    " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?[]>]\\|<%%([^\r\n>]*>\\)")
+		    " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^]\r\n>]*?[]>]\\|<%%([^\r\n>]*>\\)")
 	    org-planning-or-clock-line-re
 	    (concat "\\(?:^[ \t]*\\(" org-scheduled-string
 		    "\\|" org-deadline-string
@@ -5094,15 +5094,15 @@ This should be called after the variable `org-link-types' has changed."
 
 (org-make-link-regexps)
 
-(defconst org-ts-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^\r\n>]*?\\)>"
+(defconst org-ts-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^\r\n>]*?\\)>"
   "Regular expression for fast time stamp matching.")
-(defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?\\)[]>]"
+(defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^]\r\n>]*?\\)[]>]"
   "Regular expression for fast time stamp matching.")
 (defconst org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
   "Regular expression matching time strings for analysis.
 This one does not require the space after the date, so it can be used
 on a string that terminates immediately after the date.")
-(defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) +\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
+(defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
   "Regular expression matching time strings for analysis.")
 (defconst org-ts-regexp2 (concat "<" org-ts-regexp1 "[^>\n]\\{0,16\\}>")
   "Regular expression matching time stamps, with groups.")
@@ -17931,6 +17931,8 @@ This command does many different things, depending on context:
 	   (fboundp org-finish-function))
       (funcall org-finish-function))
      ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook))
+     ((org-in-regexp org-ts-regexp-both)
+      (org-timestamp-change 0 'day))
      ((or (looking-at org-property-start-re)
 	  (org-at-property-p))
       (call-interactively 'org-property-action))

[-- Attachment #3: Type: text/plain, Size: 409 bytes --]




>  In those cases, it is easy to type
> 2011-01-01 or whatever but it's not necessarily trivial to determine the
> day of the week...
> 
> Actually, interesting thought experiment: does org actually do any
> consistency checks, comparing the date and the day of the week?
> 
> -- 
> : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.90.1
> : using Org-mode version 7.7 (release_7.7.380.g54d7df)
> 


  parent reply	other threads:[~2011-10-13  8:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87ty7kd8oh.fsf@kanis.fr>
2011-10-12  6:53 ` Ivan Kanis
2011-10-13  7:28   ` Tassilo Horn
2011-10-13  7:48     ` Eric S Fraga
2011-10-13  7:57       ` Tassilo Horn
2011-10-13  8:02         ` Carsten Dominik
2011-10-13 10:15           ` Eric S Fraga
2011-10-13  8:27       ` Carsten Dominik [this message]
2011-10-13 10:14         ` Eric S Fraga
2011-10-13 13:04           ` Tassilo Horn
2011-10-16 13:45         ` Michael Brand
2011-11-09 18:18           ` Carsten Dominik
2011-11-09 21:32             ` Michael Brand
2011-11-03 17:22         ` Michael Brand
     [not found] ` <87ehyiitv7.fsf@googlemail.com>
2012-03-23  1:30   ` Glenn Morris

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=D5DADA52-90E0-4513-A501-E845169000D2@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=tassilo@member.fsf.org \
    --subject='Re: bug#9695: allowed date range' \
    /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

Code repositories for project(s) associated with this 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).