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

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

bug#70610: 30.0.50; [PATCH] * lisp/eshell/esh-mode.el (eshell-first-time


From: Eli Zaretskii
Subject: bug#70610: 30.0.50; [PATCH] * lisp/eshell/esh-mode.el (eshell-first-time-mode-hook): Run the hook for once
Date: Thu, 02 May 2024 12:09:58 +0300

> From: Lin Sun <sunlin7.mail@gmail.com>
> Date: Sat, 27 Apr 2024 16:32:24 +0000
> 
> The document of `eshell-first-time-mode-hook' says it would be run the
> first time eshell started.
> > A hook that gets run the first time ‘eshell-mode’ is entered.
> > That is to say, the first time during an Emacs session.
> 
> But it actually runs every time for an eshell buffer(start an eshell,
> exit it, start an eshell again).
> Here is the one line code to show that:
> (add-hook 'eshell-first-time-mode-hook '(lambda () (message "test")))
> 
> The patch will make the `eshell-first-time-mode-hook' only run once as
> its document described.
> 
> Please help review the patch. Thanks
> 
> Best Regards
> Lin
> 
> From 094be841bf2261fb5efc0cacd0a40d34695906d7 Mon Sep 17 00:00:00 2001
> From: Lin Sun <sunlin7@hotmail.com>
> Date: Sat, 27 Apr 2024 06:55:49 +0000
> Subject: [PATCH] * lisp/eshell/esh-mode.el (eshell-first-time-mode-hook): Run
>  the hook for once
> 
> ---
>  lisp/eshell/esh-mode.el | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
> index b15f99a035..5de200ce4b 100644
> --- a/lisp/eshell/esh-mode.el
> +++ b/lisp/eshell/esh-mode.el
> @@ -418,8 +418,10 @@ eshell-mode
>  
>    (add-hook 'kill-buffer-hook #'eshell-kill-buffer-function t t)
>  
> -  (if eshell-first-time-p
> -      (run-hooks 'eshell-first-time-mode-hook))
> +  (when eshell-first-time-p
> +    (setq eshell-first-time-p nil)
> +    (run-hooks 'eshell-first-time-mode-hook))
> +
>    (run-hooks 'eshell-post-command-hook))
>  
>  (put 'eshell-mode 'mode-class 'special)
> -- 
> 2.20.5

Jim, any comments on this change proposal?





reply via email to

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