emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 2a13932 252/272: counsel.el (counsel-grep-or-swiper): New


From: Oleh Krehel
Subject: [elpa] master 2a13932 252/272: counsel.el (counsel-grep-or-swiper): New command
Date: Mon, 25 Apr 2016 10:13:28 +0000

branch: master
commit 2a139329997a71044593fb416367f5db4908cb81
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-grep-or-swiper): New command
    
    * counsel.el (counsel-grep-swiper-limit): New defvar.
---
 counsel.el |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/counsel.el b/counsel.el
index a27bc68..7e9c2f7 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1496,6 +1496,28 @@ the command."
       (unless res
         (goto-char init-point)))))
 
+;;** `counsel-grep-or-swiper'
+(defcustom counsel-grep-swiper-limit 300000
+  "When the buffer is larger than this, use `counsel-grep' instead of 
`swiper'."
+  :type 'integer
+  :group 'ivy)
+
+;;;###autoload
+(defun counsel-grep-or-swiper ()
+  "Call `swiper' for small buffers and `counsel-grep' for large ones."
+  (interactive)
+  (if (and (buffer-file-name)
+           (not (ignore-errors
+                  (file-remote-p (buffer-file-name))))
+           (> (buffer-size)
+              (if (eq major-mode 'org-mode)
+                  (/ counsel-grep-swiper-limit 4)
+                counsel-grep-swiper-limit)))
+      (progn
+        (save-buffer)
+        (counsel-grep))
+    (swiper--ivy (swiper--candidates))))
+
 ;;** `counsel-recoll'
 (defun counsel-recoll-function (string)
   "Grep in the current directory for STRING."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]