emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using org-agenda-time-grid with lists


From: steve-humphreys
Subject: Re: Using org-agenda-time-grid with lists
Date: Sat, 12 Dec 2020 00:04:55 +0100


> Sent: Friday, December 11, 2020 at 11:22 PM
> From: "Marco Wahl" <marcowahlsoft@gmail.com>
> To: steve-humphreys@gmx.com
> Cc: "Org-Mode mailing list" <emacs-orgmode@gnu.org>
> Subject: Re: Using org-agenda-time-grid with lists
>
> Hi Steve!
>
> > I have made two versions for calling org-agenda-time-grid, but the first 
> > does not
> > comply with what the last call does.  Yet the parameters are identical.
> >
> > (setq grid-displ '(today daily require-timed))
> > (setq tm '(number-sequence 800 2000 100))
> > (message "tm: %s" tm)
> > (setq org-agenda-time-grid '('grid-displ 'tm
> >    "......" "----------------"))
> >
> > (setq org-agenda-time-grid '((today daily require-timed)
> >    (800 900 1000 1100 1200 1300 1400 1500 1600 1700  1800 2000)
> >    "......" "----------------"))
>
> Possibly my last answer was not so clear.
>
> IIUC you want to use some variables (concretely grid-displ and tm)
> instead of the hardcoded values in the setting of org-agenda-time-grid.

Correct

> This is a Lisp question AFAICT.
>
>     (setq org-agenda-time-grid '((today daily require-timed)
>         (800 900 1000 1100 1200 1300 1400 1500 1600 1700  1800 2000)
>         "......" "----------------"))
>
> evaluates (C-x C-e) to
>
> ((today daily require-timed) (800 900 1000 1100 1200 1300 1400 1500 1600
> 1700 1800 2000) "......" "----------------")
>
> and the agenda appears as expected, I guess.
>
> Let's check the details and use some variables.
>
>     (number-sequence 800 2000 100)
>
> evaluates to
>
> (800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000)
>
> LGTM.
>
> Introduce variables grid-displ and tm
>
>     (setq grid-displ '(today daily require-timed))
>     (setq tm '(number-sequence 800 2000 100))
>
> Ok.
>
> Let's check some variants using those variables
>
>     (setq org-agenda-time-grid '(grid-displ
>         tm
>         "......" "----------------"))
>
> evaluates to
>
> (grid-displ tm "......" "----------------")
>
> which is not the wanted value i.e. the hardcoded version above.
>
> Somehow the variables grid-displ and tm need to get evaluated before the
> setting of org-agenda-time-grid.
>
> Next try
>
>     (setq org-agenda-time-grid (list grid-displ
>         tm
>         "......" "----------------"))
>
> This evaluates to ((today daily require-timed) (number-sequence 800 2000
> 100) "......" "----------------") which is closer to the hardcoded
> version above. But the number-sequence call did not happen.
>
> Function eval can do that.
>
>     (setq org-agenda-time-grid (list grid-displ
>         (eval tm)
>         "......" "----------------"))
>
> This evaluates (almost) to the hardcoded version above.
>
> Note that function eval is considered rather bad style and should be
> avoided if possible.

If you say so.

> Possibly you can use the setting
>
>     (setq tm (number-sequence 800 2000 100))
>
> instead of
>
>     (setq tm '(number-sequence 800 2000 100))
>
> and then just use tm instead of (eval tm) to get the list of numbers.
>
> If you want to dig deeper you can study the backtick notation of lisp
> which provides an elegant notation for variable evaluation in lists.

Have used the backtick before.  Will look how I can use it for this case.

> HTH,
> --
> Marco
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]