emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/ivy-hydra 7d94e67 087/395: Use the current prompt for s


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra 7d94e67 087/395: Use the current prompt for shell history initial input
Date: Thu, 25 Feb 2021 08:31:37 -0500 (EST)

branch: externals/ivy-hydra
commit 7d94e675c9717bc3726e50af25beeed4c2719525
Author: Troy Hinckley <t.macman@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    Use the current prompt for shell history initial input
    
    Fixes #2400
---
 counsel.el | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/counsel.el b/counsel.el
index 429a91e..3d964f6 100644
--- a/counsel.el
+++ b/counsel.el
@@ -4432,12 +4432,20 @@ An extra action allows to switch to the process buffer."
 ;;** `counsel-esh-history'
 (defun counsel--browse-history (ring)
   "Use Ivy to navigate through RING."
-  (setq ivy-completion-beg (point))
-  (setq ivy-completion-end (point))
-  (ivy-read "History: " (ivy-history-contents ring)
-            :keymap ivy-reverse-i-search-map
-            :action #'ivy-completion-in-region-action
-            :caller 'counsel-shell-history))
+  (let* ((proc (get-buffer-process (current-buffer)))
+         (end (point))
+         (beg (if proc
+                  (min (process-mark proc) end)
+                end))
+         (input (when (< beg end)
+                  (concat "^" (buffer-substring beg end)))))
+    (setq ivy-completion-beg beg)
+    (setq ivy-completion-end end)
+    (ivy-read "History: " (ivy-history-contents ring)
+              :keymap ivy-reverse-i-search-map
+              :initial-input input
+              :action #'ivy-completion-in-region-action
+              :caller 'counsel-shell-history)))
 
 (defvar eshell-history-ring)
 



reply via email to

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