From 770a6c63f6f4cd687ce659ef608b7856acb3f31a Mon Sep 17 00:00:00 2001 From: Peng Li Date: Sun, 24 Sep 2017 15:00:13 +0800 Subject: [PATCH] Emacs - projectile Use rg as external search file for projectile to ignore files in .gitignore file --- emacs.d/.gitignore | 3 ++- emacs.d/config.org | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/emacs.d/.gitignore b/emacs.d/.gitignore index d444d30..fb69f00 100644 --- a/emacs.d/.gitignore +++ b/emacs.d/.gitignore @@ -23,4 +23,5 @@ irony/* tramp/* ltxpng/* tramp -image-dired/* \ No newline at end of file +image-dired/* +emacs-evil.el \ No newline at end of file diff --git a/emacs.d/config.org b/emacs.d/config.org index 76330ed..166f110 100644 --- a/emacs.d/config.org +++ b/emacs.d/config.org @@ -3086,6 +3086,31 @@ Use =ESC= to exit minibuffer. Also I map =Super-h= the same as =C-g= (let ((root (projectile-project-root))) (with-current-buffer buffer (cd root)))))) + + + + ;; https://emacs.stackexchange.com/questions/16497/how-to-exclude-files-from-projectile + (setq projectile-enable-caching t) + (if (executable-find "rg") + (progn + (defconst modi/rg-arguments + `("--line-number" ; line numbers + "--smart-case" + "--follow" ; follow symlinks + "--mmap") ; apply memory map optimization when possible + "Default rg arguments used in the functions in `projectile' package.") + + (defun modi/advice-projectile-use-rg () + "Always use `rg' for getting a list of all files in the project." + (mapconcat 'identity + (append '("\\rg") ; used unaliased version of `rg': \rg + modi/rg-arguments + '("--null" ; output null separated results, + "--files")) ; get file names matching the regex '' (all files) + " ")) + + (advice-add 'projectile-get-ext-command :override #'modi/advice-projectile-use-rg)) + (message "rg is not found")) #+END_SRC *** project config =super= keybindings -- 2.11.0