[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master efd74b8 10/90: counsel.el (counsel-find-file): Extend `fin
From: |
Oleh Krehel |
Subject: |
[elpa] master efd74b8 10/90: counsel.el (counsel-find-file): Extend `find-file' |
Date: |
Tue, 30 Jun 2015 07:28:01 +0000 |
branch: master
commit efd74b8b8b86d21f900355b2d633800738c445a3
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-find-file): Extend `find-file'
* counsel.el (counsel-find-file): Forward to `find-file', with Ivy
completion. `ivy-next-line-and-call' as well as `ivy-resume' should
work.
(counsel--find-file-matcher): New defun.
(counsel-find-file-ignore-regexp): Regexp of files to ignore.
Fixes #122
Recommended binding:
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
Peek at files with "C-M-n" and "C-M-p". Input a leading dot to see all
files.
---
counsel.el | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/counsel.el b/counsel.el
index 5538831..aae7c72 100644
--- a/counsel.el
+++ b/counsel.el
@@ -259,6 +259,34 @@
:action #'counsel-git-grep-action
:unwind #'swiper--cleanup)))
+(defun counsel-find-file ()
+ "Forward to `find-file'."
+ (interactive)
+ (ivy-read "Find file: " 'read-file-name-internal
+ :matcher #'counsel--find-file-matcher
+ :action
+ (lambda (x)
+ (find-file (expand-file-name x ivy--directory)))))
+
+(defcustom counsel-find-file-ignore-regexp "\\(?:\\`[#.]\\)\\|\\(?:[#~]\\'\\)"
+ "A regexp of files to ignore while in `counsel-find-file'.
+These files are un-ignored if `ivy-text' matches them.
+The common way to show all files is to start `ivy-text' with a dot.")
+
+(defun counsel--find-file-matcher (regexp candidates)
+ "Return REGEXP-matching CANDIDATES.
+Skip some dotfiles unless `ivy-text' requires them."
+ (let ((res (cl-remove-if-not
+ (lambda (x)
+ (string-match regexp x))
+ candidates)))
+ (if (string-match counsel-find-file-ignore-regexp ivy-text)
+ res
+ (cl-remove-if
+ (lambda (x)
+ (string-match counsel-find-file-ignore-regexp x))
+ res))))
+
(defun counsel-git-grep-matcher (regexp candidates)
(or (and (equal regexp ivy--old-re)
ivy--old-cands)
- [elpa] master 4a3d0be 01/90: swiper.el (swiper-avy): Use only the current window, (continued)
- [elpa] master 4a3d0be 01/90: swiper.el (swiper-avy): Use only the current window, Oleh Krehel, 2015/06/30
- [elpa] master 856e1bd 02/90: ivy.el (ivy-next-line): Fix wraparound at end of candidates, Oleh Krehel, 2015/06/30
- [elpa] master 04b5734 03/90: swiper.el (swiper-avy): Don't start on empty input, Oleh Krehel, 2015/06/30
- [elpa] master 23ffd5c 04/90: swiper.el (swiper--ivy): Don't double-quote preselect, Oleh Krehel, 2015/06/30
- [elpa] master d975e1a 06/90: Avoid ensuring font lock when magit-blame-mode is active, Oleh Krehel, 2015/06/30
- [elpa] master 5fdb7de 05/90: Allow to open an Info file on the file system, Oleh Krehel, 2015/06/30
- [elpa] master f899a22 08/90: Add info lookup binding to counsel-describe-map, Oleh Krehel, 2015/06/30
- [elpa] master a0347d8 09/90: counsel.el (counsel-info-lookup-symbol): Add a require, Oleh Krehel, 2015/06/30
- [elpa] master 3256d68 07/90: Change the :matcher interface, Oleh Krehel, 2015/06/30
- [elpa] master 5f7c787 11/90: counsel.el (counsel-find-file-at-point): New defcustom, Oleh Krehel, 2015/06/30
- [elpa] master efd74b8 10/90: counsel.el (counsel-find-file): Extend `find-file',
Oleh Krehel <=
- [elpa] master 8212110 15/90: Handle symbol-at-point better in non-Elisp buffers, Oleh Krehel, 2015/06/30
- [elpa] master fe057eb 14/90: Swiper should preserve column for empty input, Oleh Krehel, 2015/06/30
- [elpa] master 1a193b0 16/90: ivy.el (ivy--done): Set ivy--current, Oleh Krehel, 2015/06/30
- [elpa] master 97abd3c 17/90: ivy.el (ivy-virtual): New defface, Oleh Krehel, 2015/06/30
- [elpa] master 3c8daba 19/90: Fixup compilation warnings, Oleh Krehel, 2015/06/30
- [elpa] master ecb93a6 18/90: Regexp-quote name of candidate buffer to be preselected, Oleh Krehel, 2015/06/30
- [elpa] master 40a938b 21/90: ivy.el (ivy-minibuffer-map): Bind ivy-yank-word to "M-j", Oleh Krehel, 2015/06/30
- [elpa] master 00a1b02 22/90: counsel-git-grep should quote strings better, Oleh Krehel, 2015/06/30
- [elpa] master 52a083e 13/90: ivy.el (ivy-yank-word): New command, Oleh Krehel, 2015/06/30
- [elpa] master 9ae55b4 12/90: ivy.el (ivy-recentf): New command, Oleh Krehel, 2015/06/30