How do I add custom hierarchical keybindings?











up vote
5
down vote

favorite












I am looking for a compact way to store a lot of shortcut keybindings. This is my current idea, for which I'm looking for help how to add this into my emacs config:



I would like to make F9 "my" key, that opens up a hierarchical menu of (global) keybindings.



When pressing F9, I'd like a submenu to open that shows e.g.:



o - org-mode submenu
a - show org-mode agenda
w - org-wiki submenu
b - org-brain submenu


If I press F9-a, I'd like to directly execute the M-x org-agenda command.



But by pressing F9-w, I get a new submenu opened that e.g. shows this:



# Org-wiki submenu
i - Show Wiki index
n - Add new Wiki page


If my final keystroke sequence is F9-w-i, I want the command M-x org-wiki-index executed.




  • Does something like this exist already?

  • Is there a better solution?

  • If no, how would I add something like this in my emacs config?


/Edit: I think what I want is to write my custom version of the M-x org-agenda command.










share|improve this question




















  • 3




    Have you looked at hydra? github.com/abo-abo/hydra and available from melpa?
    – icarus
    Nov 4 at 17:35










  • Thanks, that's what I need! I wasn't aware of this package.
    – Alexander Engelhardt
    Nov 4 at 17:44















up vote
5
down vote

favorite












I am looking for a compact way to store a lot of shortcut keybindings. This is my current idea, for which I'm looking for help how to add this into my emacs config:



I would like to make F9 "my" key, that opens up a hierarchical menu of (global) keybindings.



When pressing F9, I'd like a submenu to open that shows e.g.:



o - org-mode submenu
a - show org-mode agenda
w - org-wiki submenu
b - org-brain submenu


If I press F9-a, I'd like to directly execute the M-x org-agenda command.



But by pressing F9-w, I get a new submenu opened that e.g. shows this:



# Org-wiki submenu
i - Show Wiki index
n - Add new Wiki page


If my final keystroke sequence is F9-w-i, I want the command M-x org-wiki-index executed.




  • Does something like this exist already?

  • Is there a better solution?

  • If no, how would I add something like this in my emacs config?


/Edit: I think what I want is to write my custom version of the M-x org-agenda command.










share|improve this question




















  • 3




    Have you looked at hydra? github.com/abo-abo/hydra and available from melpa?
    – icarus
    Nov 4 at 17:35










  • Thanks, that's what I need! I wasn't aware of this package.
    – Alexander Engelhardt
    Nov 4 at 17:44













up vote
5
down vote

favorite









up vote
5
down vote

favorite











I am looking for a compact way to store a lot of shortcut keybindings. This is my current idea, for which I'm looking for help how to add this into my emacs config:



I would like to make F9 "my" key, that opens up a hierarchical menu of (global) keybindings.



When pressing F9, I'd like a submenu to open that shows e.g.:



o - org-mode submenu
a - show org-mode agenda
w - org-wiki submenu
b - org-brain submenu


If I press F9-a, I'd like to directly execute the M-x org-agenda command.



But by pressing F9-w, I get a new submenu opened that e.g. shows this:



# Org-wiki submenu
i - Show Wiki index
n - Add new Wiki page


If my final keystroke sequence is F9-w-i, I want the command M-x org-wiki-index executed.




  • Does something like this exist already?

  • Is there a better solution?

  • If no, how would I add something like this in my emacs config?


/Edit: I think what I want is to write my custom version of the M-x org-agenda command.










share|improve this question















I am looking for a compact way to store a lot of shortcut keybindings. This is my current idea, for which I'm looking for help how to add this into my emacs config:



I would like to make F9 "my" key, that opens up a hierarchical menu of (global) keybindings.



When pressing F9, I'd like a submenu to open that shows e.g.:



o - org-mode submenu
a - show org-mode agenda
w - org-wiki submenu
b - org-brain submenu


If I press F9-a, I'd like to directly execute the M-x org-agenda command.



But by pressing F9-w, I get a new submenu opened that e.g. shows this:



# Org-wiki submenu
i - Show Wiki index
n - Add new Wiki page


If my final keystroke sequence is F9-w-i, I want the command M-x org-wiki-index executed.




  • Does something like this exist already?

  • Is there a better solution?

  • If no, how would I add something like this in my emacs config?


/Edit: I think what I want is to write my custom version of the M-x org-agenda command.







key-bindings






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 4 at 17:33

























asked Nov 4 at 17:21









Alexander Engelhardt

1636




1636








  • 3




    Have you looked at hydra? github.com/abo-abo/hydra and available from melpa?
    – icarus
    Nov 4 at 17:35










  • Thanks, that's what I need! I wasn't aware of this package.
    – Alexander Engelhardt
    Nov 4 at 17:44














  • 3




    Have you looked at hydra? github.com/abo-abo/hydra and available from melpa?
    – icarus
    Nov 4 at 17:35










  • Thanks, that's what I need! I wasn't aware of this package.
    – Alexander Engelhardt
    Nov 4 at 17:44








