unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21256: [RFC] Extend holiday-greek-orthodox-easter in calendar
       [not found] <yx80fv3nz4w7.fsf@zakkak.net>
@ 2015-08-13 18:01 ` Paul Eggert
  2015-08-13 18:05 ` Paul Eggert
  1 sibling, 0 replies; 5+ messages in thread
From: Paul Eggert @ 2015-08-13 18:01 UTC (permalink / raw)
  To: 21256; +Cc: Foivos S. Zakkak

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

Tags: patch
Severity: wishlist

Forwarded from:
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00519.html

-------- Forwarded Message --------
Subject: [RFC] Extend holiday-greek-orthodox-easter in calendar
Date: Thu, 13 Aug 2015 16:36:56 +0300
From: Foivos S. Zakkak <foivos@zakkak.net>
To: emacs-devel@gnu.org


* Description

Extend holiday-greek-orthodox-easter to work like holiday-easter-etc.
That is, accept two optional arguments (n string) and calculate the Date
of Nth day after Easter (named STRING), if visible in calendar window.
The date is calculated according to the rule of the Council of Nicaea.

For backwards compatibility, if this function is called with no
arguments, then it returns the Pascha (Greek Orthodox Easter) day.

* The patch

--8<---------------cut here---------------start------------->8---
--- holidays_orig.el	2015-07-06 00:27:54.992714111 +0300
+++ holidays.el	2015-07-06 00:37:19.530996341 +0300
@@ -791,8 +791,20 @@
  ;; Prior call to calendar-julian-from-absolute will autoload cal-julian.
  (declare-function calendar-julian-to-absolute "cal-julian" (date))

