Giter Site home page Giter Site logo

Comments (3)

antrmn avatar antrmn commented on June 14, 2024

Currently, I'm achieving this feature by means of the following code:

(use-package which-key
  :custom
  (which-key-mode t)
  (which-key-show-early-on-C-h 'prompt))


(defun my/which-key--before-C-h-dispatch ()
  (when (and (not (which-key--popup-showing-p))
             (eq which-key-show-early-on-C-h 'prompt))
    (which-key--create-buffer-and-show (kbd (which-key--current-key-string)))
    (setq unread-command-events (listify-key-sequence
                                 (kbd (which-key--current-key-string))))))
(advice-add 'which-key-C-h-dispatch :before #'my/which-key--before-C-h-dispatch)

Basically, if which-key-show-early-on-C-h is set with the 'prompt symbol, then a which-key window gets shown instantly after the invocation of which-key-C-h-dispatch and the same key sequence is fed again by means of the unread-command-events variable.

I'm showing this code just to give an idea of the feature. It seems to work but since the package does contain some timer based mechanisms i don't know if there are some gimmicks that I'm ignoring right now by displaying the which key windows instantly.

from emacs-which-key.

justbur avatar justbur commented on June 14, 2024

You're right that the behavior of C-h depends on whether the which-key buffer is showing when it's pressed, but I'm not sure of the purpose of your advice function. It appears to do the same thing as the first condition in which-key-C-h-dispatch as long as 'prompt is used.

The original purpose of using C-h to show the which-key buffer was to have a way to turn off the automatic display time and allow for it to be shown "on demand". If this is how it's used, the timing issue you mention is not a problem. In other words, this is not the intended setup for this option (see the docstring of which-key-show-early-on-C-h).

That being said, I may be able to help if you can describe more precisely what you are trying to achieve with this option.

from emacs-which-key.

antrmn avatar antrmn commented on June 14, 2024

Thank you for your help. I'll try to describe my issue with some gifs, I hope to be clear.

I do use which-key with the default behaviour: its window automatically pops out 1 second after a prefix key.

I often would like to invoke describe-prefix-bindings command in order to get a more detailed view of the available commands under a specific keymap. This command is under which-key-C-h-map by default.

Here is what happens when I try to type C-x C-h a few times:

2023-07-13 16-00-46

I don't know why the which key window appears earlier than expected, but this leads the C-x C-h behaviour to be rather inconsistent: sometimes it shows the which-key window, sometimes it prompts for a command.

This is the bahaviour of C-x C-h with the patch:

2023-07-13 16-24-07

This way, describe-prefix-bindings can always be called with <prefixes> C-h C-h, regardless of whether the which-key window was already shown or not. This applies to any other command that I could add to the which-key-C-h-map.

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.