I've created a generic mode for emacs, but I have trouble matching the file names I want the generic mode to be on, right now I'm using
proguard-* but I would like to match only file names with
proguard-*.pro. How can I do this?
The rules for selecting a major mode are a bit complex, the manual says this about choosing based on the file name :
Fourth—if Emacs still hasn’t found a suitable major mode—it looks at the file’s name. The correspondence between file names and major modes is controlled by the variable ‘auto-mode-alist’. Its value is a list in which each element has this form,
(REGEXP . MODE-FUNCTION)
or this form,
(REGEXP MODE-FUNCTION FLAG)
What it doesn't say explicitely (nor the docstring for
auto-mode-alist) is that what is matched against the regexp is the full pathname of the file.
The syntax of regexps is also decribed in the manual.
I expect that something like this should do what you want?
(add-to-list 'auto-mode-alist '("^proguard-.*\\.txt$" . generic-mode)) (add-to-list 'auto-mode-alist '("^proguard-.*\\.pro$" . generic-mode))
generic-mode by the actual name of your mode, of course.
The strings are regular expressions, or regexps for short. You may read about them in the elisp manual.