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

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

[elpa] externals/ivy-hydra 8d840b2 317/395: counsel.el (counsel-find-fil


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra 8d840b2 317/395: counsel.el (counsel-find-file-undo): Undo changing current directory
Date: Thu, 25 Feb 2021 08:32:28 -0500 (EST)

branch: externals/ivy-hydra
commit 8d840b2e8680e2768edb794c9ccecf975f6ba4cf
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    counsel.el (counsel-find-file-undo): Undo changing current directory
    
    This means we can undo directory changes with "RET" or "DEL", while
    using the standard `undo' binding.
    
    Since we have this, we no-longer need the "DEL" preselect logic that
    was making "RET" into and "undo" in that case.  Which is good, since
    "DEL RET" is a valid workflow to select the parent directory in
    `dired'.
    
    Re #1424
    Fixes #2593
---
 counsel.el |  9 +++++----
 ivy.el     | 20 +++++---------------
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/counsel.el b/counsel.el
index 10301f2..52cc0d3 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2144,10 +2144,11 @@ See variable `counsel-up-directory-level'."
 (defun counsel-find-file-undo ()
   (interactive)
   (if (string= ivy-text "")
-      (progn
-        (ivy-backward-delete-char)
-        (ivy--exhibit)
-        (ivy-insert-current))
+      (let ((dir (progn
+                   (pop ivy--directory-hist)
+                   (pop ivy--directory-hist))))
+        (when dir
+          (ivy--cd dir)))
     (undo)))
 
 (defun counsel-at-git-issue-p ()
diff --git a/ivy.el b/ivy.el
index d666add..9a71429 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1588,6 +1588,7 @@ If so, move to that directory, while keeping only the 
file name."
   "When completing file names, move to directory DIR."
   (if (null ivy--directory)
       (error "Unexpected")
+    (push dir ivy--directory-hist)
     (setq ivy--old-cands nil)
     (setq ivy--old-re nil)
     (ivy-set-index 0)
@@ -1602,15 +1603,7 @@ If so, move to that directory, while keeping only the 
file name."
               #'string<))))
     (ivy-set-text "")
     (setf (ivy-state-directory ivy-last) dir)
-    (delete-minibuffer-contents)
-    (when (equal dir (car ivy--directory-hist))
-      (pop ivy--directory-hist)
-      (setf (ivy-state-preselect ivy-last)
-            (if ivy--directory-hist
-                (file-name-nondirectory
-                 (directory-file-name
-                  (car ivy--directory-hist)))
-              nil)))))
+    (delete-minibuffer-contents)))
 
 (defun ivy--parent-dir (filename)
   "Return parent directory of absolute FILENAME."
@@ -1624,11 +1617,8 @@ minibuffer."
   (interactive)
   (if (and ivy--directory (= (minibuffer-prompt-end) (point)))
       (progn
-        (push ivy--directory ivy--directory-hist)
-        (if (fboundp 'counsel-up-directory)
-            (counsel-up-directory)
-          (ivy--cd (ivy--parent-dir (expand-file-name ivy--directory)))
-          (ivy--exhibit)))
+        (ivy--cd (ivy--parent-dir (expand-file-name ivy--directory)))
+        (ivy--exhibit))
     (setq prefix-arg current-prefix-arg)
     (condition-case nil
         (call-interactively #'delete-backward-char)
@@ -2223,7 +2213,7 @@ This is useful for recursive `ivy-read'."
       (setq preselect nil))
     (setq ivy--extra-candidates (ivy--compute-extra-candidates caller))
     (setq ivy--directory nil)
-    (setq ivy--directory-hist nil)
+    (setq ivy--directory-hist (list default-directory))
     (setq ivy-case-fold-search ivy-case-fold-search-default)
     (setf (ivy-state-re-builder ivy-last)
           (setq ivy--regex-function



reply via email to

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