From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Reitter Newsgroups: gmane.emacs.help Subject: Re: Mode-specific font setting? Date: Tue, 26 Apr 2005 07:42:41 +0100 Message-ID: <6bfd4e9fc12bdc8bbc3ef242a0655607@gmail.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (Apple Message framework v622) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1114498385 839 80.91.229.2 (26 Apr 2005 06:53:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 26 Apr 2005 06:53:05 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 26 08:53:01 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DQJwC-0001La-TL for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Apr 2005 08:52:53 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DQK1s-00054i-LY for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Apr 2005 02:58:44 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DQK07-0004Hg-JU for help-gnu-emacs@gnu.org; Tue, 26 Apr 2005 02:56:55 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DQK05-0004GY-EY for Help-gnu-emacs@gnu.org; Tue, 26 Apr 2005 02:56:54 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DQK02-0002jJ-Sk for Help-gnu-emacs@gnu.org; Tue, 26 Apr 2005 02:56:50 -0400 Original-Received: from [64.233.184.195] (helo=wproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DQJpj-0008J2-S0 for Help-gnu-emacs@gnu.org; Tue, 26 Apr 2005 02:46:11 -0400 Original-Received: by wproxy.gmail.com with SMTP id 50so1871251wri for ; Mon, 25 Apr 2005 23:42:34 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer; b=Vmt7a50RGw2uRPBELkRMUkyUD+a2rQypKQy/8hMZgPYowQXpVZs/hnOtwNAZ6n/SlaCv4+nTrZpn0e9VgSlWLc46A69knCJpiiw69NA2Z1mITQtn+/9rxznBrEWRwZe5nYQTZYR4yT9iJ0zd0mde2befovPBIvEckCypta6XqOc= Original-Received: by 10.54.10.6 with SMTP id 6mr2411732wrj; Mon, 25 Apr 2005 23:42:34 -0700 (PDT) Original-Received: from ?10.0.0.58? ([82.20.43.6]) by mx.gmail.com with ESMTP id 9sm1410477wrl.2005.04.25.23.42.34; Mon, 25 Apr 2005 23:42:34 -0700 (PDT) Original-To: Help-gnu-emacs@gnu.org X-Mailer: Apple Mail (2.622) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor 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:26046 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:26046 > How do I set a mode-specific font? To elaborate on this, I want a generic solution that allows me to assign special fonts to all major modes. Another thing I have tried is to find the frame for the current buffer (see code below). This doesn't work either, because although the current buffer exists, it seems like it doesn't have a window yet (or walk-windows ignores it.) What to do? --- (defun find-all-frames-internal (buffer) (let ((frames nil)) (walk-windows '(lambda (wind) (if (eq (window-buffer wind) buffer) (let ((frm (window-frame wind))) (unless (memq frm frames) (push frm frames))))) nil t) frames)) (add-hook 'after-change-major-mode-hook (lambda () ;; this doesn't work yet ;; somehow, the window doesn't exist at this point :( ;; the current-buffer is correct (setq fr (car (find-all-frames-internal (current-buffer)))) (if fr (case major-mode ('text-mode (select-frame fr) (set-frame-font "fontset-lucida14") )))))