Giter VIP home page Giter VIP logo

Comments (7)

syl20bnr avatar syl20bnr commented on May 27, 2024

This is really exciting πŸ‘
I would suggest to use alist based on the key sequence as much as possible in order to be decoupled from emacs internal, that is:

  • alist for command names like ("SPC f f" . "find files")
  • alist for prefix commands like ("SPC f" . "files")
  • alist for major mode working for both command names and prefixes like
    • ("SPC m d" . ((emacs-lisp-mode "debug") ... ))
    • ("SPC m d m" . ((emacs-lisp-mode "expand macro") ... ))

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

Thanks!

I'm not sure I understand your suggestion about using alists. Which step are you referring to?

I switched to using the mini buffer last night and the more I think about it the more sense it makes to me because it matches how I would expect this to behave. I want to include the option to use other methods but I like it so much I want to make it default until I find something better. It also saves one line of screen space :-).

I also had the idea of breaking the list of bindings into "pages" and then flip through them after short delays while waiting for the next key press. That way it's easier to deal with tall buffers.

from emacs-which-key.

syl20bnr avatar syl20bnr commented on May 27, 2024

My remark was about making all the information alist driven in some
way instead of inferring some of them from emacs. This way we get full
control about what we display in the minibuffer. But inferring from emacs
and have which-key working automatically like guide-key is what people not
using Spacemacs will want...
So making it magically working like guide-key plus the possibility to
override anything via alists may be the way to go, maybe this is what you
started to do in which case it will fit exactly what I need at Spacemacs
level (getting full control of what will be displayed in the buffer).

I like the idea to use the minibuffer, you are right that it makes sense to
use it. The only limitation I see is that you won't have the choice to
display it vertically but as far as I'm concerned it is not an issue.

For the automatic switch it is tricky because it will surprise some users
but on the other end there is not a lot of possibilities to handle this.
Some random thought about this:

  • we could mitigate the issue by sorting the bindings by usage frequency or
    by "most recently used" but it is not a solution
  • if there is not enough room then we could take the whole screen
  • use the scroll wheel ? May require some black magic
  • in the same spirit if we can make it work with scroll-wheel then there is
    no reason we could not make it work with keys like arrow keys, it has the
    disadvantage of making SPC arrow-key impossible but in the case of
    Spacemacs this combination does not exist. So if it is configurable the
    user can find some holes ?
  • we think out of the box and come with a brand new way of dealing with
    progressive discovering of keys, I think about some kind of selection or
    behavior a la magit-popup or crazier. This solution must resolve the
    following issue: be able to use some keys for which-key without perturbing
    the key sequence that the user want to input. It makes me think that with a
    smartly choosen set of keys that overlap each other for next/previous keys
    we could always have one available that would not prevent the user to reach
    her targeted sequence. For instance we can have a set of possible
    candidates for next-page and we look which one can be used safely given the
    current set of proposed keys then we display a short docstring in the
    minibuffer with the key we selected as safe to change page.

Le samedi 4 juillet 2015, Justin Burkett [email protected] a
Γ©crit :

Thanks!

I'm not sure I understand your suggestion about using alists. Which step
are you referring to?

I switched to using the mini buffer last night and the more I think about
it the more sense it makes to me because it matches how I would expect this
to behave. I want to include the option to use other methods but I like it
so much I want to make it default until I find something better. It also
saves one line of screen space :-).

I also had the idea of breaking the list of bindings into "pages" and then
flip through them after short delays while waiting for the next key press.
That way it's easier to deal with tall buffers.

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

-syl20bnr-

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

I understand what you mean about the alists now. My goal now is to give the necessary options to condense the information as each user or startup package ;-) sees fit. I even had some crazy ideas like being able to condense the window selection functions in spacemacs into "[N] -> Select Window [N]" (or something like that) using an alist with regexp enabled.

I agree that the paging stuff might be awkward if not done correctly. I built in some basic paging logic, but am just displaying the first page at the moment if that's all that fits. I was thinking about playing with automatically scaling text if the bindings don't fit, but still the best approach I think is to get the information condensed and useful. I'll keep thinking about it.

I'm not crazy about the usage frequency thing for two reasons. One is it would (I think) add a lot of complexity to the code, because I'd have to build in a way to collect and analyze choices (haven't looked into packages for this). The second is I'm not sure you are looking for your most used key binding when you look at which-key/guide-key. You might be looking for something you don't use or have never used. I don't know if there is a good way to predict what people are looking for (at least in a simple package).

The vertical buffer option will be there. I just think minibuffer is the best default at the moment. Of course, I'm also going to make it extensible. You'll be able to write your own show-buffer function to put it anywhere :-)

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

@syl20bnr We now have the (horribly named) alist which-key-key-based-description-replacement-alist which can include elements of the form ("SPC f f" . "find files") or (emacs-lisp-mode . (("SPC m d" . "debug") ("SPC m l" . "..."))). The first applies everywhere. The cdr of the second is an alist that applies when in emacs-lisp-mode. Let me know if this is adequate for spacemacs. I can put a helper function in there to easily add a lot of bindings.

These simply overwrite the description for those keybindings.

EDIT: Rewrote implementation after first comment

from emacs-which-key.

syl20bnr avatar syl20bnr commented on May 27, 2024

This seems perfect πŸ‘

from emacs-which-key.

justbur avatar justbur commented on May 27, 2024

Great :-)

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.