I want to open a file in makefile-gmake mode. Is there a way to do this from the command line?

I'm looking for something like:

$ emacs -m makefile-gmake filename

I do not want to change any config files or embed a mode comment in the file itself. I want a solution that works for any filename.

1 Answer 1


You can use the --eval command line argument:

emacs filename --eval "(makefile-gmake-mode)"
  • 3
    Alternatively, I think -f makefile-gmake-mode might also work.
    – Malabarba
    Commented Apr 9, 2015 at 22:59
  • Thanks! Both --eval and -f work, as long as they occur after filename.
    – mpb
    Commented Apr 9, 2015 at 23:29

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.