]> git.eshelyaron.com Git - emacs.git/commitdiff
Use `calendar-read-sexp` instead of the now obsolete `calendar-read`
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 21 Jan 2021 04:14:25 +0000 (23:14 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 21 Jan 2021 04:55:40 +0000 (23:55 -0500)
* lisp/calendar/diary-lib.el (diary-insert-cyclic-entry):
* lisp/calendar/cal-persia.el (calendar-persian-read-date):
* lisp/calendar/cal-move.el (calendar-goto-day-of-year):
* lisp/calendar/cal-mayan.el (calendar-mayan-read-haab-date)
(calendar-mayan-read-tzolkin-date):
* lisp/calendar/cal-julian.el (calendar-julian-goto-date)
(calendar-astro-goto-day-number):
* lisp/calendar/cal-iso.el (calendar-iso-read-date):
* lisp/calendar/cal-islam.el (calendar-islamic-read-date):
* lisp/calendar/cal-hebrew.el (calendar-hebrew-read-date)
(calendar-hebrew-list-yahrzeits):
* lisp/calendar/cal-french.el (calendar-french-goto-date):
* lisp/calendar/cal-coptic.el (calendar-coptic-read-date):
* lisp/calendar/cal-china.el (calendar-chinese-goto-date):
* lisp/calendar/cal-bahai.el (calendar-bahai-read-date):
* lisp/calendar/holidays.el (list-holidays): Use `calendar-read-sexp`.

13 files changed:
lisp/calendar/cal-bahai.el
lisp/calendar/cal-china.el
lisp/calendar/cal-coptic.el
lisp/calendar/cal-french.el
lisp/calendar/cal-hebrew.el
lisp/calendar/cal-islam.el
lisp/calendar/cal-iso.el
lisp/calendar/cal-julian.el
lisp/calendar/cal-mayan.el
lisp/calendar/cal-move.el
lisp/calendar/cal-persia.el
lisp/calendar/diary-lib.el
lisp/calendar/holidays.el

index 22e4cdbcd52929ffb2a27a851c4d6f11dbffbd1b..16176e37b4a311ef55b95821dd0c58b318341e3e 100644 (file)
@@ -153,13 +153,12 @@ Defaults to today's date if DATE is not given."
  "Interactively read the arguments for a Bahá’í date command.
 Reads a year, month and day."
   (let* ((today (calendar-current-date))
-         (year (calendar-read
-                "Bahá’í calendar year (not 0)"
+         (year (calendar-read-sexp
+                "Bahá’í calendar year (not 0)"
                 (lambda (x) (not (zerop x)))
-                (number-to-string
-                 (calendar-extract-year
-                  (calendar-bahai-from-absolute
-                   (calendar-absolute-from-gregorian today))))))
+                (calendar-extract-year
+                 (calendar-bahai-from-absolute
+                  (calendar-absolute-from-gregorian today)))))
          (completion-ignore-case t)
          (month (cdr (assoc
                       (completing-read
@@ -169,8 +168,8 @@ Reads a year, month and day."
                        nil t)
                       (calendar-make-alist calendar-bahai-month-name-array
                                            1))))
-         (day (calendar-read "Bahá’í calendar day (1-19): "
-                             (lambda (x) (and (< 0 x) (<= x 19))))))
+         (day (calendar-read-sexp "Bahá’í calendar day (1-19)"
+                                  (lambda (x) (and (< 0 x) (<= x 19))))))
     (list (list month day year))))
 
 ;;;###cal-autoload
