Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change point of the buffer after the action of counsel-ag/grep/pt #800

wants to merge 1 commit into from


Copy link

@kimim kimim commented Nov 25, 2016

add a defcunstom function to recenter the buffer after action of counsel-grep/ag/pt, pull request for

This is my first pull request in GitHub, hope it is the correct way to make a pull request.

@abo-abo abo-abo closed this in 721db4c Nov 25, 2016
Copy link

abo-abo commented Nov 25, 2016

Thanks. Here's the diff that I applied on top of your change:

diff --git a/counsel.el b/counsel.el
index e3defbb..2d7bdc3 100644
--- a/counsel.el
+++ b/counsel.el
@@ -920,10 +920,10 @@ Describe the selected candidate."
   (list counsel-git-grep-cmd-default)
   "History for `counsel-git-grep' shell commands.")

-(defcustom counsel-grep-post-function 'recenter
-  "A function to change pooint in the buffer after go to string
-match. The default is recenter"
-  :type 'function
+(defcustom counsel-grep-post-action-hook nil
+  "Hook that runs after the point moves to the next candidate.
+Typical value: '(recenter)."
+  :type 'hook
   :group 'ivy)

 (defun counsel-prompt-function-dir ()
@@ -962,7 +962,7 @@ match. The default is recenter"
         (forward-line (1- (string-to-number line-number)))
         (re-search-forward (ivy--regex ivy-text t) (line-end-position) t)
-        (funcall counsel-grep-post-function)
+        (run-hooks 'counsel-grep-post-action-hook)
         (unless (eq ivy-exit 'done)
           (swiper--add-overlays (ivy--regex ivy-text)))))))
@@ -1830,7 +1830,7 @@ the command."
           (forward-line (- line-number counsel-grep-last-line))
           (setq counsel-grep-last-line line-number))
         (re-search-forward (ivy--regex ivy-text t) (line-end-position) t)
-        (funcall counsel-grep-post-function)
+        (run-hooks 'counsel-grep-post-action-hook)
         (if (eq ivy-exit 'done)
           (isearch-range-invisible (line-beginning-position)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants