unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* holidays.el
@ 2004-07-19 15:59 ` Håkon Malmedal
  2004-07-19 17:35   ` holidays.el Ed Reingold
  2004-09-22 23:27   ` holidays.el Glenn Morris
  0 siblings, 2 replies; 8+ messages in thread
From: Håkon Malmedal @ 2004-07-19 15:59 UTC (permalink / raw)


I was thinking that if the function holiday-easter-etc looked
something like this:

(defun holiday-easter-etc (n string)
  "Holiday on Nth day after Easter called STRING."
  (let* ((century (1+ (/ displayed-year 100)))
	 (shifted-epact        ;; Age of moon for April 5...
	  (% (+ 14 (* 11 (% displayed-year 19));;     ...by Nicaean rule
		(-           ;; ...corrected for the Gregorian century rule
		 (/ (* 3 century) 4))
		(/    ;; ...corrected for Metonic cycle inaccuracy.
		 (+ 5 (* 8 century)) 25)
		(* 30 century));;              Keeps value positive.
	     30))
	 (adjusted-epact       ;;  Adjust for 29.5 day month.
	  (if (or (= shifted-epact 0)
		  (and (= shifted-epact 1) (< 10 (% displayed-year 19))))
	      (1+ shifted-epact)
	    shifted-epact))
	 (paschal-moon       ;; Day after the full moon on or after March 21.
	  (- (calendar-absolute-from-gregorian (list 4 19 displayed-year))
	     adjusted-epact))
	 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))
	 (mandatory
	  (list
	   (list (calendar-gregorian-from-absolute (+ abs-easter n))
		 string)))
	 (output-list
	  (filter-visible-calendar-holidays mandatory)))
    output-list))

and the function holiday-advent looked something like this:

(defun holiday-advent (n string)
  "Holiday on Nth day after Advent called STRING."
  (let ((year displayed-year)
        (month displayed-month))
    (increment-calendar-month month year -1)
    (let ((advent (calendar-gregorian-from-absolute
		   (+ n
                    (calendar-dayname-on-or-before 0
                     (calendar-absolute-from-gregorian
                      (list 12 3 year)))))))
      (if (calendar-date-is-visible-p advent)
          (list (list advent string))))))

then the variable christian-holidays (in calendar.el) could look like
this:

;;;###autoload
(put 'christian-holidays 'risky-local-variable t)
;;;###autoload
(defcustom christian-holidays
  '((if all-christian-calendar-holidays
        (holiday-fixed 1 6 "Epiphany"))
    (holiday-easter-etc 0 "Easter Sunday")
    (holiday-easter-etc -2 "Good Friday")
    (holiday-easter-etc -46 "Ash Wednesday")
    (if all-christian-calendar-holidays
        (holiday-easter-etc -63 "Septuagesima Sunday"))
    (if all-christian-calendar-holidays
        (holiday-easter-etc -56 "Sexagesima Sunday"))
    (if all-christian-calendar-holidays
        (holiday-easter-etc -49 "Shrove Sunday"))
    (if all-christian-calendar-holidays
        (holiday-easter-etc -48 "Shrove Monday"))
    (if all-christian-calendar-holidays
        (holiday-easter-etc -47 "Shrove Tuesday"))
    (if all-christian-calendar-holidays
        (holiday-easter-etc -14 "Passion Sunday"))
    (if all-christian-calendar-holidays
        (holiday-easter-etc -7 "Palm Sunday"))
    (if all-christian-calendar-holidays
        (holiday-easter-etc -3 "Maundy Thursday"))
    (if all-christian-calendar-holidays
        (holiday-easter-etc 35 "Rogation Sunday"))
    (if all-christian-calendar-holidays
        (holiday-easter-etc 39 "Ascension Day"))
    (if all-christian-calendar-holidays
        (holiday-easter-etc 49 "Pentecost (Whitsunday)"))
    (if all-christian-calendar-holidays
        (holiday-easter-etc 50 "Whitmonday"))
    (if all-christian-calendar-holidays
        (holiday-easter-etc 56 "Trinity Sunday"))
    (if all-christian-calendar-holidays
        (holiday-easter-etc 60 "Corpus Christi"))
    (if all-christian-calendar-holidays
        (holiday-greek-orthodox-easter))
    (if all-christian-calendar-holidays
        (holiday-fixed 8 15 "Assumption"))
    (if all-christian-calendar-holidays
        (holiday-advent 0 "Advent"))
    (holiday-fixed 12 25 "Christmas")
    (if all-christian-calendar-holidays
        (holiday-julian 12 25 "Eastern Orthodox Christmas")))
  "*Christian holidays.
See the documentation for `calendar-holidays' for details."
  :type 'sexp
  :group 'holidays)

and be much easier to customize. Is this a good/bad idea?

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

* Re: holidays.el
  2004-07-19 15:59 ` holidays.el Håkon Malmedal
@ 2004-07-19 17:35   ` Ed Reingold
  2004-09-22 23:27   ` holidays.el Glenn Morris
  1 sibling, 0 replies; 8+ messages in thread
From: Ed Reingold @ 2004-07-19 17:35 UTC (permalink / raw)
  Cc: emacs-devel

That's a good idea--there are similar things elsewhere that should be changed. 
I did not write it that way originally (nearly 20 years ago!) because it would 
have been too slow; now hardware is so fast that the difference in time would 
be negligible.  Feel free to fix this.

> I was thinking that if the function holiday-easter-etc looked
> something like this:
> 
> (defun holiday-easter-etc (n string)
>   "Holiday on Nth day after Easter called STRING."
>   (let* ((century (1+ (/ displayed-year 100)))
> 	 (shifted-epact        ;; Age of moon for April 5...
> 	  (% (+ 14 (* 11 (% displayed-year 19));;     ...by Nicaean rule
> 		(-           ;; ...corrected for the Gregorian century rule
> 		 (/ (* 3 century) 4))
> 		(/    ;; ...corrected for Metonic cycle inaccuracy.
> 		 (+ 5 (* 8 century)) 25)
> 		(* 30 century));;              Keeps value positive.
> 	     30))
> 	 (adjusted-epact       ;;  Adjust for 29.5 day month.
> 	  (if (or (= shifted-epact 0)
> 		  (and (= shifted-epact 1) (< 10 (% displayed-year 19))))
> 	      (1+ shifted-epact)
> 	    shifted-epact))
> 	 (paschal-moon       ;; Day after the full moon on or after March 21.
> 	  (- (calendar-absolute-from-gregorian (list 4 19 displayed-year))
> 	     adjusted-epact))
> 	 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))
> 	 (mandatory
> 	  (list
> 	   (list (calendar-gregorian-from-absolute (+ abs-easter n))
> 		 string)))
> 	 (output-list
> 	  (filter-visible-calendar-holidays mandatory)))
>     output-list))
> 
> and the function holiday-advent looked something like this:
> 
> (defun holiday-advent (n string)
>   "Holiday on Nth day after Advent called STRING."
>   (let ((year displayed-year)
>         (month displayed-month))
>     (increment-calendar-month month year -1)
>     (let ((advent (calendar-gregorian-from-absolute
> 		   (+ n
>                     (calendar-dayname-on-or-before 0
>                      (calendar-absolute-from-gregorian
>                       (list 12 3 year)))))))
>       (if (calendar-date-is-visible-p advent)
>           (list (list advent string))))))
> 
> then the variable christian-holidays (in calendar.el) could look like
> this:
> 
> ;;;###autoload
> (put 'christian-holidays 'risky-local-variable t)
> ;;;###autoload
> (defcustom christian-holidays
>   '((if all-christian-calendar-holidays
>         (holiday-fixed 1 6 "Epiphany"))
>     (holiday-easter-etc 0 "Easter Sunday")
>     (holiday-easter-etc -2 "Good Friday")
>     (holiday-easter-etc -46 "Ash Wednesday")
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc -63 "Septuagesima Sunday"))
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc -56 "Sexagesima Sunday"))
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc -49 "Shrove Sunday"))
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc -48 "Shrove Monday"))
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc -47 "Shrove Tuesday"))
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc -14 "Passion Sunday"))
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc -7 "Palm Sunday"))
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc -3 "Maundy Thursday"))
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc 35 "Rogation Sunday"))
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc 39 "Ascension Day"))
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc 49 "Pentecost (Whitsunday)"))
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc 50 "Whitmonday"))
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc 56 "Trinity Sunday"))
>     (if all-christian-calendar-holidays
>         (holiday-easter-etc 60 "Corpus Christi"))
>     (if all-christian-calendar-holidays
>         (holiday-greek-orthodox-easter))
>     (if all-christian-calendar-holidays
>         (holiday-fixed 8 15 "Assumption"))
>     (if all-christian-calendar-holidays
>         (holiday-advent 0 "Advent"))
>     (holiday-fixed 12 25 "Christmas")
>     (if all-christian-calendar-holidays
>         (holiday-julian 12 25 "Eastern Orthodox Christmas")))
>   "*Christian holidays.
> See the documentation for `calendar-holidays' for details."
>   :type 'sexp
>   :group 'holidays)
> 
> and be much easier to customize. Is this a good/bad idea?
> 
> 
> 
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: holidays.el
  2004-07-19 15:59 ` holidays.el Håkon Malmedal
  2004-07-19 17:35   ` holidays.el Ed Reingold
@ 2004-09-22 23:27   ` Glenn Morris
  2004-09-23  7:26     ` holidays.el Kim F. Storm
  1 sibling, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2004-09-22 23:27 UTC (permalink / raw)
  Cc: emacs-devel

Håkon Malmedal wrote:

> I was thinking that if the function holiday-easter-etc looked
> something like this:
[...]
>
> and the function holiday-advent looked something like this:
[...]
> then the variable christian-holidays (in calendar.el) could look like
> this:
[...]
> and be much easier to customize. Is this a good/bad idea?

Thank you - I installed your suggestions.

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

* Re: holidays.el
  2004-09-22 23:27   ` holidays.el Glenn Morris
@ 2004-09-23  7:26     ` Kim F. Storm
  2004-09-23 10:05       ` holidays.el Glenn Morris
  0 siblings, 1 reply; 8+ messages in thread
From: Kim F. Storm @ 2004-09-23  7:26 UTC (permalink / raw)
  Cc: hmalmedal, emacs-devel

Glenn Morris <gmorris+emacs@ast.cam.ac.uk> writes:

> Håkon Malmedal wrote:
>
>> I was thinking that if the function holiday-easter-etc looked
>> something like this:
> [...]
>>
>> and the function holiday-advent looked something like this:
> [...]
>> then the variable christian-holidays (in calendar.el) could look like
>> this:
> [...]
>> and be much easier to customize. Is this a good/bad idea?
>
> Thank you - I installed your suggestions.

These changes are more than a "tiny change", so we need papers from
Håkon to install these changes.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: holidays.el
  2004-09-23  7:26     ` holidays.el Kim F. Storm
@ 2004-09-23 10:05       ` Glenn Morris
  2004-09-23 10:28         ` holidays.el Kim F. Storm
  0 siblings, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2004-09-23 10:05 UTC (permalink / raw)
  Cc: Håkon Malmedal, emacs-devel

Kim F. Storm wrote:

> These changes are more than a "tiny change", so we need papers from
> Håkon to install these changes.

I was unsure about that, so I consulted RMS before installing the
changes. He said the opposite to you, but it's entirely possbile I
didn't explain the changes well, so I'm ready to revert them.


Richard Stallman wrote (on Wed, 22 Sep 2004 at 10:00 -0400):

>     I would install this, but I'm unsure as to whether there is a
>     copyright issue. The total number of lines changed is > 15, but
>     the actual idea behind the changes is simple, and it's really
>     just case of moving some code from one place to another in a
>     repetitive way. Can you advise please?
> 
> A change like that is not significant for copyright purposes.
> You go by the amount of new material that he actually wrote.

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

* Re: holidays.el
  2004-09-23 10:05       ` holidays.el Glenn Morris
@ 2004-09-23 10:28         ` Kim F. Storm
  2004-09-23 16:08           ` holidays.el Glenn Morris
  2004-09-23 16:44           ` holidays.el Richard Stallman
  0 siblings, 2 replies; 8+ messages in thread
From: Kim F. Storm @ 2004-09-23 10:28 UTC (permalink / raw)
  Cc: Håkon Malmedal

Glenn Morris <gmorris+emacs@ast.cam.ac.uk> writes:

> Kim F. Storm wrote:
>
>> These changes are more than a "tiny change", so we need papers from
>> Håkon to install these changes.
>
> I was unsure about that, so I consulted RMS before installing the
> changes. He said the opposite to you, but it's entirely possbile I
> didn't explain the changes well, so I'm ready to revert them.
>
>
> Richard Stallman wrote (on Wed, 22 Sep 2004 at 10:00 -0400):
>
>>     I would install this, but I'm unsure as to whether there is a
>>     copyright issue. The total number of lines changed is > 15, but
>>     the actual idea behind the changes is simple, and it's really
>>     just case of moving some code from one place to another in a
>>     repetitive way. Can you advise please?
>> 
>> A change like that is not significant for copyright purposes.
>> You go by the amount of new material that he actually wrote.

The code "moved" from holidays.el to calender.el is 'similar'
but not identical.  

It involves taking 40 lines from a function in holidays.el and change
them into a form suitable for initializing a defcustom in calender.el.

I agree that the 'transformation' is repetitive/mechanical, and the
end-result is functionally equivalent to the original code.  Still,
the change involves more than just "moving" code.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: holidays.el
  2004-09-23 10:28         ` holidays.el Kim F. Storm
@ 2004-09-23 16:08           ` Glenn Morris
  2004-09-23 16:44           ` holidays.el Richard Stallman
  1 sibling, 0 replies; 8+ messages in thread
From: Glenn Morris @ 2004-09-23 16:08 UTC (permalink / raw)
  Cc: Håkon Malmedal, emacs-devel

Kim F. Storm wrote:

> It involves taking 40 lines from a function in holidays.el and
> change them into a form suitable for initializing a defcustom in
> calender.el.
>
> I agree that the 'transformation' is repetitive/mechanical, and the
> end-result is functionally equivalent to the original code. Still,
> the change involves more than just "moving" code.

Okay, slightly more than just moving; but most of the 40-odd lines can
be described as "do the same simple transformation 20 or so times". I
thought that 40 -> 2 (effectively) in such cases? Though I can't find
the reference at present for why I though that...

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

* Re: holidays.el
  2004-09-23 10:28         ` holidays.el Kim F. Storm
  2004-09-23 16:08           ` holidays.el Glenn Morris
@ 2004-09-23 16:44           ` Richard Stallman
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Stallman @ 2004-09-23 16:44 UTC (permalink / raw)
  Cc: hmalmedal, emacs-devel

I looked at the specific change, and it qualifies as tiny.

    I agree that the 'transformation' is repetitive/mechanical, and the
    end-result is functionally equivalent to the original code.  Still,
    the change involves more than just "moving" code.

A mechanical change does not count more for copyright purposes when it
is repeated many times.

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

end of thread, other threads:[~2004-09-23 16:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <"Message from hmalmedal"@yahoo.no>
2004-07-19 15:59 ` holidays.el Håkon Malmedal
2004-07-19 17:35   ` holidays.el Ed Reingold
2004-09-22 23:27   ` holidays.el Glenn Morris
2004-09-23  7:26     ` holidays.el Kim F. Storm
2004-09-23 10:05       ` holidays.el Glenn Morris
2004-09-23 10:28         ` holidays.el Kim F. Storm
2004-09-23 16:08           ` holidays.el Glenn Morris
2004-09-23 16:44           ` holidays.el Richard Stallman

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