Commit c93b9aae authored by Edward M. Reingold's avatar Edward M. Reingold
Browse files

Fix calendar-cursor-to-date to handle starred days correctly.

parent a1d2b64a
...@@ -1946,24 +1946,27 @@ If in the calendar buffer, also sets the current date local variables." ...@@ -1946,24 +1946,27 @@ If in the calendar buffer, also sets the current date local variables."
"Returns a list of the month, day, and year of current cursor position. "Returns a list of the month, day, and year of current cursor position.
If cursor is not on a specific date, signals an error if optional parameter If cursor is not on a specific date, signals an error if optional parameter
ERROR is t, otherwise just returns nil." ERROR is t, otherwise just returns nil."
(if (and (looking-at "[*0-9]") (let* ((segment (/ (current-column) 25))
(< 2 (count-lines (point-min) (point)))) (month (% (+ displayed-month segment -1) 12))
(save-excursion (month (if (= 0 month) 12 month))
(re-search-backward "[^*0-9]") (year
(forward-char 1) (cond
(let* ((and (= 12 month) (= segment 0)) (1- displayed-year))
((day (string-to-int (buffer-substring (point) (+ 3 (point))))) ((and (= 1 month) (= segment 2)) (1+ displayed-year))
(day (if (= 0 day) starred-day day)) (t displayed-year))))
(segment (/ (current-column) 25)) (if (and (looking-at "[0-9]")
(month (% (+ displayed-month segment -1) 12)) (< 2 (count-lines (point-min) (point))))
(month (if (= 0 month) 12 month)) (save-excursion
(year (re-search-backward "[^0-9]")
(cond (list month
((and (= 12 month) (= segment 0)) (1- displayed-year)) (string-to-int (buffer-substring (1+ (point)) (+ 4 (point))))
((and (= 1 month) (= segment 2)) (1+ displayed-year)) year))
(t displayed-year)))) (if (looking-at "\\*")
(list month day year))) (save-excursion
(if error (error "Cursor is not on a date!")))) (re-search-backward "[^*]")
(if (looking-at ".\\*\\*")
(list month starred-day year)
(if error (error "Cursor is not on a date!"))))))))
(defun calendar-cursor-to-nearest-date () (defun calendar-cursor-to-nearest-date ()
"Move the cursor to the closest date. "Move the cursor to the closest date.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment