all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alexandre Oberlin <alxobr@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Different background color for different windows/modes
Date: Sun, 23 Jul 2017 06:53:33 -0700 (PDT)	[thread overview]
Message-ID: <609841d6-4b1f-4aab-9bf6-5b3dc0cc4112@googlegroups.com> (raw)
In-Reply-To: <e2881894-3574-4c3b-8297-9b0e8660e056@googlegroups.com>

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,



  parent reply	other threads:[~2017-07-23 13:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2017-07-23 17:10   ` Emanuel Berg

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=609841d6-4b1f-4aab-9bf6-5b3dc0cc4112@googlegroups.com \
    --to=alxobr@gmail.com \
    --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.