comparison lisp/calendar/calendar.el @ 92530:04183df0b71f

(calendar-date-is-legal-p): New obsolete alias. (calendar-date-is-valid-p): Rename from `calendar-date-is-legal-p'. (calendar-date-is-visible-p, mark-visible-calendar-date): Use it.
author Juanma Barranquero <lekktu@gmail.com>
date Thu, 06 Mar 2008 15:01:24 +0000
parents 107ccd98fa12
children a9c1d203dd4a
comparison
equal deleted inserted replaced
92529:7b55b0a875cc 92530:04183df0b71f
1674 (calendar-read-date t) 1674 (calendar-read-date t)
1675 (calendar-current-date))) 1675 (calendar-current-date)))
1676 (month (extract-calendar-month date)) 1676 (month (extract-calendar-month date))
1677 (year (extract-calendar-year date))) 1677 (year (extract-calendar-year date)))
1678 ;; (calendar-read-date t) returns a date with day = nil, which is 1678 ;; (calendar-read-date t) returns a date with day = nil, which is
1679 ;; not a legal date for the visible test in the diary section. 1679 ;; not a valid date for the visible test in the diary section.
1680 (if arg (setcar (cdr date) 1)) 1680 (if arg (setcar (cdr date) 1))
1681 (increment-calendar-month month year (- calendar-offset)) 1681 (increment-calendar-month month year (- calendar-offset))
1682 ;; Display the buffer before calling generate-calendar-window so that it 1682 ;; Display the buffer before calling generate-calendar-window so that it
1683 ;; can get a chance to adjust the window sizes to the frame size. 1683 ;; can get a chance to adjust the window sizes to the frame size.
1684 (pop-to-buffer calendar-buffer) 1684 (pop-to-buffer calendar-buffer)
2090 (sit-for 0)) 2090 (sit-for 0))
2091 (if (and (boundp 'font-lock-mode) 2091 (if (and (boundp 'font-lock-mode)
2092 font-lock-mode) 2092 font-lock-mode)
2093 (font-lock-fontify-buffer)) 2093 (font-lock-fontify-buffer))
2094 (and mark-holidays-in-calendar 2094 (and mark-holidays-in-calendar
2095 ;;; (calendar-date-is-legal-p today) ; useful for BC dates 2095 ;;; (calendar-date-is-valid-p today) ; useful for BC dates
2096 (mark-calendar-holidays) 2096 (mark-calendar-holidays)
2097 (and in-calendar-window (sit-for 0))) 2097 (and in-calendar-window (sit-for 0)))
2098 (unwind-protect 2098 (unwind-protect
2099 (if mark-diary-entries-in-calendar (mark-diary-entries)) 2099 (if mark-diary-entries-in-calendar (mark-diary-entries))
2100 (if today-visible 2100 (if today-visible
2350 (easy-menu-define nil map nil cal-menu-moon-menu) 2350 (easy-menu-define nil map nil cal-menu-moon-menu)
2351 (easy-menu-define nil map nil cal-menu-diary-menu) 2351 (easy-menu-define nil map nil cal-menu-diary-menu)
2352 (easy-menu-define nil map nil cal-menu-holidays-menu) 2352 (easy-menu-define nil map nil cal-menu-holidays-menu)
2353 (easy-menu-define nil map nil cal-menu-goto-menu) 2353 (easy-menu-define nil map nil cal-menu-goto-menu)
2354 (easy-menu-define nil map nil cal-menu-scroll-menu) 2354 (easy-menu-define nil map nil cal-menu-scroll-menu)
2355 2355
2356 (define-key map [down-mouse-3] 2356 (define-key map [down-mouse-3]
2357 (easy-menu-binding cal-menu-context-mouse-menu)) 2357 (easy-menu-binding cal-menu-context-mouse-menu))
2358 (define-key map [down-mouse-2] 2358 (define-key map [down-mouse-2]
2359 (easy-menu-binding cal-menu-global-mouse-menu)) 2359 (easy-menu-binding cal-menu-global-mouse-menu))
2360 2360
2925 (defun calendar-date-is-visible-p (date) 2925 (defun calendar-date-is-visible-p (date)
2926 "Return t if DATE is valid and is visible in the calendar window." 2926 "Return t if DATE is valid and is visible in the calendar window."
2927 (let ((gap (calendar-interval 2927 (let ((gap (calendar-interval
2928 displayed-month displayed-year 2928 displayed-month displayed-year
2929 (extract-calendar-month date) (extract-calendar-year date)))) 2929 (extract-calendar-month date) (extract-calendar-year date))))
2930 (and (calendar-date-is-legal-p date) (> 2 gap) (< -2 gap)))) 2930 (and (calendar-date-is-valid-p date) (> 2 gap) (< -2 gap))))
2931 2931
2932 (defun calendar-date-is-legal-p (date) 2932 (defun calendar-date-is-valid-p (date)
2933 "Return t if DATE is a valid date." 2933 "Return t if DATE is a valid date."
2934 (let ((month (extract-calendar-month date)) 2934 (let ((month (extract-calendar-month date))
2935 (day (extract-calendar-day date)) 2935 (day (extract-calendar-day date))
2936 (year (extract-calendar-year date))) 2936 (year (extract-calendar-year date)))
2937 (and (<= 1 month) (<= month 12) 2937 (and (<= 1 month) (<= month 12)
2943 ;; BC dates left as non-valid, to suppress errors from 2943 ;; BC dates left as non-valid, to suppress errors from
2944 ;; complex holiday algorithms not suitable for years BC. 2944 ;; complex holiday algorithms not suitable for years BC.
2945 ;; Note there are side effects on calendar navigation. 2945 ;; Note there are side effects on calendar navigation.
2946 (<= 1 year)))) 2946 (<= 1 year))))
2947 2947
2948 (define-obsolete-function-alias 'calendar-date-is-legal-p
2949 'calendar-date-is-valid-p "23.1")
2950
2948 (defun calendar-date-equal (date1 date2) 2951 (defun calendar-date-equal (date1 date2)
2949 "Return t if the DATE1 and DATE2 are the same." 2952 "Return t if the DATE1 and DATE2 are the same."
2950 (and 2953 (and
2951 (= (extract-calendar-month date1) (extract-calendar-month date2)) 2954 (= (extract-calendar-month date1) (extract-calendar-month date2))
2952 (= (extract-calendar-day date1) (extract-calendar-day date2)) 2955 (= (extract-calendar-day date1) (extract-calendar-day date2))
2954 2957
2955 (defun mark-visible-calendar-date (date &optional mark) 2958 (defun mark-visible-calendar-date (date &optional mark)
2956 "Mark DATE in the calendar window with MARK. 2959 "Mark DATE in the calendar window with MARK.
2957 MARK is a single-character string, a list of face attributes/values, or a face. 2960 MARK is a single-character string, a list of face attributes/values, or a face.
2958 MARK defaults to `diary-entry-marker'." 2961 MARK defaults to `diary-entry-marker'."
2959 (if (calendar-date-is-legal-p date) 2962 (if (calendar-date-is-valid-p date)
2960 (with-current-buffer calendar-buffer 2963 (with-current-buffer calendar-buffer
2961 (save-excursion 2964 (save-excursion
2962 (calendar-cursor-to-visible-date date) 2965 (calendar-cursor-to-visible-date date)
2963 (setq mark 2966 (setq mark
2964 (or (and (stringp mark) (= (length mark) 1) mark) ; single-char 2967 (or (and (stringp mark) (= (length mark) 1) mark) ; single-char