unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lin Sun <sunlin7.mail@gmail.com>
To: 70610@debbugs.gnu.org
Subject: bug#70610: 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	[thread overview]
Message-ID: <CABCREdpBtsk7PuYfvpYfsyO6ChKFrUmRbxwbXMq_fAZaCSSuvg@mail.gmail.com> (raw)

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


             reply	other threads:[~2024-04-27 16:32 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABCREdpBtsk7PuYfvpYfsyO6ChKFrUmRbxwbXMq_fAZaCSSuvg@mail.gmail.com \
    --to=sunlin7.mail@gmail.com \
    --cc=70610@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).