How to make all variables and functions of a mode visible without activating the mode

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












Let's say I want to customize a keybind for a mode that hasn't been loaded yet like so:



(define-key eshell-mode-map (kbd "C-M-i") 'eshell-previous-input)



But the problem is if I haven't yet loaded eshell I get this error:
Debugger entered--Lisp error: (void-variable eshell-mode-map)



How would I make the keymap visible without opting for the mode-hook eshell-mode-hook?

Are there multiple ways of achieving this?

If so, what is the standard way of doing so (loading files to make variables/functions/keymaps visible)?



Also, what would the implications be if I decided to load the file manually as opposed to using a mode-hook?










share|improve this question

























    up vote
    1
    down vote

    favorite












    Let's say I want to customize a keybind for a mode that hasn't been loaded yet like so:



    (define-key eshell-mode-map (kbd "C-M-i") 'eshell-previous-input)



    But the problem is if I haven't yet loaded eshell I get this error:
    Debugger entered--Lisp error: (void-variable eshell-mode-map)



    How would I make the keymap visible without opting for the mode-hook eshell-mode-hook?

    Are there multiple ways of achieving this?

    If so, what is the standard way of doing so (loading files to make variables/functions/keymaps visible)?



    Also, what would the implications be if I decided to load the file manually as opposed to using a mode-hook?










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      Let's say I want to customize a keybind for a mode that hasn't been loaded yet like so:



      (define-key eshell-mode-map (kbd "C-M-i") 'eshell-previous-input)



      But the problem is if I haven't yet loaded eshell I get this error:
      Debugger entered--Lisp error: (void-variable eshell-mode-map)



      How would I make the keymap visible without opting for the mode-hook eshell-mode-hook?

      Are there multiple ways of achieving this?

      If so, what is the standard way of doing so (loading files to make variables/functions/keymaps visible)?



      Also, what would the implications be if I decided to load the file manually as opposed to using a mode-hook?










      share|improve this question













      Let's say I want to customize a keybind for a mode that hasn't been loaded yet like so:



      (define-key eshell-mode-map (kbd "C-M-i") 'eshell-previous-input)



      But the problem is if I haven't yet loaded eshell I get this error:
      Debugger entered--Lisp error: (void-variable eshell-mode-map)



      How would I make the keymap visible without opting for the mode-hook eshell-mode-hook?

      Are there multiple ways of achieving this?

      If so, what is the standard way of doing so (loading files to make variables/functions/keymaps visible)?



      Also, what would the implications be if I decided to load the file manually as opposed to using a mode-hook?







      major-mode load






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 4 hours ago









      John DeBord

      1087




      1087




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          You don't :) At least, not for this use-case.



          Instead you defer your configuration until such time as the library in question has been loaded:



          (with-eval-after-load "esh-mode"
          (define-key eshell-mode-map (kbd "C-M-i") 'eshell-previous-input))


          Note that C-hv eshell-mode-map provided me with the "esh-mode" library name.




          If you did want to "make all variables and functions of a mode visible without activating the mode" then you would require the library. e.g.:



          (require 'eshell)




          Also, what would the implications be if I decided to load the file manually as opposed to using a mode-hook?




          If you load the file, then you incur the cost of doing so. If that's happening at init time, then you've slowed down your start-up time slightly. If it's possible that you won't even use eshell in a given session, then this probably isn't what you want to do. (Or if you invariably run emacs as a server which starts when your system boots, then maybe you do want to pre-load things to make it that much more responsive later on, should you happen use that feature -- your call.)



          If you use a mode hook then you are once again deferring the evaluation -- but rather than evaluating the code once, you are (re)evaluating it every time any buffer enters that mode. In this particular use-case we only need it to happen once, so with-eval-after-load is more appropriate.






          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: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f44814%2fhow-to-make-all-variables-and-functions-of-a-mode-visible-without-activating-the%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote



            accepted










            You don't :) At least, not for this use-case.



            Instead you defer your configuration until such time as the library in question has been loaded:



            (with-eval-after-load "esh-mode"
            (define-key eshell-mode-map (kbd "C-M-i") 'eshell-previous-input))


            Note that C-hv eshell-mode-map provided me with the "esh-mode" library name.




            If you did want to "make all variables and functions of a mode visible without activating the mode" then you would require the library. e.g.:



            (require 'eshell)




            Also, what would the implications be if I decided to load the file manually as opposed to using a mode-hook?




            If you load the file, then you incur the cost of doing so. If that's happening at init time, then you've slowed down your start-up time slightly. If it's possible that you won't even use eshell in a given session, then this probably isn't what you want to do. (Or if you invariably run emacs as a server which starts when your system boots, then maybe you do want to pre-load things to make it that much more responsive later on, should you happen use that feature -- your call.)



            If you use a mode hook then you are once again deferring the evaluation -- but rather than evaluating the code once, you are (re)evaluating it every time any buffer enters that mode. In this particular use-case we only need it to happen once, so with-eval-after-load is more appropriate.






            share|improve this answer


























              up vote
              3
              down vote



              accepted










              You don't :) At least, not for this use-case.



              Instead you defer your configuration until such time as the library in question has been loaded:



              (with-eval-after-load "esh-mode"
              (define-key eshell-mode-map (kbd "C-M-i") 'eshell-previous-input))


              Note that C-hv eshell-mode-map provided me with the "esh-mode" library name.




              If you did want to "make all variables and functions of a mode visible without activating the mode" then you would require the library. e.g.:



              (require 'eshell)




              Also, what would the implications be if I decided to load the file manually as opposed to using a mode-hook?




              If you load the file, then you incur the cost of doing so. If that's happening at init time, then you've slowed down your start-up time slightly. If it's possible that you won't even use eshell in a given session, then this probably isn't what you want to do. (Or if you invariably run emacs as a server which starts when your system boots, then maybe you do want to pre-load things to make it that much more responsive later on, should you happen use that feature -- your call.)



              If you use a mode hook then you are once again deferring the evaluation -- but rather than evaluating the code once, you are (re)evaluating it every time any buffer enters that mode. In this particular use-case we only need it to happen once, so with-eval-after-load is more appropriate.






              share|improve this answer
























                up vote
                3
                down vote



                accepted







                up vote
                3
                down vote



                accepted






                You don't :) At least, not for this use-case.



                Instead you defer your configuration until such time as the library in question has been loaded:



                (with-eval-after-load "esh-mode"
                (define-key eshell-mode-map (kbd "C-M-i") 'eshell-previous-input))


                Note that C-hv eshell-mode-map provided me with the "esh-mode" library name.




                If you did want to "make all variables and functions of a mode visible without activating the mode" then you would require the library. e.g.:



                (require 'eshell)




                Also, what would the implications be if I decided to load the file manually as opposed to using a mode-hook?




                If you load the file, then you incur the cost of doing so. If that's happening at init time, then you've slowed down your start-up time slightly. If it's possible that you won't even use eshell in a given session, then this probably isn't what you want to do. (Or if you invariably run emacs as a server which starts when your system boots, then maybe you do want to pre-load things to make it that much more responsive later on, should you happen use that feature -- your call.)



                If you use a mode hook then you are once again deferring the evaluation -- but rather than evaluating the code once, you are (re)evaluating it every time any buffer enters that mode. In this particular use-case we only need it to happen once, so with-eval-after-load is more appropriate.






                share|improve this answer














                You don't :) At least, not for this use-case.



                Instead you defer your configuration until such time as the library in question has been loaded:



                (with-eval-after-load "esh-mode"
                (define-key eshell-mode-map (kbd "C-M-i") 'eshell-previous-input))


                Note that C-hv eshell-mode-map provided me with the "esh-mode" library name.




                If you did want to "make all variables and functions of a mode visible without activating the mode" then you would require the library. e.g.:



                (require 'eshell)




                Also, what would the implications be if I decided to load the file manually as opposed to using a mode-hook?




                If you load the file, then you incur the cost of doing so. If that's happening at init time, then you've slowed down your start-up time slightly. If it's possible that you won't even use eshell in a given session, then this probably isn't what you want to do. (Or if you invariably run emacs as a server which starts when your system boots, then maybe you do want to pre-load things to make it that much more responsive later on, should you happen use that feature -- your call.)



                If you use a mode hook then you are once again deferring the evaluation -- but rather than evaluating the code once, you are (re)evaluating it every time any buffer enters that mode. In this particular use-case we only need it to happen once, so with-eval-after-load is more appropriate.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 3 hours ago

























                answered 3 hours ago









                phils

                23.7k23160




                23.7k23160



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f44814%2fhow-to-make-all-variables-and-functions-of-a-mode-visible-without-activating-the%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    One-line joke