bram85's Blog

bram85's Avatar Image
Tooting mostly about #emacs.
← All posts

This piece #elisp of makes #emacs execute certain code when opening a file with a particular name. This is useful for files that have no clear extension or mode setting.

I use it to enter yaml-mode whenever I open a .clang-format file (which I don’t want to pollute with -*- magic).

https://apps.bram85.nl/git/bram/gists/src/commit/ad450efe2064441477a9f5e8bd97cf83efd00e5a/gists/find-file-hook-for-certain-filenames.el

The original code was inspired by this StackExchange post, but I found the implementation quite cumbersome so I rewrote it to make it more condense.

https://emacs.stackexchange.com/a/77480/34645

To like or reply, open original post on Emacs.ch