From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: mode-specific font specifications? Date: Tue, 1 Sep 2009 10:50:25 -0700 (PDT) Organization: http://groups.google.com Message-ID: <286a8006-3a34-4e13-bac7-a621aff1e64b@y28g2000prd.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1251843772 14868 80.91.229.12 (1 Sep 2009 22:22:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 1 Sep 2009 22:22:52 +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:22:45 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 1MibkS-0005oh-JY for geh-help-gnu-emacs@m.gmane.org; Wed, 02 Sep 2009 00:22:44 +0200 Original-Received: from localhost ([127.0.0.1]:56179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MibkR-0007wx-U0 for geh-help-gnu-emacs@m.gmane.org; Tue, 01 Sep 2009 18:22:43 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!y28g2000prd.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 132 Original-NNTP-Posting-Host: 76.102.12.87 Original-X-Trace: posting.google.com 1251827425 22497 127.0.0.1 (1 Sep 2009 17:50:25 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 1 Sep 2009 17:50:25 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y28g2000prd.googlegroups.com; posting-host=76.102.12.87; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/530.5 (KHTML, like Gecko) Chrome/2.0.172.43 Safari/530.5, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:172564 comp.emacs:98686 X-Mailman-Approved-At: Tue, 01 Sep 2009 18:10:38 -0400 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:67713 Archived-At: am also interested in this, however, so far i have not been successful. here's a work-round command. (defun cycle-font () "Change font in current frame. When called repeatedly, cycle thru a predefined set of fonts. Warning: expected to work for Windows only, and you need to install Code2000 font." (interactive) (if (not (eq last-command this-command)) ;; correct syntax for some fonts ;; "-*-Courier New-normal-r-*-*-14-112-96-96-c-*-iso8859-1" ;; "-outline-Lucida Sans Unicode-normal-normal-normal-sans-13-*-*-*-p- *-iso8859-1" ;; "-outline-Code2000-normal-normal-normal-*-15-*-*-*-p-*-iso8859-1" ;; "-raster-Fixedsys-normal-normal-normal-mono-15-*-*-*-c-*-iso8859-1" ;; "-outline-FixedsysTTF-semi-bold-normal-normal-mono-16-*-*-*-c-*- iso8859-1" (progn (set-frame-parameter nil 'font "Courier New-10") (put this-command 'state "2")) (cond ((string=3D (get this-command 'state) "1") (set-frame-parameter nil 'font "Courier New-10") (put this- command 'state "2")) ((string=3D (get this-command 'state) "2" ) (set-frame-parameter nil 'font "Lucida Sans Unicode-10") (put this-command 'state "1")) ;; ((string=3D (get this-command 'state) "3") ;; (set-frame-parameter nil 'font "fixedsys-10") (put ;; this-command 'state "1")) ) ) ) to automatically change font by mode, i tried this: (defun set-font-by-mode () "Change font in current frame according to the major mode." (interactive) (message (symbol-name major-mode) ) (cond ((equal major-mode 'dired-mode) (set-frame-parameter nil 'font "Courier New-10") (message "aaaaaa")) (t (set-frame-parameter nil 'font "Lucida Sans Unicode-10") (message "bbbbb")) ) ) (add-hook 'after-change-major-mode-hook 'set-font-by-mode) it does work when you go into a dired dir first time. However, switching buffer doesn't work... might want to try to get the hook to run when buffer is switched, or attached it to find-file-hook. Or, also try to find a exit-major-mode hook... ps: looking at your post, seems you stuck at the same problem as me. Xah =E2=88=91 http://xahlee.org/ =E2=98=84 On Aug 24, 2:12=C2=A0am, Jim McCloskey wrote: > Just getting used to Emacs 23.1, and especially enjoying the improved > font-rendering. Thanks to all who made this possible. It's really great. > > There's one thing that I haven't figured out yet, though, so I thought > I might ask for help here. I suspect that I am not alone in wanting to > be able to do this. > > 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: > > =C2=A0 =C2=A0 (add-hook 'dired-mode-hook > =C2=A0 =C2=A0 =C2=A0 (function > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(lambda () > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (font-lock= -mode 1) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (require '= dired-x) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (set-frame= -font "Inconsolata-11") > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ))) > > or: > > =C2=A0 =C2=A0 (add-hook 'dired-mode-hook > =C2=A0 =C2=A0 =C2=A0 (function > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(lambda () > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (font-lock= -mode 1) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (require '= dired-x) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (set-defau= lt-font "Inconsolata-11") > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ))) > > and that sort of works, in the sense that the first buffer visited is > displayed in the proportional font FONTNAME, and then when you switch > to dired-mode, you get 11pt Inconsolata. However, when you then go > from dired-mode back to the first buffer (in latex-mode, say), the > font used is now Inconsolata. I had hoped to limit the scope of that > second font declaration by putting it inside: > > =C2=A0 =C2=A0(add-hook 'dired-mode-hook > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ...= . ) > > but, once called, its effects in fact seem to be global rather than > local to that mode. > > Is there a way for me to do what I'd like to be able to do? > > Thanks very much for any advice or any pointers to relevant documentation= . > > Jim