emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: nicholas.dokos@hp.com
Cc: news1142@Karl-Voit.at, emacs-orgmode@gnu.org
Subject: Re: [bug] org-agenda-write does not handle date stamps without day of week
Date: Mon, 19 Mar 2012 10:12:01 +0100	[thread overview]
Message-ID: <30E4D375-690C-4798-B341-51268082B826@gmail.com> (raw)
In-Reply-To: <4859.1331966740@alphaville>

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


On 17.3.2012, at 07:45, Nick Dokos wrote:

> Karl Voit <devnull@Karl-Voit.at> wrote:
> 
>> * Nick Dokos <nicholas.dokos@hp.com> wrote:
>>> Karl Voit <devnull@Karl-Voit.at> wrote:
>>> 
>>> For me, it was a "no time to work on org - stash it"...
>> 
>> OK. I just wanted to make sure that it *is* on someone's todo list
>> :-)
>> 
>>>> * Karl Voit <devnull@Karl-Voit.at> wrote:
>>>>> 
>>>>> * <2012-03-05 08:00-09:00> Wrong: ends up as full day event
>>> 
>>> org-agenda-write calls org-export-icalendar which calls org-print-icalendar-entries
>>> which loops over all the entries and parses them, decomposing them into timestamps.
>>> Each timestamp is then passed to org-parse-time-string. It's this one that cannot
>>> handle non-standard formats: it uses a regexp and assumes that all the matched parts
>>> are going to be in fixed places:
>>> 
>>> As to how to fix it, there are several possibilities:
>>> 
>>> 1. fix your scripts that produce time stamps to include day-of-week.
>> 
>> Sorry, deriving DOW from an arbitrary timestamps from arbitrary data
>> sources is either pretty time consuming (calendar calculations) or
>> simply hard to calculate.
>> 
>> Outside Org-mode, DOW is seldom part of time-stamp data :-(
>> 
>>> 2. change the callers of org-parse-time-string to make sure that DOW is included.
>>> There are roughly three dozen callers, so 2. is possible but a pain.
>> 
>> Ack.
>> 
>>> 3. change just one caller: org-print-icalendar-entries to make sure that DOW is included.
>>> 3. is simple but ugly as sin, 
>> 
>> Ouch, ack :-)
>> 
>>> 4. change org-parse-time-string to handle a missing DOW.
>>> 4. is the best way to handle it within org.
>> 
>> Full ack.
>> 
>>> I vote for 1. where *you* have to do all the work ;-)
>> 
>> YMMD :-)
>> 
>> If my brain would be compatible to ELISP, I'd send a patch.
>> Promised.
>> 
>> But I'll take my chance and wait for someone else (you?)
>> implementing 4. to resolve this issue for everybody. I really
>> appreciate every second you guys invest in maintaining Org-mode!
>> 
> 
> I don't know about you, but whenever I engage in hand-to-hand combat
> with a complicated regexp, I come out bruised, muddied and a lot worse
> for wear. In any case, I'm attaching an org file with my investigations.
> It contains a description and a code block for testing.
> 
> I hope that the attachment will come through unscathed: it contains
> regexps, and munging a regexp that looks like hen scratchings in the
> first place through uncooperative mailers is not something to be
> relished.
> 
> BTW, I'm not advocating a change: I'll leave it to Karl to do that if he
> really wants to and to the maintainers to decide whether it's worth
> doing. But it can be done (more or less). And maybe somebody will come
> up with a better way than the proof-of-concept that I'm attaching here.

Hi Nick and Karl,

since we did make a change to Org a while ago to allow date stamps
without the name of the day, I think it is only consequent to also do
it for this case.  Must have slipped our attention back then.
The only thing we must ensure is that this regexp matches fast
as it is used a lot.

Nick's proposal works, except for the fact that is also matches when
the time is directly attached to day name.  Maybe it is cleaner to
not match in this case.

If we are going to make the day name optional, then it is better to
include matching of the whitespace after the date into the day-name
part of the regexp.

I am attaching Nick's file again, with a third proposal for an
updated regexp.

As far as speed is concerned, this regexp will, if there is name
and time, match directly and straight.  If the date name is
missing, it will notice on the first digit belonging to
the time and switch without backtracking (well, minimal
backtracking when there are multiple spaces) to the regexp
section for the time of day.  Rematching the spaces after the
date will be the only overhead.

Cheers

- Carsten