-(defun holiday-greek-orthodox-easter ()
-  "Date of Easter according to the rule of the Council of Nicaea."
+(defun holiday-greek-orthodox-easter (&optional n string)
+  "Date of Nth day after Easter (named STRING), if visible in calendar
+window.  The date is calculated according to the rule of the Council of
+Nicaea.  Negative values of N are interpreted as days before Easter.
+STRING is used purely for display purposes.  The return value has the
+form ((MONTH DAY YEAR) STRING), where the date is that of the Nth day
+before or after Easter.
+
+For backwards compatibility, if this function is called with no
+arguments, then it returns the Pascha (Greek Orthodox Easter)
+day."
+  ;; Backwards compatibility layer.
+  (if (not n)
+      (holiday-greek-orthodox-easter 0 "Pascha (Greek Orthodox Easter)")
    (let* ((m displayed-month)
           (y displayed-year)
           (julian-year (progn
@@ -808,11 +820,11 @@
           (paschal-moon      ; day after full moon on or after March 21
            (- (calendar-julian-to-absolute (list 4 19 julian-year))
               shifted-epact))
-         (nicaean-easter           ; Sunday following the Paschal moon
-          (calendar-gregorian-from-absolute
-           (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))))
-    (if (calendar-date-is-visible-p nicaean-easter)
-        (list (list nicaean-easter "Pascha (Greek Orthodox Easter)")))))
+         ;; Sunday following the Paschal moon
+         (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))
+         (greg (calendar-gregorian-from-absolute (+ abs-easter n))))
+    (if (calendar-date-is-visible-p greg)
+          (list (list greg string))))))

  (provide 'holidays)

--8<---------------cut here---------------end--------------->8---

Kind regards,
Foivos
--
WWW: foivos.zakkak.net
PGP: 7B40 69D9 29BA AE91 C0B3  220A 0846 BFD1 03F0 4EA1




[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

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

* bug#21256: [RFC] Extend holiday-greek-orthodox-easter in calendar
       [not found] <yx80fv3nz4w7.fsf@zakkak.net>
  2015-08-13 18:01 ` bug#21256: [RFC] Extend holiday-greek-orthodox-easter in calendar Paul Eggert
@ 2015-08-13 18:05 ` Paul Eggert
  2015-08-13 18:38   ` Foivos S. Zakkak
  1 sibling, 1 reply; 5+ messages in thread
From: Paul Eggert @ 2015-08-13 18:05 UTC (permalink / raw)
  To: Foivos S. Zakkak; +Cc: 21256

[Moving this thread to the bug report email address.]

Foivos S. Zakkak wrote:

> Extend holiday-greek-orthodox-easter to work like holiday-easter-etc.

Thanks, could you give the use case for this extension?  My impression is that 
holiday-greek-orthodox-easter is intended for internal use, and the only place 
it's called wouldn't use this extension.






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

* bug#21256: [RFC] Extend holiday-greek-orthodox-easter in calendar
  2015-08-13 18:05 ` Paul Eggert
@ 2015-08-13 18:38   ` Foivos S. Zakkak
  2015-08-13 19:19     ` Paul Eggert
  0 siblings, 1 reply; 5+ messages in thread
From: Foivos S. Zakkak @ 2015-08-13 18:38 UTC (permalink / raw)
  To: Paul Eggert; +Cc: 21256

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


On 08/13/15 21:05 , Paul Eggert <eggert@cs.ucla.edu> wrote:
> [Moving this thread to the bug report email address.]
>
> Foivos S. Zakkak wrote:
>
>> Extend holiday-greek-orthodox-easter to work like holiday-easter-etc.
>
> Thanks, could you give the use case for this extension?  My impression is that
> holiday-greek-orthodox-easter is intended for internal use, and the only place
> it's called wouldn't use this extension.

Hello Paul,

To the best of my knowledge there is no preset to properly display all
the Greek holidays.  As a result, following the paradigms in [1] I
created a Greek localization.  However there are various Greek-Orthodox
holidays that are relative to the Easter date (i.e., "Καθαρά Δευτέρα" is
48 days before the Greek-Orthodox Easter) and I was not able to define
them properly.

With this extension one can use the following configuration or similar:

--8<---------------cut here---------------start------------->8---
  ;; Greek public holidays
  (setq holiday-christian-holidays
        '((holiday-fixed 1 1 "Πρωτοχρονιά")
          (holiday-fixed 1 6 "Θεοφάνεια")
          (holiday-greek-orthodox-easter -48 "Καθαρά Δευτέρα")
          (holiday-fixed 3 25 "Ευαγγελισμός της Θεοτόκου")
          (holiday-greek-orthodox-easter -2 "Μεγάλη Παρασκευή")
          (holiday-greek-orthodox-easter 0 "Κυριακή του Πάσχα")
          (holiday-greek-orthodox-easter +1 "Δευτέρα του Πάσχα")
          (holiday-fixed 5 1 "Εργατική Πρωτομαγιά")
          (holiday-greek-orthodox-easter +49 "Πεντηκοστή")
          (holiday-greek-orthodox-easter +50 "Αγίου Πνεύματος")
          (holiday-fixed 8 15 "Η Κοίμηση της Θεοτόκου")
          (holiday-fixed 12 25 "Χριστούγεννα")
          (holiday-fixed 12 26 "Σύναξις Ὑπεραγίας Θεοτόκου Μαρίας")
        ))
--8<---------------cut here---------------end--------------->8---

[1] http://www.emacswiki.org/emacs/CalendarLocalization

Kind regards,
Foivos
--
WWW: foivos.zakkak.net
PGP: 7B40 69D9 29BA AE91 C0B3  220A 0846 BFD1 03F0 4EA1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 212 bytes --]

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

* bug#21256: [RFC] Extend holiday-greek-orthodox-easter in calendar
  2015-08-13 18:38   ` Foivos S. Zakkak
@ 2015-08-13 19:19     ` Paul Eggert
  2015-08-13 19:49       ` Foivos S. Zakkak
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Eggert @ 2015-08-13 19:19 UTC (permalink / raw)
  To: Foivos S. Zakkak; +Cc: 21256-done

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

Foivos S. Zakkak wrote:
> With this extension one can use the following configuration or similar:

Thanks for the explanation.  I installed the attached patch, which should have 
the same effect, and am marking this as done.  Please let me know if it has any 
problems.

[-- Attachment #2: 0001-Optional-args-for-holiday-greek-orthodox-easter.txt --]
[-- Type: text/plain, Size: 3047 bytes --]

From 226e6dcf5696575615ae9bf26486e32de43b5aa4 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 13 Aug 2015 12:16:25 -0700
Subject: [PATCH] Optional args for holiday-greek-orthodox-easter
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* etc/NEWS: Document this.
* lisp/calendar/holidays.el (holiday-greek-orthodox-easter):
Add optional args N and STRING, mimicking the API and code of
‘holiday-easter-etc’.  From suggestion by Foivos S. Zakkak (Bug#21256).
---
 etc/NEWS                  |  3 +++
 lisp/calendar/holidays.el | 21 ++++++++++++++-------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 0a33a6e..3ec16f5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -552,6 +552,9 @@ The option customizes which day headers receive the
 `calendar-weekend-header' face.
 
 ---
