6

So I know that I can put at the first or second line of a file a line such as:

# -*- mode: conf -*-

to tell Emacs what major mode I want the file to be opened with.

But if that mode isn't installed I wish Emacs to fallback to a different mode. For example I wish to use the apache-mode, but if it doesn't exist I wish to fallback to conf-mode.

Is this possible, and if so how?

10

Found it:

# -*- mode: conf; mode: apache -*-

It seems that the last valid mode wins, so I need to put the my wanted mode last, and the fallback mode(s) before it.

  • Interesting. I suspect that will activate all the named modes (those that are available at least), one after the other. This should do no harm, but might be a bit time consuming. It's a handy trick, though. – Harald Hanche-Olsen Aug 23 '18 at 8:18

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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