[-- Attachment #2: reproducer.org --]
[-- Type: application/octet-stream, Size: 3291 bytes --]

* Modify org-ts-regexpr0 to satisfy Karl Voit :-)

This is an attempt to allow timestamps without a day-of-week.

Modifying complicated regexps is no fun: I had to resort to re-builder
to figure out what was going on. The problem was that the first " *" which
is supposed to eat all the spaces between the "2012-03-05" part and
the "Mon" part, would, in the absence of the "Mon" part, eat the space
before the time spec "08:00". But the regexp for the time part explicitly
requires that space (see the second sp in the explanatory line below).
So I tried making the DOW part optional by appending a ?, but that didn't
do the trick. re-builder showed the space problem: there was no space left
to match if DOW is absent, so I changed the literal space " " to 0 or more
spaces " *" and that did the trick (with some caveats noted below).

In the code block below, tslist is a list of test cases. The code
block sets org-ts-regexp0 first to its original value, then to the
changed value (the first one is there just for comparison between the
two). I've marked the changes (of which, the second is the significant
one). We map the function org-parse-time-string over the test
cases and get a list of results. The results look reasonable, but the
new regexp allows funny-looking input like the second and fourth test
case.

One additional caveat is that org-odt uses org-ts-regexp0, so changing
it without checking org-odt's use is fraught with peril, but that's what
I've done: I have no idea whether it causes problems in org-odt.

