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

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

[elpa] master 8312176 210/348: ivy.el (ivy-magic-tilde): New defcustom


From: Oleh Krehel
Subject: [elpa] master 8312176 210/348: ivy.el (ivy-magic-tilde): New defcustom
Date: Sat, 8 Apr 2017 11:03:58 -0400 (EDT)

branch: master
commit 83121769b411a49d1e58aab89e8c800810b223c0
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy-magic-tilde): New defcustom
    
    Decide if "~" or "~/" should cd home.
    
    * ivy.el (ivy--exhibit): Update.
    
    Fixes #687
    Fixes #679
---
 ivy.el | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/ivy.el b/ivy.el
index 42cef6f..3dbf887 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2196,6 +2196,11 @@ If SUBEXP is nil, the text properties are applied to the 
whole match."
                  (file-exists-p ivy--current))))
          (ivy--cd (expand-file-name ivy--current ivy--directory)))))
 
+(defcustom ivy-magic-tilde t
+  "When non-nil, ~ will move home when selecting files.
+Otherwise, ~/ will move home."
+  :type boolean)
+
 (defun ivy--exhibit ()
   "Insert Ivy completions display.
 Should be run via minibuffer `post-command-hook'."
@@ -2217,10 +2222,12 @@ Should be run via minibuffer `post-command-hook'."
             (ivy--insert-minibuffer
              (ivy--format ivy--all-candidates))))
       (cond (ivy--directory
-             (if (string-match "/\\'" ivy-text)
-                 (ivy--magic-file-slash)
-               (if (string-match "\\`~\\'" ivy-text)
-                   (ivy--cd (expand-file-name "~/")))))
+             (cond ((or (string= "~/" ivy-text)
+                        (and (string= "~" ivy-text)
+                             ivy-magic-tilde))
+                    (ivy--cd (expand-file-name "~/")))
+                   ((string-match "/\\'" ivy-text)
+                    (ivy--magic-file-slash))))
             ((eq (ivy-state-collection ivy-last) 'internal-complete-buffer)
              (when (or (and (string-match "\\` " ivy-text)
                             (not (string-match "\\` " ivy--old-text)))



reply via email to

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