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
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"/.*"
?– RiccardoCommented Sep 4, 2015 at 22:33 -
Maybe to avoid conflicts with files with known extensions something like this would be better:
"/etc/.*/[^\.]+$"
.– wvxvwCommented 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.– RiccardoCommented Sep 5, 2015 at 9:17
-
1Well, 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).– wvxvwCommented Sep 5, 2015 at 9:30