all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: proper setting of default font (and string-handling in elisp?)
Date: Tue, 25 Aug 2009 22:13:26 -0700 (PDT)	[thread overview]
Message-ID: <cd43743a-04b0-4ee8-8700-f802179dec38@o9g2000prg.googlegroups.com> (raw)
In-Reply-To: mailman.5382.1251252804.2239.help-gnu-emacs@gnu.org

On Aug 25, 7:11 pm, Tom Roche <Tom_Ro...@pobox.com> 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=22.2.1 when installing the Sun JRE somehow broke
> my default emacs font. After much googling and twiddling of emacs=22,
> some posts convinced me to go to emacs=23 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 (>= 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=...`) 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 (>= 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 “Options‣Set Default Font”. Choose a font. Then pull
“Options‣Save Options”. 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
∑ http://xahlee.org/

       reply	other threads:[~2009-08-26  5:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.5382.1251252804.2239.help-gnu-emacs@gnu.org>
2009-08-26  5:13 ` Xah Lee [this message]
2009-08-26  5:22   ` proper setting of default font (and string-handling in elisp?) Xah Lee
2009-08-26 12:59 Tom Roche
2009-08-26 13:45 ` Peter Dyballa
  -- strict thread matches above, loose matches on Subject: below --
2009-08-26  2:11 Tom Roche
2009-08-26  7:44 ` Peter Dyballa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cd43743a-04b0-4ee8-8700-f802179dec38@o9g2000prg.googlegroups.com \
    --to=xahlee@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.