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

From: Juri Linkov <[email-masked]>
Date: Tue, 10 Dec 2024 09:46:27 +0200

>> 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:
>
> @@ -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)))

I agree this would be the right thing, because even in Isearch
we have variables that duplicate the user options such as e.g.
the option 'search-invisible' and the internal variable 'isearch-invisible'.