emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master ad039f9 2/3: * lisp/calendar/todo-mode.el: Use cale


From: Stefan Monnier
Subject: [Emacs-diffs] master ad039f9 2/3: * lisp/calendar/todo-mode.el: Use calendar-dlet*
Date: Mon, 4 Dec 2017 15:50:34 -0500 (EST)

branch: master
commit ad039f9bcc89a8468f9eeb35ebe41a3792926ff7
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * 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.
---
 lisp/calendar/todo-mode.el | 55 +++++++++++++++++++++++-----------------------
 1 file changed, 28 insertions(+), 27 deletions(-)

diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 0ae59c5..df3953f 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.")
   "Array of abbreviated month names, in order.
 The final element is \"*\", indicating an unspecified month.")
 
-(with-no-warnings
-  ;; FIXME: These vars lack a prefix, but this is out of our control, because
-  ;; they're defined by Calendar, e.g. for calendar-date-display-form.
-  (defvar dayname)
-  (defvar monthname)
-  (defvar day)
-  (defvar month)
-  (defvar year))
-
 (defconst todo-date-pattern
   (let ((dayname (diary-name-pattern calendar-day-name-array nil t)))
     (concat "\\(?4:\\(?5:" dayname "\\)\\|"
-           (let ((dayname)
-                 (monthname (format "\\(?6:%s\\)" (diary-name-pattern
-                                                   todo-month-name-array
-                                                   todo-month-abbrev-array)))
-                 (month "\\(?7:[0-9]+\\|\\*\\)")
-                 (day "\\(?8:[0-9]+\\|\\*\\)")
-                 (year "-?\\(?9:[0-9]+\\|\\*\\)"))
+           (calendar-dlet*
+                ((dayname)
+                (monthname (format "\\(?6:%s\\)" (diary-name-pattern
+                                                  todo-month-name-array
+                                                  todo-month-abbrev-array)))
+                (month "\\(?7:[0-9]+\\|\\*\\)")
+                (day "\\(?8:[0-9]+\\|\\*\\)")
+                (year "-?\\(?9:[0-9]+\\|\\*\\)"))
              (mapconcat #'eval calendar-date-display-form ""))
            "\\)"))
   "Regular expression matching a todo item date header.")
@@ -2274,8 +2266,8 @@ made in the number or names of categories."
        ;; `todo-edit-item' as e.g. `-' or `C-u'.
        (inc (prefix-numeric-value inc))
        (buffer-read-only nil)
-       ndate ntime year monthname month day
-       dayname)        ; Needed by calendar-date-display-form.
+       ndate ntime
+        year monthname month day dayname)
     (when marked (todo--user-error-if-marked-done-item))
     (save-excursion
       (or (and marked (goto-char (point-min))) (todo-item-start))
@@ -2416,7 +2408,15 @@ made in the number or names of categories."
              ;; If year, month or day date string components were
              ;; changed, rebuild the date string.
              (when (memq what '(year month day))
-               (setq ndate (mapconcat #'eval calendar-date-display-form ""))))
+               (setq ndate
+                      (calendar-dlet*
+                          ;; Needed by calendar-date-display-form.
+                          ((year year)
+                           (monthname monthname)
+                           (month month)
+                           (day day)
+                           (dayname dayname))
+                        (mapconcat #'eval calendar-date-display-form "")))))
            (when ndate (replace-match ndate nil nil nil 1))
            ;; Add new time string to the header, if it was supplied.
            (when ntime
@@ -4613,12 +4613,13 @@ strings built using the default value of
 (defun todo-convert-legacy-date-time ()
   "Return converted date-time string.
 Helper function for `todo-convert-legacy-files'."
-  (let* ((year (match-string 1))
-        (month (match-string 2))
-        (monthname (calendar-month-name (string-to-number month) t))
-        (day (match-string 3))
-        (time (match-string 4))
-        dayname)
+  (calendar-dlet*
+      ((year (match-string 1))
+       (month (match-string 2))
+       (monthname (calendar-month-name (string-to-number month) t))
+       (day (match-string 3))
+       (time (match-string 4))
+       dayname)
     (replace-match "")
     (insert (mapconcat #'eval calendar-date-display-form "")
            (when time (concat " " time)))))
@@ -5990,8 +5991,8 @@ indicating an unspecified month, day, or year.
 
 When ARG is `day', non-nil arguments MO and YR determine the
 number of the last the day of the month."
-  (let (year monthname month day
-            dayname)                   ; Needed by calendar-date-display-form.
+  (calendar-dlet*
+      (year monthname month day dayname) ;Needed by calendar-date-display-form.
     (when (or (not arg) (eq arg 'year))
       (while (if (natnump year) (< year 1) (not (eq year '*)))
        (setq year (read-from-minibuffer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]