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.


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
    Apr 9 '15 at 22:59
  • Thanks! Both --eval and -f work, as long as they occur after filename.
    – mpb
    Apr 9 '15 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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