[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 75a059c 44/57: Allow to recenter with "C-l" during counsel
From: |
Oleh Krehel |
Subject: |
[elpa] master 75a059c 44/57: Allow to recenter with "C-l" during counsel-git-grep |
Date: |
Tue, 19 May 2015 14:21:38 +0000 |
branch: master
commit 75a059c57002502f493042a1cc6bdd24fbbde93d
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Allow to recenter with "C-l" during counsel-git-grep
* counsel.el (counsel-git-grep-map): New defvar.
(counsel-git-grep-recenter): New command.
(counsel-git-grep-action): New defun.
(counsel-git-grep): Update.
Fixes #103
---
counsel.el | 53 +++++++++++++++++++++++++++++++++--------------------
1 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/counsel.el b/counsel.el
index 447371d..23c9f0a 100644
--- a/counsel.el
+++ b/counsel.el
@@ -211,6 +211,27 @@
(setq ivy--full-length (counsel-git-grep-count ivy-text)))
(split-string res "\n" t))))
+(defvar counsel-git-grep-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map (kbd "C-l") 'counsel-git-grep-recenter)
+ map))
+
+(defun counsel-git-grep-recenter ()
+ (interactive)
+ (with-selected-window (ivy-state-window ivy-last)
+ (counsel-git-grep-action)
+ (recenter-top-bottom)))
+
+(defun counsel-git-grep-action ()
+ (let ((lst (split-string ivy--current ":")))
+ (find-file (expand-file-name (car lst) counsel--git-grep-dir))
+ (goto-char (point-min))
+ (forward-line (1- (string-to-number (cadr lst))))
+ (unless (eq ivy-exit 'done)
+ (setq swiper--window (selected-window))
+ (swiper--cleanup)
+ (swiper--add-overlays (ivy--regex ivy-text)))))
+
(defun counsel-git-grep (&optional initial-input)
"Grep for a string in the current git repository."
(interactive)
@@ -222,32 +243,24 @@
:matcher #'counsel-git-grep-matcher
:dynamic-collection (when (> counsel--git-grep-count 20000)
'counsel-git-grep-function)
- :action
- (lambda ()
- (let ((lst (split-string ivy--current ":")))
- (find-file (expand-file-name (car lst) counsel--git-grep-dir))
- (goto-char (point-min))
- (forward-line (1- (string-to-number (cadr lst))))
- (unless (eq ivy-exit 'done)
- (setq swiper--window (selected-window))
- (swiper--cleanup)
- (swiper--add-overlays (ivy--regex ivy-text)))))
+ :keymap counsel-git-grep-map
+ :action #'counsel-git-grep-action
:unwind #'swiper--cleanup))
(defun counsel-git-grep-matcher (x)
(when (string-match "^[^:]+:[^:]+:" x)
(setq x (substring x (match-end 0)))
(if (stringp ivy--old-re)
- (string-match ivy--old-re x)
- (let ((res t))
- (dolist (re ivy--old-re)
- (setq res
- (and res
- (ignore-errors
- (if (cdr re)
- (string-match (car re) x)
- (not (string-match (car re) x)))))))
- res))))
+ (string-match ivy--old-re x)
+ (let ((res t))
+ (dolist (re ivy--old-re)
+ (setq res
+ (and res
+ (ignore-errors
+ (if (cdr re)
+ (string-match (car re) x)
+ (not (string-match (car re) x)))))))
+ res))))
(defun counsel-locate-function (str &rest _u)
(if (< (length str) 3)
- [elpa] master 8630048 47/57: Fixed ivy--preselect-index on windows where the drives folders ends with a backslash (C:\, D:\), (continued)
- [elpa] master 8630048 47/57: Fixed ivy--preselect-index on windows where the drives folders ends with a backslash (C:\, D:\), Oleh Krehel, 2015/05/19
- [elpa] master 1c0703e 36/57: Forward to minibuffer-complete for filenames only if "^/", Oleh Krehel, 2015/05/19
- [elpa] master 70c8c8a 40/57: ivy.el (ivy-switch-buffer): Preselect other-buffer, Oleh Krehel, 2015/05/19
- [elpa] master 9da8e53 54/57: counsel.el (counsel-info-lookup-symbol): Turn on sorting, Oleh Krehel, 2015/05/19
- [elpa] master e0b6c0c 46/57: Update the way spaces are quoted using ivy, Oleh Krehel, 2015/05/19
- [elpa] master 323efda 38/57: counsel-git-grep now works with ivy-resume, Oleh Krehel, 2015/05/19
- [elpa] master 88f4508 49/57: ivy.el (ivy-kill-word): Add and bind to "M-d", Oleh Krehel, 2015/05/19
- [elpa] master de5833e 51/57: Don't error on incomplete bad regexp in counsel-git-grep, Oleh Krehel, 2015/05/19
- [elpa] master 89b9e9a 48/57: README.md: Add sample init, Oleh Krehel, 2015/05/19
- [elpa] master 28cb795 53/57: Don't try to call permanent action if there's none, Oleh Krehel, 2015/05/19
- [elpa] master 75a059c 44/57: Allow to recenter with "C-l" during counsel-git-grep,
Oleh Krehel <=
- [elpa] master 4f75381 55/57: When building a regex, consider ^ only at start, Oleh Krehel, 2015/05/19
- [elpa] master 5afceff 52/57: ivy.el (ivy-forward-char): Add and bind to "C-f", Oleh Krehel, 2015/05/19
- [elpa] master 155f2a6 57/57: Merge commit 'bc335af4d94d80d3605b66ed51a15d2476ad2179' from swiper, Oleh Krehel, 2015/05/19
- [elpa] master bc335af 56/57: Fixup compilation warnings, Oleh Krehel, 2015/05/19