help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: with-eval-after-load with sh-mode


From: Arthur Miller
Subject: Re: with-eval-after-load with sh-mode
Date: Fri, 02 Jul 2021 15:14:15 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

lisa-asket@perso.be writes:

>>From: Emanuel Berg via Users list for the GNU Emacs text editor 
>><help-gnu-emacs@gnu.org>
>>To: help-gnu-emacs@gnu.org
>>Subject: Re: with-eval-after-load with sh-mode
>>Date: 02/07/2021 08:58:36 Europe/Paris
>
>>lisa-asket wrote:
>
>>> Basically I want to defer call to sh-mode-map until sh-mode
>>> is loaded
>
>>First try
>
>>(require 'sh-script)

You don't need to require sh-script.el. sh-mode is autolaoded function
so Emacs will load sh-script when sh-mode is invoked automatically.

>>Then set the keys in `sh-mode-map' (which is a variable BTW) ...
>
>>If that doesn't work keep the first line but turn the second
>>line to into a function (just enclose it in a `defun'), then
>>do
>
>>(defun sh-mode-hook-f ()
>>;; call your key setting function here
>>)
>>(add-hook 'sh-mode-hook #'sh-mode-hook-f)
>
>
>
> So I don't use `with-eval-after-load`?  Just do `add-hook`?

It depends if you want your code to run only once, when sh-script.el is
loaded or do you want it to run each every time the mode is loaded,
which will happen every time you open or create a shell file.

If you wish to modify key shortcuts, with-eval-after-load is probably
better place.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]