Try to use Projectile to find files in *compilation* buffer if possible.

If not, fallback to the original function.

* projectile.el (projectile-compilation-find-file): Use projectile to find
files in *compilation* buffer if possible.

(projectile-mode): Add the previous function around `compilation-find-file'.

Add/Remove the advice around `compilation-find-file' when the mode is on/off.
Bozhidar Batsov <notifications@github.com> writes:

> In projectile.el:
>
>> @@ -1732,6 +1732,24 @@ with a prefix ARG."
>>      (puthash project-root compilation-cmd projectile-compilation-cmd-map)
>>      (compilation-start compilation-cmd)))
>>  
>> +(defun projectile-compilation-find-file (oldfun &rest args)
>> +  "Try to find a buffer for FILENAME, if we cannot find it,
>> +fallback to the original function, OLDFUN.
>> +
>> +\(advice-add 'compilation-find-file :around projectile-compilation-find-file)"
>> +  (destructuring-bind (marker filename directory &rest formats) args
>> +    (or
>> +     ;; Try to find the filename using projectile
>> +     (and (projectile-project-p)
>
> Shouldn't we first try to find the file using compilation-find-file. Often the paths will be either absolute or relative to the default-directory and using Projectile for those would be an overkill.

I don't think it is a good idea because if the project isn't recognize
as a projectile project, then it will fail silently without giving the
use a chance to select the correct file. Whereas if
~compilation-find-file~ doesn't find the file, it asks the user for the
correct path.