unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Different background color for different windows/modes
@ 2017-06-29 10:45 Alexandre Oberlin
  2017-06-29 11:24 ` Emanuel Berg
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Alexandre Oberlin @ 2017-06-29 10:45 UTC (permalink / raw)
  To: help-gnu-emacs

Hi all, I am using a hook to change my background color using stuff like:
(add-hook 'change-major-mode-hook 'change-my-background-color)

This is sub-optimal because 
- there is a terrible flash as soon as I enter the minibuffer
- all the displayed windows change color (not only the one getting focus). 

How can I have different colors for different window  modes?  If currently impossible, is something planned in that regard? Or maybe xemacs does this?


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

* Re: Different background color for different windows/modes
  2017-06-29 10:45 Different background color for different windows/modes Alexandre Oberlin
@ 2017-06-29 11:24 ` Emanuel Berg
  2017-06-29 11:40 ` tomas
  2017-07-23 13:53 ` Alexandre Oberlin
  2 siblings, 0 replies; 5+ messages in thread
From: Emanuel Berg @ 2017-06-29 11:24 UTC (permalink / raw)
  To: help-gnu-emacs

Alexandre Oberlin wrote:

> Hi all, I am using a hook to change my
> background color using stuff like: (add-hook
> 'change-major-mode-hook
> 'change-my-background-color)

You want the background color to be a function
of the major mode?

And there are no mode-specific variables to
control this so you instead have a function
that maps on the fly?

Oh, man...

> This is sub-optimal because - there is
> a terrible flash as soon as I enter the
> minibuffer - all the displayed windows change
> color (not only the one getting focus).

*If* you are going to stick to this sub-optimal
solution indeed, I suppose you could write
a more advanced function that will examine if
the new context is such that the change of
background color should or shouldn't kick in.

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

* Re: Different background color for different windows/modes
  2017-06-29 10:45 Different background color for different windows/modes Alexandre Oberlin
  2017-06-29 11:24 ` Emanuel Berg
@ 2017-06-29 11:40 ` tomas
  2017-07-23 13:53 ` Alexandre Oberlin
  2 siblings, 0 replies; 5+ messages in thread
From: tomas @ 2017-06-29 11:40 UTC (permalink / raw)
  To: Alexandre Oberlin; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Jun 29, 2017 at 03:45:31AM -0700, Alexandre Oberlin wrote:
> Hi all, I am using a hook to change my background color using stuff like:
> (add-hook 'change-major-mode-hook 'change-my-background-color)
> 
> This is sub-optimal because 
> - there is a terrible flash as soon as I enter the minibuffer
> - all the displayed windows change color (not only the one getting focus). 
> 
> How can I have different colors for different window  modes?  If currently impossible, is something planned in that regard? Or maybe xemacs does this?

You don't state it explicitly, but I assume you want to change
the background color per buffer, perhaps per window.

For a long time it was only possible to set the whole frame's
(an Emacs frame is what the window manager considers a "window")
background color. This has changed since Emacs 24-ish, see for
example

  https://stackoverflow.com/questions/3094638/emacs-custom-background-color-by-mode

(this seems to be exactly what you're looking for).

Cheers
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAllU5ygACgkQBcgs9XrR2kYSgACfT8hG9yXfeclPQwLOGU5O7KEo
3McAniy9SLPfXdCYcsnZW2Xl+4HvM2rN
=OkVt
-----END PGP SIGNATURE-----



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

* Re: Different background color for different windows/modes
  2017-06-29 10:45 Different background color for different windows/modes Alexandre Oberlin
  2017-06-29 11:24 ` Emanuel Berg
  2017-06-29 11:40 ` tomas
@ 2017-07-23 13:53 ` Alexandre Oberlin
  2017-07-23 17:10   ` Emanuel Berg
  2 siblings, 1 reply; 5+ messages in thread
From: Alexandre Oberlin @ 2017-07-23 13:53 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

Someone gave me a hint to do this in Emacs 24.4+ but I don't find the message on gnu.emacs.help (Is this NG dying?). 

The trick is to uses defface and face-remap-add-relative. It works very well, including in GNU Emacs 24.5.1 (x86_64-unknown-cygwin) under Cygwin without X.

To modify the font and colors of your shell windows for instance, just add/load the code below from your .emacs and add more attributes and more modes (text, lisp, etc.) as desired. 

The commented out entries are not necessary but may come handy when tweaking your config.

Important: this code should be loaded before you visit/find any concerned file or launch a shell from .emacs. 

;;;;;;;;;;;;;;;;;;;;;;;; BEGIN .emacs CODE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; (face-spec-reset-face 'myshellface)
(defface myshellface
  '((t :foreground "black"
       :background "aquamarine"
       :weight semi-bold
       :underline nil
       ))
  "Face for shells."
  :group 'myfaces )

;; (face-spec-set
;;  'myshellface
;;    '((t :foreground "black"
;;        :background "aquamarine"
;;        :weight semi-bold
;;        :underline nil
;;        ))
;;  'face-defface-spec
;;  )

;; (facep 'myshellface)
;; (boundp 'myshellface)
;; (remove-hook 'shell-mode-hook
;; (lambda ()
;;   (face-remap-add-relative 'default 'myshellface)))

(setq shell-mode-hook nil)
(add-hook 'shell-mode-hook
          (lambda ()
            (face-remap-add-relative 'default 'myshellface)))

;;;;;;;;;;;;;;;;;;;;;;;; END .emacs CODE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Cheers,



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

* Re: Different background color for different windows/modes
  2017-07-23 13:53 ` Alexandre Oberlin
@ 2017-07-23 17:10   ` Emanuel Berg
  0 siblings, 0 replies; 5+ messages in thread
From: Emanuel Berg @ 2017-07-23 17:10 UTC (permalink / raw)
  To: help-gnu-emacs

Alexandre Oberlin wrote:

> Someone gave me a hint to do this in Emacs
> 24.4+ but I don't find the message on
> gnu.emacs.help (Is this NG dying?).

Usenet has been dying for a very long time.
Many once hugely populated groups are
completely quiet or consists only of senior
citizens telling their tales and reliving their
memories, not caring much what the topic of the
group is. They still have the knowledge tho so
it can be useful to ask questions. And not just
for the 1975 answer.

Are you getting gnu.emacs.help from aioe.org?
Well, the newsgroup is operational.

Last time I heard, the mailing list had a small
program attached that posted all incomings to
gnu.emacs.help, and reposted newsgroup posts as
mails - I suppose? - however that seemed not to
have ever worked perfectly, and now, it seems
it is left adrift even more so...

But there is no real reason to use
gnu.emacs.help anymore. If you want the mailing
list material but with the superior Usenet
common interface and organization, you can use
gmane.emacs.help - this is the hole purpose of
Gmane, to enable us to use mailing lists
as newsgroups.

Which is much better. Many people realize this,
while others are in denial.

Gmane is the best of both world, the
on-topicness of mailing lists, and the interface
and organization of Usenet. That's why I call
Gmane "Usenet 2.0" or "Usenet Reloaded".

Sadly, it is only partly true. Because what it
isn't, and never will be (why?), is the
computer culture, the Might and Magic world
that was old Usenet, with heroes, villains,
techno-wizards, and jesters - fuds that lasted
decades and discussions about virtually
*anything* - a whole superstructure of HUMANS
on top of the technology. Now there's only
technology left.

Where are the humans? H-e-l-l-o-o? Can anyone
read this?!

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-29 10:45 Different background color for different windows/modes Alexandre Oberlin
2017-06-29 11:24 ` Emanuel Berg
2017-06-29 11:40 ` tomas
2017-07-23 13:53 ` Alexandre Oberlin
2017-07-23 17:10   ` Emanuel Berg

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