GNU bug report logs - #74287
[PATCH] Rework history Isearch for Eshell

Previous Next

Package: emacs;

Reported by: Pengji Zhang <me <at> pengjiz.com>

Date: Sun, 10 Nov 2024 01:23:02 UTC

Severity: normal

Tags: patch

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

Bug is archived. No further changes may be made.

Full log


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

From: Pengji Zhang <me <at> pengjiz.com>
To: Jim Porter <jporterbugs <at> gmail.com>, Juri Linkov <juri <at> linkov.net>
Cc: 74287 <at> debbugs.gnu.org
Subject: Re: bug#74287: [PATCH] Rework history Isearch for Eshell
Date: Mon, 09 Dec 2024 21:35:52 +0800
[Message part 1 (text/plain, inline)]
Pengji Zhang <me <at> pengjiz.com> writes:

> Jim Porter <jporterbugs <at> gmail.com> writes:
>
>> Is there a way we could change this so that users who use 'setopt'
>> (or even 'setq'?) instead of the Customize package can enable this
>> feature?
>
> Indeed, it only works with 'M-x customize' (and friends). I guess we
> can instead save the original value to another variable and restore
> from it.

How about the change in the attachment? If it looks good to you, I will
merge it into the main patch.

[em-hist-restore-option.patch (text/x-patch, inline)]
diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el
index c85e7704eca..4bcf434f6e4 100644
--- a/lisp/eshell/em-hist.el
+++ b/lisp/eshell/em-hist.el
@@ -218,6 +218,9 @@ eshell--history-isearch-message-overlay
   "Overlay for Isearch message when searching through input history.")
 (defvar-local eshell--stored-incomplete-input nil
   "Stored input for history cycling.")
+(defvar eshell--force-history-isearch nil
+  "Non-nil means to force searching in input history.
+If nil, respect the option `eshell-history-isearch'.")
 
 (defvar-keymap eshell-hist-mode-map
   "<up>"     #'eshell-previous-matching-input-from-input
@@ -951,7 +954,8 @@ eshell--isearch-setup
   (when (and
          ;; Eshell is busy running a foreground process
          (not eshell-foreground-command)
-         (or (eq eshell-history-isearch t)
+         (or eshell--force-history-isearch
+             (eq eshell-history-isearch t)
              (and (eq eshell-history-isearch 'dwim)
                   (>= (point) eshell-last-output-end))))
     (setq isearch-message-prefix-add "history ")
@@ -975,7 +979,7 @@ eshell-history-isearch-end
   (remove-hook 'isearch-mode-end-hook #'eshell-history-isearch-end t)
   (setq isearch-opoint (point))
   (unless isearch-suspended
-    (custom-reevaluate-setting 'eshell-history-isearch)))
+    (setq eshell--force-history-isearch nil)))
 
 (defun eshell-history-isearch-search ()
   "Return search function for Isearch in input history."
@@ -1077,7 +1081,7 @@ eshell-history-isearch-push-state
 (defun eshell-isearch-backward (&optional invert)
   "Do incremental search backward through past commands."
   (interactive nil eshell-mode)
-  (setq eshell-history-isearch t)
+  (setq eshell--force-history-isearch t)
   (if invert
       (isearch-forward nil t)
     (isearch-backward nil t)))
@@ -1090,7 +1094,7 @@ eshell-isearch-forward
 (defun eshell-isearch-backward-regexp (&optional invert)
   "Do incremental regexp search backward through past commands."
   (interactive nil eshell-mode)
-  (setq eshell-history-isearch t)
+  (setq eshell--force-history-isearch t)
   (if invert
       (isearch-forward-regexp nil t)
     (isearch-backward-regexp nil t)))

This bug report was last modified 165 days ago.

Previous Next


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