2

I have a customized grep-find-command.

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(grep-find-command
   (quote
("find . -type f -exec grep  -nHi  \"{}\" \";\"" . 31))))

How can I configure projectile to use this find & grep command? Because the default one won't work on MS Windows.

2

It is possible to set Projectile to use Git's version of the grep command. If you have Git installed on Windows, simply applying the configuration below should suffice:

(setq projectile-use-git-grep t)

Another alternative would be to try to use Windows' findstr command instead. One instance of a search that barely works is:

(defun grep-projectile-windows(&optional search-string)
  (interactive)
  (let ((search-string (or search-string (read-string "[search in project] string pattern: "))))
    (shell-command-to-string (concat "findstr /s /i /p"
                           (concat "/c:\"" search-string "\" ")
                           (concat "\"" (replace-regexp-in-string "/" "\\" (projectile-project-root) t t) "*.*\"")))))

However, to have a fully working solution with this alternative, integration with Projectile would still be required by hacking into the package code, alongside better implementation of the command call (e.g., excluding undesided dirs such as .git, etc.).

A third alternative is to use other search tools search as ag or ack, that have integration with Projectile via external packages.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.