How to make all variables and functions of a mode visible without activating the mode
Clash 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?
major-mode load
add a comment |Â
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?
major-mode load
add a comment |Â
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?
major-mode load
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
major-mode load
asked 4 hours ago
John DeBord
1087
1087
add a comment |Â
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
edited 3 hours ago
answered 3 hours ago
phils
23.7k23160
23.7k23160
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password