Emacs - projectile Use rg as external search file for projectile to ignore files
authorPeng Li <seudut@gmail.com>
Sun, 24 Sep 2017 07:00:13 +0000 (15:00 +0800)
committerPeng Li <seudut@gmail.com>
Tue, 26 Sep 2017 18:30:49 +0000 (02:30 +0800)
in .gitignore file

emacs.d/.gitignore
emacs.d/config.org

index d444d30..fb69f00 100644 (file)
@@ -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
index 76330ed..166f110 100644 (file)
@@ -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