[Orgmode] Re: icalendar: exporting times of day specified in heading?

2010-03-18 Thread Carsten Dominik

Applied, thanks.

- Carsten

On Mar 18, 2010, at 3:17 AM, Matthew Lundin wrote:


Hi Stephen,

Stephen Eglen s.j.eg...@damtp.cam.ac.uk writes:


When I enter the time of day after typing i d, the time of day is
added to the timestamp (as above) but is *not* removed the headline.
E.g.,

Day entry: 9:00am go shopping [RET]

...results in the following headline...

* 9:00am go shopping
 2010-03-17 Wed 09:00


that's odd; I just tried that and got:

*** go shopping
2010-03-17 Wed 09:00
which then shows in the agenda as:

 agenda:  9:00.. go shopping


I'd be curious to know whether others can duplicate this bug.

me too!

Do you get any better behaviour if you just put 9:00 or 09:00?   
Would be

good to resolve this in case there is a bug lurking elsewhere...


I believe I've pinned down the cause of the reported behavior.

My default agenda buffer is a custom agenda block, which consists of  
an

agenda view and a todo view. The inclusion of the todo view caused the
variable org-prefix-has-time to be set to nil, which in turn prevented
org-format-agenda-item from removing the time of day string from the
headline (see lines 4857-64 of org-agenda.el). Thus, when I called  
i d
from the block agenda, the time was not removed from the headline;  
when
I called i d from the default agenda or the calendar, it was  
removed.


Here's a patch that ensures the time of day is removed regardless of  
the

current value of org-prefix-has-time:

--8---cut here---start-8---
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index a50a364..9d4a4c4 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7107,6 +7107,7 @@ the resulting entry will not be shown.  When  
TEXT is empty, switch to

 ((eq type 'day)
  (let*
  (fmt time time2
+  (org-prefix-has-time t)
   (org-agenda-time-leading-zero t))
(if org-agenda-insert-diary-extract-time
;; Use org-format-agenda-item to parse text for a time-range and
--8---cut here---end---8---


Currently, org-agenda.el has (l 7079)

(if org-agenda-search-headline-for-time

to check whether we should extract the time; how about if I  
replaced it
with a variable called org-agenda-extract-time-from-entry which  
defaults

to nil so this behaviour is normally off?


Many thanks for adding this new variable.

Best,
Matt


- Carsten





___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: icalendar: exporting times of day specified in heading?

2010-03-17 Thread Matt Lundin
Hi Stephen,

Sorry for the late reply, but I've just begun using i d to enter dates
into my org files and I have a few comments on the patch you submitted
in February.

Stephen Eglen s.j.eg...@damtp.cam.ac.uk writes:

 
 I often use org-agenda-diary-entry to make simple entries into
 an agenda.org file.  I see that the agenda is clever enough to recognise
 if a time range has been typed into the heading.  However, this time
 range is not exported by the icalendar code.

 Attached is a patch to the code underlying 'i d' entries in the *Org
 Agenda* buffer.  If a time of day is specified in the entry, it is
 extracted from the entry and put into the timestamp of the diary entry.
 (The .ics exporting code recognises these timestamps and therefore the
 ics export code does not need altering.)

 For example, given the following three entries added using 'i d' from
 *Org Agenda*:

 i d RET test 1 12:00-14:00 classes RET
 i d RET test 2 did you get 7am wake up call? RET
 i d RET test 3 find 3--5 volunteers RET

 then the following entries are added to agenda.org:

 *** 2010-02-03 Wednesday

  test 3 find 3--5 volunteers
  2010-02-03 Wed
  test 2 did you get wake up call?
  2010-02-03 Wed 07:00
  test 1 classes
  2010-02-03 Wed 12:00-14:00

When I enter the time of day after typing i d, the time of day is
added to the timestamp (as above) but is *not* removed the headline.
E.g.,

--8---cut here---start-8---
Day entry: 9:00am go shopping [RET] 
--8---cut here---end---8---

...results in the following headline...

--8---cut here---start-8---
* 9:00am go shopping
  2010-03-17 Wed 09:00
--8---cut here---end---8---

As a consequence, the agenda line duplicates the time of day.

--8---cut here---start-8---
index:  9:00.. 9:00am go shopping
--8---cut here---end---8---

I'd be curious to know whether others can duplicate this bug.

 As this behvaiour may not be desired by all, I've currently put the code
 conditional on org-agenda-search-headline-for-time being non-nil (the
 default is t).  If that variable is nil, then the above three test
 entries generates the regular tree:

Might I request an independent variable for this? While I would like the
agenda to scan my headlines for time of day specifications (and thus
have org-agenda-search-headline-for-time set to t), I am not sure I want
org-agenda-add-entry-to-org-agenda-diary-file to alter the information I
enter at the Day entry:  prompt.

Thanks,
Matt



___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: icalendar: exporting times of day specified in heading?

2010-03-17 Thread Stephen Eglen
hi Matt,

 When I enter the time of day after typing i d, the time of day is
 added to the timestamp (as above) but is *not* removed the headline.
 E.g.,
 
 Day entry: 9:00am go shopping [RET] 
 
 ...results in the following headline...
 
 * 9:00am go shopping
   2010-03-17 Wed 09:00

that's odd; I just tried that and got:

*** go shopping
2010-03-17 Wed 09:00
which then shows in the agenda as:

  agenda:  9:00.. go shopping

 I'd be curious to know whether others can duplicate this bug.
me too! 

Do you get any better behaviour if you just put 9:00 or 09:00?  Would be
good to resolve this in case there is a bug lurking elsewhere...



 Might I request an independent variable for this? While I would like the
 agenda to scan my headlines for time of day specifications (and thus
 have org-agenda-search-headline-for-time set to t), I am not sure I want
 org-agenda-add-entry-to-org-agenda-diary-file to alter the information I
 enter at the Day entry:  prompt.

Certainly I'd be in agreement with that, as I don't want to jump on
others preferences.  

Currently, org-agenda.el has (l 7079)

(if org-agenda-search-headline-for-time

to check whether we should extract the time; how about if I replaced it
with a variable called org-agenda-extract-time-from-entry which defaults
to nil so this behaviour is normally off?

Sorry about this Matt.

Stephen


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: icalendar: exporting times of day specified in heading?

2010-03-17 Thread Stephen Eglen
Ok, here is a patch that introduces a new variable so that the code to
extract times from diary entries entered using 'i d' is off by default.

2010-03-17  Stephen Eglen  step...@gnu.org

* org-agenda.el (org-agenda-insert-diary-extract-time): New
variable.
(org-agenda-add-entry-to-org-agenda-diary-file): Use this new
variable rather than org-agenda-search-headline-for-time.

*** /tmp/ediff23195Zk   2010-03-17 15:22:42.0 +
--- /home/stephen/langs/emacs/elisp-ds/org-mode/lisp/org-agenda.el  
2010-03-17 15:20:56.0 +
***
*** 7066,7071 
--- 7066,7076 
  (const :tag in a date tree date-tree)
  (const :tag as top level at end of file top-level)))
  
+ (defcustom org-agenda-insert-diary-extract-time nil
+   Non-nil means extract any time specification from the diary entry.
+   :group 'org-agenda
+   :type 'boolean)
+ 
  (defun org-agenda-add-entry-to-org-agenda-diary-file (type text optional d1 
d2)
Add a diary entry with TYPE to `org-agenda-diary-file'.
  If TEXT is not empty, it will become the headline of the new entry, and
***
*** 7103,7109 
(let*
  (fmt time time2
   (org-agenda-time-leading-zero t))
!   (if org-agenda-search-headline-for-time
;; Use org-format-agenda-item to parse text for a time-range and
;; remove it.  
(setq fmt (org-format-agenda-item nil text nil nil t)
--- 7108,7114 
(let*
  (fmt time time2
   (org-agenda-time-leading-zero t))
!   (if org-agenda-insert-diary-extract-time
;; Use org-format-agenda-item to parse text for a time-range and
;; remove it.  
(setq fmt (org-format-agenda-item nil text nil nil t)


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: icalendar: exporting times of day specified in heading?

2010-03-17 Thread Carsten Dominik

Applied, thanks.

Stephen, woudl you ming changing your diff format to diff -u ?   
Somehow I have problems to apply your patches (already earlier...)


Thanks

- Carsten

On Mar 17, 2010, at 4:28 PM, Stephen Eglen wrote:


Ok, here is a patch that introduces a new variable so that the code to
extract times from diary entries entered using 'i d' is off by  
default.


2010-03-17  Stephen Eglen  step...@gnu.org

* org-agenda.el (org-agenda-insert-diary-extract-time): New
variable.
(org-agenda-add-entry-to-org-agenda-diary-file): Use this new
variable rather than org-agenda-search-headline-for-time.

*** /tmp/ediff23195Zk   2010-03-17 15:22:42.0 +
--- /home/stephen/langs/emacs/elisp-ds/org-mode/lisp/org-agenda.el	 
2010-03-17 15:20:56.0 +

***
*** 7066,7071 
--- 7066,7076 
  (const :tag in a date tree date-tree)
  (const :tag as top level at end of file top-level)))

+ (defcustom org-agenda-insert-diary-extract-time nil
+   Non-nil means extract any time specification from the diary  
entry.

+   :group 'org-agenda
+   :type 'boolean)
+
 (defun org-agenda-add-entry-to-org-agenda-diary-file (type text  
optional d1 d2)

   Add a diary entry with TYPE to `org-agenda-diary-file'.
 If TEXT is not empty, it will become the headline of the new entry,  
and

***
*** 7103,7109 
   (let*
  (fmt time time2
   (org-agenda-time-leading-zero t))
!   (if org-agenda-search-headline-for-time
;; Use org-format-agenda-item to parse text for a time-range and
;; remove it.
(setq fmt (org-format-agenda-item nil text nil nil t)
--- 7108,7114 
   (let*
  (fmt time time2
   (org-agenda-time-leading-zero t))
!   (if org-agenda-insert-diary-extract-time
;; Use org-format-agenda-item to parse text for a time-range and
;; remove it.
(setq fmt (org-format-agenda-item nil text nil nil t)


- Carsten





___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: icalendar: exporting times of day specified in heading?

2010-03-17 Thread Stephen Eglen
Carsten Dominik carsten.domi...@gmail.com wrote:

 Applied, thanks.
 
 Stephen, woudl you ming changing your diff format to diff -u ?
 Somehow I have problems to apply your patches (already earlier...)

Thanks for applying it.  

Sure, re: diffs -- actually, all I do is M-x ediff-revision on a file,
and then send the output of 'D'.  Is there a git command for comparing
the current local version of a file and the last check-in of that file?

Stephen



___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Re: icalendar: exporting times of day specified in heading?

2010-03-17 Thread Stephen Eglen
thanks -- this works great:

  git diff  org-agenda.el

for comparing my version against last check in.  

Stephen


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: icalendar: exporting times of day specified in heading?

2010-03-17 Thread Matthew Lundin
Hi Stephen,

Stephen Eglen s.j.eg...@damtp.cam.ac.uk writes:

 When I enter the time of day after typing i d, the time of day is
 added to the timestamp (as above) but is *not* removed the headline.
 E.g.,
 
 Day entry: 9:00am go shopping [RET] 
 
 ...results in the following headline...
 
 * 9:00am go shopping
   2010-03-17 Wed 09:00

 that's odd; I just tried that and got:

 *** go shopping
   2010-03-17 Wed 09:00
 which then shows in the agenda as:

   agenda:  9:00.. go shopping

 I'd be curious to know whether others can duplicate this bug.
 me too! 

 Do you get any better behaviour if you just put 9:00 or 09:00?  Would be
 good to resolve this in case there is a bug lurking elsewhere...

I believe I've pinned down the cause of the reported behavior.

My default agenda buffer is a custom agenda block, which consists of an
agenda view and a todo view. The inclusion of the todo view caused the
variable org-prefix-has-time to be set to nil, which in turn prevented
org-format-agenda-item from removing the time of day string from the
headline (see lines 4857-64 of org-agenda.el). Thus, when I called i d
from the block agenda, the time was not removed from the headline; when
I called i d from the default agenda or the calendar, it was removed.

Here's a patch that ensures the time of day is removed regardless of the
current value of org-prefix-has-time:

--8---cut here---start-8---
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index a50a364..9d4a4c4 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7107,6 +7107,7 @@ the resulting entry will not be shown.  When TEXT is 
empty, switch to
  ((eq type 'day)
   (let*
  (fmt time time2
+  (org-prefix-has-time t)
   (org-agenda-time-leading-zero t))
(if org-agenda-insert-diary-extract-time
;; Use org-format-agenda-item to parse text for a time-range and
--8---cut here---end---8---

 Currently, org-agenda.el has (l 7079)

   (if org-agenda-search-headline-for-time

 to check whether we should extract the time; how about if I replaced it
 with a variable called org-agenda-extract-time-from-entry which defaults
 to nil so this behaviour is normally off?

Many thanks for adding this new variable.

Best,
Matt


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Re: icalendar: exporting times of day specified in heading?

2010-02-03 Thread Carsten Dominik

Hi Stephen,

this is an interesting patch.  I am a bit uneasy because
it changes the entered text and that may work better in
some cases than in others.  However, as the resulting agenda
entry is the same, I have applied the patch.  We'll see how
it goes - maybe we do need to add another variable for this
eventually.

Thanks!

- Carsten


On Feb 2, 2010, at 2:16 PM, Stephen Eglen wrote:



I often use org-agenda-diary-entry to make simple entries into
an agenda.org file.  I see that the agenda is clever enough to  
recognise

if a time range has been typed into the heading.  However, this time
range is not exported by the icalendar code.


Attached is a patch to the code underlying 'i d' entries in the *Org
Agenda* buffer.  If a time of day is specified in the entry, it is
extracted from the entry and put into the timestamp of the diary  
entry.

(The .ics exporting code recognises these timestamps and therefore the
ics export code does not need altering.)

For example, given the following three entries added using 'i d' from
*Org Agenda*:

i d RET test 1 12:00-14:00 classes RET
i d RET test 2 did you get 7am wake up call? RET
i d RET test 3 find 3--5 volunteers RET

then the following entries are added to agenda.org:

*** 2010-02-03 Wednesday

 test 3 find 3--5 volunteers
2010-02-03 Wed
 test 2 did you get wake up call?
2010-02-03 Wed 07:00
 test 1 classes
2010-02-03 Wed 12:00-14:00

As this behvaiour may not be desired by all, I've currently put the  
code

conditional on org-agenda-search-headline-for-time being non-nil (the
default is t).  If that variable is nil, then the above three test
entries generates the regular tree:

*** 2010-02-03 Wednesday

 test 3 find 3--5 volunteers
2010-02-03 Wed
 test 2 did you get 7am wake up call?
2010-02-03 Wed
 test 1 12:00-14:00 classes
2010-02-03 Wed


Perhaps org-agenda-search-headline-for-time is not the right variable
though (happy to had another) given that it defaults to t?

Stephen

2010-02-02  Stephen Eglen  step...@gnu.org

* org-agenda.el (org-agenda-add-entry-to-org-agenda-diary-file):
Optionally extract time specification from text and add to the
timestamp.

*** /tmp/ediff11782joC  2010-02-02 13:07:49.0 +
--- /home/stephen/langs/emacs/elisp-ds/org-mode/lisp/org-agenda.el	 
2010-02-02 09:48:10.0 +

***
*** 6891,6903 
(insert (format (diary-anniversary %s) %s
(calendar-date-string d1 nil t) text
  ((eq type 'day)
!   (if (eq org-agenda-insert-diary-strategy 'top-level)
! (org-agenda-insert-diary-as-top-level text)
!   (require 'org-datetree)
!   (org-datetree-find-date-create d1)
!   (org-agenda-insert-diary-make-new-entry text))
!   (org-insert-time-stamp (org-time-from-absolute
! (calendar-absolute-from-gregorian d1)))
   (end-of-line 0))
  ((eq type 'block)
   (if ( (calendar-absolute-from-gregorian d1)
--- 6891,6919 
(insert (format (diary-anniversary %s) %s
(calendar-date-string d1 nil t) text
  ((eq type 'day)
!   (let*
! (fmt time time2
!  (org-agenda-time-leading-zero t))
!   (if org-agenda-search-headline-for-time
! 	;; Use org-format-agenda-item to parse text for a time-range  
and

!   ;; remove it.
!   (setq fmt (org-format-agenda-item nil text nil nil t)
! time (get-text-property 0 'time fmt)
! time2 (if ( (length time) 0)
!   ;; split-string removes trailing .. if
!   ;; no end time given.  First space
!   ;; separates time from date.
!   (concat   (car (split-string time \\.)))
! nil)
! text (get-text-property 0 'txt fmt)))
!   (if (eq org-agenda-insert-diary-strategy 'top-level)
!   (org-agenda-insert-diary-as-top-level text)
! (require 'org-datetree)
! (org-datetree-find-date-create d1)
! (org-agenda-insert-diary-make-new-entry text))
!   (org-insert-time-stamp (org-time-from-absolute
!   (calendar-absolute-from-gregorian d1))
!  nil nil nil nil time2))
   (end-of-line 0))
  ((eq type 'block)
   (if ( (calendar-absolute-from-gregorian d1)


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


- Carsten





___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: icalendar: exporting times of day specified in heading?

2010-02-02 Thread Stephen Eglen
 
 I often use org-agenda-diary-entry to make simple entries into
 an agenda.org file.  I see that the agenda is clever enough to recognise
 if a time range has been typed into the heading.  However, this time
 range is not exported by the icalendar code.

Attached is a patch to the code underlying 'i d' entries in the *Org
Agenda* buffer.  If a time of day is specified in the entry, it is
extracted from the entry and put into the timestamp of the diary entry.
(The .ics exporting code recognises these timestamps and therefore the
ics export code does not need altering.)

For example, given the following three entries added using 'i d' from
*Org Agenda*:

i d RET test 1 12:00-14:00 classes RET
i d RET test 2 did you get 7am wake up call? RET
i d RET test 3 find 3--5 volunteers RET

then the following entries are added to agenda.org:

*** 2010-02-03 Wednesday

 test 3 find 3--5 volunteers
 2010-02-03 Wed
 test 2 did you get wake up call?
 2010-02-03 Wed 07:00
 test 1 classes
 2010-02-03 Wed 12:00-14:00

As this behvaiour may not be desired by all, I've currently put the code
conditional on org-agenda-search-headline-for-time being non-nil (the
default is t).  If that variable is nil, then the above three test
entries generates the regular tree:

*** 2010-02-03 Wednesday

 test 3 find 3--5 volunteers
 2010-02-03 Wed
 test 2 did you get 7am wake up call?
 2010-02-03 Wed
 test 1 12:00-14:00 classes
 2010-02-03 Wed


Perhaps org-agenda-search-headline-for-time is not the right variable
though (happy to had another) given that it defaults to t?

Stephen

2010-02-02  Stephen Eglen  step...@gnu.org

* org-agenda.el (org-agenda-add-entry-to-org-agenda-diary-file):
Optionally extract time specification from text and add to the
timestamp.

*** /tmp/ediff11782joC  2010-02-02 13:07:49.0 +
--- /home/stephen/langs/emacs/elisp-ds/org-mode/lisp/org-agenda.el  
2010-02-02 09:48:10.0 +
***
*** 6891,6903 
(insert (format (diary-anniversary %s) %s
(calendar-date-string d1 nil t) text
   ((eq type 'day)
!   (if (eq org-agenda-insert-diary-strategy 'top-level)
! (org-agenda-insert-diary-as-top-level text)
!   (require 'org-datetree)
!   (org-datetree-find-date-create d1)
!   (org-agenda-insert-diary-make-new-entry text))
!   (org-insert-time-stamp (org-time-from-absolute
! (calendar-absolute-from-gregorian d1)))
(end-of-line 0))
   ((eq type 'block)
(if ( (calendar-absolute-from-gregorian d1)
--- 6891,6919 
(insert (format (diary-anniversary %s) %s
(calendar-date-string d1 nil t) text
   ((eq type 'day)
!   (let*
! (fmt time time2
!  (org-agenda-time-leading-zero t))
!   (if org-agenda-search-headline-for-time
!   ;; Use org-format-agenda-item to parse text for a time-range and
!   ;; remove it.  
!   (setq fmt (org-format-agenda-item nil text nil nil t)
! time (get-text-property 0 'time fmt)
! time2 (if ( (length time) 0)
!   ;; split-string removes trailing .. if
!   ;; no end time given.  First space
!   ;; separates time from date.
!   (concat   (car (split-string time \\.)))
! nil)
! text (get-text-property 0 'txt fmt)))
!   (if (eq org-agenda-insert-diary-strategy 'top-level)
!   (org-agenda-insert-diary-as-top-level text)
! (require 'org-datetree)
! (org-datetree-find-date-create d1)
! (org-agenda-insert-diary-make-new-entry text))
!   (org-insert-time-stamp (org-time-from-absolute
!   (calendar-absolute-from-gregorian d1))
!  nil nil nil nil time2))
(end-of-line 0))
   ((eq type 'block)
(if ( (calendar-absolute-from-gregorian d1)


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode