emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/calendar/holidays.el,v


From: Glenn Morris
Subject: [Emacs-diffs] Changes to emacs/lisp/calendar/holidays.el,v
Date: Fri, 14 Mar 2008 07:04:44 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Glenn Morris <gm>       08/03/14 07:04:44

Index: holidays.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/calendar/holidays.el,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- holidays.el 13 Mar 2008 05:54:06 -0000      1.61
+++ holidays.el 14 Mar 2008 07:04:44 -0000      1.62
@@ -47,14 +47,75 @@
 
 ;;; Code:
 
-(defvar displayed-month)
-(defvar displayed-year)
-
 (require 'calendar)
 
 (eval-and-compile
   (load "hol-loaddefs" nil 'quiet))
 
+(defvar displayed-month)                ; from generate-calendar
+(defvar displayed-year)
+
+;;;###diary-autoload
+(defun calendar-holiday-list ()
+  "Form the list of holidays that occur on dates in the calendar window.
+The holidays are those in the list `calendar-holidays'."
+  (let (holiday-list)
+    (dolist (p calendar-holidays)
+      (let* ((holidays
+              (if calendar-debug-sexp
+                  (let ((stack-trace-on-error t))
+                    (eval p))
+                (condition-case nil
+                    (eval p)
+                  (error (beep)
+                         (message "Bad holiday list item: %s" p)
+                         (sleep-for 2))))))
+        (if holidays
+            (setq holiday-list (append holidays holiday-list)))))
+    (setq holiday-list (sort holiday-list 'calendar-date-compare))))
+
+;;;###cal-autoload
+(defun calendar-list-holidays ()
+  "Create a buffer containing the holidays for the current calendar window.
+The holidays are those in the list `calendar-notable-days'.  Returns t if any
+holidays are found, nil if not."
+  (interactive)
+  (message "Looking up holidays...")
+  (let ((holiday-list (calendar-holiday-list))
+        (m1 displayed-month)
+        (y1 displayed-year)
+        (m2 displayed-month)
+        (y2 displayed-year))
+    (if (not holiday-list)
+        (progn
+          (message "Looking up holidays...none found")
+          nil)
+      (set-buffer (get-buffer-create holiday-buffer))
+      (setq buffer-read-only nil)
+      (increment-calendar-month m1 y1 -1)
+      (increment-calendar-month m2 y2 1)
+      (calendar-set-mode-line
+       (if (= y1 y2)
+           (format "Notable Dates from %s to %s, %d%%-"
+                   (calendar-month-name m1) (calendar-month-name m2) y2)
+         (format "Notable Dates from %s, %d to %s, %d%%-"
+                 (calendar-month-name m1) y1 (calendar-month-name m2) y2)))
+      (erase-buffer)
+      (insert
+       (mapconcat
+        (lambda (x) (concat (calendar-date-string (car x))
+                            ": " (cadr x)))
+        holiday-list "\n"))
+      (goto-char (point-min))
+      (set-buffer-modified-p nil)
+      (setq buffer-read-only t)
+      (display-buffer holiday-buffer)
+      (message "Looking up holidays...done")
+      t)))
+
+(define-obsolete-function-alias
+  'list-calendar-holidays 'calendar-list-holidays "23.1")
+
 ;;;###autoload
 (defun holidays (&optional arg)
   "Display the holidays for last month, this month, and next month.
@@ -63,8 +124,7 @@
   (interactive "P")
   (save-excursion
     (let* ((completion-ignore-case t)
-           (date (if arg
-                     (calendar-read-date t)
+           (date (if arg (calendar-read-date t)
                    (calendar-current-date)))
            (displayed-month (extract-calendar-month date))
            (displayed-year (extract-calendar-year date)))
@@ -161,7 +221,7 @@
       (insert
        (mapconcat
         (lambda (x) (concat (calendar-date-string (car x))
-                             ": " (car (cdr x))))
+                            ": " (cadr x)))
         holiday-list "\n"))
       (goto-char (point-min))
       (set-buffer-modified-p nil)
@@ -185,6 +245,9 @@
           (setq holiday-list (append holiday-list (cdr h)))))
     holiday-list))
 
+(define-obsolete-function-alias
+  'check-calendar-holidays 'calendar-check-holidays "23.1")
+
 ;;;###cal-autoload
 (defun calendar-cursor-holidays ()
   "Find holidays for the date specified by the cursor in the calendar window."
@@ -217,67 +280,11 @@
   (setq mark-holidays-in-calendar t)
   (message "Marking holidays...")
   (dolist (holiday (calendar-holiday-list))
-    (mark-visible-calendar-date
-     (car holiday) calendar-holiday-marker))
+    (mark-visible-calendar-date (car holiday) calendar-holiday-marker))
   (message "Marking holidays...done"))
 
-;;;###cal-autoload
-(defun calendar-list-holidays ()
-  "Create a buffer containing the holidays for the current calendar window.
-The holidays are those in the list `calendar-notable-days'.  Returns t if any
-holidays are found, nil if not."
-  (interactive)
-  (message "Looking up holidays...")
-  (let ((holiday-list (calendar-holiday-list))
-        (m1 displayed-month)
-        (y1 displayed-year)
-        (m2 displayed-month)
-        (y2 displayed-year))
-    (if (not holiday-list)
-        (progn
-          (message "Looking up holidays...none found")
-          nil)
-      (set-buffer (get-buffer-create holiday-buffer))
-      (setq buffer-read-only nil)
-      (increment-calendar-month m1 y1 -1)
-      (increment-calendar-month m2 y2 1)
-      (calendar-set-mode-line
-       (if (= y1 y2)
-           (format "Notable Dates from %s to %s, %d%%-"
-                   (calendar-month-name m1) (calendar-month-name m2) y2)
-         (format "Notable Dates from %s, %d to %s, %d%%-"
-                 (calendar-month-name m1) y1 (calendar-month-name m2) y2)))
-      (erase-buffer)
-      (insert
-       (mapconcat
-        (lambda (x) (concat (calendar-date-string (car x))
-                             ": " (car (cdr x))))
-        holiday-list "\n"))
-      (goto-char (point-min))
-      (set-buffer-modified-p nil)
-      (setq buffer-read-only t)
-      (display-buffer holiday-buffer)
-      (message "Looking up holidays...done")
-      t)))
-
-;;;###diary-autoload
-(defun calendar-holiday-list ()
-  "Form the list of holidays that occur on dates in the calendar window.
-The holidays are those in the list `calendar-holidays'."
-  (let (holiday-list)
-    (dolist (p calendar-holidays)
-      (let* ((holidays
-              (if calendar-debug-sexp
-                  (let ((stack-trace-on-error t))
-                    (eval p))
-                (condition-case nil
-                    (eval p)
-                  (error (beep)
-                         (message "Bad holiday list item: %s" p)
-                         (sleep-for 2))))))
-        (if holidays
-            (setq holiday-list (append holidays holiday-list)))))
-    (setq holiday-list (sort holiday-list 'calendar-date-compare))))
+(define-obsolete-function-alias
+  'mark-calendar-holidays 'calendar-mark-holidays "23.1")
 
 ;; Below are the functions that calculate the dates of holidays; these
 ;; are eval'ed in the function calendar-holiday-list.  If you
@@ -305,18 +312,18 @@
 An optional parameter DAY means the Nth DAYNAME on or after/before MONTH DAY.
 
 Returns nil if it is not visible in the current calendar window."
-;; This is messy because the holiday may be visible, while the date on which
-;; it is based is not.  For example, the first Monday after December 30 may be
-;; visible when January is not.  For large values of |n| the problem is more
-;; grotesque.  If we didn't have to worry about such cases, we could just use
-
-;;  (let ((m displayed-month)
-;;        (y displayed-year))
-;;    (increment-calendar-month m y (- 11 month))
-;;    (if (> m 9); month in year y is visible
-;;      (list (list (calendar-nth-named-day n dayname month y day) string)))))
+  ;; This is messy because the holiday may be visible, while the date on which
+  ;; it is based is not.  For example, the first Monday after December 30 may 
be
+  ;; visible when January is not.  For large values of |n| the problem is more
+  ;; grotesque.  If we didn't have to worry about such cases, we could just use
+
+  ;;  (let ((m displayed-month)
+  ;;        (y displayed-year))
+  ;;    (increment-calendar-month m y (- 11 month))
+  ;;    (if (> m 9); month in year y is visible
+  ;;      (list (list (calendar-nth-named-day n dayname month y day) 
string)))))
 
-;; which is the way the function was originally written.
+  ;; which is the way the function was originally written.
 
   (let* ((m1 displayed-month)
          (y1 displayed-year)
@@ -348,6 +355,18 @@
           (list (list (calendar-nth-named-day n dayname month y d)
                       string))))))
 
+(defun holiday-filter-visible-calendar (l)
+  "Return a list of all visible holidays of those on L."
+  (let ((visible ()))
+    (dolist (p l)
+      (and (car p)
+           (calendar-date-is-visible-p (car p))
+           (push p visible)))
+    visible))
+
+(define-obsolete-function-alias
+  'filter-visible-calendar-holidays 'holiday-filter-visible-calendar "23.1")
+
 (defun holiday-sexp (sexp string)
   "Sexp holiday for dates in the calendar window.
 SEXP is an expression in variable `year' evaluates to `date'.
@@ -480,25 +499,6 @@
       (if (calendar-date-is-visible-p nicaean-easter)
           (list (list nicaean-easter "Pascha (Greek Orthodox Easter)"))))))
 
-(defun holiday-filter-visible-calendar (l)
-  "Return a list of all visible holidays of those on L."
-  (let ((visible ()))
-    (dolist (p l)
-      (and (car p)
-           (calendar-date-is-visible-p (car p))
-           (push p visible)))
-    visible))
-
-;; Backward compatibility.
-(define-obsolete-function-alias
-  'filter-visible-calendar-holidays 'holiday-filter-visible-calendar "23.1")
-(define-obsolete-function-alias
-  'list-calendar-holidays 'calendar-list-holidays "23.1")
-(define-obsolete-function-alias
-  'mark-calendar-holidays 'calendar-mark-holidays "23.1")
-(define-obsolete-function-alias
-  'check-calendar-holidays 'calendar-check-holidays "23.1")
-
 (provide 'holidays)
 
 ;; arch-tag: 48eb3117-75a7-4dbe-8fd9-873c3cbb0d37




reply via email to

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