Giter VIP home page Giter VIP logo

Comments (9)

justbur avatar justbur commented on May 27, 2024

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.

kaushalmodi avatar kaushalmodi commented on May 27, 2024

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.

justbur avatar justbur commented on May 27, 2024

@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

  1. key
  2. description
  3. key or description grouping prefixes and commands separately
  4. key or description grouping by keymap (major then minors)
  5. usage freq ascending (least used first) for discovery
  6. usage freq descending
  7. some combination of the above
  8. user defined

from emacs-which-key.

kaushalmodi avatar kaushalmodi commented on May 27, 2024

(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 use d. I know that I can also do C-h c or C-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.

justbur avatar justbur commented on May 27, 2024

@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.

kaushalmodi avatar kaushalmodi commented on May 27, 2024

@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.

justbur avatar justbur commented on May 27, 2024

@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.

kaushalmodi avatar kaushalmodi commented on May 27, 2024

Works great! Thanks!

from emacs-which-key.

kaushalmodi avatar kaushalmodi commented on May 27, 2024

The sorted lists look really really good. Thanks for implementing this feature! πŸ‘

from emacs-which-key.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.