Customize ag usage.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sun, 12 Feb 2017 13:15:25 +0200
changeset 1479 1caaafbd177d
parent 1478 e6f6dd580012
child 1480 34b763cbc5cf
Customize ag usage.
.emacs-my
--- a/.emacs-my	Thu Feb 09 15:41:59 2017 +0200
+++ b/.emacs-my	Sun Feb 12 13:15:25 2017 +0200
@@ -812,9 +812,17 @@
     (cl-flet ( (grep-compute-defaults () nil) )
       (call-interactively #'rgrep))))
 
+(defun my/ag (&optional str)
+  "Search with ag from project roor without prefix and from
+`default-directory' with prefix."
+  (interactive (when current-prefix-arg (list (ag/read-from-minibuffer "Search string"))))
+  (if str
+      (let ((current-prefix-arg nil)) (ag str default-directory))
+    (call-interactively #'ag-project)))
+
 (setq ag-highlight-search t)
 (when (featurep 'ag)
-  (global-set-key [f7] 'ag-project))
+  (global-set-key [f7] 'my/ag))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (message "highlighting")