aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2013-06-09 21:16:39 +0200
committerStephen Berman2013-06-09 21:16:39 +0200
commitd7a49dae500b62803d35dfc47d99f462479fb66d (patch)
tree6b9a05acaaea499ee4f80cd787f904bef6c07090
parent85ea34e22c971c7e7bbd6cc48972905bcf70c72f (diff)
downloademacs-d7a49dae500b62803d35dfc47d99f462479fb66d.tar.gz
emacs-d7a49dae500b62803d35dfc47d99f462479fb66d.zip
* todos.el: Fix and improve item date string editing.
(todos-date-pattern): Make dayname an explicitly numbered group. (todos-basic-edit-item-header): Set match for dayname and use it to ensure attempting to edit day, month or year of a date header containing a day name is a noop, simplifying and fixing buggy code.
-rw-r--r--lisp/calendar/ChangeLog8
-rw-r--r--lisp/calendar/todos.el19
2 files changed, 17 insertions, 10 deletions
diff --git a/lisp/calendar/ChangeLog b/lisp/calendar/ChangeLog
index b09cf30f1c7..0d8fda0d147 100644
--- a/lisp/calendar/ChangeLog
+++ b/lisp/calendar/ChangeLog
@@ -1,3 +1,11 @@
12013-06-09 Stephen Berman <stephen.berman@gmx.net>
2
3 * todos.el: Fix and improve item date string editing.
4 (todos-date-pattern): Make dayname an explicitly numbered group.
5 (todos-basic-edit-item-header): Set match for dayname and use it
6 to ensure attempting to edit day, month or year of a date header
7 containing a day name is a noop, simplifying and fixing buggy code.
8
12013-06-08 Stephen Berman <stephen.berman@gmx.net> 92013-06-08 Stephen Berman <stephen.berman@gmx.net>
2 10
3 * todos.el: Improve commentary. 11 * todos.el: Improve commentary.
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el
index 6d79fadd106..4f83ead0d48 100644
--- a/lisp/calendar/todos.el
+++ b/lisp/calendar/todos.el
@@ -211,7 +211,7 @@ The final element is \"*\", indicating an unspecified month.")
211 211
212(defconst todos-date-pattern 212(defconst todos-date-pattern
213 (let ((dayname (diary-name-pattern calendar-day-name-array nil t))) 213 (let ((dayname (diary-name-pattern calendar-day-name-array nil t)))
214 (concat "\\(?5:" dayname "\\|" 214 (concat "\\(?4:\\(?5:" dayname "\\)\\|"
215 (let ((dayname) 215 (let ((dayname)
216 (monthname (format "\\(?6:%s\\)" (diary-name-pattern 216 (monthname (format "\\(?6:%s\\)" (diary-name-pattern
217 todos-month-name-array 217 todos-month-name-array
@@ -2099,6 +2099,7 @@ otherwise, edit just the item at point."
2099 (line-end-position) t) 2099 (line-end-position) t)
2100 (let* ((odate (match-string-no-properties 1)) 2100 (let* ((odate (match-string-no-properties 1))
2101 (otime (match-string-no-properties 2)) 2101 (otime (match-string-no-properties 2))
2102 (odayname (match-string-no-properties 5))
2102 (omonthname (match-string-no-properties 6)) 2103 (omonthname (match-string-no-properties 6))
2103 (omonth (match-string-no-properties 7)) 2104 (omonth (match-string-no-properties 7))
2104 (oday (match-string-no-properties 8)) 2105 (oday (match-string-no-properties 8))
@@ -2133,9 +2134,8 @@ otherwise, edit just the item at point."
2133 (when (> (length ntime) 0) 2134 (when (> (length ntime) 0)
2134 (setq ntime (concat " " ntime)))) 2135 (setq ntime (concat " " ntime))))
2135 ;; When date string consists only of a day name, 2136 ;; When date string consists only of a day name,
2136 ;; passing other date components is a NOP. 2137 ;; passing other date components is a noop.
2137 ((and (memq what '(year month day)) 2138 ((and odayname (memq what '(year month day))))
2138 (not (or oyear omonth oday))))
2139 ((eq what 'year) 2139 ((eq what 'year)
2140 (setq day oday 2140 (setq day oday
2141 monthname omonthname 2141 monthname omonthname
@@ -2220,12 +2220,11 @@ otherwise, edit just the item at point."
2220 (setq monthname (aref tma-array (1- adjmm)))) 2220 (setq monthname (aref tma-array (1- adjmm))))
2221 ;; Return changed numerical day as a string. 2221 ;; Return changed numerical day as a string.
2222 (number-to-string (nth 1 date))))))))) 2222 (number-to-string (nth 1 date)))))))))
2223 ;; If new year, month or day date string components were 2223 (unless odayname
2224 ;; calculated, rebuild the whole date string from them. 2224 ;; If year, month or day date string components were
2225 (when (memq what '(year month day)) 2225 ;; changed, rebuild the date string.
2226 (if (or oyear omonth omonthname oday) 2226 (when (memq what '(year month day))
2227 (setq ndate (mapconcat 'eval calendar-date-display-form "")) 2227 (setq ndate (mapconcat 'eval calendar-date-display-form ""))))
2228 (message "Cannot edit date component of empty date string")))
2229 (when ndate (replace-match ndate nil nil nil 1)) 2228 (when ndate (replace-match ndate nil nil nil 1))
2230 ;; Add new time string to the header, if it was supplied. 2229 ;; Add new time string to the header, if it was supplied.
2231 (when ntime 2230 (when ntime