githubnemo/CompileDaemon — pull request #4 by jimstudt (2014-04-15 15:23:34+00:00)
Title: Exclusions and inclusions

On OS X fsnotify holds open a file descriptor for each watched file. The .git directory easily uses up all available descriptors causing a fatal error. It is possible to muck around with sysctl to raise the limit, but some better control of what is watched is also useful, to that end…

-exclude-dir=XXX – Don't watch directories whose name (not path) matches the glob pattern XXX

-exclude=XXX – Don't watch files whose name matches the glob pattern XXX

-include=XXX – Watch files whose name matches the glob pattern XXX (this is in parallel with the -pattern regexp. passing either one is sufficient)

I went with globs because they aren't so beastly to escape in Bourne shell and are more familiar to people comfortable with the command line. The regexp benefit of matching multiple types of files is accomplished by alloying the flags to be repeated…

CompileDaemon -exclude-dir=.git -exclude-dir=.hg -exclude-dir=.svn

… would ignore the big three VCS.

The file exclude is helpful for emacs users who get files like ".#main.go" when they edit main.go. These pass the pattern and generate spurious builds.

The "include" came basically for free once the rest was written. It is more convenient for adding files than the pattern. For instance if using "less" you can just add a -include="*.less" and not worry about backslashes and escaping.

As a bonus, I think I remembered to format the got *before* submitting the pull request this time. Going forward, I've added enough flags that it is time for a man page and probably some examples in the README.md. I'll try to schedule that next week.