GNU bug report logs - #70610
30.0.50; [PATCH] * lisp/eshell/esh-mode.el (eshell-first-time-mode-hook): Run the hook for once

Previous Next

Package: emacs;

Reported by: Lin Sun <sunlin7.mail <at> gmail.com>

Date: Sat, 27 Apr 2024 16:34:02 UTC

Severity: normal

Tags: patch

Found in version 30.0.50

Done: Jim Porter <jporterbugs <at> gmail.com>

To reply to this bug, email your comments to 70610 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#70610; Package emacs. (Sat, 27 Apr 2024 16:34:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lin Sun <sunlin7.mail <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 27 Apr 2024 16:34:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lin Sun <sunlin7.mail <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50;
 [PATCH] * lisp/eshell/esh-mode.el (eshell-first-time-mode-hook):
 Run the hook for once
Date: Sat, 27 Apr 2024 16:32:24 +0000
[Message part 1 (text/plain, inline)]
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
[0001-lisp-eshell-esh-mode.el-eshell-first-time-mode-hook-.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70610; Package emacs. (Thu, 02 May 2024 09:11:02 GMT) Full text and rfc822 format available.

Message #8 received at 70610 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lin Sun <sunlin7.mail <at> gmail.com>, Jim Porter <jporterbugs <at> gmail.com>
Cc: 70610 <at> debbugs.gnu.org
Subject: Re: 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 <at> 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 <at> 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 sent to Jim Porter <jporterbugs <at> gmail.com>:
You have taken responsibility. (Fri, 03 May 2024 03:17:02 GMT) Full text and rfc822 format available.

Notification sent to Lin Sun <sunlin7.mail <at> gmail.com>:
bug acknowledged by developer. (Fri, 03 May 2024 03:17:02 GMT) Full text and rfc822 format available.

Message #13 received at 70610-done <at> debbugs.gnu.org (full text, mbox):

From: Jim Porter <jporterbugs <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Lin Sun <sunlin7.mail <at> gmail.com>
Cc: 70610-done <at> debbugs.gnu.org
Subject: Re: bug#70610: 30.0.50; [PATCH] * lisp/eshell/esh-mode.el
 (eshell-first-time-mode-hook): Run the hook for once
Date: Thu, 2 May 2024 20:15:42 -0700
On 5/2/2024 2:09 AM, Eli Zaretskii wrote:
>> From: Lin Sun <sunlin7.mail <at> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70610; Package emacs. (Fri, 03 May 2024 03:57:02 GMT) Full text and rfc822 format available.

Message #16 received at 70610-done <at> debbugs.gnu.org (full text, mbox):

From: Lin Sun <sunlin7.mail <at> gmail.com>
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 70610-done <at> debbugs.gnu.org
Subject: Re: bug#70610: 30.0.50; [PATCH] * lisp/eshell/esh-mode.el
 (eshell-first-time-mode-hook): Run the hook for once
Date: Fri, 3 May 2024 03:55:50 +0000
On Fri, May 3, 2024 at 3:15 AM Jim Porter <jporterbugs <at> gmail.com> wrote:
>
> On 5/2/2024 2:09 AM, Eli Zaretskii wrote:
> >> From: Lin Sun <sunlin7.mail <at> 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!




This bug report was last modified 10 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.