#+BEGIN_SRC elisp
  ;                           year_______    -   month______    -   day________    sp   DOW____________       sp  hour_________    :   minutes____
  (setq org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{1,2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)")
  ; changed                                                                                                v    v
  (setq org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)?\\( *\\([0-9]\\{1,2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)")
  ; New version by Carsten                                                         ^^vv                         v
  (setq org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)\\( +[^]+0-9>\r\n -]+\\)?\\( +\\([0-9]\\{1,2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
  (setq tslist '(
          "<2012-03-05 Mon 08:00>"
          "<2012-03-05 Mon08:00>"
          "<2012-03-05 Mon 8:00>"
          "<2012-03-05 Mon8:00>"
          "<2012-03-05 Mon     8:00>"
          "<2012-03-05    Mon     8:00>"
          "<2012-03-05 Mon >"
          "<2012-03-05 Mon>"
          "<2012-03-05 08:00>"
          "<2012-03-05 8:00>"
          "<2012-03-05       8:00>"
          "<2012-03-05>"))
  
  (pp (mapcar 'org-parse-time-string tslist))
  
  
#+END_SRC

#+RESULTS:
#+begin_example
((0 0 8 5 3 2012 nil nil nil)
 (0 0 8 5 3 2012 nil nil nil)
 (0 0 8 5 3 2012 nil nil nil)
 (0 0 8 5 3 2012 nil nil nil)
 (0 0 8 5 3 2012 nil nil nil)
 (0 0 8 5 3 2012 nil nil nil)
 (0 0 0 5 3 2012 nil nil nil)
 (0 0 0 5 3 2012 nil nil nil)
 (0 0 8 5 3 2012 nil nil nil)
 (0 0 8 5 3 2012 nil nil nil)
 (0 0 8 5 3 2012 nil nil nil)
 (0 0 0 5 3 2012 nil nil nil))
#+end_example


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





> 
> Nick
> 
> PS. BTW, if you look at the attachment, it helps if you have a wide window,
>    something like 165 characters wide.
> 
> <reproducer.org>


  reply	other threads:[~2012-03-19  9:12 UTC|newest]

Thread overview: 157+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-07 15:55 Referencing elemts of a table Karl Voit
2011-06-07 17:22 ` Michael Brand
2011-06-08  0:05   ` kinouchou
2011-06-08  3:54     ` Jambunathan K
2011-06-08  4:25     ` Nick Dokos
2011-06-08 12:49   ` Karl Voit
2011-06-08 13:47     ` Michael Brand
     [not found]     ` <devnull@Karl-Voit.at>
2011-06-08 13:49       ` Nick Dokos
2011-06-24 14:32       ` org-time-stamp loses repeater interval Karl Voit
2011-06-24 16:08         ` Bernt Hansen
2011-06-24 16:01       ` Nick Dokos
2011-06-24 17:40         ` Michael Brand
2011-06-24 18:00           ` Nick Dokos
2011-06-26 11:30           ` Bug: " Karl Voit
2011-06-27 16:23             ` Bastien
2011-06-28 13:40               ` Karl Voit
2011-06-28 14:28                 ` Bastien
2011-06-28 15:04                   ` Nick Dokos
2011-06-28 15:13                   ` Karl Voit
2011-06-28 15:33                     ` Nick Dokos
2011-06-28 16:03                       ` Karl Voit
2011-06-28 15:48                     ` Bastien
2011-06-28 16:05                 ` Karl Voit
2011-06-28 17:27                   ` Bastien
2011-06-28 18:43                     ` Karl Voit
2011-06-28 23:02                       ` Bastien
2011-06-28 23:10                         ` Nick Dokos
2011-06-28 23:58                           ` Bastien
2011-06-29  1:44                             ` Nick Dokos
2011-06-29  7:28                               ` Sebastien Vauban
2011-06-29  9:30                                 ` Bastien
2011-06-29 14:34                                 ` Nick Dokos
2011-07-02 13:29                                   ` Bastien
2011-06-29 12:47                               ` Karl Voit
2011-07-02 13:26                                 ` Bastien
2011-07-02 13:26                               ` Bastien
2011-09-30 15:31       ` How to debug "Specified time is not representable" Nick Dokos
2011-10-18 17:26       ` Recurring events with exceptions Nick Dokos
2011-10-18 20:38         ` Karl Voit
2012-03-16 17:52       ` [bug] org-agenda-write does not handle date stamps without day of week Nick Dokos
2012-03-16 18:53         ` Karl Voit
2012-03-17  6:45       ` Nick Dokos
2012-03-19  9:12         ` Carsten Dominik [this message]
2012-03-20  5:54           ` Carsten Dominik
2012-03-20 12:26             ` Karl Voit
2012-03-20 13:47               ` Carsten Dominik
2012-04-10 17:38           ` Bastien
2012-04-10 17:44             ` Nick Dokos
2012-04-10 18:03               ` Bastien
2012-03-20 13:39       ` Nick Dokos
2012-03-21 16:32         ` Karl Voit
2012-03-21 16:57           ` Carsten Dominik
2012-03-26 16:10       ` Plotting (with gnuplot) using dates timestamps Nick Dokos
2012-08-13 22:27       ` table: referencing row of other table Nick Dokos
2012-08-13 22:44         ` Karl Voit
2012-08-19 12:32       ` What HW/SW issues influence org/Emacs performance? Nick Dokos
2012-08-19 13:04         ` Karl Voit
2012-08-20 17:23       ` Replacement for org-make-link Nick Dokos
2012-08-20 17:54         ` Bastien
2012-08-20 19:29           ` Karl Voit
2012-08-27 16:09       ` comma as decimal point: bug? Nick Dokos
2012-08-27 16:17         ` Karl Voit
2013-01-18 14:07       ` Wish: switch active time-stamps to inactive when CANCELED Nick Dokos
2013-01-18 21:24         ` Karl Voit
2013-01-18 21:59       ` Nick Dokos
2013-01-20 16:05         ` Karl Voit
2013-01-20 18:16           ` Viktor Rosenfeld
2013-01-21 10:18         ` Memnon Anon
2013-01-21 11:39           ` OT: Learning ELISP (was: Wish: switch active time-stamps to inactive when CANCELED) Karl Voit
2013-01-21 21:56             ` OT: Learning ELISP Jonathan Arkell
2013-01-23 14:40               ` Using Org/babel for Emacs config files (was: OT: Learning ELISP) Karl Voit
2013-01-23 15:52                 ` Using Org/babel for Emacs config files David Bjergaard
2013-01-23 22:06                 ` Using Org/babel for Emacs config files (was: OT: Learning ELISP) Darlan Cavalcante Moreira
2013-01-23 22:32                   ` Kyle Machulis
2013-01-24 13:27                     ` [OT] open url in emacs was: Re: Using Org/babel for Emacs config files Andreas Leha
2013-01-24 13:29                       ` Bastien
2013-01-24 14:13                         ` Andreas Leha
2013-01-24 15:19                           ` Bastien
2013-01-24 19:48                             ` Andreas Leha
2013-01-25  4:48                             ` Jambunathan K
2013-01-26  8:34                               ` Andreas Leha
2013-01-26 13:05                                 ` Jambunathan K
2013-01-28  9:41                                   ` Andreas Leha
2013-01-24 15:18                       ` Daimrod
2013-01-24  1:04                 ` Thorsten Jolitz
2013-01-24  1:33                   ` Thomas S. Dye
2013-01-24  8:42                     ` Thorsten Jolitz
2013-01-24 11:36                   ` full outline functionality in .el files: how? (was: Re: Using Org/babel for Emacs config files) Gregor Zattler
2013-01-24 12:48                     ` full outline functionality in .el files: how? Bastien
2013-01-24 13:40                       ` Thorsten Jolitz
2013-01-24 13:46                         ` Bastien
2013-01-24 14:17                           ` Thorsten Jolitz
2013-01-24 15:57                             ` Bastien
2013-01-24 13:36                     ` Thorsten Jolitz
2013-01-25 18:08                     ` Memnon Anon
  -- strict thread matches above, loose matches on Subject: below --
2011-09-30 14:32 How to debug "Specified time is not representable" Karl Voit
2011-09-30 14:52 ` Jambunathan K
2011-10-03 11:50   ` Karl Voit
2011-10-04  7:40     ` Jambunathan K
2011-10-04 11:42       ` Karl Voit
2011-10-04 12:13         ` Carsten Dominik
2011-10-04 11:41     ` Carsten Dominik
2011-10-04 11:47       ` Karl Voit
2011-10-18 16:52 Recurring events with exceptions Karl Voit
2011-10-18 17:04 ` Brian Wightman
2011-10-18 17:35   ` Karl Voit
2011-10-18 18:15   ` Skip Collins
2011-10-18 18:46     ` Tassilo Horn
2011-10-18 19:57     ` Eric S Fraga
2011-10-19  0:34       ` Skip Collins
2011-10-19 10:02         ` Eric S Fraga
2011-10-21 21:48           ` Skip Collins
2011-10-22  8:38             ` Sync with Outlook/Exchange (was: Recurring events with exceptions) Karl Voit
2011-10-24  7:13             ` Recurring events with exceptions Eric S Fraga
2012-03-05 14:44 [bug] org-agenda-write does not handle date stamps without day of week Karl Voit
2012-03-16 16:14 ` Karl Voit
2012-03-17 14:04 ` Simon Thum
2012-03-19  9:13   ` Carsten Dominik
2012-03-26 13:37 Plotting (with gnuplot) using dates timestamps Alan Schmitt
2012-03-26 14:00 ` Allen S. Rout
2012-03-26 14:06 ` Michael Brand
2012-03-26 14:07 ` Steven Buczkowski
     [not found]   ` <steven.buczkowski@gmail.com>
2012-03-26 14:37     ` Nick Dokos
2012-03-26 14:59       ` Alan Schmitt
2012-03-26 15:48         ` Karl Voit
2012-03-26 17:02           ` Alan Schmitt
2012-03-26 17:06             ` Karl Voit
2012-03-26 17:11               ` Ian Barton
2012-03-27  7:59                 ` Karl Voit
2012-03-30  1:09 ` Mueen Nawaz
2012-08-13 21:50 table: referencing row of other table Karl Voit
2012-08-19 10:56 What HW/SW issues influence org/Emacs performance? Karl Voit
2012-08-19 11:23 ` Achim Gratz
2012-08-19 16:45 ` Luis Anaya
2012-08-20 17:03 Replacement for org-make-link Karl Voit
2012-08-26 13:54 comma as decimal point: bug? Rainer Thiel
2012-08-26 20:57 ` Nicolas Goaziou
2012-08-26 21:05   ` Bastien
2012-08-26 21:08     ` Nicolas Goaziou
2012-08-27 16:19       ` Bastien
2012-08-27 15:44   ` Karl Voit
2012-08-26 20:59 ` Bastien
2012-08-27  9:08   ` Rainer Thiel
2012-08-27 12:30     ` AW
2013-01-18 10:34 Wish: switch active time-stamps to inactive when CANCELED Karl Voit
2013-01-18 11:04 ` Daimrod
2013-01-18 11:08   ` Karl Voit
2013-01-18 11:24     ` Daimrod
2013-01-18 21:22       ` Karl Voit
2013-01-18 21:59         ` Viktor Rosenfeld
2013-01-18 22:50           ` Daimrod
2013-01-20 15:39           ` Karl Voit
2013-01-23 13:18           ` Bastien
2013-01-23 17:21             ` Viktor Rosenfeld
2013-01-24 14:11               ` Bastien
2013-01-18 23:10 ` Samuel Wales
2013-01-26 11:06 ` Bastien

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=30E4D375-690C-4798-B341-51268082B826@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=news1142@Karl-Voit.at \
    --cc=nicholas.dokos@hp.com \
    /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).