tags:

views:

58

answers:

2

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:

  1. I need to change default font for a one file, for example ~/some. How can I do it?
  2. I need to change default fonr for a gnux (M-x gnus). How can I achieve it?
+1  A: 

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.

Bozhidar Batsov
I need to change the font automatically. Something like: if(openfilename = '~/some') (set-default-font "...").
demas
+1  A: 

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"))))))
huaiyuan