emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Setting org-agenda-time-grid: My day starts at midnight
@ 2010-08-19  6:17 Memnon Anon
  2010-08-22 10:25 ` [Bug] : org-agenda-time-grid (was: Setting org-agenda-time-grid: My day starts at midnight) Memnon Anon
  2010-09-02 13:22 ` Setting org-agenda-time-grid: My day starts at midnight Bastien
  0 siblings, 2 replies; 9+ messages in thread
From: Memnon Anon @ 2010-08-19  6:17 UTC (permalink / raw)
  To: Org Mode

Hi,

I am working nightshifts these days, so I wanted this:

,----
| (setq org-agenda-time-grid (quote 
|       ((daily weekly today require-timed) "----------------" 
|       ( 000 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2359))))
`----

which ... did not work.

Afaics, the reason is in org-agenda-add-time-grid-maybe:

--8<---------------cut here---------------start------------->8---
      (while (setq time (pop gridtimes))
	(unless (and remove (member time have))
=>	  (setq time (int-to-string time))
	  (push (org-format-agenda-item
		 nil string "" nil
=>		 (concat (substring time 0 -2) ":" (substring time -2)))
		new)
	  (put-text-property
	   1 (length (car new)) 'face 'org-time-grid (car new))))
--8<---------------cut here---------------end--------------->8---

(setq time (int-to-string time)) => time= "0", so
(substring time 0 -2) => args-out-of-range.

I added one line:
--8<---------------cut here---------------start------------->8---
          (unless (and remove (member time have))
            (setq time (int-to-string time))
;;MAN make sure time is at least 3 characters long or substring will fail
=>          (when (< (length time) 3) (setq time (concat "00" time)))  
            (push (org-format-agenda-item
--8<---------------cut here---------------end--------------->8---

and it seems to work: I used it for the last hours and found no problem.

So you elisp gurus out there:

a) Will this break anything I am not aware of yet?
b) Is there a better way to achieve this?

Memnon 'Rock around the clock' Anon

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug] : org-agenda-time-grid (was: Setting org-agenda-time-grid: My day starts at midnight)
  2010-08-19  6:17 Setting org-agenda-time-grid: My day starts at midnight Memnon Anon
@ 2010-08-22 10:25 ` Memnon Anon
  2010-09-02 13:22 ` Setting org-agenda-time-grid: My day starts at midnight Bastien
  1 sibling, 0 replies; 9+ messages in thread
From: Memnon Anon @ 2010-08-22 10:25 UTC (permalink / raw)
  To: Memnon Anon; +Cc: Org Mode

Okay, resend in a more concise way.

! Problem:
,----
| (setq org-agenda-time-grid (quote 
|       ((daily weekly today require-timed) "----------------" 
|       ( 000 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2359))))
`----
-> args-out-of-range!

! Reason:
,----[ org-agenda-add-time-grid-maybe ]
|       (while (setq time (pop gridtimes))
| 	(unless (and remove (member time have))
| =>	  (setq time (int-to-string time))
| 	  (push (org-format-agenda-item
| 		 nil string "" nil
| =>		 (concat (substring time 0 -2) ":" (substring time -2)))
| 		new)
| 	  (put-text-property
| 	   1 (length (car new)) 'face 'org-time-grid (car new))))
`----

,----[ Analysis ]
| (setq time (int-to-string time)) => time= "0", so
| (substring time 0 -2) => args-out-of-range.
`----

