all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Syntax for  <%%(diary-float )>
@ 2022-10-12 18:19 Renato Pontefice
  2022-10-12 19:23 ` Michael Heerdegen
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Renato Pontefice @ 2022-10-12 18:19 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,
It’s a while that I’m searching information about this statement. I need it on org mode but I ‘m unable to write in in the way I need it.
I need that (in org mode) an Agenda TODO happen: the first Friday of each mont of all the year. 
Can someone tell me the exact syntax if this statement?


Thank you

Renato


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

* Re: Syntax for  <%%(diary-float )>
  2022-10-12 18:19 Syntax for <%%(diary-float )> Renato Pontefice
@ 2022-10-12 19:23 ` Michael Heerdegen
  2022-10-12 19:42   ` Jean Louis
  2022-10-12 19:37 ` Jean Louis
  2022-10-21  6:03 ` Michael Heerdegen
  2 siblings, 1 reply; 6+ messages in thread
From: Michael Heerdegen @ 2022-10-12 19:23 UTC (permalink / raw)
  To: help-gnu-emacs

Renato Pontefice <renato.pontefice@gmail.com> writes:

> Hi,
> It’s a while that I’m searching information about this statement. I
> need it on org mode but I ‘m unable to write in in the way I need it.
> I need that (in org mode) an Agenda TODO happen: the first Friday of
> each mont of all the year.
> Can someone tell me the exact syntax if this statement?

(diary-float t 5 1)?

Michael.




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

* Re: Syntax for  <%%(diary-float )>
  2022-10-12 18:19 Syntax for <%%(diary-float )> Renato Pontefice
  2022-10-12 19:23 ` Michael Heerdegen
@ 2022-10-12 19:37 ` Jean Louis
  2022-10-21  6:03 ` Michael Heerdegen
  2 siblings, 0 replies; 6+ messages in thread
From: Jean Louis @ 2022-10-12 19:37 UTC (permalink / raw)
  To: Renato Pontefice; +Cc: help-gnu-emacs

* Renato Pontefice <renato.pontefice@gmail.com> [2022-10-12 21:21]:
> It’s a while that I’m searching information about this statement. I
> need it on org mode but I ‘m unable to write in in the way I need
> it.  I need that (in org mode) an Agenda TODO happen: the first
> Friday of each mont of all the year.  Can someone tell me the exact
> syntax if this statement?

(diary-float 1 1 1) this gives me void variable date, there is
problem.

Use C-h f on function to examine it:

{C-h f diary-float RET}

diary-float is a Lisp closure in ‘diary-lib.el’.

(diary-float MONTH DAYNAME N &optional DAY MARK)

Diary entry for the Nth DAYNAME after/before MONTH DAY.
DAYNAME=0 means Sunday, DAYNAME=1 means Monday, and so on.
If N>0, use the Nth DAYNAME after MONTH DAY.
If N<0, use the Nth DAYNAME before MONTH DAY.
DAY defaults to 1 if N>0, and MONTH’s last day otherwise.
MONTH can be a list of months, an integer, or t (meaning all months).
Optional MARK specifies a face or single-character string to use when
highlighting the day in the calendar.

-------------

I guess there is nothing bad using external tools to get the
information you want.

The sqlite3 database, will give this result:

sqlite> SELECT DATE('2022-11-01', 'start of month', 'weekday 5');
2022-11-04

It means now we can easily calculate which date is first day of month,
by doing the list:

