[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 9970ae6 180/184: counsel.el (counsel-read-directory-name):
From: |
Oleh Krehel |
Subject: |
[elpa] master 9970ae6 180/184: counsel.el (counsel-read-directory-name): Add |
Date: |
Wed, 16 Oct 2019 13:15:18 -0400 (EDT) |
branch: master
commit 9970ae60b60dca532b9aed2ec56773786d9519f0
Author: Hong Xu <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-read-directory-name): Add
This is a partial replacement of `read-directory-name', except that
DEFAULT-DIRNAME does not have any effect. This should be able to
mitigate the issue mentioned in #1646 to allow more flexibility
regarding customized key bindings.
Fixes #2277
---
counsel.el | 31 ++++++++++++++++++++++---------
ivy-test.el | 8 ++++++++
2 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/counsel.el b/counsel.el
index 8f92523..a6fe736 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2540,9 +2540,9 @@ FZF-PROMPT, if non-nil, is passed as `ivy-read' prompt
argument."
(let ((fzf-basename (car (split-string counsel-fzf-cmd))))
(list nil
(when current-prefix-arg
- (read-directory-name (concat
- fzf-basename
- " in directory: "))))))
+ (counsel-read-directory-name (concat
+ fzf-basename
+ " in directory: "))))))
(counsel-require-program counsel-fzf-cmd)
(setq counsel--fzf-dir
(or initial-directory
@@ -2651,7 +2651,7 @@ INITIAL-DIRECTORY, if non-nil, is used as the root
directory for search."
(interactive
(list nil
(when current-prefix-arg
- (read-directory-name "From directory: "))))
+ (counsel-read-directory-name "From directory: "))))
(counsel-require-program find-program)
(let ((default-directory (or initial-directory default-directory)))
(ivy-read "Find file: "
@@ -2685,7 +2685,7 @@ INITIAL-DIRECTORY, if non-nil, is used as the root
directory for search."
(interactive
(list nil
(when current-prefix-arg
- (read-directory-name "From directory: "))))
+ (counsel-read-directory-name "From directory: "))))
(counsel-require-program find-program)
(let ((default-directory (or initial-directory default-directory)))
(ivy-read "Find directory: "
@@ -2813,9 +2813,9 @@ CALLER is passed to `ivy-read'."
(when current-prefix-arg
(setq initial-directory
(or initial-directory
- (read-directory-name (concat
- (car (split-string counsel-ag-command))
- " in directory: "))))
+ (counsel-read-directory-name (concat
+ (car (split-string
counsel-ag-command))
+ " in directory: "))))
(setq extra-ag-args
(or extra-ag-args
(read-from-minibuffer (format
@@ -2842,12 +2842,25 @@ CALLER is passed to `ivy-read'."
:grep-p t
:exit-codes '(1 "No matches found"))
+(defun counsel-read-directory-name (prompt)
+ "Read a directory name from user, a (partial) replacement of
`read-directory-name'."
+ (let ((counsel--find-file-predicate #'file-directory-p))
+ (ivy-read prompt
+ #'read-file-name-internal
+ :matcher #'counsel--find-file-matcher
+ :history 'file-name-history
+ :keymap counsel-find-file-map
+ :caller 'counsel-read-directory-name)))
+
+(ivy-configure 'counsel-read-directory-name
+ :display-transformer-fn #'ivy-read-file-transformer)
+
(defun counsel-cd ()
"Change the directory for the currently running Ivy grep-like command.
Works for `counsel-git-grep', `counsel-ag', etc."
(interactive)
(let ((input ivy-text)
- (new-dir (read-directory-name "cd: ")))
+ (new-dir (counsel-read-directory-name "cd: ")))
(ivy-quit-and-run
(funcall (ivy-state-caller ivy-last) input new-dir))))
diff --git a/ivy-test.el b/ivy-test.el
index 9a645fd..c15cf2f 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -975,6 +975,14 @@ will bring the behavior in line with the newer Emacsen."
"DEL C-M-j"
:dir "/tmp"))))
+(ert-deftest ivy-counsel-read-directory-name ()
+ (should
+ (equal (expand-file-name "/tmp/")
+ (ivy-with
+ '(counsel-read-directory-name "cd: ")
+ "RET"
+ :dir "/tmp/"))))
+
(ert-deftest ivy-partial-files ()
(when (file-exists-p "/tmp/ivy-partial-test")
(delete-directory "/tmp/ivy-partial-test" t))
- [elpa] master b39f383 125/184: counsel.el (counsel-git-grep-occur): Re-use counsel-grep-like-occur, (continued)
- [elpa] master b39f383 125/184: counsel.el (counsel-git-grep-occur): Re-use counsel-grep-like-occur, Oleh Krehel, 2019/10/16
- [elpa] master c9f1889 136/184: swiper.el (swiper--query-replace-setup): Fix "^$" issue, Oleh Krehel, 2019/10/16
- [elpa] master b9bb7c6 140/184: ivy.el (ivy-configure): New function to configure many things at once, Oleh Krehel, 2019/10/16
- [elpa] master e3dabec 143/184: counsel.el: Use ivy-configure :unwind-fn, Oleh Krehel, 2019/10/16
- [elpa] master f16ac0e 148/184: ivy.el (ivy--format): Set case-fold-search, Oleh Krehel, 2019/10/16
- [elpa] master 501ac71 151/184: ivy.el (ivy-occur-revert-buffer): Re-use ivy-highlight-grep-commands, Oleh Krehel, 2019/10/16
- [elpa] master 6b0c41b 167/184: ivy.el (ivy-sort-file-function-using-ido): Make obsolete, Oleh Krehel, 2019/10/16
- [elpa] master 22cc602 160/184: counsel.el (counsel-find-symbol): Should not show up in counsel-M-x, Oleh Krehel, 2019/10/16
- [elpa] master b85f857 166/184: .github/FUNDING.yml: Add github, Oleh Krehel, 2019/10/16
- [elpa] master 722250c 162/184: counsel.el (counsel-imenu-action): Handle nil case, Oleh Krehel, 2019/10/16
- [elpa] master 9970ae6 180/184: counsel.el (counsel-read-directory-name): Add,
Oleh Krehel <=
- [elpa] master 7054901 176/184: ivy.el (ivy-occur-revert-buffer): Make more generic, Oleh Krehel, 2019/10/16
- [elpa] master fcef913 023/184: swiper-isearch: Fix regexes in "ignore-order" case, Oleh Krehel, 2019/10/16
- [elpa] master 0b85d9d 030/184: counsel.el (counsel-at-git-issue-p): Add vc-git-log-view-mode, Oleh Krehel, 2019/10/16
- [elpa] master 2db2c51 050/184: counsel.el (counsel-find-file-mkdir-action): make parents too, Oleh Krehel, 2019/10/16
- [elpa] master f90bc8c 164/184: ivy.el (ivy-configure): Add :height, Oleh Krehel, 2019/10/16
- [elpa] master 09c40fc 175/184: swiper.el (swiper--occur-insert-lines): Simplify, Oleh Krehel, 2019/10/16
- [elpa] master c69deb2 179/184: ivy.el: "~~" now works as expected for /sudo::, Oleh Krehel, 2019/10/16
- [elpa] master 24a6354 170/184: ivy.el (ivy--format): Improve docstring, Oleh Krehel, 2019/10/16
- [elpa] master 0d842e3 062/184: ivy.el (ivy-switch-buffer): Clean up, Oleh Krehel, 2019/10/16
- [elpa] master 560957f 074/184: Check if ivy--done is accepting a string., Oleh Krehel, 2019/10/16