3




3




Have you looked at hydra? github.com/abo-abo/hydra and available from melpa?
– icarus
Nov 4 at 17:35




Have you looked at hydra? github.com/abo-abo/hydra and available from melpa?
– icarus
Nov 4 at 17:35












Thanks, that's what I need! I wasn't aware of this package.
– Alexander Engelhardt
Nov 4 at 17:44




Thanks, that's what I need! I wasn't aware of this package.
– Alexander Engelhardt
Nov 4 at 17:44










2 Answers
2






active

oldest

votes

















up vote
7
down vote



accepted










As @icarus suggested, hydra is the way to go here. Check out my solution that is similar to what you want here: https://github.com/jkitchin/scimax/blob/master/scimax-hydra.el



there are submenus of keys that open new hydras. I have mine bound to f12, and then remapped caps lock to be f12. It is convenient for me.






share|improve this answer





















  • Thanks! I'm actually using it for org-ref now, so double-thanks :) Then org-wiki and/or org-brain.
    – Alexander Engelhardt
    Nov 4 at 17:47




















up vote
2
down vote













If you install and enable which-key then Emacs will do that (albeit with more compact formatting) for every prefix binding, including your custom ones.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "583"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f45743%2fhow-do-i-add-custom-hierarchical-keybindings%23new-answer', 'question_page');
    }
    );

    Post as a guest
































    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    7
    down vote



    accepted










    As @icarus suggested, hydra is the way to go here. Check out my solution that is similar to what you want here: https://github.com/jkitchin/scimax/blob/master/scimax-hydra.el



    there are submenus of keys that open new hydras. I have mine bound to f12, and then remapped caps lock to be f12. It is convenient for me.






    share|improve this answer





















    • Thanks! I'm actually using it for org-ref now, so double-thanks :) Then org-wiki and/or org-brain.
      – Alexander Engelhardt
      Nov 4 at 17:47

















    up vote
    7
    down vote



    accepted










    As @icarus suggested, hydra is the way to go here. Check out my solution that is similar to what you want here: https://github.com/jkitchin/scimax/blob/master/scimax-hydra.el



    there are submenus of keys that open new hydras. I have mine bound to f12, and then remapped caps lock to be f12. It is convenient for me.






    share|improve this answer





















    • Thanks! I'm actually using it for org-ref now, so double-thanks :) Then org-wiki and/or org-brain.
      – Alexander Engelhardt
      Nov 4 at 17:47















    up vote
    7
    down vote



    accepted







    up vote
    7
    down vote



    accepted






    As @icarus suggested, hydra is the way to go here. Check out my solution that is similar to what you want here: https://github.com/jkitchin/scimax/blob/master/scimax-hydra.el



    there are submenus of keys that open new hydras. I have mine bound to f12, and then remapped caps lock to be f12. It is convenient for me.






    share|improve this answer












    As @icarus suggested, hydra is the way to go here. Check out my solution that is similar to what you want here: https://github.com/jkitchin/scimax/blob/master/scimax-hydra.el



    there are submenus of keys that open new hydras. I have mine bound to f12, and then remapped caps lock to be f12. It is convenient for me.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 4 at 17:42









    John Kitchin

    5,4901520




    5,4901520












    • Thanks! I'm actually using it for org-ref now, so double-thanks :) Then org-wiki and/or org-brain.
      – Alexander Engelhardt
      Nov 4 at 17:47




















    • Thanks! I'm actually using it for org-ref now, so double-thanks :) Then org-wiki and/or org-brain.
      – Alexander Engelhardt
      Nov 4 at 17:47


















    Thanks! I'm actually using it for org-ref now, so double-thanks :) Then org-wiki and/or org-brain.
    – Alexander Engelhardt
    Nov 4 at 17:47






    Thanks! I'm actually using it for org-ref now, so double-thanks :) Then org-wiki and/or org-brain.
    – Alexander Engelhardt
    Nov 4 at 17:47












    up vote
    2
    down vote













    If you install and enable which-key then Emacs will do that (albeit with more compact formatting) for every prefix binding, including your custom ones.






    share|improve this answer

























      up vote
      2
      down vote













      If you install and enable which-key then Emacs will do that (albeit with more compact formatting) for every prefix binding, including your custom ones.






      share|improve this answer























        up vote
        2
        down vote










        up vote
        2
        down vote









        If you install and enable which-key then Emacs will do that (albeit with more compact formatting) for every prefix binding, including your custom ones.






        share|improve this answer












        If you install and enable which-key then Emacs will do that (albeit with more compact formatting) for every prefix binding, including your custom ones.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 4 at 20:39









        phils

        24.8k23463




        24.8k23463






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f45743%2fhow-do-i-add-custom-hierarchical-keybindings%23new-answer', 'question_page');
            }
            );

            Post as a guest




















































































            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()