unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Is it possible to set different background for different modes?
@ 2005-10-13 12:48 i.c.code
  2005-10-13 14:05 ` Slawomir Nowaczyk
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: i.c.code @ 2005-10-13 12:48 UTC (permalink / raw)


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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Is it possible to set different background for different modes?
  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
  2005-10-13 23:07 ` c.c
  2 siblings, 0 replies; 4+ messages in thread
From: Slawomir Nowaczyk @ 2005-10-13 14:05 UTC (permalink / raw)


On Thu, 13 Oct 2005 05:48:27 -0700
i.c.code@gmail.com wrote:

#> 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?

Everything is possible in Emacs ;)

Something along those lines seems to work:

(add-hook 'post-command-hook 
          (lambda () (if (equal major-mode 'lisp-interaction-mode)
                         (set-background-color "red")
                       (set-background-color "green"))))

Of course, post-command-hook gets executed after every command, so it
may not be the best possible solution.

-- 
 Best wishes,
   Slawomir Nowaczyk
     ( slawomir.nowaczyk.847@student.lu.se )

Be nice to other people--they outnumber you six billion to one.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Is it possible to set different background for different modes?
  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
  2005-10-13 23:07 ` c.c
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Cadilhac @ 2005-10-13 14:49 UTC (permalink / raw)
  Cc: help-gnu-emacs

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 |

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Is it possible to set different background for different modes?
  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
@ 2005-10-13 23:07 ` c.c
  2 siblings, 0 replies; 4+ messages in thread
From: c.c @ 2005-10-13 23:07 UTC (permalink / raw)


Thank you, you are all so nice.

But :(,  I think it is possible now, because every time I change one
window's background color, the all windows' background color are
changed, the windows I said are all in one frame.  I think the
impossible is because that the set-background-color is for frame.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-10-13 23:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2005-10-13 23:07 ` c.c

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).