aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2016-02-20 13:44:47 +0100
committerStephen Berman2016-02-20 13:44:47 +0100
commit1cb126866df0b01aa2eaa51eeba696997d6d37ae (patch)
treea753e8f43129b46b5c3537dc4ffe7b978a8ed27a
parent1e996cfbd0ab64e4d74d92a80ef3aefc39249462 (diff)
downloademacs-1cb126866df0b01aa2eaa51eeba696997d6d37ae.tar.gz
emacs-1cb126866df0b01aa2eaa51eeba696997d6d37ae.zip
Fix todo-mode item date editing bugs
* lisp/calendar/todo-mode.el (todo-edit-item--header): Prevent out of range error by making sure the value of the numerical month date component cannot be nil. Prevent wrong type error on trying to edit day number in February by making sure numerical instead of string value of the year component is passed to todo-read-date. (todo-read-date): When using the numerical month date component make sure to use `*' for an arbitrary month instead of its numerical value.
-rw-r--r--lisp/calendar/todo-mode.el20
1 files changed, 9 insertions, 11 deletions
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 29d8dfcfb7f..94cd08eaa4e 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -2262,9 +2262,8 @@ made in the number or names of categories."
2262 (mlist (append tmn-array nil)) 2262 (mlist (append tmn-array nil))
2263 (tma-array todo-month-abbrev-array) 2263 (tma-array todo-month-abbrev-array)
2264 (mablist (append tma-array nil)) 2264 (mablist (append tma-array nil))
2265 (yy (and oyear (unless (string= oyear "*") 2265 (yy (and oyear (string-to-number oyear))) ; 0 if year is "*".
2266 (string-to-number oyear)))) 2266 (mm (or (and omonth (if (string= omonth "*") 13
2267 (mm (or (and omonth (unless (string= omonth "*")
2268 (string-to-number omonth))) 2267 (string-to-number omonth)))
2269 (1+ (- (length mlist) 2268 (1+ (- (length mlist)
2270 (length (or (member omonthname mlist) 2269 (length (or (member omonthname mlist)
@@ -2330,12 +2329,11 @@ made in the number or names of categories."
2330 (if omonth 2329 (if omonth
2331 (number-to-string mm) 2330 (number-to-string mm)
2332 (aref tma-array (1- mm)))))) 2331 (aref tma-array (1- mm))))))
2333 (let ((yy (string-to-number year)) ; 0 if year is "*". 2332 ;; Since the number corresponding to the arbitrary
2334 ;; When mm is 13 (corresponding to "*" as value 2333 ;; month name "*" is out of the range of
2335 ;; of month), this raises an args-out-of-range 2334 ;; calendar-last-day-of-month, set it to 1
2336 ;; error in calendar-last-day-of-month, so use 1 2335 ;; (corresponding to January) to allow 31 days.
2337 ;; (corresponding to January) to get 31 days. 2336 (let ((mm (if (= mm 13) 1 mm)))
2338 (mm (if (= mm 13) 1 mm)))
2339 (if (> (string-to-number day) 2337 (if (> (string-to-number day)
2340 (calendar-last-day-of-month mm yy)) 2338 (calendar-last-day-of-month mm yy))
2341 (user-error "%s %s does not have %s days" 2339 (user-error "%s %s does not have %s days"
@@ -2347,7 +2345,7 @@ made in the number or names of categories."
2347 monthname omonthname 2345 monthname omonthname
2348 day (cond 2346 day (cond
2349 ((not current-prefix-arg) 2347 ((not current-prefix-arg)
2350 (todo-read-date 'day mm oyear)) 2348 (todo-read-date 'day mm yy))
2351 ((string= oday "*") 2349 ((string= oday "*")
2352 (user-error "Cannot increment *")) 2350 (user-error "Cannot increment *"))
2353 ((or (string= omonth "*") (string= omonthname "*")) 2351 ((or (string= omonth "*") (string= omonthname "*"))
@@ -5933,7 +5931,7 @@ number of the last the day of the month."
5933 (and day (setq day (if (eq day '*) 5931 (and day (setq day (if (eq day '*)
5934 (symbol-name '*) 5932 (symbol-name '*)
5935 (number-to-string day)))) 5933 (number-to-string day))))
5936 (and month (setq month (if (eq month '*) 5934 (and month (setq month (if (= month 13)
5937 (symbol-name '*) 5935 (symbol-name '*)
5938 (number-to-string month)))) 5936 (number-to-string month))))
5939 (if arg 5937 (if arg