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

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

[elpa] master 596461e 005/399: counsel.el (counsel-grep-use-swiper-p): N


From: Oleh Krehel
Subject: [elpa] master 596461e 005/399: counsel.el (counsel-grep-use-swiper-p): New defcustom
Date: Sat, 20 Jul 2019 14:56:37 -0400 (EDT)

branch: master
commit 596461e1ff09431eb417877a9870e53c452e1b62
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-grep-use-swiper-p): New defcustom
    
    * counsel.el (counsel-grep-use-swiper-p-default): Extract.
    (counsel-grep-or-swiper): Update.
    
    Fixes #1908.
---
 counsel.el | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/counsel.el b/counsel.el
index af83039..5c4183e 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2828,6 +2828,19 @@ When the number of characters in a buffer exceeds this 
threshold,
 `counsel-grep' will be used instead of `swiper'."
   :type 'integer)
 
+(defcustom counsel-grep-use-swiper-p #'counsel-grep-use-swiper-p-default
+  "When this function returns non-nil, call `swiper', else `counsel-grep'."
+  :type '(choice
+          (const :tag "Rely on `counsel-grep-swiper-limit'."
+           counsel-grep-use-swiper-p-default)
+          (const :tag "Always use `counsel-grep'." ignore)
+          (function :tag "Custom")))
+
+(defun counsel-grep-use-swiper-p-default ()
+  (<= (buffer-size)
+      (/ counsel-grep-swiper-limit
+         (if (eq major-mode 'org-mode) 4 1))))
+
 ;;;###autoload
 (defun counsel-grep-or-swiper (&optional initial-input)
   "Call `swiper' for small buffers and `counsel-grep' for large ones.
@@ -2838,9 +2851,7 @@ When non-nil, INITIAL-INPUT is the initial search 
pattern."
           (ignore-errors
             (file-remote-p buffer-file-name))
           (jka-compr-get-compression-info buffer-file-name)
-          (<= (buffer-size)
-              (/ counsel-grep-swiper-limit
-                 (if (eq major-mode 'org-mode) 4 1))))
+          (funcall counsel-grep-use-swiper-p))
       (swiper initial-input)
     (when (file-writable-p buffer-file-name)
       (save-buffer))



reply via email to

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