all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Highlighting current window
@ 2012-06-30 10:30 Francesco Mazzoli
  2012-06-30 18:23 ` Drew Adams
  0 siblings, 1 reply; 9+ messages in thread
From: Francesco Mazzoli @ 2012-06-30 10:30 UTC (permalink / raw)
  To: help-gnu-emacs

Hi list,

I was looking for ways to make the focused window clearer. The best
way would probably a slightly lighter background.

However, I couldn't find any hooks to easily do that. I was expecting
something along the lines of `window-leave-hook' and
`window-focus-hook' but I couldn't find anything similar.

The best suggestion that the IRC people came up with is to use
`post-command-hook' and match `switch-buffer', but that sounds a bit
ugly. Is there a better way?

--
Francesco * Often in error, never in doubt



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

* RE: Highlighting current window
  2012-06-30 10:30 Francesco Mazzoli
@ 2012-06-30 18:23 ` Drew Adams
  2012-06-30 19:30   ` Francesco Mazzoli
  0 siblings, 1 reply; 9+ messages in thread
From: Drew Adams @ 2012-06-30 18:23 UTC (permalink / raw)
  To: 'Francesco Mazzoli', 'help-gnu-emacs'

 
> I was looking for ways to make the focused window clearer. The best
> way would probably a slightly lighter background.
> 
> However, I couldn't find any hooks to easily do that. I was expecting
> something along the lines of `window-leave-hook' and
> `window-focus-hook' but I couldn't find anything similar.
> 
> The best suggestion that the IRC people came up with is to use
> `post-command-hook' and match `switch-buffer', but that sounds a bit
> ugly. Is there a better way?

Typically folks just look at the mode line to tell which window is selected.
Can you get by by customizing faces `mode-line' and `mode-line-inactive', making
the former something that stands out for you?




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

* Re: Highlighting current window
  2012-06-30 18:23 ` Drew Adams
@ 2012-06-30 19:30   ` Francesco Mazzoli
  2012-06-30 20:16     ` Christopher Grubert
  0 siblings, 1 reply; 9+ messages in thread
From: Francesco Mazzoli @ 2012-06-30 19:30 UTC (permalink / raw)
  To: 'help-gnu-emacs'

Hi Drew, thanks for your answer.

At Sat, 30 Jun 2012 11:23:50 -0700,
Drew Adams wrote:
> Typically folks just look at the mode line to tell which window is selected.
> Can you get by by customizing faces `mode-line' and `mode-line-inactive', making
> the former something that stands out for you?

Yes, I am aware of that. However I often find myself not being sure
about what is focused, so I think that some more visual aid would
help.

--
Francesco * Often in error, never in doubt



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

* Re: Highlighting current window
  2012-07-01  1:22       ` Drew Adams
@ 2012-07-01  1:48         ` Christopher Grubert
  0 siblings, 0 replies; 9+ messages in thread
From: Christopher Grubert @ 2012-07-01  1:48 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'help-gnu-emacs'

On 06/30/2012 09:22 PM, Drew Adams wrote:
>> I use ... the hl-line+ package which gives current line
>> highlighting but only in the active window....
>> I also use a fairly innocuous line highlighting color
>> (:background "#222") so that it doesn't really conflict...,
>> but still draws attention to where I am.  It draws your
>> attention to the exact line you're on as opposed to just
>> the window you're in, but I've found that useful.
> Thanks for mentioning hl-line+, Chris.  There is also crosshairs.el, which
> extends hl-line+ by adding a vertical line through point.  So it is easy to see
> where the cursor is (e.g. when you move your attention to another window).
> Typically you use the crosshairs display temporarily.
>
> http://www.emacswiki.org/emacs/CrosshairHighlighting
>
Yes, I use that as well.  I've found that it is slow to refresh and 
creates a flickering effect when typing so I have it bound to a function 
key and don't normally leave it turned on.  It is useful at times when 
you want to see where you are in relation to some location on another 
line (typically when setting up rectangular operations).  I didn't 
mention it here because I don't leave it on and use it to identify point 
like I do with hl-line which is what the OP was after, but yes, it's a 
nice complementary package.
Chris.



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

