aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2017-12-04 15:39:32 -0500
committerStefan Monnier2017-12-04 15:39:32 -0500
commitad039f9bcc89a8468f9eeb35ebe41a3792926ff7 (patch)
treeab89fdbe8a73293ae14ee3e5ea06536f23667fce
parent512f81407c772992bc2ac355ebef002df2bfdf1f (diff)
downloademacs-ad039f9bcc89a8468f9eeb35ebe41a3792926ff7.tar.gz
emacs-ad039f9bcc89a8468f9eeb35ebe41a3792926ff7.zip
* lisp/calendar/todo-mode.el: Use calendar-dlet*
(dayname, monthname, day, month, year): Don't declare globally. (todo-date-pattern, todo-edit-item--header) (todo-convert-legacy-date-time, todo-read-date): Use calendar-dlet* around uses of calendar-date-display-form.
-rw-r--r--lisp/calendar/todo-mode.el55
1 files changed, 28 insertions, 27 deletions
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 0ae59c58804..df3953f7a70 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -188,25 +188,17 @@ The final element is \"*\", indicating an unspecified month.")
188 "Array of abbreviated month names, in order. 188 "Array of abbreviated month names, in order.
189The final element is \"*\", indicating an unspecified month.") 189The final element is \"*\", indicating an unspecified month.")
190 190
191(with-no-warnings
192 ;; FIXME: These vars lack a prefix, but this is out of our control, because
193 ;; they're defined by Calendar, e.g. for calendar-date-display-form.
194 (defvar dayname)
195 (defvar monthname)
196 (defvar day)
197 (defvar month)
198 (defvar year))
199
200(defconst todo-date-pattern 191(defconst todo-date-pattern
201 (let ((dayname (diary-name-pattern calendar-day-name-array nil t))) 192 (let ((dayname (diary-name-pattern calendar-day-name-array nil t)))
202 (concat "\\(?4:\\(?5:" dayname "\\)\\|" 193 (concat "\\(?4:\\(?5:" dayname "\\)\\|"
203 (let ((dayname) 194 (calendar-dlet*
204 (monthname (format "\\(?6:%s\\)" (diary-name-pattern 195 ((dayname)
205 todo-month-name-array 196 (monthname (format "\\(?6:%s\\)" (diary-name-pattern
206 todo-month-abbrev-array))) 197 todo-month-name-array
207 (month "\\(?7:[0-9]+\\|\\*\\)") 198 todo-month-abbrev-array)))
208 (day "\\(?8:[0-9]+\\|\\*\\)") 199 (month "\\(?7:[0-9]+\\|\\*\\)")
209 (year "-?\\(?9:[0-9]+\\|\\*\\)")) 200 (day "\\(?8:[0-9]+\\|\\*\\)")
201 (year "-?\\(?9:[0-9]+\\|\\*\\)"))
210 (mapconcat #'eval calendar-date-display-form "")) 202 (mapconcat #'eval calendar-date-display-form ""))
211 "\\)")) 203 "\\)"))
212 "Regular expression matching a todo item date header.") 204 "Regular expression matching a todo item date header.")
@@ -2274,8 +2266,8 @@ made in the number or names of categories."
2274 ;; `todo-edit-item' as e.g. `-' or `C-u'. 2266 ;; `todo-edit-item' as e.g. `-' or `C-u'.
2275 (inc (prefix-numeric-value inc)) 2267 (inc (prefix-numeric-value inc))
2276 (buffer-read-only nil) 2268 (buffer-read-only nil)
2277 ndate ntime year monthname month day 2269 ndate ntime
2278 dayname) ; Needed by calendar-date-display-form. 2270 year monthname month day dayname)
2279 (when marked (todo--user-error-if-marked-done-item)) 2271 (when marked (todo--user-error-if-marked-done-item))
2280 (save-excursion 2272 (save-excursion
2281 (or (and marked (goto-char (point-min))) (todo-item-start)) 2273 (or (and marked (goto-char (point-min))) (todo-item-start))
@@ -2416,7 +2408,15 @@ made in the number or names of categories."
2416 ;; If year, month or day date string components were 2408 ;; If year, month or day date string components were
2417 ;; changed, rebuild the date string. 2409 ;; changed, rebuild the date string.
2418 (when (memq what '(year month day)) 2410 (when (memq what '(year month day))
2419 (setq ndate (mapconcat #'eval calendar-date-display-form "")))) 2411 (setq ndate
2412 (calendar-dlet*
2413 ;; Needed by calendar-date-display-form.
2414 ((year year)
2415 (monthname monthname)
2416 (month month)
2417 (day day)
2418 (dayname dayname))
2419 (mapconcat #'eval calendar-date-display-form "")))))
2420 (when ndate (replace-match ndate nil nil nil 1)) 2420 (when ndate (replace-match ndate nil nil nil 1))
2421 ;; Add new time string to the header, if it was supplied. 2421 ;; Add new time string to the header, if it was supplied.
2422 (when ntime 2422 (when ntime
@@ -4613,12 +4613,13 @@ strings built using the default value of
4613(defun todo-convert-legacy-date-time () 4613(defun todo-convert-legacy-date-time ()
4614 "Return converted date-time string. 4614 "Return converted date-time string.
4615Helper function for `todo-convert-legacy-files'." 4615Helper function for `todo-convert-legacy-files'."
4616 (let* ((year (match-string 1)) 4616 (calendar-dlet*
4617 (month (match-string 2)) 4617 ((year (match-string 1))
4618 (monthname (calendar-month-name (string-to-number month) t)) 4618 (month (match-string 2))
4619 (day (match-string 3)) 4619 (monthname (calendar-month-name (string-to-number month) t))
4620 (time (match-string 4)) 4620 (day (match-string 3))
4621 dayname) 4621 (time (match-string 4))
4622 dayname)
4622 (replace-match "") 4623 (replace-match "")
4623 (insert (mapconcat #'eval calendar-date-display-form "") 4624 (insert (mapconcat #'eval calendar-date-display-form "")
4624 (when time (concat " " time))))) 4625 (when time (concat " " time)))))
@@ -5990,8 +5991,8 @@ indicating an unspecified month, day, or year.
5990 5991
5991When ARG is `day', non-nil arguments MO and YR determine the 5992When ARG is `day', non-nil arguments MO and YR determine the
5992number of the last the day of the month." 5993number of the last the day of the month."
5993 (let (year monthname month day 5994 (calendar-dlet*
5994 dayname) ; Needed by calendar-date-display-form. 5995 (year monthname month day dayname) ;Needed by calendar-date-display-form.
5995 (when (or (not arg) (eq arg 'year)) 5996 (when (or (not arg) (eq arg 'year))
5996 (while (if (natnump year) (< year 1) (not (eq year '*))) 5997 (while (if (natnump year) (< year 1) (not (eq year '*)))
5997 (setq year (read-from-minibuffer 5998 (setq year (read-from-minibuffer