bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Pengji Zhang
Subject: bug#74287: [PATCH] Rework history Isearch for Eshell
Date: Mon, 09 Dec 2024 21:35:52 +0800

Pengji Zhang <me@pengjiz.com> writes:

> Jim Porter <jporterbugs@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.

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]