-;; Time-stamp: <2016-02-04 00:09:38 kmodi>
+;; Time-stamp: <2016-02-23 18:05:47 kmodi>
 
 ;; Projectile
 ;; https://github.com/bbatsov/projectile

        project-name))
    (setq projectile-project-name-function #'modi/projectile-project-name)

    (when (executable-find "ag")
      (defconst modi/projectile-ag-command
        (mapconcat 'identity
                   (append '("\\ag") ; used unaliased version of `ag': \ag
                           modi/ag-arguments
                           '("-0" ; output null separated results
                             "-g ''")) ; get file names matching the regex '' (all files)
                   " ")
        "Ag command to be used by projectile to generate file cache.")

      ;; Patch
      (defun projectile-get-ext-command ()
        "Override the projectile-defined function so that `ag' is always used
for getting a list of all files in a project."
        modi/projectile-ag-command))

    ;; Patch
    ;; Make the file list creation faster by NOT calling `projectile-get-sub-projects-files'
    (defun projectile-get-repo-files ()
      (projectile-files-via-ext-command (projectile-get-ext-command)))

    ;; Patch
    ;; Use older version of `projectile-cache-current-file' that did not cache
    ;; the true names.
    ;; https://github.com/bbatsov/projectile/commit/924d73120bca6adc5b9bf3d79ad53075a63b5f1e
    (defun projectile-cache-current-file ()
      "Add the currently visited file to the cache."
      (interactive)
      (let* ((current-project (projectile-project-root))
             (abs-current-file (buffer-file-name (current-buffer)))
             (current-file (file-relative-name abs-current-file current-project)))
        (when (gethash (projectile-project-root) projectile-projects-cache)
          (unless (or (projectile-file-cached-p current-file current-project)
                      (projectile-ignored-directory-p (file-name-directory abs-current-file))
                      (projectile-ignored-file-p abs-current-file))
            (puthash current-project
                     (cons current-file (gethash current-project projectile-projects-cache))
                     projectile-projects-cache)
            (projectile-serialize-cache)
            (message "File %s added to project %s cache."
                     (propertize current-file 'face 'font-lock-keyword-face)
                     (propertize current-project 'face 'font-lock-keyword-face))))))

    ;; Patch
    ;; Do not cache files from ignored projects.
    (defun projectile-cache-files-find-file-hook ()
      "Function for caching files with `find-file-hook'."
      (when (and projectile-enable-caching
                 (projectile-project-p)
                 (not (member (projectile-project-p) projectile-ignored-projects)))
        (projectile-cache-current-file)))

    (when (fboundp 'ggtags-mode)
      ;; Patch
      (defun projectile-visit-project-tags-table ()
        "Visit the current project's tags table ONLY IF `ggtags-mode' is not loaded.
If `ggtags-mode' function is defined, “empty” this definition so that it does
nothing.

Doing so prevents prevents the unnecessary call to `visit-tags-table' function
and the subsequent `find-file' call for the `TAGS' file."
        ))

    ;; http://emacs.stackexchange.com/a/10187/115
    (defun modi/kill-non-project-buffers (&optional kill-special)

    ;; (setq projectile-enable-caching nil)
    (setq projectile-enable-caching t) ; Enable caching, otherwise
                                        ; `projectile-find-file' is really slow
                                        ; for large projects.
    (dolist (item '(".SOS" "nobackup"))
      (add-to-list 'projectile-globally-ignored-directories item))
    (dolist (item '("GTAGS" "GRTAGS" "GPATH"))