(defun my-fridays ()
  (interactive)
  (insert "\n\n")
  (let ((years '(2022 2023 2024)))
    (while years
      (let ((year (pop years))
	    (months '("01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12")))
	(while months
	  (let* ((month (pop months))
		 (date (format "%s-%s-01" year month))
		 (sql (format "SELECT DATE('%s', 'start of month', 'weekday 5')" date)))
	    (insert (caar (sqlite-select rcd-people-sqlite-db sql)) "\n")))))))

(my-fridays)

2022-01-07
2022-02-04
2022-03-04
2022-04-01
2022-05-06
2022-06-03
2022-07-01
2022-08-05
2022-09-02
2022-10-07
2022-11-04
2022-12-02
2023-01-06
2023-02-03
2023-03-03
2023-04-07
2023-05-05
2023-06-02
2023-07-07
2023-08-04
2023-09-01
2023-10-06
2023-11-03
2023-12-01
2024-01-05
2024-02-02
2024-03-01
2024-04-05
2024-05-03
2024-06-07
2024-07-05
2024-08-02
2024-09-06
2024-10-04
2024-11-01
2024-12-06

Now you could use this function to set up events. I do not know how do you set it up.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: Syntax for  <%%(diary-float )>
  2022-10-12 19:23 ` Michael Heerdegen
@ 2022-10-12 19:42   ` Jean Louis
  2022-10-12 19:59     ` Michael Heerdegen
  0 siblings, 1 reply; 6+ messages in thread
From: Jean Louis @ 2022-10-12 19:42 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

* Michael Heerdegen <michael_heerdegen@web.de> [2022-10-12 22:30]:
> Renato Pontefice <renato.pontefice@gmail.com> writes:
> 
> > Hi,
> > It’s a while that I’m searching information about this statement. I
> > need it on org mode but I ‘m unable to write in in the way I need it.
> > I need that (in org mode) an Agenda TODO happen: the first Friday of
> > each mont of all the year.
> > Can someone tell me the exact syntax if this statement?
> 
> (diary-float t 5 1)

Debugger entered--Lisp error: (void-variable date)
  (calendar-day-of-week date)
  (= dayname (calendar-day-of-week date))
  (and (= dayname (calendar-day-of-week date)) (let* ((m (calendar-extract-month date)) (d (calendar-extract-day date)) (y (calendar-extract-year date)) (limit (calendar-nth-named-absday (- n) dayname m y d)) (last-abs (if (> n 0) limit (+ limit 6))) (first-abs (if (> n 0) (- limit 6) limit)) (last (calendar-gregorian-from-absolute last-abs)) (first (calendar-gregorian-from-absolute first-abs)) (m1 (calendar-extract-month first)) (d1 (calendar-extract-day first)) (y1 (calendar-extract-year first)) (m2 (calendar-extract-month last)) (d2 (calendar-extract-day last)) (y2 (calendar-extract-year last))) (if (or (and (= m1 m2) (or (eq month t) (if (listp month) (memq m1 month) (= m1 month))) (let ((d ...)) (and (<= d1 d) (<= d d2)))) (and (or (< y1 y2) (and (= y1 y2) (< m1 m2))) (or (and (or ...
  ...) (<= d1 ...)) (and (or ... ...) (<= ... d2))))) (cons mark entry))))
  (progn (with-no-warnings (defvar date) (defvar entry)) (and (= dayname (calendar-day-of-week date)) (let* ((m (calendar-extract-month date)) (d (calendar-extract-day date)) (y (calendar-extract-year date)) (limit (calendar-nth-named-absday (- n) dayname m y d)) (last-abs (if (> n 0) limit (+ limit 6))) (first-abs (if (> n 0) (- limit 6) limit)) (last (calendar-gregorian-from-absolute last-abs)) (first (calendar-gregorian-from-absolute first-abs)) (m1 (calendar-extract-month first)) (d1 (calendar-extract-day first)) (y1 (calendar-extract-year first)) (m2 (calendar-extract-month last)) (d2 (calendar-extract-day last)) (y2 (calendar-extract-year last))) (if (or (and (= m1 m2) (or (eq month t) (if ... ... ...)) (let (...) (and ... ...))) (and (or (< y1 y2) (and ... ...)) (or (and ... ...) (a
 nd ... ...)))) (cons mark entry)))))
  diary-float(t 5 1)
  eval((diary-float t 5 1))
  rcd-eval-visually()
  funcall-interactively(rcd-eval-visually)
  call-interactively(rcd-eval-visually nil nil)
  command-execute(rcd-eval-visually)


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: Syntax for  <%%(diary-float )>
  2022-10-12 19:42   ` Jean Louis
@ 2022-10-12 19:59     ` Michael Heerdegen
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2022-10-12 19:59 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> > (diary-float t 5 1)
>
> Debugger entered--Lisp error: (void-variable date)

Of course you must use it in the diary or org (or in any other valid
context)!

Alternatively you can bind the special variable `date` if you want to
play with diary sexps (but load diary and calendar before that).

Michael.




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

* Re: Syntax for  <%%(diary-float )>
  2022-10-12 18:19 Syntax for <%%(diary-float )> Renato Pontefice
  2022-10-12 19:23 ` Michael Heerdegen
  2022-10-12 19:37 ` Jean Louis
@ 2022-10-21  6:03 ` Michael Heerdegen
  2 siblings, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2022-10-21  6:03 UTC (permalink / raw)
  To: Renato Pontefice; +Cc: help-gnu-emacs

Renato Pontefice <renato.pontefice@gmail.com> writes:

> Can someone tell me the exact syntax if this statement?

So, if you have more specific questions about diary sexps, please ask.
I can't tell that much about the syntax for the usage in org-mode.  If
you have found out your typical way of use patterns, it is a good idea
to add appropriate entries in `org-capture-templates' for them (prevent
mistakes) and use org-capture to add such entries.  You can call your
own defuns in these templates if stuff (e.g. input reading) gets more
complicated.

When you want to use diary sexps as timestamps (e.g. following SCHEDULED
or DEADLINE keywords), AFAIR they are not allowed to be multiline.  That
will just break them.  If you need complex diary sexps there it's better
to define a named function and use that (in one line, then).

For org agenda generation as described in

  (info "(org) Weekly/daily agenda")

you don't need timestamps - you can write the diary sexp in %%(...) form
just after the property list (if there is one) of the entry, and that
%%(...) syntax _is_ allowed to be multiline.  Another important
difference is that in this case the string that appears in the agenda is
the return value of the diary sexp, not the headline of the current
item (as for time stamps).

And then let me add what I always say: many people have a wrong
impression how diary sexps work: these can be _any_ Elisp expression,
anything is allowed.  There is no limitation to use only built-in diary
sexps, you can freely combine them, define your own ones, etc.  The
(only) rule is: A diary sexp is evaluated with the special variable
`date` bound to the considered date, and it is considered to apply for
that day when and only when the return value is non-nil.  That's all.
The built-in diary sexps just implement that - it's a good idea to look
at the code to get a feeling for how that works internally.

Ok, that's all I could think of at the moment - any questions in
particular?

Michael.



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

end of thread, other threads:[~2022-10-21  6:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-12 18:19 Syntax for <%%(diary-float )> Renato Pontefice
2022-10-12 19:23 ` Michael Heerdegen
2022-10-12 19:42   ` Jean Louis
2022-10-12 19:59     ` Michael Heerdegen
2022-10-12 19:37 ` Jean Louis
2022-10-21  6:03 ` Michael Heerdegen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.