aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-02-07 20:42:44 +0000
committerRichard M. Stallman1994-02-07 20:42:44 +0000
commitffd82264f0afc7b1f6605dd92fd7c3880bb574eb (patch)
tree8c2d432a8b68ce343126d223eaa201805b2d1e42
parentd1462f221c316bf6094c046adb70e5a7e2f0eab0 (diff)
downloademacs-ffd82264f0afc7b1f6605dd92fd7c3880bb574eb.tar.gz
emacs-ffd82264f0afc7b1f6605dd92fd7c3880bb574eb.zip
(calendar-mode-line-format): Change "current" to "today".
(calendar-cursor-to-date): Add optional parameter to cause error signal when cursor is not on a date---this allows lots of simplifications throughout the code. (calendar-forward-month,calendar-set-mark, calendar-exchange-point-and-mark,calendar-count-days-region, calendar-print-day-of-year,calendar-print-iso-date, calendar-print-julian-date,calendar-print-islamic-date, calendar-print-hebrew-date,calendar-print-astro-day-number): Use simplification.
-rw-r--r--lisp/calendar/calendar.el46
1 files changed, 16 insertions, 30 deletions
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index 53676fa19d1..0ab741ea572 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -1539,7 +1539,7 @@ the inserted text. Value is always t."
1539 (list 1539 (list
1540 (substitute-command-keys "\\<calendar-mode-map>\\[scroll-calendar-left]") 1540 (substitute-command-keys "\\<calendar-mode-map>\\[scroll-calendar-left]")
1541 "Calendar" 1541 "Calendar"
1542 (substitute-command-keys "\\<calendar-mode-map>\\[describe-calendar-mode] help/\\[calendar-other-month] other/\\[calendar-current-month] current") 1542 (substitute-command-keys "\\<calendar-mode-map>\\[describe-calendar-mode] help/\\[calendar-other-month] other/\\[calendar-current-month] today")
1543 '(calendar-date-string (calendar-current-date) t) 1543 '(calendar-date-string (calendar-current-date) t)
1544 (substitute-command-keys "\\<calendar-mode-map>\\[scroll-calendar-right]")) 1544 (substitute-command-keys "\\<calendar-mode-map>\\[scroll-calendar-right]"))
1545 "The mode line of the calendar buffer.") 1545 "The mode line of the calendar buffer.")
@@ -1850,8 +1850,7 @@ concatenated and the result truncated."
1850Movement is backward if ARG is negative." 1850Movement is backward if ARG is negative."
1851 (interactive "p") 1851 (interactive "p")
1852 (calendar-cursor-to-nearest-date) 1852 (calendar-cursor-to-nearest-date)
1853 (let* ((cursor-date (or (calendar-cursor-to-date) 1853 (let* ((cursor-date (calendar-cursor-to-date t))
1854 (error "Cursor is not on a date!")))
1855 (month (extract-calendar-month cursor-date)) 1854 (month (extract-calendar-month cursor-date))
1856 (day (extract-calendar-day cursor-date)) 1855 (day (extract-calendar-day cursor-date))
1857 (year (extract-calendar-year cursor-date))) 1856 (year (extract-calendar-year cursor-date)))
@@ -1943,9 +1942,10 @@ If in the calendar buffer, also sets the current date local variables."
1943 (string-to-int (substring date (match-beginning 4) (match-end 4))))) 1942 (string-to-int (substring date (match-beginning 4) (match-end 4)))))
1944 (list month day year))) 1943 (list month day year)))
1945 1944
1946(defun calendar-cursor-to-date () 1945(defun calendar-cursor-to-date (&optional error)
1947 "Returns a list of the month, day, and year of current cursor position. 1946 "Returns a list of the month, day, and year of current cursor position.
1948Returns nil if the cursor is not on a specific day." 1947If cursor is not on a specific date, signals an error if optional parameter
1948ERROR is t, otherwise just returns nil."
1949 (if (and (looking-at "[*0-9]") 1949 (if (and (looking-at "[*0-9]")
1950 (< 2 (count-lines (point-min) (point)))) 1950 (< 2 (count-lines (point-min) (point))))
1951 (save-excursion 1951 (save-excursion
@@ -1962,7 +1962,8 @@ Returns nil if the cursor is not on a specific day."
1962 ((and (= 12 month) (= segment 0)) (1- displayed-year)) 1962 ((and (= 12 month) (= segment 0)) (1- displayed-year))
1963 ((and (= 1 month) (= segment 2)) (1+ displayed-year)) 1963 ((and (= 1 month) (= segment 2)) (1+ displayed-year))
1964 (t displayed-year)))) 1964 (t displayed-year))))
1965 (list month day year))))) 1965 (list month day year)))
1966 (if error (error "Cursor is not on a date!"))))
1966 1967
1967(defun calendar-cursor-to-nearest-date () 1968(defun calendar-cursor-to-nearest-date ()
1968 "Move the cursor to the closest date. 1969 "Move the cursor to the closest date.
@@ -2233,8 +2234,7 @@ Gregorian date Sunday, December 31, 1 BC."
2233With no prefix argument, push current date onto marked date ring. 2234With no prefix argument, push current date onto marked date ring.
2234With argument, jump to mark, pop it, and put point at end of ring." 2235With argument, jump to mark, pop it, and put point at end of ring."
2235 (interactive "P") 2236 (interactive "P")
2236 (let ((date (or (calendar-cursor-to-date) 2237 (let ((date (calendar-cursor-to-date t)))
2237 (error "Cursor is not on a date!"))))
2238 (if (null arg) 2238 (if (null arg)
2239 (progn 2239 (progn
2240 (setq calendar-mark-ring (cons date calendar-mark-ring)) 2240 (setq calendar-mark-ring (cons date calendar-mark-ring))
@@ -2254,8 +2254,7 @@ With argument, jump to mark, pop it, and put point at end of ring."
2254 "Exchange the current cursor position with the marked date." 2254 "Exchange the current cursor position with the marked date."
2255 (interactive) 2255 (interactive)
2256 (let ((mark (car calendar-mark-ring)) 2256 (let ((mark (car calendar-mark-ring))
2257 (date (or (calendar-cursor-to-date) 2257 (date (calendar-cursor-to-date t)))
2258 (error "Cursor is not on a date!"))))
2259 (if (null mark) 2258 (if (null mark)
2260 (error "No mark set in this buffer") 2259 (error "No mark set in this buffer")
2261 (setq calendar-mark-ring (cons date (cdr calendar-mark-ring))) 2260 (setq calendar-mark-ring (cons date (cdr calendar-mark-ring)))
@@ -2265,8 +2264,7 @@ With argument, jump to mark, pop it, and put point at end of ring."
2265 "Count the number of days (inclusive) between point and the mark." 2264 "Count the number of days (inclusive) between point and the mark."
2266 (interactive) 2265 (interactive)
2267 (let* ((days (- (calendar-absolute-from-gregorian 2266 (let* ((days (- (calendar-absolute-from-gregorian
2268 (or (calendar-cursor-to-date) 2267 (calendar-cursor-to-date t))
2269 (error "Cursor is not on a date!")))
2270 (calendar-absolute-from-gregorian 2268 (calendar-absolute-from-gregorian
2271 (or (car calendar-mark-ring) 2269 (or (car calendar-mark-ring)
2272 (error "No mark set in this buffer"))))) 2270 (error "No mark set in this buffer")))))
@@ -2653,9 +2651,7 @@ Defaults to today's date if DATE is not given."
2653(defun calendar-print-day-of-year () 2651(defun calendar-print-day-of-year ()
2654 "Show day number in year/days remaining in year for date under the cursor." 2652 "Show day number in year/days remaining in year for date under the cursor."
2655 (interactive) 2653 (interactive)
2656 (message (calendar-day-of-year-string 2654 (message (calendar-day-of-year-string (calendar-cursor-to-date t))))
2657 (or (calendar-cursor-to-date)
2658 (error "Cursor is not on a date!")))))
2659 2655
2660(defun calendar-absolute-from-iso (date) 2656(defun calendar-absolute-from-iso (date)
2661 "The number of days elapsed between the Gregorian date 12/31/1 BC and DATE. 2657 "The number of days elapsed between the Gregorian date 12/31/1 BC and DATE.
@@ -2709,9 +2705,7 @@ Defaults to today's date if DATE is not given."
2709 "Show equivalent ISO date for the date under the cursor." 2705 "Show equivalent ISO date for the date under the cursor."
2710 (interactive) 2706 (interactive)
2711 (message "ISO date: %s" 2707 (message "ISO date: %s"
2712 (calendar-iso-date-string 2708 (calendar-iso-date-string (calendar-cursor-to-date t))))
2713 (or (calendar-cursor-to-date)
2714 (error "Cursor is not on a date!")))))
2715 2709
2716(defun calendar-julian-from-absolute (date) 2710(defun calendar-julian-from-absolute (date)
2717 "Compute the Julian (month day year) corresponding to the absolute DATE. 2711 "Compute the Julian (month day year) corresponding to the absolute DATE.
@@ -2767,9 +2761,7 @@ Driven by the variable `calendar-date-display-form'."
2767 "Show the Julian calendar equivalent of the date under the cursor." 2761 "Show the Julian calendar equivalent of the date under the cursor."
2768 (interactive) 2762 (interactive)
2769 (message "Julian date: %s" 2763 (message "Julian date: %s"
2770 (calendar-julian-date-string 2764 (calendar-julian-date-string (calendar-cursor-to-date t))))
2771 (or (calendar-cursor-to-date)
2772 (error "Cursor is not on a date!")))))
2773 2765
2774(defun islamic-calendar-leap-year-p (year) 2766(defun islamic-calendar-leap-year-p (year)
2775 "Returns t if YEAR is a leap year on the Islamic calendar." 2767 "Returns t if YEAR is a leap year on the Islamic calendar."
@@ -2857,9 +2849,7 @@ Driven by the variable `calendar-date-display-form'."
2857(defun calendar-print-islamic-date () 2849(defun calendar-print-islamic-date ()
2858 "Show the Islamic calendar equivalent of the date under the cursor." 2850 "Show the Islamic calendar equivalent of the date under the cursor."
2859 (interactive) 2851 (interactive)
2860 (let ((i (calendar-islamic-date-string 2852 (let ((i (calendar-islamic-date-string (calendar-cursor-to-date t))))
2861 (or (calendar-cursor-to-date)
2862 (error "Cursor is not on a date!")))))
2863 (if (string-equal i "") 2853 (if (string-equal i "")
2864 (message "Date is pre-Islamic") 2854 (message "Date is pre-Islamic")
2865 (message "Islamic date (until sunset): %s" i)))) 2855 (message "Islamic date (until sunset): %s" i))))
@@ -3002,9 +2992,7 @@ Driven by the variable `calendar-date-display-form'."
3002 "Show the Hebrew calendar equivalent of the date under the cursor." 2992 "Show the Hebrew calendar equivalent of the date under the cursor."
3003 (interactive) 2993 (interactive)
3004 (message "Hebrew date (until sunset): %s" 2994 (message "Hebrew date (until sunset): %s"
3005 (calendar-hebrew-date-string 2995 (calendar-hebrew-date-string (calendar-cursor-to-date t))))
3006 (or (calendar-cursor-to-date)
3007 (error "Cursor is not on a date!")))))
3008 2996
3009(defun hebrew-calendar-yahrzeit (death-date year) 2997(defun hebrew-calendar-yahrzeit (death-date year)
3010 "Absolute date of the anniversary of Hebrew DEATH-DATE in Hebrew YEAR." 2998 "Absolute date of the anniversary of Hebrew DEATH-DATE in Hebrew YEAR."
@@ -3130,9 +3118,7 @@ Defaults to today's date if DATE is not given."
3130 (interactive) 3118 (interactive)
3131 (message 3119 (message
3132 "Astronomical (Julian) day number after noon UTC: %s" 3120 "Astronomical (Julian) day number after noon UTC: %s"
3133 (calendar-astro-date-string 3121 (calendar-astro-date-string (calendar-cursor-to-date t))))
3134 (or (calendar-cursor-to-date)
3135 (error "Cursor is not on a date!")))))
3136 3122
3137(defun calendar-goto-astro-day-number (daynumber &optional noecho) 3123(defun calendar-goto-astro-day-number (daynumber &optional noecho)
3138 "Move cursor to astronomical (Julian) DAYNUMBER. 3124 "Move cursor to astronomical (Julian) DAYNUMBER.