branch: master
commit 5f7c787a08619dcf54df2e1c716b9153b69450eb
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
counsel.el (counsel-find-file-at-point): New defcustom
* counsel.el (counsel-find-file): When `counsel-find-file-at-point' is
non-nil, add the file at point to the list of candidates.
Fixes #123
---
counsel.el | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/counsel.el b/counsel.el
index aae7c72..f27095e 100644
--- a/counsel.el
+++ b/counsel.el
@@ -259,6 +259,10 @@
:action #'counsel-git-grep-action
:unwind #'swiper--cleanup)))
+(defcustom counsel-find-file-at-point nil
+ "When non-nil, add file-at-point to the list of candidates."
+ :type 'boolean)
+
(defun counsel-find-file ()
"Forward to `find-file'."
(interactive)
@@ -266,7 +270,10 @@
:matcher #'counsel--find-file-matcher
:action
(lambda (x)
- (find-file (expand-file-name x ivy--directory)))))
+ (find-file (expand-file-name x ivy--directory)))
+ :preselect (when counsel-find-file-at-point
+ (require 'ffap)
+ (ffap-guesser))))
(defcustom counsel-find-file-ignore-regexp "\\(?:\\`[#.]\\)\\|\\(?:[#~]\\'\\)"
"A regexp of files to ignore while in `counsel-find-file'.