+*** New optional args N and STRING for ‘holiday-greek-orthodox-easter’.
+
+---
 *** Many items obsolete since at least version 23.1 have been removed.
 The majority were function/variable/face aliases, too numerous to list here.
 The remainder were:
diff --git a/lisp/calendar/holidays.el b/lisp/calendar/holidays.el
index 8085c1c..6d7cea6 100644
--- a/lisp/calendar/holidays.el
+++ b/lisp/calendar/holidays.el
@@ -791,8 +791,16 @@ is non-nil)."
 ;; Prior call to calendar-julian-from-absolute will autoload cal-julian.
 (declare-function calendar-julian-to-absolute "cal-julian" (date))
 
-(defun holiday-greek-orthodox-easter ()
-  "Date of Easter according to the rule of the Council of Nicaea."
+(defun holiday-greek-orthodox-easter (&optional n string)
+  "Date of Nth day after Easter (named STRING), if visible in calendar window.
+It is calculated according to the rule of the Council of Nicaea.
+Negative values of N are interpreted as days before Easter.
+STRING is used purely for display purposes.  The return value has
+the form ((MONTH DAY YEAR) STRING), where the date is that of the
+Nth day before or after Easter.
+
+For backwards compatibility, if this function is called with no
+arguments, it returns the date of Pascha (Greek Orthodox Easter)."
   (let* ((m displayed-month)
          (y displayed-year)
          (julian-year (progn
@@ -808,11 +816,10 @@ is non-nil)."
          (paschal-moon      ; day after full moon on or after March 21
           (- (calendar-julian-to-absolute (list 4 19 julian-year))
              shifted-epact))
-         (nicaean-easter           ; Sunday following the Paschal moon
-          (calendar-gregorian-from-absolute
-           (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))))
-    (if (calendar-date-is-visible-p nicaean-easter)
-        (list (list nicaean-easter "Pascha (Greek Orthodox Easter)")))))
+	 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))
+	 (greg (calendar-gregorian-from-absolute (+ abs-easter (or n 0)))))
+    (if (calendar-date-is-visible-p greg)
+	(list (list greg (or string "Pascha (Greek Orthodox Easter)"))))))
 
 (provide 'holidays)
 
-- 
2.1.4


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

* bug#21256: [RFC] Extend holiday-greek-orthodox-easter in calendar
  2015-08-13 19:19     ` Paul Eggert
@ 2015-08-13 19:49       ` Foivos S. Zakkak
  0 siblings, 0 replies; 5+ messages in thread
From: Foivos S. Zakkak @ 2015-08-13 19:49 UTC (permalink / raw)
  To: Paul Eggert; +Cc: 21256-done

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


On 08/13/15 22:19 , Paul Eggert <eggert@cs.ucla.edu> wrote:
> Foivos S. Zakkak wrote:
>> With this extension one can use the following configuration or similar:
>
> Thanks for the explanation.  I installed the attached patch, which should have
> the same effect, and am marking this as done.  Please let me know if it has any
> problems.

I only see some tabs instead of spaces in the patch but functionally it
is OK, thanks!

Foivos
--
WWW: foivos.zakkak.net
PGP: 7B40 69D9 29BA AE91 C0B3  220A 0846 BFD1 03F0 4EA1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 212 bytes --]

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

end of thread, other threads:[~2015-08-13 19:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <yx80fv3nz4w7.fsf@zakkak.net>
2015-08-13 18:01 ` bug#21256: [RFC] Extend holiday-greek-orthodox-easter in calendar Paul Eggert
2015-08-13 18:05 ` Paul Eggert
2015-08-13 18:38   ` Foivos S. Zakkak
2015-08-13 19:19     ` Paul Eggert
2015-08-13 19:49       ` Foivos S. Zakkak

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).