all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Distinguish inactive windows
@ 2011-06-24  0:52 Joe Riel
  2011-06-24  2:45 ` Alp Aker
  2011-06-24  2:51 ` Alp Aker
  0 siblings, 2 replies; 6+ messages in thread
From: Joe Riel @ 2011-06-24  0:52 UTC (permalink / raw)
  To: help-gnu-emacs

I'm creating an application where focus is in a particular Emacs
frame, call it the control panel.  Events in the control panel affect
a selected window in a separate frame.  How can the selected window be
visually distinguished from the other windows in its frame?  I'd like
to, say, set mode-line background of the selected window to a
particular color.  Using (set-face-background 'mode-line-inactive
"yellow") doesn't work because that changes the mode-line of all
inactive windows, not just the one desired.  Similarly, setting
mode-line doesn't work because the active window is in the control
panel, not the one that is being changed.

-- 
Joe Riel




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

* Re: Distinguish inactive windows
  2011-06-24  0:52 Distinguish inactive windows Joe Riel
@ 2011-06-24  2:45 ` Alp Aker
  2011-06-25  4:47   ` Joe Riel
  2011-06-24  2:51 ` Alp Aker
  1 sibling, 1 reply; 6+ messages in thread
From: Alp Aker @ 2011-06-24  2:45 UTC (permalink / raw)
  To: help-gnu-emacs

> How can the selected window be visually distinguished from the other
> windows in its frame?  I'd like to, say, set mode-line background of the
> selected window to a particular color.  

Is specifically a unique *window* whose mode-line you want to distinguish, or
would it suffice to change the mode-line for all windows displaying a
particular *buffer*?  If the former, you're out of luck; there's no way (that
I'm aware of) to do it.  If the latter, you can use the variable
`mode-line-format', which is buffer-local and which allows you to specify a
face.  E.g., 

  (setq mode-line-format `(:propertize ,mode-line-format face default))

will highlight (part of) the mode-line.  Unfortunately, to get the full
effect you're probably looking for, you'll have to dissect the mode-line
format construct and put the face properties you want on elements buried
several levels deep.  See the info node "(elisp) Mode Line Format" for the
details on how it works.  (Be forewarned that the API is rather
cumbersome.)

Another way to get a buffer-specific (rather that window-specific) effect is
to use `header-line-format', which, when given a non-nil value, will put a
line at the top of every window displaying the buffer, and whose appearance
is controlled by the face `header-line'.  (The format construct rules for
header lines are the same as for mode lines.  Two advantages header lines
might have for your purposes is that they're displayed the same whether the
window is selected or not, and they're only used by a few modes, so you can,
in most contexts, specify a simple header line you construct from scratch,
rather than, as you have to do with mode lines, modifying an existing--and 
non-trivial--construct.)

If what you need really is to highlight a specific window, you might consider
using the fringes or marginal display areas to indicate the window of
interest.  Those can be controlled on a per-window basis.  





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

* Re: Distinguish inactive windows
  2011-06-24  0:52 Distinguish inactive windows Joe Riel
  2011-06-24  2:45 ` Alp Aker
@ 2011-06-24  2:51 ` Alp Aker
  2011-06-24  5:38   ` Joe Riel
  1 sibling, 1 reply; 6+ messages in thread
From: Alp Aker @ 2011-06-24  2:51 UTC (permalink / raw)
  To: help-gnu-emacs

I just thought of another, potentially much simpler expedient, one which will
work for a particular window.  You can use an overlay to put a light shading
over the contents of the window.  E.g., 

  (setq o (make-overlay (window-start w) (window-end w t)))
  (overlay-put o 'face '(:background "gray97"))

where `w' is the window of interest.  





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

* Re: Distinguish inactive windows
  2011-06-24  2:51 ` Alp Aker
@ 2011-06-24  5:38   ` Joe Riel
  0 siblings, 0 replies; 6+ messages in thread
From: Joe Riel @ 2011-06-24  5:38 UTC (permalink / raw)
  To: help-gnu-emacs

On Fri, 24 Jun 2011 02:51:41 +0000 (UTC)
Alp Aker <alp.tekin.aker@gmail.com> wrote:

> I just thought of another, potentially much simpler expedient, one
> which will work for a particular window.  You can use an overlay to
> put a light shading over the contents of the window.  E.g., 
> 
>   (setq o (make-overlay (window-start w) (window-end w t)))
>   (overlay-put o 'face '(:background "gray97"))
> 
> where `w' is the window of interest.  

Thanks for both ideas, I'll see which I prefer.  I'm already
customizing the mode-line, but the overlay is simple to implement.

-- 
Joe Riel




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

* Re: Distinguish inactive windows
  2011-06-24  2:45 ` Alp Aker
@ 2011-06-25  4:47   ` Joe Riel
  2011-06-25 16:00     ` Alp Aker
  0 siblings, 1 reply; 6+ messages in thread
From: Joe Riel @ 2011-06-25  4:47 UTC (permalink / raw)
  To: Alp Aker; +Cc: help-gnu-emacs

On Fri, 24 Jun 2011 02:45:41 +0000 (UTC)
Alp Aker <alp.tekin.aker@gmail.com> wrote:

> > How can the selected window be visually distinguished from the other
> > windows in its frame?  I'd like to, say, set mode-line background
> > of the selected window to a particular color.  
> 
> Is specifically a unique *window* whose mode-line you want to
> distinguish, or would it suffice to change the mode-line for all
> windows displaying a particular *buffer*?  If the former, you're out
> of luck; there's no way (that I'm aware of) to do it.  If the latter,
> you can use the variable `mode-line-format', which is buffer-local
> and which allows you to specify a face.

It only has to be unique to a buffer.  Here's a simpler variant
on your scheme that does precisely what I want:

(make-local-variable 'face-remapping-alist)
(setq face-remapping-alist 
      '((mode-line-inactive :foreground "black" :background "yellow")))

Thanks again for the ideas, they helped.

Joe Riel



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

* Re: Distinguish inactive windows
  2011-06-25  4:47   ` Joe Riel
@ 2011-06-25 16:00     ` Alp Aker
  0 siblings, 0 replies; 6+ messages in thread
From: Alp Aker @ 2011-06-25 16:00 UTC (permalink / raw)
  To: help-gnu-emacs

Joe Riel <jriel@maplesoft.com> wrote:

> It only has to be unique to a buffer.  Here's a simpler variant on your
> scheme that does precisely what I want:
> 
> (make-local-variable 'face-remapping-alist)
> (setq face-remapping-alist
>      '((mode-line-inactive :foreground "black" :background "yellow")))
> 
> Thanks again for the ideas, they helped.

That's a nice solution, better than either of mine.  (Be aware that it's not
supported on v22, though.)





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

end of thread, other threads:[~2011-06-25 16:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-24  0:52 Distinguish inactive windows Joe Riel
2011-06-24  2:45 ` Alp Aker
2011-06-25  4:47   ` Joe Riel
2011-06-25 16:00     ` Alp Aker
2011-06-24  2:51 ` Alp Aker
2011-06-24  5:38   ` Joe Riel

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.