[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Improving prefix map names
From: |
Jeremy Bryant |
Subject: |
Re: Improving prefix map names |
Date: |
Sun, 26 Jan 2025 14:03:28 +0000 |
Matthias Meulien <orontee@gmail.com> writes:
> The `Which-Key mode' was a really nice addition! It greatly improves
> discoverability.
Thank you.
>
> As a consequence I now often find myself pressing a prefix then
> lazily wait for the popup to read the exact keys to run the command I
> have in mind and know is in the prefix map but can't remember exactly
> where...
>
> Unfortunately there are many anonymous nested prefix maps. Example:
> In a "NEWS" buffer, after I press "C-c", I learn that the @ key binds
> to "+prefix" which is almost helpless. See:
>
> Capture d’écran du 2025-01-26 12-14-28.png
>
>
>
> I've updated my configuration file with explicit names for the prefix
> maps I create, for example:
>
> (require 'whitespace)
> (define-prefix-command 'whitespace-prefix-map)
> (keymap-global-set "C-c w" 'whitespace-prefix-map)
> (keymap-set whitespace-prefix-map "t" 'whitespace-mode)
> (keymap-set whitespace-prefix-map "c" 'whitespace-cleanup)
> (keymap-set whitespace-prefix-map "r" 'whitespace-report)
>
> But is there any way to improve this situation in Emacs? How could it
> be done?
>
> I'd be happy to help.
Indeed, this is the problem with anonymous prefix maps.
There could be different approaches to solving this problem.
One idea is perhaps we show the first entry in the prefix map, as a hint
to the rest which is relevant for a prefix map corresponding to a common
symbol prefix. (For prefix maps made of mostly unrelated bindings it is
less useful, but perhaps those maps would not be anonymous.)
In your example, we could display something like the following
@ : +prefix (outline-insert-heading...)
WDYT?