I am trying to configure .emacsso that any file starting with letters makefilesets it to makefile mode. For instance. makefile-somethingmust be in makefile mode.
.emacs
makefile
makefile-something
This does not work:
(setq auto-mode-alist (cons '("^makefile" . makefile-mode) auto-mode-alist))
But it does:
(setq auto-mode-alist (cons '("makefile" . makefile-mode) auto-mode-alist))
Can someone explain why?
This is because there is a path component in front of the file name, try:
"/makefile[^/]*$"
see http://www.gnu.org/s/emacs/manual/html_node/elisp/Auto-Major-Mode.html (bottom of page)
EDI: fixed regex according to Sean's comment
, , , auto-mode-alist, , ^, /. :
auto-mode-alist
^
/
("/\\.?\\(?:gnokiirc\\|kde.*rc\\|mime\\.types\\|wgetrc\\)\\'" . conf-mode)
( Emacs 23.2.1) , , , regexp , .
(setq auto-mode-alist (cons '("/makefile" . makefile-mode) auto-mode-alist))
.
Just try for convenience.
(add-to-list 'auto-mode-alist ...