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

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

[elpa] master f9f2c8c 251/348: counsel.el (counsel-bookmark-avoid-dired)


From: Oleh Krehel
Subject: [elpa] master f9f2c8c 251/348: counsel.el (counsel-bookmark-avoid-dired): Add
Date: Sat, 8 Apr 2017 11:04:07 -0400 (EDT)

branch: master
commit f9f2c8c42d677682cbc37333a0d4991a89c50049
Author: Justin Burkett <address@hidden>
Commit: Justin Burkett <address@hidden>

    counsel.el (counsel-bookmark-avoid-dired): Add
    
    When non-nil and a directory is selected from counsel-bookmark, forward the
    choice to counsel-find-file instead of opening a dired buffer.
    
    Fixes #813
---
 counsel.el | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/counsel.el b/counsel.el
index 09570e7..2f32162 100644
--- a/counsel.el
+++ b/counsel.el
@@ -616,6 +616,13 @@ input corresponding to the chosen variable."
 
 (declare-function bookmark-all-names "bookmark")
 
+(defcustom counsel-bookmark-avoid-dired nil
+  "If non-nil, choosing a directory in `counsel-bookmark'
+forwards the choice to `counsel-find-file' instead of opening a
+dired buffer."
+  :type 'boolean
+  :group 'ivy)
+
 ;;;###autoload
 (defun counsel-bookmark ()
   "Forward to `bookmark-jump' or `bookmark-set' if bookmark doesn't exist."
@@ -624,10 +631,17 @@ input corresponding to the chosen variable."
   (ivy-read "Create or jump to bookmark: "
             (bookmark-all-names)
             :action (lambda (x)
-                      (if (member x (bookmark-all-names))
-                          (with-ivy-window
-                            (bookmark-jump x))
-                        (bookmark-set x)))
+                      (cond ((and counsel-bookmark-avoid-dired
+                                  (member x (bookmark-all-names))
+                                  (file-directory-p (bookmark-location x)))
+                             (with-ivy-window
+                               (let ((default-directory (bookmark-location x)))
+                                 (counsel-find-file))))
+                            ((member x (bookmark-all-names))
+                             (with-ivy-window
+                               (bookmark-jump x)))
+                            (t
+                             (bookmark-set x))))
             :caller 'counsel-bookmark))
 
 (ivy-set-actions



reply via email to

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