Comments (9)
The order is according to how they are displayed by
display-buffer-bindings
right now.
How would you like them sorted?
On Thu, Jul 16, 2015 at 11:21 AM, Kaushal Modi [email protected]
wrote:
I have noticed that the bindings are not always listed in sorted order.
The same prefix map seems to get shuffled around when displayed (either in
the same or across different emacs sessions).For instance, C-c shows me this (you can click on the image for the
zoomed view):Note that the lower case s, t, w appear at the very end. Also bindings
for P and W are not along with other upper case bindings.[image: clipboard01]
https://cloud.githubusercontent.com/assets/3578197/8727225/946c1f44-2bac-11e5-9b75-b97f8207870b.pngβ
Reply to this email directly or view it on GitHub
#42.
from emacs-which-key.
I thought it would be nice to show them in an order similar to this:
- in <ascii-table-order>
- followed by
C-<ascii-table-order>
- followed by
M-<ascii-table-order>
- followed by
C-M-<ascii-table-order>
- followed by
s-<ascii-table-order>
Here's an example order:
A
B
C
a
b
c
C-S-a
C-S-b
C-S-c
C-a
C-b
C-c
M-A
M-B
M-C
M-a
M-b
M-c
.. and so on
from emacs-which-key.
@syl20bnr suggested another alternative in #1 (by usage freq). I'm not convinced what the right way to sort is yet, but I'm happy to listen to arguments for one method or the other. Some that I've considered are by
- key
- description
- key or description grouping prefixes and commands separately
- key or description grouping by keymap (major then minors)
- usage freq ascending (least used first) for discovery
- usage freq descending
- some combination of the above
- user defined
from emacs-which-key.
(1) key MY Preferred Way
Reasons:
- Predicatability.. it will always be consistency, with keys sorted alphabetically (as demonstrated in my above comment).
- Easy to find available bindings. Let's say I want to make one binding but want to quickly scan the already occupied bindings. It will be easily to see:
a
taken,b
taken,c
taken,e
taken, .. OK I can used
. I know that I can also doC-h c
orC-h k
to figure out if a key is taken, but being able to do a full review of the whole map feels better.
(2) description
Not sure about this, I tend to rebind stuff a lot, especially for commands from new packages that I'd like to integrate in my work flow. I haven't yet settled on how I'd like to bind yasnippet
.
(3) key or description grouping prefixes and commands separately
I like the next grouping better, by keymap. That way related commands are listed together.
(4) key or description grouping by keymap (major then minors)
In general, I liked the idea to be able to group by prefix maps. A very good example would be to list the rectangle and register block in different groups when user hits C-x r
. In guide-key
, it set different faces for different gropus but did not arrange them (that would be great too).
(5) usage freq ascending (least used first) for discovery
I didn't like this method, for the reason of unpredictability. Also this approach could result in always showing the most useless and difficult to access bindings. Hypothetically if a prefix map could have 100 bindings, a user might be using just 50 of those. But with this approach, those useful 50 or a major chunk of those could end up being hidden or on a different page of bindings (if that feature is implemented).
(6) usage freq descending
I didn't like this method, for the reason of unpredictability.
(7) some combination of the above
My preference: Option 1 > Option 4 > Option 6
(8) user defined
If it means that user can set one of the above options, then why not. Of course that would mean a higher burden of implementing all the options and making sure all work well. :)
from emacs-which-key.
@kaushalmodi Is this ordering function adequate? It does everything you asked except it makes "C-a" < "C-S-a"
. I can fix this if it's important. You can test this function on some sample data. Or if you want to write your own?
My idea is to write a default ordering function and then support alternatives for options. It would be easy to order based on description for example.
(defun key-description< (a b)
(let ((la (string-width a))
(lb (string-width b)))
(cond ((and (= la 1) (= lb 1)) (string-lessp a b))
((or (= la 1) (= lb 1)) (= la 1))
((string-equal (substring a 0 2) (substring b 0 2))
(key-description< (substring a 2) (substring b 2)))
(t (string-lessp a b)))))
(setq test '("A" "B" "C" "a" "b" "c" "C-S-a" "C-S-b" "C-S-c" "C-a" "C-c" "M-A" "M-B" "M-C" "M-a" "M-b" "M-c"))
(sort test 'key-description<)
from emacs-which-key.
@justbur That is great! I wouldn't care if "C-a" < "C-S-a"
as long as it is consistent. Thanks for working on this!
from emacs-which-key.
@kaushalmodi I added an option, which-key-sort
, to sort using that order in 2c6ab4d. It's off by default for now, so you'll have to (setq which-key-sort t)
to activate it. Let me know if you see any problems with it.
from emacs-which-key.
Works great! Thanks!
from emacs-which-key.
The sorted lists look really really good. Thanks for implementing this feature! π
from emacs-which-key.
Related Issues (20)
- Composition not being used in which-key buffer HOT 2
- BUG: conflict between which-key-window and avy-goto-char-2. HOT 2
- which-key menu misalignment with ellipsis char HOT 1
- Setting which-key-show-operator-state-maps to true "breaks" outer and inner evil maps HOT 1
- which-key crashes when trying to display term-raw-map HOT 1
- How to switch among different pages of keys conveniently in which-key mode? HOT 1
- which-key canβt show keys: There is not enough space based on your settings and frame size HOT 2
- Customize which-key-C-h-dispatch prompt HOT 1
- Make "<prefix> C-h" display which key and prompt for command at the same time HOT 3
- The texts for the same key in different keymaps are overridden each other HOT 2
- Question about `which-key-undo` HOT 1
- which-key is good enough to be built-into Emacs HOT 1
- Question about full description popups HOT 3
- Automatic expansion of unnamed prefixes
- misoperation
- Once which-key popup is triggered via which-key-show-early-on-C-h all delays are ignored afterwards HOT 1
- Which-key shows wrong labels from inactive keymaps HOT 1
- Side window is too narrow HOT 1
- Scrolling/ moving the screen
- How can I hide keys from the which-key popup? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emacs-which-key.