all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#11272: 24.1.50; `holiday-sexp' not always sufficient
@ 2012-04-18 17:28 Michael Heerdegen
  2022-05-10 11:50 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Heerdegen @ 2012-04-18 17:28 UTC (permalink / raw)
  To: 11272

Hello,

I wonder why it is currently not possible to have `holiday-sexp' or a
similar function return a _list_ of entries for a given year, instead of
only one (or nil).  Could we provide such a feature?

Some background (just an example): I have a function like this:

(defun sundays-after-trinitatis (year)
  "List of sundays after Trinitatis in year YEAR."
  (let ((i 1)
        (results ())
        (easterday (tagnummer-ostertag year))
        (3lSoKj (3lSoKj year)))
    (while (<= i 24)
      (let* ((day (+ easterday 56 (* 7 i))))
        (when (< day 3lSoKj)
          (push (list (calendar-gregorian-from-absolute
                       (+ (calendar-absolute-from-gregorian (list 1 1 year))
                          -1 day))
                      (format "%s. sunday after Trinitatis" i))
                results)))
      (setq i (+ i 1)))
    results))

For any year, according to certain rules, certain sundays are named "nth
sunday after Trinitatis", depending on `year'.  The above function
returns the list of them for any given year.  But I can't use it
directly with `holiday-sexp' - I have to write my own interface function
for the calendar:

(defun holiday-sundays-after-trinitatis ()
  "List of visible sundays after Trinitatis in `calendar'."
  (let ((year displayed-year))
    (holiday-filter-visible-calendar
     (append (sonntage-nach-trinitatis year)
             (sonntage-nach-trinitatis (+ 1 year))))))

(eval-after-load "holidays"
  '(add-to-list 'calendar-holidays '(holiday-sundays-after-trinitatis)))

I wonder if we could provide a function `holiday-list', so that it
would be possible to do this:

(add-to-list 'calendar-holidays '(holidays-list '(holiday-sundays-after-trinitatis)))

It would no doubt be useful for other cases as well.  It could look
similar to this:

(defun holiday-list (sexp)
  (let ((y displayed-year)
        year dates)
    (holiday-filter-visible-calendar
     (append
      (progn
        (setq year y)
        (eval sexp))
      (progn
        (setq year (1+ y))
        (eval sexp))))))

Please tell me what you think.

If you don't want to add something like that, maybe we could at least
improve the manual a bit.  Under "Holiday Customization", there is this
paragraph:

|    Some holidays just don't fit into any of these forms because special
| calculations are involved in their determination.  In such cases you
| must write a Lisp function to do the calculation.  To include eclipses,
| for example, add `(eclipses)' to `holiday-other-holidays' and write an
| Emacs Lisp function `eclipses' that returns a (possibly empty) list of
| the relevant Gregorian dates among the range visible in the calendar
| window, with descriptive strings, like this:
| 
|      (((6 4 2012) "Lunar Eclipse") ((11 13 2012) "Solar Eclipse") ... )

I think it would be good to add a simple example for how such a
function could look like.  No user not browsing the sources will know
about `holiday-filter-visible-calendar'.  At least that function
should be mentioned somewhere.


Thanks,

Michael.



In GNU Emacs 24.1.50.1 (i486-pc-linux-gnu, GTK+ Version 3.2.3)
 of 2012-04-10 on zelenka, modified by Debian
 (emacs-snapshot package, version 2:20120410-1)
Windowing system distributor `The X.Org Foundation', version 11.0.11104000
Configured using:
 `configure '--build' 'i486-linux-gnu' '--host' 'i486-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.1.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.1.50/site-lisp:/usr/share/emacs/site-lisp'
 '--without-compress-info' '--with-crt-dir=/usr/lib/i386-linux-gnu/'
 '--with-x=yes' '--with-x-toolkit=gtk3' '--with-imagemagick=yes'
 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu'
 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2''






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

* bug#11272: 24.1.50; `holiday-sexp' not always sufficient
  2012-04-18 17:28 bug#11272: 24.1.50; `holiday-sexp' not always sufficient Michael Heerdegen
@ 2022-05-10 11:50 ` Lars Ingebrigtsen
  2022-05-11  0:25   ` Michael Heerdegen
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-10 11:50 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 11272

Michael Heerdegen <michael_heerdegen@web.de> writes:

> I wonder if we could provide a function `holiday-list', so that it
> would be possible to do this:
>
> (add-to-list 'calendar-holidays '(holidays-list '(holiday-sundays-after-trinitatis)))

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I don't use the calendar much myself, but if I understand the report
correctly, what you're suggesting makes sense to me.  This was ten years
ago, though, so perhaps you've chosen to do something else?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#11272: 24.1.50; `holiday-sexp' not always sufficient
  2022-05-10 11:50 ` Lars Ingebrigtsen
@ 2022-05-11  0:25   ` Michael Heerdegen
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Heerdegen @ 2022-05-11  0:25 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 11272

Lars Ingebrigtsen <larsi@gnus.org> writes:

> > I wonder if we could provide a function `holiday-list', so that it
> > would be possible to do this:
> >
> > (add-to-list 'calendar-holidays
> >  '(holidays-list '(holiday-sundays-after-trinitatis)))

> I don't use the calendar much myself, but if I understand the report
> correctly, what you're suggesting makes sense to me.  This was ten years
> ago, though, so perhaps you've chosen to do something else?

Now I'm using my own extension library for diary sexps, it also handles
holidays.

AFAIR, one problem (with holidays) I later faced had been that it was
not possible at all to use the calendar holiday definitions in diary
sexps.  You can mark and list holidays in the calendar, but it is
not possible to use a diary sexp for date definitions like "Every Monday
meet Peter unless it's a holiday".

So I wrote some glue code to make things like that possible, but it's
all a bit hackish because Calendar and Diary are written in a way that I
don't like, like Ediff, with lots of special variables and weird
references to global state.

So now I'm using only the basic mechanisms from Calendar and Diary, and
the stuff I need to hack is only my own code.  Not sure yet what I will
do with that code.  Touching the calendar and diary libs is nothing I
look forward to, to be honest.

Michael.





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

end of thread, other threads:[~2022-05-11  0:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-18 17:28 bug#11272: 24.1.50; `holiday-sexp' not always sufficient Michael Heerdegen
2022-05-10 11:50 ` Lars Ingebrigtsen
2022-05-11  0:25   ` 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.