branch: master
commit fef96f414ee00a836a7ebd173a6d90297640a4f0
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
counsel.el (counsel--find-file-1): Extract
---
counsel.el | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/counsel.el b/counsel.el
index 970da1b..6b9a8ba 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1837,20 +1837,26 @@ The preselect behaviour can be customized via user
options
buffer-file-name
(file-name-nondirectory buffer-file-name))))
-;;;###autoload
-(defun counsel-find-file (&optional initial-input)
- "Forward to `find-file'.
-When INITIAL-INPUT is non-nil, use it in the minibuffer during completion."
- (interactive)
- (ivy-read "Find file: " #'read-file-name-internal
+(defun counsel--find-file-1 (prompt initial-input action caller)
+ (ivy-read prompt #'read-file-name-internal
:matcher #'counsel--find-file-matcher
:initial-input initial-input
- :action #'counsel-find-file-action
+ :action action
:preselect (counsel--preselect-file)
:require-match 'confirm-after-completion
:history 'file-name-history
:keymap counsel-find-file-map
- :caller 'counsel-find-file))
+ :caller caller))
+
+;;;###autoload
+(defun counsel-find-file (&optional initial-input)
+ "Forward to `find-file'.
+When INITIAL-INPUT is non-nil, use it in the minibuffer during completion."
+ (interactive)
+ (counsel--find-file-1
+ "Find file: " initial-input
+ #'counsel-find-file-action
+ 'counsel-find-file))
(ivy-set-occur 'counsel-find-file 'counsel-find-file-occur)