! Possible Fix:
,----
|           (unless (and remove (member time have))
|             (setq time (int-to-string time))
| ;;MAN make sure time is at least 3 characters long or substring will fail
+ =>          (when (< (length time) 3) (setq time (concat "00" time)))  
|             (push (org-format-agenda-item
`----

! Questions:
,----
| a) Will this break anything I am not aware of yet?
| b) Is there a better way to achieve this?
`----

Memnon Anon

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Setting org-agenda-time-grid: My day starts at midnight
  2010-08-19  6:17 Setting org-agenda-time-grid: My day starts at midnight Memnon Anon
  2010-08-22 10:25 ` [Bug] : org-agenda-time-grid (was: Setting org-agenda-time-grid: My day starts at midnight) Memnon Anon
@ 2010-09-02 13:22 ` Bastien
  2010-09-02 15:05   ` Memnon Anon
  1 sibling, 1 reply; 9+ messages in thread
From: Bastien @ 2010-09-02 13:22 UTC (permalink / raw)
  To: Memnon Anon; +Cc: Org Mode

Memnon Anon <gegendosenfleisch@googlemail.com> writes:

> I added one line:
>           (unless (and remove (member time have))
>             (setq time (int-to-string time))
> ;;MAN make sure time is at least 3 characters long or substring will fail
> =>          (when (< (length time) 3) (setq time (concat "00" time)))  
>             (push (org-format-agenda-item

Thanks for the report.

I fixed this in a slightly different way:

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 3f66725..90c6935 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -5118,7 +5118,7 @@ The modified list may contain inherited tags, and tags matched by
 	  (throw 'exit list))
       (while (setq time (pop gridtimes))
 	(unless (and remove (member time have))
-	  (setq time (int-to-string time))
+	  (setq time (format "%2d" time))
 	  (push (org-format-agenda-item
 		 nil string "" nil
 		 (concat (substring time 0 -2) ":" (substring time -2)))

-- 
 Bastien

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: Setting org-agenda-time-grid: My day starts at midnight
  2010-09-02 13:22 ` Setting org-agenda-time-grid: My day starts at midnight Bastien
@ 2010-09-02 15:05   ` Memnon Anon
  2010-09-02 15:48     ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Memnon Anon @ 2010-09-02 15:05 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode

Hey ;),

Bastien <bastien.guerry@wikimedia.fr> writes:

> Memnon Anon <gegendosenfleisch@googlemail.com> writes:
>> ;;MAN make sure time is at least 3 characters long or substring will fail
>> =>          (when (< (length time) 3) (setq time (concat "00" time)))  

> I fixed this in a slightly different way:
> -	  (setq time (int-to-string time))
> +	  (setq time (format "%2d" time))

Yes, I see. 
This prevents the error, however have a look at my agenda:

My 'fix':
Day-agenda (W35):
Thursday    2 September 2010
               0:00...... ----------------
               2:00...... ----------------
               4:00...... ----------------
               6:00...... ----------------
               8:00...... ----------------
              10:00...... ----------------
  WORK:       11:25-12:00 XXXXXXXXXXXXXXXXXX                        :DUTY:WORK::
  WORK:       12:00-15:00 XXXXXXXXXXXXXXXXXXXX                      :DUTY:WORK::
              12:00...... ----------------
              14:00...... ----------------
              16:00...... ----------------
              18:00...... ----------------
              20:00...... ----------------
              22:00...... ----------------
  WORK:       22:15-22:59 [#A] XXXXXXXXXXXXX                        :DUTY:WORK::
  WORK:       23:00-23:59 TODO [#A] Job: XXXXXXXXXXXXX              :DUTY:WORK::
              23:59...... ----------------
  DUTY:       Scheduled:  TODO [#A] XXXXXXXXXXXXXXXXXXXX              :DUTY:REP::HOME:
  MAG:        Sched. 3x:  TODO XXXXXXXXXX                             :STUDIUM::
  DUTY:       Sched. 2x:  TODO XXXXXXXXXXXXXXXXXXXX                   :DUTY:REP::HOME:
  DUTY:       Sched. 2x:  TODO XXXXXXXXXXXXXXXXXX                     :DUTY:REP::HOME:
  DUTY:       Sched. 2x:  TODO xxxxxxxxxxxxxx                  :DUTY:REP::HOME:DUTY:
  DUTY:       Sched. 2x:  TODO xxxxxxxxxxxxxxxxxxxx            :DUTY::HOME:DUTY:
  FUN:        Scheduled:  TODO [#C] xxxxxxx                           :FUN:REP::
  FUN:        Scheduled:  TODO [#C] xxxxxxxx                          :FUN:REP::
  FUN:        Scheduled:  TODO [#C] xxxxxxxxx                         :FUN:REP::
  FUN:        Scheduled:  STARTED [#C] Reading Mail/News              :FUN:REP::
126.% load: 415 minutes to be alloted, 328 minutes free today, -87 minutes difference

Your fix:
Day-agenda (W35):
Thursday    2 September 2010
               2:00...... ----------------
               4:00...... ----------------
               6:00...... ----------------
               8:00...... ----------------
              10:00...... ----------------
  WORK:       11:25-12:00 DONE xxxxxxxxxxxxx                        :DUTY:WORK::
  WORK:       12:00-15:00 DONE xxxxxxxxxxxxxxx                      :DUTY:WORK::
              12:00...... ----------------
              14:00...... ----------------
              16:00...... ----------------
              18:00...... ----------------
              20:00...... ----------------
              22:00...... ----------------
  WORK:       22:15-22:59 [#A] xxxxxxxxxxxx                         :DUTY:WORK::
  WORK:       23:00-23:59 TODO [#A] xxxxxxxxxxx                     :DUTY:WORK::
              23:59...... ----------------
  DUTY:       Scheduled:  TODO [#A] xxxxxxxxx                       :DUTY:REP::HOME:
  MAG:        Sched. 3x:  TODO xxxxxxxx                             :STUDIUM::
  DUTY:       Sched. 2x:  TODO xxxxxxxxxxxxxx                   :DUTY:REP::HOME:
  DUTY:       Sched. 2x:  TODO xxxxxxxxxxxx xxxxxx                  :DUTY:REP::HOME:
  DUTY:       Scheduled:  TODO [#C] xxxx xxxx                   :DUTY:REP::HOME:
  FUN:        Scheduled:  TODO [#C] xxxxxxxx                          :FUN:REP::
  FUN:        Scheduled:  TODO [#C] xxxxxxxx                          :FUN:REP::
  FUN:        Scheduled:  STARTED [#C] Reading Mail/News              :FUN:REP::
              ----------------
126.% load: 415 minutes to be alloted, 327 minutes free today, -88 minutes difference


Somehow, no 0:00 line on top, but a line (without hour) printed down at
the bottom of the agenda (above the org-calculate-free-time line).

However, calculations now are fine and thats for me the most important
thing :).

Thanks, 

Memnon

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Re: Setting org-agenda-time-grid: My day starts at midnight
  2010-09-02 15:05   ` Memnon Anon
@ 2010-09-02 15:48     ` Bastien
  2010-09-02 17:02       ` Memnon Anon
  2010-09-05 14:59       ` Memnon Anon
  0 siblings, 2 replies; 9+ messages in thread
From: Bastien @ 2010-09-02 15:48 UTC (permalink / raw)
  To: Memnon Anon; +Cc: Org Mode

Memnon Anon <gegendosenfleisch@googlemail.com> writes:

> This prevents the error, however have a look at my agenda:

Please pull again, this should be fixed now...

-- 
 Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Setting org-agenda-time-grid: My day starts at midnight
  2010-09-02 15:48     ` Bastien
@ 2010-09-02 17:02       ` Memnon Anon
  2010-09-05 14:59       ` Memnon Anon
  1 sibling, 0 replies; 9+ messages in thread
From: Memnon Anon @ 2010-09-02 17:02 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode

Bastien <bastien.guerry@wikimedia.fr> writes:
>> This prevents the error, however have a look at my agenda:
> Please pull again, this should be fixed now...

No change with %4d:
- 00:00 line not there.
- additional line above org-calculate-free-time line

--8<---------------cut here---------------start------------->8---
Day-agenda (W35):
Thursday    2 September 2010
               2:00...... ----------------
               4:00...... ----------------
               6:00...... ----------------
               8:00...... ----------------
              10:00...... ----------------
  WORK:       11:25-12:00 [...]
  WORK:       12:00-15:00 [...]
              12:00...... ----------------
              14:00...... ----------------
              16:00...... ----------------
              18:00...... ----------------
              20:00...... ----------------
              22:00...... ----------------
  WORK:       22:15-22:59 [...]
  WORK:       23:00-23:59 [...]
              23:59...... ----------------
  DUTY:       Scheduled:  [...]
  DUTY:       Sched. 2x:  [...]
[...]
              ----------------
88.3% load: 190 minutes to be alloted, 215 minutes free today, 25
minutes difference
--8<---------------cut here---------------end--------------->8---

with

(setq org-agenda-time-grid 
      (quote (
      (daily weekly today require-timed) "----------------" 
      ( 0000 0200 0400 0600 0800 1000 1200 1400 1600 1800 2000 2200
      2359))))

and

"Org-mode version TAG=7.01g" 
(I only evaluated the new org-agenda-add-time-grid-maybe in scratch).

Did you actually try the latest version?
No time right now, will try some more this weekend.

Memnon

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Setting org-agenda-time-grid: My day starts at midnight
  2010-09-02 15:48     ` Bastien
  2010-09-02 17:02       ` Memnon Anon
@ 2010-09-05 14:59       ` Memnon Anon
  2010-09-05 19:10         ` Bastien
  1 sibling, 1 reply; 9+ messages in thread
From: Memnon Anon @ 2010-09-05 14:59 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode

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

Bastien <bastien.guerry@wikimedia.fr> writes:
> Please pull again, this should be fixed now...

Still problem here.

Please try this:

0. Put attached 2 files into ~
1. `emacs -Q ~/minimal.el'
2. Adjust path to org-mode git dir and Eval Buffer minimal.el
3. Try 'C-c a a'
-> It fails for me
4. Uncomment `org-agenda-add-time-grid-maybe' in minimal.el
5. Eval Buffer
6. Try `C-c a a'
-> It works for me

If you do it not today, reschedule item1 in test.org to $today.

Memnon

Tested with: 
Org-mode version 7.01trans (release_7.01h.441.g798a78)
Last commit: commit 798a78fe06daf75bdbc2031a8f49edadd30612e1
             Author: Dan Davison <davison@stats.ox.ac.uk>
             Date:   Sat Sep 4 13:36:48 2010 -0400
"GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0)
 of 2010-08-14 on raven, modified by Debian"


[-- Attachment #2: minimal.el --]
[-- Type: application/emacs-lisp, Size: 2045 bytes --]

[-- Attachment #3: test.org --]
[-- Type: application/octet-stream, Size: 44 bytes --]

* Item 1
  SCHEDULED: <2010-09-05 So 18:00>

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Re: Setting org-agenda-time-grid: My day starts at midnight
  2010-09-05 14:59       ` Memnon Anon
@ 2010-09-05 19:10         ` Bastien
  2010-09-05 19:57           ` [Squashed] (was: Setting org-agenda-time-grid: My day starts at midnight) Memnon Anon
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2010-09-05 19:10 UTC (permalink / raw)
  To: Memnon Anon; +Cc: Org Mode

Memnon Anon <gegendosenfleisch@googlemail.com> writes:

> Bastien <bastien.guerry@wikimedia.fr> writes:
>> Please pull again, this should be fixed now...
>
> Still problem here.

Fixed again - thanks for the detailed feedback!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Squashed] (was: Setting org-agenda-time-grid: My day starts at midnight)
  2010-09-05 19:10         ` Bastien
@ 2010-09-05 19:57           ` Memnon Anon
  0 siblings, 0 replies; 9+ messages in thread
From: Memnon Anon @ 2010-09-05 19:57 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode

Bastien <bastien.guerry@wikimedia.fr> writes:
> Memnon Anon <gegendosenfleisch@googlemail.com> writes:
>> Still problem here.
> Fixed again - thanks for the detailed feedback!

Yes! 
Confirmed, it works.
Thank *you* for persisting ;).

Memnon

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-09-05 19:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-19  6:17 Setting org-agenda-time-grid: My day starts at midnight Memnon Anon
2010-08-22 10:25 ` [Bug] : org-agenda-time-grid (was: Setting org-agenda-time-grid: My day starts at midnight) Memnon Anon
2010-09-02 13:22 ` Setting org-agenda-time-grid: My day starts at midnight Bastien
2010-09-02 15:05   ` Memnon Anon
2010-09-02 15:48     ` Bastien
2010-09-02 17:02       ` Memnon Anon
2010-09-05 14:59       ` Memnon Anon
2010-09-05 19:10         ` Bastien
2010-09-05 19:57           ` [Squashed] (was: Setting org-agenda-time-grid: My day starts at midnight) Memnon Anon

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).