From 0ef224598b847d754d6315ee4dbfe40f20f53143 Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Sat, 5 Jul 2025 21:17:00 +0200 Subject: [PATCH] Saner defaults for `calendar-read-sexp' (Bug#78964) * lisp/calendar/cal-bahai.el (calendar-bahai-read-date): * lisp/calendar/cal-china.el (calendar-chinese-goto-date): * lisp/calendar/cal-coptic.el (calendar-coptic-read-date): * lisp/calendar/cal-french.el (calendar-french-goto-date): * lisp/calendar/cal-hebrew.el (calendar-hebrew-read-date): * lisp/calendar/cal-islam.el (calendar-islamic-read-date): * lisp/calendar/cal-iso.el (calendar-iso-read-date): * lisp/calendar/cal-julian.el (calendar-julian-goto-date) (calendar-astro-goto-day-number): * lisp/calendar/cal-mayan.el (calendar-mayan-read-haab-date) (calendar-mayan-read-tzolkin-date): * lisp/calendar/cal-persia.el (calendar-persian-read-date): * lisp/calendar/diary-lib.el (diary-insert-cyclic-entry): Use first day as default. * lisp/calendar/cal-hebrew.el (calendar-hebrew-list-yahrzeits): Set the default of end-year as start-year plus ten years. (cherry picked from commit eb252e645492069621e633d9269a02b778a80678) --- lisp/calendar/cal-bahai.el | 3 ++- lisp/calendar/cal-china.el | 2 +- lisp/calendar/cal-coptic.el | 2 +- lisp/calendar/cal-french.el | 6 ++++-- lisp/calendar/cal-hebrew.el | 6 +++--- lisp/calendar/cal-islam.el | 2 +- lisp/calendar/cal-iso.el | 5 +++-- lisp/calendar/cal-julian.el | 5 +++-- lisp/calendar/cal-mayan.el | 6 ++++-- lisp/calendar/cal-persia.el | 2 +- lisp/calendar/diary-lib.el | 3 ++- 11 files changed, 25 insertions(+), 17 deletions(-) diff --git a/lisp/calendar/cal-bahai.el b/lisp/calendar/cal-bahai.el index 073d04e7707..fd0faf1e2ce 100644 --- a/lisp/calendar/cal-bahai.el +++ b/lisp/calendar/cal-bahai.el @@ -169,7 +169,8 @@ Reads a year, month and day." (calendar-make-alist calendar-bahai-month-name-array 1)))) (day (calendar-read-sexp "Bahá’í calendar day (1-19)" - (lambda (x) (and (< 0 x) (<= x 19)))))) + (lambda (x) (and (< 0 x) (<= x 19))) + 1))) (list (list month day year)))) ;;;###cal-autoload diff --git a/lisp/calendar/cal-china.el b/lisp/calendar/cal-china.el index 776d1d287bf..8d080e36072 100644 --- a/lisp/calendar/cal-china.el +++ b/lisp/calendar/cal-china.el @@ -630,7 +630,7 @@ Echo Chinese date unless NOECHO is non-nil." (day (calendar-read-sexp "Chinese calendar day (1-%d)" (lambda (x) (and (<= 1 x) (<= x last))) - nil + 1 last))) (list (list cycle year month day)))) (calendar-goto-date (calendar-gregorian-from-absolute diff --git a/lisp/calendar/cal-coptic.el b/lisp/calendar/cal-coptic.el index 11b244c930d..04ef239897e 100644 --- a/lisp/calendar/cal-coptic.el +++ b/lisp/calendar/cal-coptic.el @@ -157,7 +157,7 @@ Reads a year, month, and day." (day (calendar-read-sexp "%s calendar day (1-%d)" (lambda (x) (and (< 0 x) (<= x last))) - nil + 1 calendar-coptic-name last))) (list (list month day year)))) diff --git a/lisp/calendar/cal-french.el b/lisp/calendar/cal-french.el index 3c7906e5620..3b98ea30216 100644 --- a/lisp/calendar/cal-french.el +++ b/lisp/calendar/cal-french.el @@ -363,8 +363,10 @@ Echo French Revolutionary date unless NOECHO is non-nil." (day (if (> month 13) (- month 13) (calendar-read-sexp - (format "Jour (1-%d): " last-day) - (lambda (x) (<= 1 x last-day))))) + "Jour (1-%d): " + (lambda (x) (<= 1 x last-day)) + 1 + last-day))) ;; All days in Vendémiaire and numbered 1 to 365 e.g., "Pomme" ;; gives 31 Vendémiaire automatically normalized to 1 Brumaire ;; "Céleri" gives 32 Vnd normalized to 2 Bru, "Raiponce" gives diff --git a/lisp/calendar/cal-hebrew.el b/lisp/calendar/cal-hebrew.el index 69fac1d751d..160f9e0a761 100644 --- a/lisp/calendar/cal-hebrew.el +++ b/lisp/calendar/cal-hebrew.el @@ -259,7 +259,7 @@ Reads a year, month, and day." (day (calendar-read-sexp "Hebrew calendar day (%d-%d)" (lambda (x) (and (<= first x) (<= x last))) - nil + first first last))) (list (list month day year)))) @@ -696,7 +696,7 @@ from the cursor position." (day (calendar-read-sexp "Day of death (1-%d)" (lambda (x) (and (< 0 x) (<= x last))) - nil + 1 last))) (list month day year)))) (death-year (calendar-extract-year death-date)) @@ -708,7 +708,7 @@ from the cursor position." (end-year (calendar-read-sexp "Ending year of Yahrzeit table (>=%d)" (lambda (x) (>= x start-year)) - nil + (+ 10 start-year) start-year))) (list death-date start-year end-year))) (message "Computing Yahrzeits...") diff --git a/lisp/calendar/cal-islam.el b/lisp/calendar/cal-islam.el index 2053852add0..1cefdc805a4 100644 --- a/lisp/calendar/cal-islam.el +++ b/lisp/calendar/cal-islam.el @@ -160,7 +160,7 @@ Reads a year, month, and day." (day (calendar-read-sexp "Islamic calendar day (1-%d)" (lambda (x) (and (< 0 x) (<= x last))) - nil + 1 last))) (list (list month day year)))) diff --git a/lisp/calendar/cal-iso.el b/lisp/calendar/cal-iso.el index 8697a0f2b1f..5f8e835749e 100644 --- a/lisp/calendar/cal-iso.el +++ b/lisp/calendar/cal-iso.el @@ -105,11 +105,12 @@ taken to be 1)." (week (calendar-read-sexp "ISO calendar week (1-%d)" (lambda (x) (and (> x 0) (<= x no-weeks))) - nil + 1 no-weeks)) (day (if dayflag (calendar-read-sexp "ISO day (1-7)" - (lambda (x) (and (<= 1 x) (<= x 7)))) + (lambda (x) (and (<= 1 x) (<= x 7))) + 1) 1))) (list (list week day year)))) diff --git a/lisp/calendar/cal-julian.el b/lisp/calendar/cal-julian.el index 6ab9626c7e3..d580a8f3605 100644 --- a/lisp/calendar/cal-julian.el +++ b/lisp/calendar/cal-julian.el @@ -118,7 +118,7 @@ Driven by the variable `calendar-date-display-form'." (lambda (x) (and (< (if (and (= year 1) (= month 1)) 2 0) x) (<= x last))) - nil + (if (and (= year 1) (= month 1)) 3 1) (if (and (= year 1) (= month 1)) 3 1) last))) (list (list month day year)))) (calendar-goto-date (calendar-gregorian-from-absolute @@ -174,7 +174,8 @@ Defaults to today's date if DATE is not given." Echo astronomical (Julian) day number unless NOECHO is non-nil." (interactive (list (calendar-read-sexp "Astronomical (Julian) day number (>1721425)" - (lambda (x) (> x 1721425))))) + (lambda (x) (> x 1721425)) + 1721426))) (calendar-goto-date (calendar-gregorian-from-absolute (floor diff --git a/lisp/calendar/cal-mayan.el b/lisp/calendar/cal-mayan.el index 4bbd1a7a3cd..52330e17280 100644 --- a/lisp/calendar/cal-mayan.el +++ b/lisp/calendar/cal-mayan.el @@ -136,7 +136,8 @@ but some use 1137140. Using 1232041 gives you Spinden's correlation; using "Prompt for a Mayan haab date." (let* ((haab-day (calendar-read-sexp "Haab kin (0-19)" - (lambda (x) (and (>= x 0) (< x 20))))) + (lambda (x) (and (>= x 0) (< x 20))) + 0)) (haab-month-list (append calendar-mayan-haab-month-name-array (and (< haab-day 5) '("Uayeb")))) (haab-month (cdr @@ -152,7 +153,8 @@ but some use 1137140. Using 1232041 gives you Spinden's correlation; using "Prompt for a Mayan tzolkin date." (let* ((tzolkin-count (calendar-read-sexp "Tzolkin kin (1-13)" - (lambda (x) (and (> x 0) (< x 14))))) + (lambda (x) (and (> x 0) (< x 14))) + 1)) (tzolkin-name-list (append calendar-mayan-tzolkin-names-array nil)) (tzolkin-name (cdr (assoc-string diff --git a/lisp/calendar/cal-persia.el b/lisp/calendar/cal-persia.el index 5305607d315..d572d2f57fb 100644 --- a/lisp/calendar/cal-persia.el +++ b/lisp/calendar/cal-persia.el @@ -177,7 +177,7 @@ Reads a year, month, and day." (day (calendar-read-sexp "Persian calendar day (1-%d)" (lambda (x) (and (< 0 x) (<= x last))) - nil + 1 last))) (list (list month day year)))) diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index 8fb6fadfe4c..3d8d827417e 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el @@ -2234,7 +2234,8 @@ Prefix argument ARG makes the entry nonmarking." (format "%s(diary-cyclic %d %s)" diary-sexp-entry-symbol (calendar-read-sexp "Repeat every how many days" - (lambda (x) (> x 0))) + (lambda (x) (> x 0)) + 1) (calendar-date-string (calendar-cursor-to-date t) nil t)) arg))) -- 2.39.5