简体   繁体   中英

how to get emacs to treat a matplotlibrc as a sh-mode

I'm trying to get emacs to treat a matplotlibrc file as sh-mode for reasonable syntax highlighting.

Adding these variations to my user.el fails to work:

(add-to-list 'auto-mode-alist '("*matplotlibrc'" . sh-mode))
(add-to-list 'auto-mode-alist '("matplotlibrc'" . sh-mode))

Why?

I think you'll find that it works if you escape the single quote:

(add-to-list 'auto-mode-alist '("matplotlibrc\\'" . sh-mode))

From the manual :

\\' matches the empty string, but only at the end of the buffer or string being matched against.

And because it's Emacs Lisp, you need to double the backslash .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM