By default, my Emacs opens config.php in conf-mode. It looks like conf-mode uses a set of regular expressions to match the filename, but I can't figure out how to make it open in php-mode.

Any idea?

  • That's because the entries for conf-mode come before the entries for php-mode in auto-mode-alist.
    – legoscia
    Feb 4 '15 at 11:07

You can add an entry specifically for config.php into auto-mode-alist, as follows:

(add-to-list 'auto-mode-alist (cons (rx bos "config.php" eos) 'php-mode))

(Where bos and eos are shortcuts for string-start and string-end, abbreviated from Beginning/End Of String.)

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.