LefterisJP/malinka

File listening to rebuild compile_commands.json

Closed this issue · 3 comments

I am thinking we can support something like this.

(file-notify-add-watch
 "SomeFile.txt"
 '(change)
 (lambda (event)
   (rebuild-compile-commands-db)))

https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Notifications.html

To automatically update the compile_commands file and retrigger rtags/ycmd/irony/etc with a new file.

Maybe something like this:

(malinka-define-project
   :name "Test"
   :root-directory "TestRoot"
   :build-directory "TestRoot/build"
   :configure-cmd "cmake .. -DCMAKE_BUILD_TYPE=Debug -DHEADLESS=1"
   :watch-file "FileToWatch.txt or CmakeLists.txt etc")

Maybe I'm running into another use case and we don't need this. I'm just finding that I have to rebuild the compile_commands file since Malinka doesn't seem to build it if it's already existing. (Right?)

Let me know if you think this is a good idea, I might be able to get a PR for it.

@jojojames Apologies for the late reply. I actually think that rtags already uses inotify kernel calls to re-index any modified files. So what you propose is an extension to that via malinka if you add a new file to the project.

That would of course be really nice, as right now you indeed would need to re-run the command to build the compile_commands manually.

I have changes on my fork that I haven't pushed up yet. Just doing some dogfooding with it before i do a PR.

Closing in favor of #18