Change font for the file
I have a line in my .emacs which set a default font:
(set-default-font "Monaco-10")
It works fine for me, but I need two exceptions:
- I need to change default font for a one file, for example ~/some. How can I do it?
- I need to change default fonr for a gnux (M-x gn开发者_开发知识库us). How can I achieve it?
Take a look at the variable `face-remapping-alist'
. For example, you can have something like this:
(add-hook 'find-file-hook
(lambda ()
(if (equal "~/some" (abbreviate-file-name (buffer-file-name)))
(set (make-local-variable 'face-remapping-alist)
'((default :family "DejaVu Serif"))))))
In Emacs files are represented in buffers - you don't change the font of the file, but that of the buffer. Shift-LeftClick in a buffer and you'll get a font dialog. In it you should select:
Change Buffer Font...
You might take a look at the code this command is bound to and use it for your needs.
精彩评论