]> code.delx.au - gnu-emacs/blobdiff - lisp/calendar/calendar.el
(calc-embedded-close-formula, calc-embedded-open-formula,
[gnu-emacs] / lisp / calendar / calendar.el
index baa18d769c2cba72a25447b1696aecde25066e76..3e075b9d6bd564fa4e763d2576a11a087d61e0d5 100644 (file)
@@ -22,8 +22,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
 ;;       solar.el                      Sunrise/sunset, equinoxes/solstices
 
 ;; Technical details of all the calendrical calculations can be found in
-;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
-;; Cambridge University Press (1997).
+;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold
+;; and Nachum Dershowitz, Cambridge University Press (2001).
 
 ;; An earlier version of the technical details appeared in
 ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
 ;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990),
-;; pages 899-928 ``Calendrical Calculations, Part II: Three Historical
+;; pages 899-928, and in ``Calendrical Calculations, Part II: Three Historical
 ;; Calendars'' by E. M. Reingold,  N. Dershowitz, and S. M. Clamen,
 ;; Software--Practice and Experience, Volume 23, Number 4 (April, 1993),
 ;; pages 383-404.
@@ -206,24 +206,32 @@ If nil, make an icon of the frame.  If non-nil, delete the frame."
   :type 'boolean
   :group 'view)
 
