]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix adding to history via 'eshell-command'
authorJim Porter <jporterbugs@gmail.com>
Tue, 28 May 2024 21:43:28 +0000 (14:43 -0700)
committerEshel Yaron <me@eshelyaron.com>
Wed, 29 May 2024 10:12:32 +0000 (12:12 +0200)
* lisp/eshell/eshell.el (eshell-read-command): Don't handle history
here.

* lisp/eshell/em-hist.el (eshell-hist-initialize): Properly set up
history for minibuffer.
(eshell-add-command-to-history): Immediately save history.

(cherry picked from commit 7e326b915f45346803edb52b5023db9b765ed07a)

lisp/eshell/em-hist.el
lisp/eshell/eshell.el

index b171a2850ff5d8c1d3c409329b45d098716532f3..2749749bb93b8868e3c833e86b4a02db9083e630 100644 (file)
@@ -294,13 +294,13 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil."
   (make-local-variable 'eshell-save-history-index)
   (setq-local eshell-hist--new-items 0)
 
+  (setq-local eshell-history-ring nil)
   (if (minibuffer-window-active-p (selected-window))
-      (setq-local eshell-save-history-on-exit nil)
-    (setq-local eshell-history-ring nil)
+      (progn
+        (setq-local eshell-history-append t)
+        (add-hook 'minibuffer-exit-hook #'eshell-add-command-to-history nil t))
     (if eshell-history-file-name
-       (eshell-read-history nil t))
-
-    (add-hook 'eshell-exit-hook #'eshell--save-history nil t))
+       (eshell-read-history nil t)))
 
   (unless eshell-history-ring
     (setq eshell-history-ring (make-ring eshell-history-size)))
@@ -421,7 +421,8 @@ command.
 This function is supposed to be called from the minibuffer, presumably
 as a `minibuffer-exit-hook'."
   (eshell-add-input-to-history
-   (buffer-substring (minibuffer-prompt-end) (point-max))))
+   (buffer-substring (minibuffer-prompt-end) (point-max)))
+  (eshell--save-history))
 
 (defun eshell-add-to-history ()
   "Add last Eshell command to the history ring.
index 503f64add4159238697a2bce0305f7a530b7c867..18e05a371a4d88b521dc796b9ca5031b1f5106a6 100644 (file)
@@ -281,10 +281,7 @@ information on Eshell, see Info node `(eshell)Top'."
     (minibuffer-with-setup-hook (lambda ()
                                   (eshell-mode)
                                   (eshell-command-mode +1))
-      (let ((command (read-from-minibuffer prompt)))
-        (when (eshell-using-module 'eshell-hist)
-          (eshell-add-input-to-history command))
-        command))))
+      (read-from-minibuffer prompt))))
 
 ;;;###autoload
 (defun eshell-command (command &optional to-current-buffer)