From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oliver Scholz Newsgroups: gmane.emacs.help Subject: Re: mode-specific font specifications? Date: Tue, 01 Sep 2009 23:28:22 +0200 Organization: Arcor Message-ID: <4a9d91f8$0$31880$9b4e6d93@newsspool3.arcor-online.net> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1251842602 11614 80.91.229.12 (1 Sep 2009 22:03:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 1 Sep 2009 22:03:22 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Sep 02 00:03:15 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MibRa-00008j-CE for geh-help-gnu-emacs@m.gmane.org; Wed, 02 Sep 2009 00:03:14 +0200 Original-Received: from localhost ([127.0.0.1]:44747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MibRZ-0008SP-Vm for geh-help-gnu-emacs@m.gmane.org; Tue, 01 Sep 2009 18:03:14 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!bnewspeer01.bru.ops.eu.uu.net!bnewspeer00.bru.ops.eu.uu.net!emea.uu.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Original-Lines: 84 Original-NNTP-Posting-Date: 01 Sep 2009 23:28:24 CEST Original-NNTP-Posting-Host: 4620fec7.newsspool3.arcor-online.net Original-X-Trace: DXC=GbZacjLTh56^cW`WBF>WQ List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:67705 Archived-At: I have a similar problem. But I use muse for my prose and verse, rather than text mode. Jim McCloskey writes: [...] > I'd like to be able to set a default font for text and latex mode (for > prose composition essentially) and to have a nice proportional font > for that context (Linux Libertine or something). But such a font makes > little or no sense for dired-mode, for example, where you really want > a monospace font like Inconsolata (so that the alignment looks right). > > I thought I could do what I wanted by setting a default font in the > init file with (set-default-font "FONTNAME") and then: > > (add-hook 'dired-mode-hook > (function > (lambda () > (font-lock-mode 1) > (require 'dired-x) > (set-frame-font "Inconsolata-11") > ))) > [...] This changes the font of the frame's default face, only when you activate dired-mode. What you probably want, instead of changing the default face globally or for the frame, is specifying the font only for the specific buffer. Unfortunately, as far as I know, Gnu Emacs provides no means to make a face buffer-local. There is the variable `default-text-properties', though, which provides something close, but not quite close. Something like .... (add-hook 'text-mode-hook (lambda () (set (make-local-variable 'default-text-properties) '(face variable-pitch)))) ... would probably do the job for text-mode. It has, however, no effect on text that is already fontified (for instance, because it is italic.) I use overlays: (defface egoge-proportional '((((type x)) (:family "monotype-Garamond" :height 1.4)) (((type w32)) (:family "Sylfaen" :height 1.4))) "Basic face with variable width font.") (defvar egoge-font-overlay nil) (defun egoge-add-font-overlay () (interactive) (let ((from (point-min)) (to (point-max))) (when (eq major-mode 'message-mode) (save-excursion (message-goto-body) (setq from (point) to (if (message-goto-signature) (progn (forward-line -1) (point)) (point-max))))) (let ((overlay (make-overlay from to))) (overlay-put overlay 'face 'egoge-proportional) (set (make-local-variable 'egoge-font-overlay) overlay)))) (add-hook 'muse-mode-hook #'egoge-add-font-overlay) Oliver -- 15 Fructidor an 217 de la Révolution Liberté, Egalité, Fraternité!