-(defvar diary-face 'diary-face
+(defvar diary-face 'diary
   "Face name to use for diary entries.")
-(defface diary-face
-  '((((class color) (background light))
+(defface diary
+  '((((min-colors 88) (class color) (background light))
+     :foreground "red1")
+    (((class color) (background light))
      :foreground "red")
+    (((min-colors 88) (class color) (background dark))
+     :foreground "yellow1")
     (((class color) (background dark))
      :foreground "yellow")
     (t
      :weight bold))
   "Face for highlighting diary entries."
   :group 'diary)
+;; backward-compatibility alias
+(put 'diary-face 'face-alias 'diary)
 
-(defface calendar-today-face
+(defface calendar-today
   '((t (:underline t)))
   "Face for indicating today's date."
   :group 'diary)
+;; backward-compatibility alias
+(put 'calendar-today-face 'face-alias 'calendar-today)
 
-(defface holiday-face
+(defface holiday
   '((((class color) (background light))
      :background "pink")
     (((class color) (background dark))
@@ -232,17 +240,19 @@ If nil, make an icon of the frame.  If non-nil, delete the frame."
      :inverse-video t))
   "Face for indicating dates that have holidays."
   :group 'diary)
+;; backward-compatibility alias
+(put 'holiday-face 'face-alias 'holiday)
 
 (eval-after-load "facemenu"
   '(progn
-     (add-to-list 'facemenu-unlisted-faces 'diary-face)
-     (add-to-list 'facemenu-unlisted-faces 'calendar-today-face)
-     (add-to-list 'facemenu-unlisted-faces 'holiday-face)))
+     (add-to-list 'facemenu-unlisted-faces 'diary)
+     (add-to-list 'facemenu-unlisted-faces 'calendar-today)
+     (add-to-list 'facemenu-unlisted-faces 'holiday)))
 
 (defcustom diary-entry-marker
   (if (not (display-color-p))
       "+"
-    'diary-face)
+    'diary)
   "*How to mark dates that have diary entries.
 The value can be either a single-character string or a face."
   :type '(choice string face)
@@ -251,7 +261,7 @@ The value can be either a single-character string or a face."
 (defcustom calendar-today-marker
   (if (not (display-color-p))
       "="
-    'calendar-today-face)
+    'calendar-today)
   "*How to mark today's date in the calendar.
 The value can be either a single-character string or a face.
 Marking today's date is done only if you set up `today-visible-calendar-hook'
@@ -262,7 +272,7 @@ to request that."
 (defcustom calendar-holiday-marker
   (if (not (display-color-p))
       "*"
-    'holiday-face)
+    'holiday)
   "*How to mark notable dates in the calendar.
 The value can be either a single-character string or a face."
   :type '(choice string face)
@@ -1808,7 +1818,7 @@ Driven by the variable `calendar-date-display-form'.")
   t)
 
 (autoload 'calendar-goto-hebrew-date "cal-hebrew"
-  "Move cursor to Hebrew date date."
+  "Move cursor to Hebrew date."
   t)
 
 (autoload 'calendar-print-hebrew-date "cal-hebrew"
@@ -1820,7 +1830,7 @@ Driven by the variable `calendar-date-display-form'.")
   t)
 
 (autoload 'calendar-goto-coptic-date "cal-coptic"
-   "Move cursor to Coptic date date."
+   "Move cursor to Coptic date."
    t)
 
 (autoload 'calendar-print-coptic-date "cal-coptic"
@@ -1832,7 +1842,7 @@ Driven by the variable `calendar-date-display-form'.")
   t)
 
 (autoload 'calendar-goto-ethiopic-date "cal-coptic"
-   "Move cursor to Ethiopic date date."
+   "Move cursor to Ethiopic date."
    t)
 
 (autoload 'calendar-print-ethiopic-date "cal-coptic"
@@ -1844,7 +1854,7 @@ Driven by the variable `calendar-date-display-form'.")
   t)
 
 (autoload 'calendar-goto-persian-date "cal-persia"
-   "Move cursor to Persian date date."
+   "Move cursor to Persian date."
    t)
 
 (autoload 'calendar-print-persian-date "cal-persia"
@@ -2195,9 +2205,11 @@ movement commands will not work correctly."
                                 calendar-mode-map global-map)
       (setq l (cdr l))))
   (define-key calendar-mode-map "-"     'negative-argument)
+  (define-key calendar-mode-map ">"     'scroll-calendar-right)
   (define-key calendar-mode-map "\C-x>" 'scroll-calendar-right)
   (define-key calendar-mode-map [prior] 'scroll-calendar-right-three-months)
   (define-key calendar-mode-map "\ev"   'scroll-calendar-right-three-months)
+  (define-key calendar-mode-map "<"     'scroll-calendar-left)
   (define-key calendar-mode-map "\C-x<" 'scroll-calendar-left)
   (define-key calendar-mode-map [next]  'scroll-calendar-left-three-months)
   (define-key calendar-mode-map "\C-v"  'scroll-calendar-left-three-months)
@@ -2331,6 +2343,7 @@ movement commands will not work correctly."
    (propertize (substitute-command-keys
                "\\<calendar-mode-map>\\[scroll-calendar-left]")
               'help-echo "mouse-2: scroll left"
+              'mouse-face 'mode-line-highlight
               'keymap (make-mode-line-mouse-map 'mouse-2
                                                 'mouse-scroll-calendar-left))
    "Calendar"
@@ -2339,12 +2352,14 @@ movement commands will not work correctly."
      (substitute-command-keys
       "\\<calendar-mode-map>\\[calendar-goto-info-node] info")
      'help-echo "mouse-2: read Info on Calendar"
+     'mouse-face 'mode-line-highlight
      'keymap (make-mode-line-mouse-map 'mouse-2 'calendar-goto-info-node))
     "/"
     (propertize
      (substitute-command-keys
      "\\<calendar-mode-map>\\[calendar-other-month] other")
      'help-echo "mouse-2: choose another month"
+     'mouse-face 'mode-line-highlight
      'keymap (make-mode-line-mouse-map
              'mouse-2 'mouse-calendar-other-month))
     "/"
@@ -2352,11 +2367,13 @@ movement commands will not work correctly."
      (substitute-command-keys
      "\\<calendar-mode-map>\\[calendar-goto-today] today")
      'help-echo "mouse-2: go to today's date"
+     'mouse-face 'mode-line-highlight
      'keymap (make-mode-line-mouse-map 'mouse-2 #'calendar-goto-today)))
    '(calendar-date-string (calendar-current-date) t)
    (propertize (substitute-command-keys
                "\\<calendar-mode-map>\\[scroll-calendar-right]")
               'help-echo "mouse-2: scroll right"
+              'mouse-face 'mode-line-highlight
               'keymap (make-mode-line-mouse-map
                        'mouse-2 'mouse-scroll-calendar-right)))
   "The mode line of the calendar buffer.
@@ -2432,7 +2449,6 @@ For a complete description, type \
 \\<calendar-mode-map>\\[calendar-goto-info-node] from within the calendar.
 
 \\<calendar-mode-map>\\{calendar-mode-map}"
-
   (kill-all-local-variables)
   (setq major-mode 'calendar-mode)
   (setq mode-name "Calendar")
@@ -2445,7 +2461,8 @@ For a complete description, type \
   (make-local-variable 'displayed-month);;  Month in middle of window.
   (make-local-variable 'displayed-year)        ;;  Year in middle of window.
   (set (make-local-variable 'font-lock-defaults)
-       '(calendar-font-lock-keywords t)))
+       '(calendar-font-lock-keywords t))
+  (run-mode-hooks 'calendar-mode-hook))
 
 (defun calendar-string-spread (strings char length)
   "Concatenate list of STRINGS separated with copies of CHAR to fill LENGTH.
@@ -2570,7 +2587,7 @@ ERROR is t, otherwise just returns nil."
           (if (not (looking-at " "))
                    (re-search-backward "[^0-9]"))
           (list month
-                (string-to-int (buffer-substring (1+ (point)) (+ 4 (point))))
+                (string-to-number (buffer-substring (1+ (point)) (+ 4 (point))))
                 year))
       (if (looking-at "\\*")
           (save-excursion
@@ -2763,7 +2780,7 @@ in `calendar-day-name-array'.  These abbreviations may be used
 instead of the full names in the diary file.  Do not include a
 trailing `.' in the strings specified in this variable, though
 you may use such in the diary file.  If any element of this array
-is nil, then the abbreviation will be constructed as the first 
+is nil, then the abbreviation will be constructed as the first
 `calendar-abbrev-length' characters of the corresponding full name.")
 
 (defvar calendar-month-name-array
@@ -2884,20 +2901,20 @@ interpreted as BC; -1 being 1 BC, and so on."
   (redraw-calendar))
 
 (defun calendar-date-is-visible-p (date)
-  "Return t if DATE is legal and is visible in the calendar window."
+  "Return t if DATE is valid and is visible in the calendar window."
   (let ((gap (calendar-interval
               displayed-month displayed-year
               (extract-calendar-month date) (extract-calendar-year date))))
     (and (calendar-date-is-legal-p date) (> 2 gap) (< -2 gap))))
 
 (defun calendar-date-is-legal-p (date)
-  "Return t if DATE is a legal date."
+  "Return t if DATE is a valid date."
   (let ((month (extract-calendar-month date))
         (day (extract-calendar-day date))
         (year (extract-calendar-year date)))
     (and (<= 1 month) (<= month 12)
          (<= 1 day) (<= day (calendar-last-day-of-month month year))
-         ;; BC dates left as non-legal, to suppress errors from
+         ;; BC dates left as non-valid, to suppress errors from
          ;; complex holiday algorithms not suitable for years BC.
          ;; Note there are side effects on calendar navigation.
          (<= 1 year))))
@@ -2934,7 +2951,7 @@ MARK defaults to `diary-entry-marker'."
                   (forward-char -2))
               (let                      ; attr list
                   ((temp-face
-                    (make-symbol (apply 'concat "temp-face-"
+                    (make-symbol (apply 'concat "temp-"
                                         (mapcar '(lambda (sym)
                                                    (cond ((symbolp sym) (symbol-name sym))
                                                          ((numberp sym) (int-to-string sym))
@@ -2960,7 +2977,7 @@ calendar window has been prepared."
     (make-local-variable 'calendar-starred-day)
     (forward-char 1)
     (setq calendar-starred-day
-          (string-to-int
+          (string-to-number
            (buffer-substring (point) (- (point) 2))))
     (delete-char -2)
     (insert "**")