all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#70610: 30.0.50; [PATCH] * lisp/eshell/esh-mode.el (eshell-first-time-mode-hook): Run the hook for once
@ 2024-04-27 16:32 Lin Sun
  2024-05-02  9:09 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Lin Sun @ 2024-04-27 16:32 UTC (permalink / raw)
  To: 70610

[-- Attachment #1: Type: text/plain, Size: 614 bytes --]

Hi,

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

[-- Attachment #2: 0001-lisp-eshell-esh-mode.el-eshell-first-time-mode-hook-.patch --]
[-- Type: text/x-patch, Size: 882 bytes --]

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#70610: 30.0.50; [PATCH] * lisp/eshell/esh-mode.el (eshell-first-time-mode-hook): Run the hook for once
  2024-04-27 16:32 bug#70610: 30.0.50; [PATCH] * lisp/eshell/esh-mode.el (eshell-first-time-mode-hook): Run the hook for once Lin Sun
@ 2024-05-02  9:09 ` Eli Zaretskii
  2024-05-03  3:15   ` Jim Porter
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2024-05-02  9:09 UTC (permalink / raw)
  To: Lin Sun, Jim Porter; +Cc: 70610

> 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?





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#70610: 30.0.50; [PATCH] * lisp/eshell/esh-mode.el (eshell-first-time-mode-hook): Run the hook for once
  2024-05-02  9:09 ` Eli Zaretskii
@ 2024-05-03  3:15   ` Jim Porter
  2024-05-03  3:55     ` Lin Sun
  0 siblings, 1 reply; 4+ messages in thread
From: Jim Porter @ 2024-05-03  3:15 UTC (permalink / raw)
  To: Eli Zaretskii, Lin Sun; +Cc: 70610-done

On 5/2/2024 2:09 AM, Eli Zaretskii wrote:
>> 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).
[snip]
> Jim, any comments on this change proposal?

Thanks for the patch, Lin Sun. This looks good, so I've merged it to the 
master branch as a2ccda71c15. Closing this bug now.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#70610: 30.0.50; [PATCH] * lisp/eshell/esh-mode.el (eshell-first-time-mode-hook): Run the hook for once
  2024-05-03  3:15   ` Jim Porter
@ 2024-05-03  3:55     ` Lin Sun
  0 siblings, 0 replies; 4+ messages in thread
From: Lin Sun @ 2024-05-03  3:55 UTC (permalink / raw)
  To: Jim Porter; +Cc: Eli Zaretskii, 70610-done

On Fri, May 3, 2024 at 3:15 AM Jim Porter <jporterbugs@gmail.com> wrote:
>
> On 5/2/2024 2:09 AM, Eli Zaretskii wrote:
> >> 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).
> [snip]
> > Jim, any comments on this change proposal?
>
> Thanks for the patch, Lin Sun. This looks good, so I've merged it to the
> master branch as a2ccda71c15. Closing this bug now.
Great! Thank you so much!





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-03  3:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-27 16:32 bug#70610: 30.0.50; [PATCH] * lisp/eshell/esh-mode.el (eshell-first-time-mode-hook): Run the hook for once Lin Sun
2024-05-02  9:09 ` Eli Zaretskii
2024-05-03  3:15   ` Jim Porter
2024-05-03  3:55     ` Lin Sun

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.