all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Oliver Scholz <alkibiades@gmx.de>
To: help-gnu-emacs@gnu.org
Subject: Re: mode-specific font specifications?
Date: Tue, 01 Sep 2009 23:28:22 +0200	[thread overview]
Message-ID: <4a9d91f8$0$31880$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: mailman.5251.1251123404.2239.help-gnu-emacs@gnu.org

I have a similar problem. But I use muse for my prose and verse, rather
than text mode.

Jim McCloskey <mcclosk@ucsc.edu> 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é!


  parent reply	other threads:[~2009-09-01 21:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.5251.1251123404.2239.help-gnu-emacs@gnu.org>
2009-08-24 16:14 ` mode-specific font specifications? A.Politz
2009-09-01 17:50 ` Xah Lee
2009-09-01 21:28 ` Oliver Scholz [this message]
2009-09-01 21:38   ` Oliver Scholz
2009-08-24  9:12 Jim McCloskey

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='4a9d91f8$0$31880$9b4e6d93@newsspool3.arcor-online.net' \
    --to=alkibiades@gmx.de \
    --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.