Usually when I load a project, I want to compile it once right away, be it to again see the compilation error I was working on or just to build the dependencies of the checkout, so I don't have to wait for the entire build when I've actually done some changes.

Of course I can simply press C-c m (which I've mapped to recompile), but is there a way to achieve the build without any extra cue?

  • You project have specified language or it's a common question? Aug 13, 2016 at 11:29
  • I just want to execute the standard compile command right after loading. Aug 13, 2016 at 11:33

1 Answer 1


You could add hook into init.el

(add-hook 'find-file-hook
          (lambda ()
            (when (string= major-mode "c-mode")

for c-mode to recompile it automatically when you'll find-file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.