Giter VIP home page Giter VIP logo

Comments (25)

kaushalmodi avatar kaushalmodi commented on May 27, 2024

I am pasting a part of my comment in that old issue thread here ( #42 (comment) ) which I think is interesting to pursue. It would be nice to sort the keys first by keymap and then alphabetically. If not that, at least use different faces for keys from different keymaps.

(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).

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

I just looked into it and it seems guide key relied on a user specified regexp to highlight groups of keys. That's certainly possible but not quite the same thing as finding their respective keymaps and organizing them that way

from emacs-which-key.

PythonNut avatar PythonNut commented on May 27, 2024

I would definitely love the ability to organize by the map the keybinding came from (with or without colors). That means that the keys are sorted by topic, which can be really helpful.

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

@PythonNut As far as I know it's tricky to determine for a given key which keymap it comes from, but I had a thought about a way to easily do this. Are you familiar with helm-descbinds? because it would be easy to use the same order that that tool prints in, which is the order produced by describe-buffer-bindings. I'd be happy to add that as an option.

from emacs-which-key.

PythonNut avatar PythonNut commented on May 27, 2024

@justbur I don't use helm-descbinds. I normally just do M-x describe-bindings + isearch. That said, the ordering sounds perfect. In fact, I can't really tell how your implementation would deviate from the proposal.

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

Actually @PythonNut I think this is really simple. You should get the same
order by setting which-key-sort-order to nil. If you want to make changes
from there I can look into it.
On Wed, Sep 16, 2015 at 7:26 PM PythonNut [email protected] wrote:

@justbur https://github.com/justbur I don't use helm-descbinds. I
normally just do M-x describe-bindings + isearch. That said, the ordering
sounds perfect. In fact, I can't really tell how your implementation would
deviate from the proposal.

β€”
Reply to this email directly or view it on GitHub
#44 (comment)
.

from emacs-which-key.

PythonNut avatar PythonNut commented on May 27, 2024

@justbur I just tried that and it looks great.

from emacs-which-key.

kaushalmodi avatar kaushalmodi commented on May 27, 2024

I like the recently added highlighting feature. This gets me similar to what guide-key did; separation of rectangle and register/bookmark commands visually.

clipboard01

Will need to click on the above image to see it properly.

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

@kaushalmodi Great! I didn't add that feature initially, because I thought it might be too noisy, but I like your use of it

from emacs-which-key.

hmelman avatar hmelman commented on May 27, 2024

Something (I think) I'd like is the ability to move all the prefix bindings to the beginning or end of the list.

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

@hmelman It shouldn't be too hard to do this, but I'd like to know if/how you would like to sort within the prefix bindings and whether you'd like them to come first or last.

from emacs-which-key.

hmelman avatar hmelman commented on May 27, 2024

It's something I'd have to play with but my sense is that it should be another setting. So I could sort by key or description as now, but also have a setting to move prefixes to start or end of list. End is probably more useful to me (particularly in the C-x 8 case).

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

@hmelman If you know any elisp, all you need to do is write a comparison function that takes two cons cells (car is the string describing the key and cdr is a string for the command description) and reports if the first should come before the second. Here's one interpretation of your request

(defun prefix-last-then-by-keys (acons bcons)
  (let ((apref? (which-key--group-p (cdr acons)))
        (bpref? (which-key--group-p (cdr bcons))))
    (if (not (eq apref? bpref?))
        (and (not apref?) bpref?)
      (which-key-key-order acons bcons))))
(setq which-key-sort-order 'prefix-last-then-by-keys)

which-key--group-p is the function I use to identify prefixes in the code.

from emacs-which-key.

hmelman avatar hmelman commented on May 27, 2024

Yes, I think I like this as a sort order. Thanks.

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

@hmelman If you use it for a while and continue to like it, let me know and I can add it as a built-in option.

from emacs-which-key.

hmelman avatar hmelman commented on May 27, 2024

Yes, I definitely like this (prefix-last-then-by-keys).

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

@hmelman e9aa7c3 To use it, do

(setq which-key-sort-order 'which-key-prefix-then-key-order)

from emacs-which-key.

mfiano avatar mfiano commented on May 27, 2024

I'm new to emacs, and this is a helpful utility. however, i'd really like the ability to sort capital keys next to lowercase keys. I have similar commands bound to the same key, such as a -> goto-address-mode, A -> goto-address-prog-mode. however all capital keys are listed before any lowercase keys.

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

@Axionix It's not documented yet, but I recently added

(setq which-key-sort-order 'which-key-key-order-alpha)

from emacs-which-key.

mfiano avatar mfiano commented on May 27, 2024

@justbur thanks!

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

I think we have a good range of options, so I'll close this. I'm happy to consider others if someone wants to reopen.

from emacs-which-key.

ChauhanT avatar ChauhanT commented on May 27, 2024

Hi, does which-key have an option to sort in the order of definition? I have gone through the github page and couldn't find anything!

from emacs-which-key.

hmelman avatar hmelman commented on May 27, 2024

Hi, does which-key have an option to sort in the order of definition? I have gone through the github page and couldn't find anything!

@ChauhanT I usually use customize-group for a package (in this case which-key) to see all its options. Searching for "sort" in that customize buffer takes you right to which-key-sort-order. Searching the source for all the defcustoms is the equivalent.

from emacs-which-key.

ChauhanT avatar ChauhanT commented on May 27, 2024

Thanks @hmelman, I am indeed new and didn't how I could use customize-group this way! I see now there is no way to sort according to the order of definition.

from emacs-which-key.

hmelman avatar hmelman commented on May 27, 2024

I see now there is no way to sort according to the order of definition.

You can set which-key-sort-order to which-key-description-order which I think will do what you want.

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.