index 7e5d0c46e1127a09e51d8b6eaece2de36f62cb43..dd69d849df168769b9014df976e4dc6ab8208fcb 100644 (file)
@@ -602,14 +602,14 @@ Echo Chinese date unless NOECHO is non-nil."
   (interactive
    (let* ((c (calendar-chinese-from-absolute
               (calendar-absolute-from-gregorian (calendar-current-date))))
-          (cycle (calendar-read
-                  "Chinese calendar cycle number (>44)"
+          (cycle (calendar-read-sexp
+                  "Chinese calendar cycle number (>44)"
                   (lambda (x) (> x 44))
-                  (number-to-string (car c))))
-          (year (calendar-read
-                 "Year in Chinese cycle (1..60)"
+                  (car c)))
+          (year (calendar-read-sexp
+                 "Year in Chinese cycle (1..60)"
                  (lambda (x) (and (<= 1 x) (<= x 60)))
-                 (number-to-string (cadr c))))
+                 (cadr c)))
           (month-list (calendar-chinese-months-to-alist
                        (calendar-chinese-months cycle year)))
           (month (cdr (assoc
@@ -624,9 +624,11 @@ Echo Chinese date unless NOECHO is non-nil."
                                  (list cycle year month 1))))))
                     30
                   29))
-          (day (calendar-read
-                (format "Chinese calendar day (1-%d): " last)
-                (lambda (x) (and (<= 1 x) (<= x last))))))
+          (day (calendar-read-sexp
+                "Chinese calendar day (1-%d)"
+                (lambda (x) (and (<= 1 x) (<= x last)))
+                nil
+                last)))
      (list (list cycle year month day))))
   (calendar-goto-date (calendar-gregorian-from-absolute
                        (calendar-chinese-to-absolute date)))
index 3461f3259b918c5e877c5ae0873407330b8d18a5..2a0e7d81e0c06ec78fb68a6f8d337603fd88aefe 100644 (file)
@@ -136,13 +136,13 @@ Defaults to today's date if DATE is not given."
   "Interactively read the arguments for a Coptic date command.
 Reads a year, month, and day."
   (let* ((today (calendar-current-date))
-         (year (calendar-read
-                (format "%s calendar year (>0): " calendar-coptic-name)
+         (year (calendar-read-sexp
+                "%s calendar year (>0)"
                 (lambda (x) (> x 0))
-                (number-to-string
-                 (calendar-extract-year
-                  (calendar-coptic-from-absolute
-                   (calendar-absolute-from-gregorian today))))))
+                (calendar-extract-year
+                 (calendar-coptic-from-absolute
+                  (calendar-absolute-from-gregorian today)))
+                calendar-coptic-name))
          (completion-ignore-case t)
          (month (cdr (assoc-string
                       (completing-read
@@ -151,11 +151,14 @@ Reads a year, month, and day."
                                (append calendar-coptic-month-name-array nil))
                        nil t)
                       (calendar-make-alist calendar-coptic-month-name-array
-                                           1) t)))
+                                           1)
+                      t)))
          (last (calendar-coptic-last-day-of-month month year))
-         (day (calendar-read
-               (format "%s calendar day (1-%d): " calendar-coptic-name last)
-               (lambda (x) (and (< 0 x) (<= x last))))))
+         (day (calendar-read-sexp
+               "%s calendar day (1-%d)"
+               (lambda (x) (and (< 0 x) (<= x last)))
+               nil
+               calendar-coptic-name last)))
     (list (list month day year))))
 
 ;;;###cal-autoload
