Subject: bug#78753: [PATCH] Add repeat-map for calendar year navigation commands

From: "Paul D. Nelson" <[email-masked]>
Date: Wed, 11 Jun 2025 20:15:37 +0200

Juri Linkov <[email-masked]> writes:

>>>> With this patch and with repeat-mode active, one can navigate by year in
>>>> calendar using 'C-x ] ]' rather than 'C-x ] C-x ]', for instance.
>>>
>>> I wanted to suggest the same thing for 'C-x >', but discovered it has
>>> a shorter alternative '>' for the same command 'calendar-scroll-left'.
>>> (I don't remember whether I usually use it or the longer sequence).
>>>
>>> Would it be simpler just to add the single key bindings '[' and ']'?
>>> There are currently free in 'calendar-mode-map'.
>>
>> Ah, good thinking.  Yes, and along similar lines, how about binding '{'
>> and '}' to 'calendar-backward-month' and 'calendar-forward-month'?
>
> Good idea.
>
>> Let me know if I can help with this or if it's easier for you just to do
>> it.
>
> It's not easier for me since it requires also updating the documentation ;-)

Very well, please see attached.

>From 5023c4b163a26f2f93a743eb08426264d7716985 Mon Sep 17 00:00:00 2001
From: Paul Nelson <[email-masked]>
Date: Tue, 10 Jun 2025 11:33:05 +0200
Subject: [PATCH] Add simpler binds for calendar month/year navigation

* lisp/calendar/calendar.el (calendar-mode-map): Add keybindings
'{' and '}' for month navigation, '[' and ']' for year
navigation (bug#78753).
* doc/emacs/calendar.texi (Calendar Unit Motion): Document
them.
---
 doc/emacs/calendar.texi   | 11 +++++++++++
 etc/NEWS                  |  5 +++++
 lisp/calendar/calendar.el |  4 ++++
 3 files changed, 20 insertions(+)

diff --git a/doc/emacs/calendar.texi b/doc/emacs/calendar.texi
index 56f297db5d0..b3558448975 100644
--- a/doc/emacs/calendar.texi
+++ b/doc/emacs/calendar.texi
@@ -84,12 +84,16 @@ Calendar Unit Motion
 @item C-p
 Move point one week backward (@code{calendar-backward-week}).
 @item M-@}
+@itemx @}
 Move point one month forward (@code{calendar-forward-month}).
 @item M-@{
+@itemx @{
 Move point one month backward (@code{calendar-backward-month}).
 @item C-x ]
+@itemx ]
 Move point one year forward (@code{calendar-forward-year}).
 @item C-x [
+@itemx [
 Move point one year backward (@code{calendar-backward-year}).
 @end table
 
@@ -114,12 +118,16 @@ Calendar Unit Motion
 @kbd{C-p}, just as they normally are in other modes.
 
 @kindex M-@} @r{(Calendar mode)}
+@kindex @} @r{(Calendar mode)}
 @findex calendar-forward-month
 @kindex M-@{ @r{(Calendar mode)}
+@kindex @{ @r{(Calendar mode)}
 @findex calendar-backward-month
 @kindex C-x ] @r{(Calendar mode)}
+@kindex ] @r{(Calendar mode)}
 @findex calendar-forward-year
 @kindex C-x [ @r{(Calendar mode)}
+@kindex [ @r{(Calendar mode)}
 @findex calendar-backward-year
   The commands for motion by months and years work like those for
 weeks, but move a larger distance.  The month commands @kbd{M-@}}
@@ -137,6 +145,9 @@ Calendar Unit Motion
 commands move by an entire month or an entire year, keeping the same
 date within the month or year.
 
+  You can also use the simpler to type keystrokes @kbd{@}} and @kbd{@{}
+to navigate by month, and @kbd{]} and @kbd{[} to navigate by year.
+
   All these commands accept a numeric argument as a repeat count.
 For convenience, the digit keys and the minus sign specify numeric
 arguments in Calendar mode even without the Meta modifier.  For example,
diff --git a/etc/NEWS b/etc/NEWS
index c5172b40da6..0a9450614d4 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2168,6 +2168,11 @@ is bound to 'C-l' in the calendar buffer.
 You can now use the mouse wheel to scroll the calendar by 3 months.
 With the shift modifier, it scrolls by one month.  With the meta
 modifier, it scrolls by year.
+
+*** Simpler month and year navigation binds in calendar.
+The month and year navigation binds 'M-}', 'M-{', 'C-x ]' and 'C-x ['
+now admit the alternatives '}', '{', ']' and '['.
+
 
 * New Modes and Packages in Emacs 31.1
 
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index c448955450e..1c98de98b9b 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -1603,7 +1603,9 @@ calendar-mode-map
     (define-key map "\C-b"  'calendar-backward-day)
     (define-key map "\C-p"  'calendar-backward-week)
     (define-key map "\e{"   'calendar-backward-month)
+    (define-key map "{"   'calendar-backward-month)
     (define-key map "\C-x[" 'calendar-backward-year)
+    (define-key map "[" 'calendar-backward-year)
     (define-key map "\C-f"  'calendar-forward-day)
     (define-key map "\C-n"  'calendar-forward-week)
     (define-key map [left]  'calendar-backward-day)
@@ -1611,7 +1613,9 @@ calendar-mode-map
     (define-key map [right] 'calendar-forward-day)
     (define-key map [down]  'calendar-forward-week)
     (define-key map "\e}"   'calendar-forward-month)
+    (define-key map "}"   'calendar-forward-month)
     (define-key map "\C-x]" 'calendar-forward-year)
+    (define-key map "]" 'calendar-forward-year)
     (define-key map "\C-a"  'calendar-beginning-of-week)
     (define-key map "\C-e"  'calendar-end-of-week)
     (define-key map "\ea"   'calendar-beginning-of-month)
-- 
2.39.3 (Apple Git-145)