From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: bug#9695: allowed date range Date: Thu, 13 Oct 2011 10:27:12 +0200 Message-ID: References: <87ty7kd8oh.fsf@kanis.fr> <87ehyiitv7.fsf__48109.1452217244$1318487785$gmane$org@googlemail.com> <87mxd5jqpn.fsf@thinkpad.tsdh.de> <87lisp9vsm.fsf@pinto.chemeng.ucl.ac.uk> Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: multipart/mixed; boundary=Apple-Mail-3-884816260 Return-path: Received: from eggs.gnu.org ([140.186.70.92]:39723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REGdG-0007Sj-HO for emacs-orgmode@gnu.org; Thu, 13 Oct 2011 04:27:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1REGdF-0000H5-7q for emacs-orgmode@gnu.org; Thu, 13 Oct 2011 04:27:14 -0400 Received: from mail-bw0-f41.google.com ([209.85.214.41]:36002) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REGdE-0000H1-U4 for emacs-orgmode@gnu.org; Thu, 13 Oct 2011 04:27:13 -0400 Received: by bkbzu5 with SMTP id zu5so582945bkb.0 for ; Thu, 13 Oct 2011 01:27:11 -0700 (PDT) In-Reply-To: <87lisp9vsm.fsf@pinto.chemeng.ucl.ac.uk> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric S Fraga Cc: Tassilo Horn , emacs-orgmode@gnu.org --Apple-Mail-3-884816260 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On 13.10.2011, at 09:48, Eric S Fraga wrote: > Tassilo Horn writes: > >> Ivan Kanis 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 --Apple-Mail-3-884816260 Content-Disposition: attachment; filename=time-stamp-no-space.patch Content-Type: application/octet-stream; name="time-stamp-no-space.patch" Content-Transfer-Encoding: 7bit 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)) --Apple-Mail-3-884816260 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii > 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) > --Apple-Mail-3-884816260--