index c8ab6c41d8bc94568f1f8d0371cea496c2a40e0f..07c41c00bfe0715dcaa8c93d9b3aacf959bd65ac 100644 (file)
@@ -188,14 +188,13 @@ Echo French Revolutionary date unless NOECHO is non-nil."
    (let* ((months calendar-french-month-name-array)
           (special-days calendar-french-special-days-array)
           (year (progn
-                  (calendar-read
-                   "Année de la Révolution (>0)"
+                  (calendar-read-sexp
+                   "Année de la Révolution (>0)"
                    (lambda (x) (> x 0))
-                   (number-to-string
-                    (calendar-extract-year
-                     (calendar-french-from-absolute
-                      (calendar-absolute-from-gregorian
-                       (calendar-current-date))))))))
+                   (calendar-extract-year
+                    (calendar-french-from-absolute
+                     (calendar-absolute-from-gregorian
+                      (calendar-current-date)))))))
           (month-list
            (mapcar 'list
                    (append months
@@ -219,8 +218,8 @@ Echo French Revolutionary date unless NOECHO is non-nil."
                        (calendar-make-alist month-list 1 'car) t)))
           (day (if (> month 12)
                    (- month 12)
-                 (calendar-read
-                  "Jour (1-30)"
+                 (calendar-read-sexp
+                  "Jour (1-30)"
                   (lambda (x) (and (<= 1 x) (<= x 30))))))
           (month (if (> month 12) 13 month)))
      (list (list month day year))))
index bcc80f0877bfe3f69a5ee698de7a142032ceaba9..a835f9b430e7c1af17954f6e17f31f7b3b7d2f02 100644 (file)
@@ -225,13 +225,12 @@ Driven by the variable `calendar-date-display-form'."
   "Interactively read the arguments for a Hebrew date command.
 Reads a year, month, and day."
   (let* ((today (calendar-current-date))
-         (year (calendar-read
-                "Hebrew calendar year (>3760)"
+         (year (calendar-read-sexp
+                "Hebrew calendar year (>3760)"
                 (lambda (x) (> x 3760))
-                (number-to-string
-                 (calendar-extract-year
-                  (calendar-hebrew-from-absolute
-                   (calendar-absolute-from-gregorian today))))))
+                (calendar-extract-year
+                 (calendar-hebrew-from-absolute
+                  (calendar-absolute-from-gregorian today)))))
          (month-array (if (calendar-hebrew-leap-year-p year)
                           calendar-hebrew-month-name-array-leap-year
                         calendar-hebrew-month-name-array-common-year))
@@ -258,10 +257,11 @@ Reads a year, month, and day."
          (last (calendar-hebrew-last-day-of-month month year))
          (first (if (and (= year 3761) (= month 10))
                     18 1))
-         (day (calendar-read
-               (format "Hebrew calendar day (%d-%d): "
-                       first last)
-               (lambda (x) (and (<= first x) (<= x last))))))
+         (day (calendar-read-sexp
+               "Hebrew calendar day (%d-%d)"
+               (lambda (x) (and (<= first x) (<= x last)))
+               nil
+               first last)))
     (list (list month day year))))
 
 ;;;###cal-autoload
@@ -681,10 +681,10 @@ from the cursor position."
            (if (equal (current-buffer) (get-buffer calendar-buffer))
                (calendar-cursor-to-date t)
              (let* ((today (calendar-current-date))
-                    (year (calendar-read
-                           "Year of death (>0)"
+                    (year (calendar-read-sexp
+                           "Year of death (>0)"
                            (lambda (x) (> x 0))
-                           (number-to-string (calendar-extract-year today))))
+                           (calendar-extract-year today)))
                     (month-array calendar-month-name-array)
                     (completion-ignore-case t)
                     (month (cdr (assoc-string
@@ -694,20 +694,23 @@ from the cursor position."
                                   nil t)
                                  (calendar-make-alist month-array 1) t)))
                     (last (calendar-last-day-of-month month year))
-                    (day (calendar-read
-                          (format "Day of death (1-%d): " last)
-                          (lambda (x) (and (< 0 x) (<= x last))))))
+                    (day (calendar-read-sexp
+                          "Day of death (1-%d)"
+                          (lambda (x) (and (< 0 x) (<= x last)))
+                          nil
+                          last)))
                (list month day year))))
           (death-year (calendar-extract-year death-date))
-          (start-year (calendar-read
-                       (format "Starting year of Yahrzeit table (>%d): "
-                               death-year)
+          (start-year (calendar-read-sexp
+                       "Starting year of Yahrzeit table (>%d)"
                        (lambda (x) (> x death-year))
-                       (number-to-string (1+ death-year))))
-          (end-year (calendar-read
-                     (format "Ending year of Yahrzeit table (>=%d): "
-                             start-year)
-                     (lambda (x) (>= x start-year)))))
+                       (1+ death-year)
+                       death-year))
+          (end-year (calendar-read-sexp
+                     "Ending year of Yahrzeit table (>=%d)"
+                     (lambda (x) (>= x start-year))
+                     nil
+                     start-year)))
      (list death-date start-year end-year)))
   (message "Computing Yahrzeits...")
   (let* ((h-date (calendar-hebrew-from-absolute
index d256310ba6c0107d87197aa6e7570dccff0df2ac..4082ed43e5dc5b96d0cf36fde74ac42c35a732bb 100644 (file)
@@ -143,13 +143,12 @@ Driven by the variable `calendar-date-display-form'."
   "Interactively read the arguments for an Islamic date command.
 Reads a year, month, and day."
   (let* ((today (calendar-current-date))
-         (year (calendar-read
-                "Islamic calendar year (>0)"
+         (year (calendar-read-sexp
+                "Islamic calendar year (>0)"
                 (lambda (x) (> x 0))
-                (number-to-string
-                 (calendar-extract-year
-                  (calendar-islamic-from-absolute
-                   (calendar-absolute-from-gregorian today))))))
+                (calendar-extract-year
+                 (calendar-islamic-from-absolute
+                  (calendar-absolute-from-gregorian today)))))
          (month-array calendar-islamic-month-name-array)
          (completion-ignore-case t)
          (month (cdr (assoc-string
@@ -159,9 +158,11 @@ Reads a year, month, and day."
                        nil t)
                       (calendar-make-alist month-array 1) t)))
          (last (calendar-islamic-last-day-of-month month year))
-         (day (calendar-read
-               (format "Islamic calendar day (1-%d): " last)
-               (lambda (x) (and (< 0 x) (<= x last))))))
+         (day (calendar-read-sexp
+               "Islamic calendar day (1-%d)"
+               (lambda (x) (and (< 0 x) (<= x last)))
+               nil
+               last)))
     (list (list month day year))))
 
 ;;;###cal-autoload
index 956433e4a20a23914a815c16eabdb83f6c04c93a..a247b2d15a9ab9e19121b69a97bd38cb87d4cd79 100644 (file)
@@ -92,22 +92,23 @@ date Sunday, December 31, 1 BC."
   "Interactively read the arguments for an ISO date command.
 Reads a year and week, and if DAYFLAG is non-nil a day (otherwise
 taken to be 1)."
-  (let* ((year (calendar-read
-                "ISO calendar year (>0)"
+  (let* ((year (calendar-read-sexp
+                "ISO calendar year (>0)"
                 (lambda (x) (> x 0))
-                (number-to-string (calendar-extract-year
-                                (calendar-current-date)))))
+                (calendar-extract-year (calendar-current-date))))
          (no-weeks (calendar-extract-month
                     (calendar-iso-from-absolute
                      (1-
                       (calendar-dayname-on-or-before
                        1 (calendar-absolute-from-gregorian
                           (list 1 4 (1+ year))))))))
-         (week (calendar-read
-                (format "ISO calendar week (1-%d): " no-weeks)
-                (lambda (x) (and (> x 0) (<= x no-weeks)))))
-         (day (if dayflag (calendar-read
-                           "ISO day (1-7): "
+         (week (calendar-read-sexp
+                "ISO calendar week (1-%d)"
+                (lambda (x) (and (> x 0) (<= x no-weeks)))
+                nil
+                no-weeks))
+         (day (if dayflag (calendar-read-sexp
+                           "ISO day (1-7)"
                            (lambda (x) (and (<= 1 x) (<= x 7))))
                 1)))
     (list (list week day year))))
index 235b4d00900fb19056030de4e944085c1d2cb879..47880a4e9744ecb433b5feadc30e75fe4f0aae80 100644 (file)
@@ -95,14 +95,13 @@ Driven by the variable `calendar-date-display-form'."
   "Move cursor to Julian DATE; echo Julian date unless NOECHO is non-nil."
   (interactive
    (let* ((today (calendar-current-date))
-          (year (calendar-read
-                 "Julian calendar year (>0)"
+          (year (calendar-read-sexp
+                 "Julian calendar year (>0)"
                  (lambda (x) (> x 0))
-                 (number-to-string
-                  (calendar-extract-year
-                   (calendar-julian-from-absolute
-                    (calendar-absolute-from-gregorian
-                     today))))))
+                 (calendar-extract-year
+                  (calendar-julian-from-absolute
+                   (calendar-absolute-from-gregorian
+                    today)))))
           (month-array calendar-month-name-array)
           (completion-ignore-case t)
           (month (cdr (assoc-string
@@ -115,12 +114,13 @@ Driven by the variable `calendar-date-display-form'."
            (if (and (zerop (% year 4)) (= month 2))
                29
              (aref [31 28 31 30 31 30 31 31 30 31 30 31] (1- month))))
-          (day (calendar-read
-                (format "Julian calendar day (%d-%d): "
-                        (if (and (= year 1) (= month 1)) 3 1) last)
+          (day (calendar-read-sexp
+                "Julian calendar day (%d-%d)"
                 (lambda (x)
                   (and (< (if (and (= year 1) (= month 1)) 2 0) x)
-                       (<= x last))))))
+                       (<= x last)))
+                nil
+                (if (and (= year 1) (= month 1)) 3 1) last)))
      (list (list month day year))))
   (calendar-goto-date (calendar-gregorian-from-absolute
                        (calendar-julian-to-absolute date)))
