swiper icon indicating copy to clipboard operation
swiper copied to clipboard

counsel.el: Make find-program customizable

Open condy0919 opened this issue 5 years ago • 7 comments

counsel-file-jump and counsel-dired-jump can use the faster find implementation fd.

condy0919 avatar Sep 05 '20 09:09 condy0919

Instead of adding a new user option counsel-find-program (whose :type should be file, not string BTW), why don't you customise find-program directly?

basil-conto avatar Sep 05 '20 17:09 basil-conto

Instead of adding a new user option counsel-find-program (whose :type should be file, not string BTW), why don't you customise find-program directly?

Customizing find-program directly will break some builtin packages such as project.el which uses find-program with hard coded find arguments like this:

(defun project--files-in-directory (dir ignores &optional files)
  (require 'find-dired)
  (require 'xref)
  (defvar find-name-arg)
  (let* ((default-directory dir)
         ;; Make sure ~/ etc. in local directory name is
         ;; expanded and not left for the shell command
         ;; to interpret.
         (localdir (file-local-name (expand-file-name dir)))
         (command (format "%s %s %s -type f %s -print0"
                          find-program
                          localdir
                          (xref--find-ignores-arguments ignores localdir)
                          (if files
                              (concat (shell-quote-argument "(")
                                      " " find-name-arg " "
                                      (mapconcat
                                       #'shell-quote-argument
                                       (split-string files)
                                       (concat " -o " find-name-arg " "))
                                      " "
                                      (shell-quote-argument ")"))"")
                          )))
    (project--remote-file-names
     (sort (split-string (shell-command-to-string command) "\0" t)
           #'string<))))

Using a new user option is to keep those still workable.

condy0919 avatar Sep 05 '20 17:09 condy0919

Customizing find-program directly will break some builtin packages such as project.el which uses find-program with hard coded find arguments like this:

Please report this with M-x report-emacs-bug RET if there is no such issue already on the Emacs issue tracker.

Using a new user option is to keep those still workable.

Thanks, SGTM.

basil-conto avatar Sep 05 '20 18:09 basil-conto

Please report this with M-x report-emacs-bug RET if there is no such issue already on the Emacs issue tracker.

Thanks for advice, I will report it after a while.

condy0919 avatar Sep 05 '20 18:09 condy0919

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44210

Sorry for late reporting...

condy0919 avatar Oct 25 '20 11:10 condy0919

Thanks, no need to apologise.

basil-conto avatar Oct 25 '20 13:10 basil-conto

Hello, how can I use fd with counsel now?

Is it enough to change the find-program variable?

BajaCali avatar Sep 25 '23 06:09 BajaCali