Skip to main content
added 95 characters in body
Source Link
phils
  • 55k
  • 3
  • 90
  • 134
(setq auto-mode-alist (cons '("\\.md" . markdown-mode) auto-mode-alist)) 

That \\.md should be \\.md\\' otherwise it'll match every filename containing the sequence .md anywhere. (I.e. You already weren't limiting your usage to just matching filename extensions. For instance /home/alper/.mdir/foo/bar.c would match your pattern.)

 

TheAs you can see, the regexps in auto-mode-alist are matched against the entire filename, so you can easily use the same technique forit to match your COMMIT_EDITMSG files. You

One would also normally use add-to-list to update it.the variable:

(add-to-list 'auto-mode-alist '("/\\.git/COMMIT_EDITMSG\\'" . markdown-mode)) 
(setq auto-mode-alist (cons '("\\.md" . markdown-mode) auto-mode-alist)) 

That \\.md should be \\.md\\' otherwise it'll match every filename containing the sequence .md anywhere.

The regexps in auto-mode-alist are matched against the entire filename, so you can use the same technique for COMMIT_EDITMSG. You would also normally use add-to-list to update it.

(add-to-list 'auto-mode-alist '("/\\.git/COMMIT_EDITMSG\\'" . markdown-mode)) 
(setq auto-mode-alist (cons '("\\.md" . markdown-mode) auto-mode-alist)) 

That \\.md should be \\.md\\' otherwise it'll match every filename containing the sequence .md anywhere. (I.e. You already weren't limiting your usage to just matching filename extensions. For instance /home/alper/.mdir/foo/bar.c would match your pattern.)

 

As you can see, the regexps in auto-mode-alist are matched against the entire filename, so you can easily use it to match your COMMIT_EDITMSG files.

One would normally use add-to-list to update the variable:

(add-to-list 'auto-mode-alist '("/\\.git/COMMIT_EDITMSG\\'" . markdown-mode)) 
Source Link
phils
  • 55k
  • 3
  • 90
  • 134

(setq auto-mode-alist (cons '("\\.md" . markdown-mode) auto-mode-alist)) 

That \\.md should be \\.md\\' otherwise it'll match every filename containing the sequence .md anywhere.

The regexps in auto-mode-alist are matched against the entire filename, so you can use the same technique for COMMIT_EDITMSG. You would also normally use add-to-list to update it.

(add-to-list 'auto-mode-alist '("/\\.git/COMMIT_EDITMSG\\'" . markdown-mode))