* Re: Highlighting current window
       [not found]       ` <mailman.3792.1341105740.855.help-gnu-emacs@gnu.org>
@ 2012-07-01  1:56         ` Michael Heerdegen
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Heerdegen @ 2012-07-01  1:56 UTC (permalink / raw)
  To: help-gnu-emacs

"Drew Adams" <drew.adams@oracle.com> writes:

> There is also crosshairs.el, which extends hl-line+ by adding a
> vertical line through point.  So it is easy to see where the cursor is
> (e.g. when you move your attention to another window).  Typically you
> use the crosshairs display temporarily.
>
> http://www.emacswiki.org/emacs/CrosshairHighlighting

This indeed works very well for this purpose.  You see which window is
selected, as well as the position of point in that window at the same
time.

I use a setup like the following (just as an example):


--8<---------------cut here---------------start------------->8---
(add-hook   ;flash selected window when changing window config
 'window-size-change-functions
 #'(lambda (_)
     (when
	 (memq last-command
	       '(split-window-vertically
		 split-window-horizontally
		 delete-window icicle-delete-window
		 delete-other-windows))
        (crosshairs-flash))))

(global-set-key [S-next]
		(lambda () (interactive)
		  (other-window  1) (crosshairs-flash)))
(global-set-key [S-prior]
		(lambda () (interactive)
--8<---------------cut here---------------end--------------->8---


Michael.



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

* Re: Highlighting current window
@ 2012-07-01  9:06 martin rudalics
  2012-07-04  1:20 ` Le Wang
  0 siblings, 1 reply; 9+ messages in thread
From: martin rudalics @ 2012-07-01  9:06 UTC (permalink / raw)
  To: f; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]

 > I was looking for ways to make the focused window clearer. The best
 > way would probably a slightly lighter background.
 >
 > However, I couldn't find any hooks to easily do that. I was expecting
 > something along the lines of `window-leave-hook' and
 > `window-focus-hook' but I couldn't find anything similar.
 >
 > The best suggestion that the IRC people came up with is to use
 > `post-command-hook' and match `switch-buffer',

What is `switch-buffer'?

 > but that sounds a bit
 > ugly. Is there a better way?

I don't think that using `post-command-hook' is a priori bad in this
case.  Doing it on a `window-leave-hook' or `window-focus-hook' would
mean you'd have to do that background setting whenever you leave a
window or change the focus, which can happen a couple of times during
one and the same command.  Obviously `post-command-hook' will fail when
the focus changes asynchronously but I think such cases should be rare.

I attach an old version which can run into a problem I forgot about.
There's a better way to provide whole-window overlays for Emacs 24.1 but
I didn't implement them yet.  If you use Emacs 24, I can look into this.

martin

[-- Attachment #2: hiselwin.el --]
[-- Type: application/emacs-lisp, Size: 1358 bytes --]

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

* Re: Highlighting current window
  2012-06-30 20:16     ` Christopher Grubert
  2012-07-01  1:22       ` Drew Adams
       [not found]       ` <mailman.3792.1341105740.855.help-gnu-emacs@gnu.org>
@ 2012-07-01 11:49       ` Francesco Mazzoli
  2 siblings, 0 replies; 9+ messages in thread
From: Francesco Mazzoli @ 2012-07-01 11:49 UTC (permalink / raw)
  To: cgrubert02, 'help-gnu-emacs'

Hi Christopher,
At Sat, 30 Jun 2012 16:16:21 -0400,
Christopher Grubert wrote:
> I use a combination of the three faces mode-line, mode-line-inactive, 
> mode-line-buffer-id and the hl-line+ package which gives current line 
> highlighting but only in the active window.  I've found this combination 
> to work pretty well for me.  I also use a fairly innocuous line 
> highlighting color (:background "#222") so that it doesn't really 
> conflict with any other fontification colors, but still draws attention 
> to where I am.  It draws your attention to the exact line you're on as 
> opposed to just the window you're in, but I've found that useful.
> Chris.

I looked at hl-line mode and it supports that functionality as well. I
looked at the source and the trick is using overlays. Knowing that, I
was able to do what I want quite quickly:

----------------8<-------------------------------

;;; Darker background for current buffer
(set-face-attribute 'default nil :background "#1e1e1e")
(set-cursor-color "#ffffff")

(defvar current-buffer-backround-overlay
  nil)

(defun darken-current-buffer-background ()
  (unless (window-minibuffer-p (selected-window))
    (unless current-buffer-backround-overlay
      (setq current-buffer-backround-overlay (make-overlay 1 1))
      (overlay-put current-buffer-backround-overlay 'face '(:background "black")))
    (overlay-put current-buffer-backround-overlay 'window
                 (selected-window))
    (move-overlay current-buffer-backround-overlay
                  (point-min) (point-max))))

(defun undarken-current-buffer-background ()
  (when darken-current-buffer-background
    (delete-overlay current-buffer-backround-overlay)))

(add-hook 'pre-command-hook #'undarken-current-buffer-background)
(add-hook 'post-command-hook #'darken-current-buffer-background)

---------------->8-------------------------------

However, I think that using hl-line might be an even better solution,
I'll try both a bit and see what I prefer.

--
Francesco * Often in error, never in doubt



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

* Re: Highlighting current window
  2012-07-01  9:06 Highlighting current window martin rudalics
@ 2012-07-04  1:20 ` Le Wang
  2012-07-04  9:18   ` martin rudalics
  0 siblings, 1 reply; 9+ messages in thread
From: Le Wang @ 2012-07-04  1:20 UTC (permalink / raw)
  To: martin rudalics; +Cc: f, help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 453 bytes --]

Martin,

Sorry about the last message which didn't cc the group.

On Sun, Jul 1, 2012 at 5:06 PM, martin rudalics <rudalics@gmx.at> wrote:

>
> I attach an old version which can run into a problem I forgot about.
> There's a better way to provide whole-window overlays for Emacs 24.1 but
> I didn't implement them yet.  If you use Emacs 24, I can look into this.
>
>
This seems cool.  Can you elaborate on the "better way" in 24?


> martin
>



-- 
Le

[-- Attachment #2: Type: text/html, Size: 1035 bytes --]

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

* Re: Highlighting current window
  2012-07-04  1:20 ` Le Wang
@ 2012-07-04  9:18   ` martin rudalics
  0 siblings, 0 replies; 9+ messages in thread
From: martin rudalics @ 2012-07-04  9:18 UTC (permalink / raw)
  To: Le Wang; +Cc: f, help-gnu-emacs

 > Can you elaborate on the "better way" in 24?

The basic problem we have to solve is how to extend the window
background to the entire window and not only to the last buffer
position.  That's inherently what the after-string property of the
hiselwin overlay accomplishes.

Emacs 24.1 offers a better solution following the discussion of

bug#11068: 24.0.94; Face-remapped background does not extend to end of window

which you can find here:

http://lists.gnu.org/archive/html/bug-gnu-emacs/2012-03/msg00569.html

The solution has one drawback wrt to highlighting the selected window:
When the same buffer appears in the selected window _and_ in another
window, that other window will be highlighted too.

The solution is similar to the one proposed by Francesco Mazzoli: Show
the overlay only in the current buffer and give it a 'window property to
show it only in the selected window.

martin



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

end of thread, other threads:[~2012-07-04  9:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-01  9:06 Highlighting current window martin rudalics
2012-07-04  1:20 ` Le Wang
2012-07-04  9:18   ` martin rudalics
  -- strict thread matches above, loose matches on Subject: below --
2012-06-30 10:30 Francesco Mazzoli
2012-06-30 18:23 ` Drew Adams
2012-06-30 19:30   ` Francesco Mazzoli
2012-06-30 20:16     ` Christopher Grubert
2012-07-01  1:22       ` Drew Adams
2012-07-01  1:48         ` Christopher Grubert
     [not found]       ` <mailman.3792.1341105740.855.help-gnu-emacs@gnu.org>
2012-07-01  1:56         ` Michael Heerdegen
2012-07-01 11:49       ` Francesco Mazzoli

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.