3

I work a lot with unix config files (i.e the files in /etc in the various linux system) that have no extension. How can I set-up my .emacs file to load conf-unix-mode on those files?

1 Answer 1

5

If you mean specifically "all files in the /etc/ directory," you could add an absolute path to your auto-mode-alist:

(add-to-list 'auto-mode-alist '("/etc/.*" . conf-unix-mode))
4
  • Thanks for your helpful suggestion. Is there a way to apply this rule to all the config files? Should I replace "/etc/.*" with "/.*" ?
    – Riccardo
    Commented Sep 4, 2015 at 22:33
  • Maybe to avoid conflicts with files with known extensions something like this would be better: "/etc/.*/[^\.]+$".
    – wvxvw
    Commented Sep 5, 2015 at 8:14
  • @wvxvw: I tried your solution but do not seems to work as expected. I tried the approach proposed by Dan and it works better also with my change. I also added some exceptions using a similar string.
    – Riccardo
    Commented Sep 5, 2015 at 9:17
  • 1
    Well, the thing Dan suggested will match files like /etc/ant.conf, /etc/aliases.db and so on, while what I am suggesting will only match /etc/aliases for example (i.e. if there is an extension, then it won't match).
    – wvxvw
    Commented Sep 5, 2015 at 9:30

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.