1

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?

3

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))
  • Thanks for your helpful suggestion. Is there a way to apply this rule to all the config files? Should I replace "/etc/.*" with "/.*" ? – Riccardo Sep 4 '15 at 22:33
  • Maybe to avoid conflicts with files with known extensions something like this would be better: "/etc/.*/[^\.]+$". – wvxvw Sep 5 '15 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 Sep 5 '15 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 Sep 5 '15 at 9:30

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.