unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Michael Cadilhac <michael.cadilhac-@t-lrde.epita.fr>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Is it possible to set different background for different modes?
Date: Thu, 13 Oct 2005 16:49:16 +0200	[thread overview]
Message-ID: <87mzldtqtv.fsf@mahaena.lrde> (raw)
In-Reply-To: <1129207707.380328.50610@g14g2000cwa.googlegroups.com> (i. c. code's message of "13 Oct 2005 05:48:27 -0700")

i.c.code@gmail.com writes:

> Hi,
>
> I want to set different background for different modes at same time.
> For example, I open two window, one for perl and another for c, but I
> want them have different background colors. Is it possible?
>
> Thanks.


  To complete Slawomir's answer, you could use an alist and the
  after-change-major-mode-hook hook.

(defvar back-colors
  '((c-mode . "red") (emacs-lisp-mode . "blue"))
  "Alist for background colors regarding major mode.")
(defvar default-back-color "black")

(defun change-back-color-according-to-major-mode ()
  (interactive)
  (let ((color-elt (assq major-mode back-colors)))
    (set-background-color
     (if color-elt
	 (cdr color-elt)
       default-back-color))))


(add-hook 'after-change-major-mode-hook
          'change-back-color-according-to-major-mode)

-- 
    Michael Cadilhac, a.k.a. Micha [mika] |
                    Epita/LRDE promo 2007 |  Please note that you should
  2 rue de la Convention | 08.70.65.13.14 |  s/-@t-/@/ my mail address.
94270 Le Kremlin Bicetre | 06.23.20.31.30 |

  parent reply	other threads:[~2005-10-13 14:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-13 12:48 Is it possible to set different background for different modes? i.c.code
2005-10-13 14:05 ` Slawomir Nowaczyk
2005-10-13 14:49 ` Michael Cadilhac [this message]
2005-10-13 23:07 ` c.c

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87mzldtqtv.fsf@mahaena.lrde \
    --to=michael.cadilhac-@t-lrde.epita.fr \
    --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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).