@@ -173,8 +173,8 @@ Defaults to today's date if DATE is not given."
 (defun calendar-astro-goto-day-number (daynumber &optional noecho)
   "Move cursor to astronomical (Julian) DAYNUMBER.
 Echo astronomical (Julian) day number unless NOECHO is non-nil."
-  (interactive (list (calendar-read
-                      "Astronomical (Julian) day number (>1721425)"
+  (interactive (list (calendar-read-sexp
+                      "Astronomical (Julian) day number (>1721425)"
                       (lambda (x) (> x 1721425)))))
   (calendar-goto-date
    (calendar-gregorian-from-absolute
index 8d894ebd986ec5fd7590d1b711d7ba8c0eb88a49..e3533e7b1d61d2bea7a2bad368f9bec3d78dc254 100644 (file)
@@ -135,8 +135,8 @@ but some use 1137140.  Using 1232041 gives you Spinden's correlation; using
 (defun calendar-mayan-read-haab-date ()
   "Prompt for a Mayan haab date."
   (let* ((completion-ignore-case t)
-         (haab-day (calendar-read
-                    "Haab kin (0-19)"
+         (haab-day (calendar-read-sexp
+                    "Haab kin (0-19)"
                     (lambda (x) (and (>= x 0) (< x 20)))))
          (haab-month-list (append calendar-mayan-haab-month-name-array
                                   (and (< haab-day 5) '("Uayeb"))))
@@ -151,8 +151,8 @@ but some use 1137140.  Using 1232041 gives you Spinden's correlation; using
 (defun calendar-mayan-read-tzolkin-date ()
   "Prompt for a Mayan tzolkin date."
   (let* ((completion-ignore-case t)
-         (tzolkin-count (calendar-read
-                         "Tzolkin kin (1-13)"
+         (tzolkin-count (calendar-read-sexp
+                         "Tzolkin kin (1-13)"
                          (lambda (x) (and (> x 0) (< x 14)))))
          (tzolkin-name-list (append calendar-mayan-tzolkin-names-array nil))
          (tzolkin-name (cdr
index 710ce37ccbf8a63712afa977d6fe6112de87d67f..c2b5d618ea0c0d068b217921784b1d612d8e9c78 100644 (file)
@@ -386,15 +386,16 @@ Moves forward if ARG is negative."
   "Move cursor to YEAR, DAY number; echo DAY/YEAR unless NOECHO is non-nil.
 Negative DAY counts backward from end of year."
   (interactive
-   (let* ((year (calendar-read
-                 "Year (>0)"
+   (let* ((year (calendar-read-sexp
+                 "Year (>0)"
                  (lambda (x) (> x 0))
-                 (number-to-string (calendar-extract-year
-                                 (calendar-current-date)))))
+                 (calendar-extract-year (calendar-current-date))))
           (last (if (calendar-leap-year-p year) 366 365))
-          (day (calendar-read
-                (format "Day number (+/- 1-%d): " last)
-                (lambda (x) (and (<= 1 (abs x)) (<= (abs x) last))))))
+          (day (calendar-read-sexp
+                "Day number (+/- 1-%d)"
+                (lambda (x) (and (<= 1 (abs x)) (<= (abs x) last)))
+                nil
+                last)))
      (list year day)))
   (calendar-goto-date
    (calendar-gregorian-from-absolute
index a9c99fedbdb323afc2518c37a9f7cc84d27cb4f1..21085284ac830564e843356b096ed40105a67925 100644 (file)
@@ -157,14 +157,13 @@ Gregorian date Sunday, December 31, 1 BC."
 (defun calendar-persian-read-date ()
   "Interactively read the arguments for a Persian date command.
 Reads a year, month, and day."
-  (let* ((year (calendar-read
-                "Persian calendar year (not 0)"
+  (let* ((year (calendar-read-sexp
+                "Persian calendar year (not 0)"
                 (lambda (x) (not (zerop x)))
-                (number-to-string
-                 (calendar-extract-year
-                  (calendar-persian-from-absolute
-                   (calendar-absolute-from-gregorian
-                    (calendar-current-date)))))))
+                (calendar-extract-year
+                 (calendar-persian-from-absolute
+                  (calendar-absolute-from-gregorian
+                   (calendar-current-date))))))
          (completion-ignore-case t)
          (month (cdr (assoc
                       (completing-read
@@ -175,9 +174,11 @@ Reads a year, month, and day."
                       (calendar-make-alist calendar-persian-month-name-array
                                            1))))
          (last (calendar-persian-last-day-of-month month year))
-         (day (calendar-read
-               (format "Persian calendar day (1-%d): " last)
-               (lambda (x) (and (< 0 x) (<= x last))))))
+         (day (calendar-read-sexp
+               "Persian calendar day (1-%d)"
+               (lambda (x) (and (< 0 x) (<= x last)))
+               nil
+               last)))
     (list (list month day year))))
 
 ;;;###cal-autoload
index aad70161f9fe4f48a131aa81098a7e2baeae43a4..4efa366996729be7d4efcbe25571b5e280297ac4 100644 (file)
@@ -2221,8 +2221,8 @@ Prefix argument ARG makes the entry nonmarking."
     (diary-make-entry
      (format "%s(diary-cyclic %d %s)"
              diary-sexp-entry-symbol
-             (calendar-read "Repeat every how many days: "
-                            (lambda (x) (> x 0)))
+             (calendar-read-sexp "Repeat every how many days"
+                                 (lambda (x) (> x 0)))
              (calendar-date-string (calendar-cursor-to-date t) nil t))
      arg)))
 
index 932993beba07ebf1f7fcfb37d93b0f36d58fb476..4bc17de3067e2a3dee7f7848998839587625dcf4 100644 (file)
@@ -423,16 +423,15 @@ of a holiday list.
 
 The optional LABEL is used to label the buffer created."
   (interactive
-   (let* ((start-year (calendar-read
-                       "Starting year of holidays (>0)"
+   (let* ((start-year (calendar-read-sexp
+                       "Starting year of holidays (>0)"
                        (lambda (x) (> x 0))
-                       (number-to-string (calendar-extract-year
-                                       (calendar-current-date)))))
-          (end-year (calendar-read
-                     (format "Ending year (inclusive) of holidays (>=%s): "
-                             start-year)
+                       (calendar-extract-year (calendar-current-date))))
+          (end-year (calendar-read-sexp
+                     "Ending year (inclusive) of holidays (>=%s)"
                      (lambda (x) (>= x start-year))
-                     (number-to-string start-year)))
+                     start-year
+                     start-year))
           (completion-ignore-case t)
           (lists
            (list