[Top][All Lists]

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

with-eval-after-load with sh-mode

From: lisa-asket
Subject: with-eval-after-load with sh-mode
Date: Fri, 2 Jul 2021 12:35:16 +0200 (CEST)

>From: Arthur Miller <>
>Subject: Re: with-eval-after-load with sh-mode
>Date: 02/07/2021 10:56:14 Europe/Paris

> writes:

>>From: Arthur Miller <>
>>Subject: Re: with-eval-after-load with sh-mode
>>Date: 02/07/2021 10:42:38 Europe/Paris
>> writes:
>>> How can I use `with-eval-after-load` with sh-mode?
>>> Basically I want to defer call to sh-mode-map until sh-mode is loaded
>>> (with-eval-after-load 'sh
>>Try this:
>>(with-eval-after-load 'sh-script
>>(message "My cool one-time config follows here ..."))
>>sh-mode is defined in lisp/progmodes/sh-script.el.
> What is the difference between 
> (with-eval-after-load 'sh-script
> (myfun))
> and
> (add-hook 'sh-mode-hook #'myfun)

>Obviously sh-mode-hook gets executed every time you load sh-mode, i.e,
>when you open a shell file.

>eval after load will kick in when feature is loaded, i.e. when you read
>in (load or require) sh-script.el, so it least in theory it should get
>executed only once, unless you unload feature 'sh-script for some reason.

This leads to another consideraion.  There are certainly advantages about using

`with-eval-after-load`.  But, then, what are the circumstances for using 

reply via email to

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