help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detect window switches?


From: Joost Kremers
Subject: Re: Detect window switches?
Date: 26 Sep 2013 10:23:35 GMT
User-agent: slrn/pre1.0.0-18 (Linux)

Eli Zaretskii wrote:
>> From: Joost Kremers <joostkremers@yahoo.com>
>> Date: 26 Sep 2013 02:50:53 GMT
>> 
>> What I'd like to do is remove a highlight from a buffer or change its
>> appearance when said buffer is not current, and restore it when it
>> becomes current again. Similar to what happens to the cursor in a window
>> that is not selected.
>
> OK, but the requirements are still not clear.  First, what do you mean
> by "remove a highlight from a buffer", and what "change in its
> appearance" did you have in mind?

Sorry, I meant an overlay. So that would be (delete-overlay <overlay>)
or changing the face property of an overlay.

>  And second, what if the same buffer
> is displayed in more than one window?

In this particular case, that shouldn't happen and won't happen, unless
a user explicitly sets out to do so. If that happens, I'm confident that
Emacs won't crash. :-)

Long story long: I'm talking about a BibTeX database manager I maintain:

<http://ebib.sourceforge.net>

Best to look at the screen shot:

<http://ebib.sourceforge.net/images/Main-view.png>

I'm using two buffers, one to list all the entry keys in the database
and one to list the fields of the current entry. I use two overlays, one
in each buffer, to indicate which entry and which field is active. In
the screen shot, the top (index) buffer is active (look at the cursor
shape), and what I'd like to do is change or hide the overlay of the
bottom (entry) buffer in that case.

There are keys to switch from the index to the entry buffer and back
(`e' and `q', respectively), so a user normally doesn't use the standard
buffer switching commands to switch between them. In fact, if the kind
of hook I'm asking about doesn't exist, I'll use the commands to which
`e' and `q' are bound to change the overlay, I just thought that a hook
would be a bit more robust.[1]

>  Finally, why the differences in
> the mode-line appearance are not already what you want?

Well, as you can see in the screen shot, there are colour themes that
don't distinguish very clearly between the selected window and
non-selected ones. (This particular theme is zenburn, I think, which I'm
not using anymore, but my current theme, anti-zenburn, isn't much better
in this respect.) 

Joost



[1] In fact, these commands do a bit more than just switching to the
index/entry buffer, so a user really *shouldn't* be using the normal
buffer switching commands. If a buffer switch hook or a window select
hook would exist, I'd move the extra stuff to the hook functions as
well, so that normal buffer switching commands work properly.

-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]