justbur / emacs-which-key

Emacs package that displays available keybindings in popup
GNU General Public License v3.0
1.74k stars 87 forks source link

Fix which-key-description-order #300

Closed zhaojiangbin closed 3 years ago

zhaojiangbin commented 3 years ago

which-key-description-order was not sorting the bindings by their descriptions (i.e. replacements).

Pull requests are welcome as long as the following apply.

  1. The issue you are fixing or feature you are adding is clearly described and/or referenced in the pull request or github issue.
  2. Since which-key is on GNU ELPA, any legally significant changes must have their copyright assigned to the FSF (more info). If you have not done so and would like to assign copyright, please see the request form. This process is easy, but can be slow.
justbur commented 3 years ago

I don't see a fix here

zhaojiangbin commented 3 years ago

Given the following keymap,

(setq a-map (make-sparse-keymap))
(bind-keys :map a-map
           ("a" . ("one" . some-command))
           ("b" . ("two" . another-command)))

without the changes, in particular that in which-key--get-bindings, the binding "b -> two" would be displayed first, followed by "a -> one". The sorting was on the command names ("some-command" vs. "another-command") but it were the replacements shown.

With the changes, the bindings are displayed in the expected order: "a -> one" followed by "b -> two". The sorting is now on the replacements ("one" vs. "two").