Giter Site home page Giter Site logo

Comments (13)

justbur avatar justbur commented on May 17, 2024

Sorry! Yes, I broke that way of doing it. I switched to a better way of storing the keys that doesn't rely on strings. This should work for you

(which-key-add-key-based-replacements
  "C-x 8" "unicode"
  "C-x a" "abbrev/expand"
...
)

from emacs-which-key.

justbur avatar justbur commented on May 17, 2024

I just realized that I didn't update the README. Doing that now..

from emacs-which-key.

kaushalmodi avatar kaushalmodi commented on May 17, 2024

Cool! I will try that. While you are doing that, you can also mark that var as deprecated.

from emacs-which-key.

justbur avatar justbur commented on May 17, 2024

Well... It's not deprecated because I'm still using it. Maybe I screwed up, but my intention was for people to use the helper functions, which are used the same way. At least the readme is correct now. Sorry for the confusion.

from emacs-which-key.

kaushalmodi avatar kaushalmodi commented on May 17, 2024

No problem. Your suggested method brings back the functionality. Thanks for the quick reply!

from emacs-which-key.

kaushalmodi avatar kaushalmodi commented on May 17, 2024

If you wish, you can make that a defvar instead of a defcustom and rename it to which-key--key-based-description-replacement-alist (Note the which-key-- prefix). That will give a clear indication that users are not supposed to tinker with it.

from emacs-which-key.

justbur avatar justbur commented on May 17, 2024

That's a good idea. I'll do that soon. Thanks

from emacs-which-key.

justbur avatar justbur commented on May 17, 2024

@kaushalmodi Do you think I should use a message or a warning for the old variable?

from emacs-which-key.

kaushalmodi avatar kaushalmodi commented on May 17, 2024

I believe a warning would be justified as it's a signification change in the structure of that alist.

I had a related suggestion; why not merge these two into a single function and set the major mode specific options ".dir-locals.el style":

Before

(which-key-add-key-based-replacements
  "C-x C-f" "find files")
(which-key-add-major-mode-key-based-replacements 'org-mode
  "C-c C-c" "Org C-c C-c"
  "C-c C-a" "Org Attach")

After

(which-key-add-key-based-replacements
  '((nil . (("C-x C-f" . "find files")))
    (org-mode . (("C-c C-c" . "Org C-c C-c")
                 ("C-c C-a" . "Org Attach")))))

This might need a quite some code reworking. So it can be understood if you choose not to take this approach.

from emacs-which-key.

justbur avatar justbur commented on May 17, 2024

I think what I'll do is switch to defvar as you suggested but not change the name. I can put some code in there to detect if the old style of key string is being used and warn then, but also do the conversion automatically.

Thanks, I'll think about your suggestion for the function change. I think I find the current way more readable at a glance.

from emacs-which-key.

justbur avatar justbur commented on May 17, 2024

I pushed the changes. I opted not to change the variable names, but just to add code that fixes the old format if necessary for backwards compatibility. It will print a message now if it detects the old format.

Thanks for the report. Your old code should work now too, actually, but the new way will be preferred going forward.

from emacs-which-key.

justbur avatar justbur commented on May 17, 2024

@kaushalmodi Are you happy with the solution?

from emacs-which-key.

kaushalmodi avatar kaushalmodi commented on May 17, 2024

Yes, thanks!

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.