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: proper setting of default font (and string-handling in elisp?) Date: Tue, 25 Aug 2009 22:13:26 -0700 (PDT) Organization: http://groups.google.com Message-ID: 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 1251273959 5676 80.91.229.12 (26 Aug 2009 08:05:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 26 Aug 2009 08:05:59 +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 Aug 26 10:05:52 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 1MgDVv-0002ei-Pk for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Aug 2009 10:05:52 +0200 Original-Received: from localhost ([127.0.0.1]:39819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgDVv-00059y-3y for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Aug 2009 04:05:51 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!o9g2000prg.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 87 Original-NNTP-Posting-Host: 76.102.12.87 Original-X-Trace: posting.google.com 1251263607 9773 127.0.0.1 (26 Aug 2009 05:13:27 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 26 Aug 2009 05:13:27 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: o9g2000prg.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.39 Safari/530.5, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:172399 X-Mailman-Approved-At: Wed, 26 Aug 2009 03:50:33 -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:67546 Archived-At: On Aug 25, 7:11 pm, Tom Roche wrote: > summary: > > I'm running an emacs-23 and am wanting to set my default font for > every frame in init.el. How to do so properly? > > details: > > This morning I was happily running an up-to-date ubuntu 9.04 (jaunty) > and its stock emacs=3D22.2.1 when installing the Sun JRE somehow broke > my default emacs font. After much googling and twiddling of emacs=3D22, > some posts convinced me to go to emacs=3D23 for > > mainmenu>Options>Set Default Font... > > So I installed emacs-snapshot-gtk, and it indeed works as advertised. > Unfortunately > > 0 I want to set the default font automagically on each start of emacs. > Putting > > (setq tlr-default-font "Courier 10 Pitch-9") > (if (>=3D emacs-major-version 23) > (progn > (set-frame-font tlr-default-font))) > > in my init.el sorta fixes that, except ... > > 1 I would like emacs to come up showing the default font I set. If > it's possible to make that happen via init.el (rather than, e.g., > `emacs --font=3D...`) I'd like to know. However this is not as > important to me as the next item ... > > 2 I also want every new frame I open (with e.g. C-x 5 b) to use my > default font. From googling, my impression is that I should do > something like > > (setq tlr-default-font "Courier 10 Pitch-9") > (if (>=3D emacs-major-version 23) > (progn > (set-frame-font tlr-default-font) > ; (add-to-list 'default-frame-alist '(font . tlr-default-font)) > ; (add-to-list 'default-frame-alist '(font . 'tlr-default-font)) > )) > > but the commented lines fail. Is this solely an elisp problem (which > I'd like to know how to fix anyway)? Or is there also a better way > to set the default font for every frame I open? yeah, there's a better way. pull the menu =E2=80=9COptions=E2=80=A3Set Default Font=E2=80=9D. Choose a = font. Then pull =E2=80=9COptions=E2=80=A3Save Options=E2=80=9D. That should do it. However,= on Windows, i noticed there's a bug that doesn't save the font. A work around is that, once you did the above, then type M-x customize. Then randomly choose something to customize. Then press Save for Future Sessions. That should save the font you've choosen. In particular, you should add something like the following in your emacs init file: (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(default ((t (:inherit nil :stipple nil :background "honeydew" :foreground "SystemWindowText" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :foundry "outline" :family "Lucida Sans Unicode")))) '(completions-common-part ((t (:inherit default :foreground "red")))) '(pp^L-highlight ((((type x w32 mac graphic) (class color)) (:underline "maroon")))) '(show-paren-match ((((class color) (background light)) (:background "azure2"))))) I am also interested in the raw elisp code to save the font or other face related things, without the custom-set-faces. Given a (custome-set-faces ...) code, how do i pull things out and create the equivalent elisp code? setq certainly won't work. Xah =E2=88=91 http://xahlee.org/ =E2=98=84