Subject: bug#11325: 24.1.50; regression: bad order for `substitute-command-keys' with keymap

From: Stefan Kangas <[email-masked]>
Date: Wed, 20 Oct 2021 14:32:58 -0700

Lars Ingebrigtsen <[email-masked]> writes:

> "Drew Adams" <[email-masked]> writes:
>
>> Then it was broken differently in Emacs 24, which puts `e..f'
>> first in the list, but restores `0..9' to its rightful place.
>
> Isn't the main problem here that it even tries to do a two-letter range?
> Seems awfully odd to me:

This could be easily fixed using:

diff --git a/src/keymap.c b/src/keymap.c
index ca1dbe368e..1c6f75a767 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -3101,10 +3101,13 @@ describe_vector (Lisp_Object vector,
Lisp_Object prefix, Lisp_Object args,
 	    }
 	}

-      /* If we have a range of more than one character,
-	 print where the range reaches to.  */
+      /* If we have a range of more than two characters, print where
+	 the range reaches to.  We specifically avoid printing two
+	 character ranges, as they aren't very easy on the reader.  */

-      if (i != starting_i)
+      if ((i - starting_i) < 2)
+	i = starting_i;
+      else
 	{
 	  insert (" .. ", 4);

> (substitute-command-keys "\\{dired-mode-map}")
> "key             binding
> ---             -------
>
> e .. f		dired-find-file
>
> C-c		Prefix Command
> RET		dired-find-file
> C-o		dired-display-file
> C-t		Prefix Command
> ESC		Prefix Command
> SPC		dired-next-line
> !		dired-do-shell-command
> #		dired-flag-auto-save-files
> $		dired-hide-subdir
> %		Prefix Command
> &		dired-do-async-shell-command
> (		dired-hide-details-mode
> *		Prefix Command
> +		dired-create-directory
> -		negative-argument
> .		dired-clean-directory
> 0 .. 9		digit-argument