aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward M. Reingold1994-02-23 02:38:23 +0000
committerEdward M. Reingold1994-02-23 02:38:23 +0000
commitc93b9aaef9b7e3e1228632e986f85d9ee41193f1 (patch)
treea37b5fbfaaaac84c8bd394e11d6e327bb3c52596
parenta1d2b64a3366cd9a5b8fd840bf3de498099cf67b (diff)
downloademacs-c93b9aaef9b7e3e1228632e986f85d9ee41193f1.tar.gz
emacs-c93b9aaef9b7e3e1228632e986f85d9ee41193f1.zip
Fix calendar-cursor-to-date to handle starred days correctly.
-rw-r--r--lisp/calendar/calendar.el39
1 files changed, 21 insertions, 18 deletions
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index e4823e590ae..8aefa785b80 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -1946,24 +1946,27 @@ If in the calendar buffer, also sets the current date local variables."
1946 "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.
1947If cursor is not on a specific date, signals an error if optional parameter 1947If cursor is not on a specific date, signals an error if optional parameter
1948ERROR is t, otherwise just returns nil." 1948ERROR is t, otherwise just returns nil."
1949 (if (and (looking-at "[*0-9]") 1949 (let* ((segment (/ (current-column) 25))
1950 (< 2 (count-lines (point-min) (point)))) 1950 (month (% (+ displayed-month segment -1) 12))
1951 (save-excursion 1951 (month (if (= 0 month) 12 month))
1952 (re-search-backward "[^*0-9]") 1952 (year
1953 (forward-char 1) 1953 (cond
1954 (let* 1954 ((and (= 12 month) (= segment 0)) (1- displayed-year))
1955 ((day (string-to-int (buffer-substring (point) (+ 3 (point))))) 1955 ((and (= 1 month) (= segment 2)) (1+ displayed-year))
1956 (day (if (= 0 day) starred-day day)) 1956 (t displayed-year))))
1957 (segment (/ (current-column) 25)) 1957 (if (and (looking-at "[0-9]")
1958 (month (% (+ displayed-month segment -1) 12)) 1958 (< 2 (count-lines (point-min) (point))))
1959 (month (if (= 0 month) 12 month)) 1959 (save-excursion
1960 (year 1960 (re-search-backward "[^0-9]")
1961 (cond 1961 (list month
1962 ((and (= 12 month) (= segment 0)) (1- displayed-year)) 1962 (string-to-int (buffer-substring (1+ (point)) (+ 4 (point))))
1963 ((and (= 1 month) (= segment 2)) (1+ displayed-year)) 1963 year))
1964 (t displayed-year)))) 1964 (if (looking-at "\\*")
1965 (list month day year))) 1965 (save-excursion
1966 (if error (error "Cursor is not on a date!")))) 1966 (re-search-backward "[^*]")
1967 (if (looking-at ".\\*\\*")
1968 (list month starred-day year)
1969 (if error (error "Cursor is not on a date!"))))))))
1967 1970
1968(defun calendar-cursor-to-nearest-date () 1971(defun calendar-cursor-to-nearest-date ()
1969 "Move the cursor to the closest date. 1972 "Move the cursor to the closest date.