Subject: bug#74287: [PATCH] Rework history Isearch for Eshell

From: Pengji Zhang <[email-masked]>
Date: Tue, 10 Dec 2024 08:55:27 +0800

Juri Linkov <[email-masked]> writes:

> [...]
>
> So do you propose to add an internal variable that duplicates the user
> option?

Yes, sort of. It does not fully duplicates the user option though.
Because we only need to force turning *on* history search, it is made to
override the user option only when it is non-nil. Basically, it is
something like:

--8<---------------cut here---------------start------------->8---
@@ -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)))
--8<---------------cut here---------------end--------------->8---