help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: conditional font faces


From: Suvayu Ali
Subject: Re: conditional font faces
Date: Mon, 01 Mar 2010 14:17:55 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20100120 Fedora/3.0.1-1.fc12 Lightning/1.0b2pre Thunderbird/3.0.1

On 01/03/10 03:28 AM, Tim Visher wrote:
On Sun, Feb 28, 2010 at 5:10 PM, Suvayu Ali<fatkasuvayu+linux@gmail.com>  wrote:
On 28/02/10 03:00 AM, Tim Visher wrote:

On Sat, Feb 27, 2010 at 7:55 PM, Suvayu Ali<fatkasuvayu+linux@gmail.com>
  wrote:

I was trying to customise the font face to make everything more
visible. Usually I use Emacs with a GUI but quite often I need to use
no-window. The default face for the minibuffer-prompt is medium blue
in no-window which makes it very difficult for me to see. I however
like the defaults when using the GUI.

Is there some way I could keep the defaults when using GUI and set it
to something more readable when using no-window?

I can't remember if it's built in or not but `C-h f emacs-type RET`.

Its not. But I found the library:
http://malsyned.net/repos/dotemacs/site-lisp/emacs-type.el

You can then key off of that like so:

     (defun emacs-is-windowed ()
       "Returns non-nil if Emacs is running in Windowed mode."
       (string-match "window" (emacs-type)))

It returns a symbol, so I had to modify it like this:

  (require 'emacs-type)
  (defun emacs-is-windowed ()
   "Returns non-nil if Emacs is running in Windowed mode."
   (string-match "window" (symbol-name (emacs-type))))

  (if (emacs-is-windowed)
     (progn (set-face-background 'default "black")
              (set-face-foreground 'default "white")))

That's interesting.  The file I got from I not where returned strings.
  If you don't mind doing the conversion then you're more than welcome
to but you could download the version I use from my [GitHub
page](http://github.com/timvisher/.emacs/blob/master/site-lisp/emacs-type.el)
if you so desired.  Again, I had to override it like
[so](http://github.com/timvisher/.emacs/blob/master/lisp/platform-detection.el)
in order to correctly detect Macs.

Now should I be putting above block in a hook? Or is there a better way to
implement this? If using a hook is the proper solution, which should I be
using? Something like find-file-hook is definitely inappropriate as
we can easily have buffers associated with no files (my lisp abilities
are limited at best). :(

If I were you I'd put it in my .emacs file.  That way it gets
evaluated for everything in the life of that emacs process.  This
works for me at least.  Here's a [very simple example of how I use
it](http://github.com/timvisher/.emacs/blob/master/lisp/my-config.el#L33).


Thanks for all the help Tim, I ended up using it like this:

(require 'emacs-type)
(defun emacs-is-windowed ()
  "Returns non-nil if Emacs is running in Windowed mode."
  ;; (string-match "window" (emacs-type)))
  (string-match "window" (symbol-name (emacs-type))))
(defun dark-looks()
  (if (emacs-is-windowed)
    (progn (set-face-background 'default "black")
           (set-face-foreground 'default "white"))))
(add-hook 'before-make-frame-hook 'dark-looks)
(dark-looks)

I don't use Macs, so I don't need to worry about that aspect. ;)
--
Suvayu

Open source is the future. It sets us free.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]