* Hook for "buffer switched"
@ 2010-12-14 13:14 Deniz Dogan
2010-12-14 13:18 ` Leo
0 siblings, 1 reply; 9+ messages in thread
From: Deniz Dogan @ 2010-12-14 13:14 UTC (permalink / raw)
To: help-gnu-emacs
Is there any hook that is run when a buffer is switched? If not, why not?
I'm really trying to avoid defadvice here.
--
Deniz Dogan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hook for "buffer switched"
2010-12-14 13:14 Hook for "buffer switched" Deniz Dogan
@ 2010-12-14 13:18 ` Leo
0 siblings, 0 replies; 9+ messages in thread
From: Leo @ 2010-12-14 13:18 UTC (permalink / raw)
To: help-gnu-emacs
On 2010-12-14 13:14 +0000, Deniz Dogan wrote:
> Is there any hook that is run when a buffer is switched? If not, why not?
>
> I'm really trying to avoid defadvice here.
window-configuration-change-hook
Leo
--
Oracle is the new evil
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hook for "buffer switched"
[not found] <mailman.1.1292332531.794.help-gnu-emacs@gnu.org>
@ 2010-12-15 5:07 ` Stefan Monnier
2010-12-15 9:02 ` Elena
0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2010-12-15 5:07 UTC (permalink / raw)
To: help-gnu-emacs
> Is there any hook that is run when a buffer is switched?
I think generally the answer is "no", tho this question is ill-formed:
it's not clear what you mean by switching buffer: do you mean "change
the currently active buffer" (i.e. what is done by `set-buffer'), or
"change the buffer displayed in the current window", or "select
a different window showing a different buffer", or ...
> If not, why not?
Maybe because to a large extent it's an ill-defined problem and once
they try to define it better, people seem to end up deciding they don't
really need to solve it any more?
E.g. often the original problem of the OP becomes simply unsolvable in
the general context, such as when a buffer is displayed in several
windows at the same time.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hook for "buffer switched"
2010-12-15 5:07 ` Stefan Monnier
@ 2010-12-15 9:02 ` Elena
2010-12-15 10:22 ` Deniz Dogan
2010-12-15 15:48 ` Stefan Monnier
0 siblings, 2 replies; 9+ messages in thread
From: Elena @ 2010-12-15 9:02 UTC (permalink / raw)
To: help-gnu-emacs
On Dec 15, 5:07 am, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> > Is there any hook that is run when a buffer is switched?
>
> I think generally the answer is "no", tho this question is ill-formed:
> it's not clear what you mean by switching buffer: do you mean "change
> the currently active buffer" (i.e. what is done by `set-buffer'), or
> "change the buffer displayed in the current window", or "select
> a different window showing a different buffer", or ...
I would like to be able to handle the "change
the currently active buffer" case.
> > If not, why not?
>
> Maybe because to a large extent it's an ill-defined problem and once
> they try to define it better, people seem to end up deciding they don't
> really need to solve it any more?
Or maybe because they are not able to solve it reliably. For
instance, I'd like Viper state to be global instead of buffer-local.
For this to work, I would have to know whenever the current active
buffer changes and switch Viper state when needed. Or I could just
prefer always switching to Normal state whenever I switch buffer.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hook for "buffer switched"
2010-12-15 9:02 ` Elena
@ 2010-12-15 10:22 ` Deniz Dogan
2010-12-15 10:33 ` egarrulo
2010-12-15 15:40 ` Peter Dyballa
2010-12-15 15:48 ` Stefan Monnier
1 sibling, 2 replies; 9+ messages in thread
From: Deniz Dogan @ 2010-12-15 10:22 UTC (permalink / raw)
To: Elena; +Cc: help-gnu-emacs
2010/12/15 Elena <egarrulo@gmail.com>:
> On Dec 15, 5:07 am, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
>> > Is there any hook that is run when a buffer is switched?
>>
>> I think generally the answer is "no", tho this question is ill-formed:
>> it's not clear what you mean by switching buffer: do you mean "change
>> the currently active buffer" (i.e. what is done by `set-buffer'), or
>> "change the buffer displayed in the current window", or "select
>> a different window showing a different buffer", or ...
>
> I would like to be able to handle the "change
> the currently active buffer" case.
>
>
>> > If not, why not?
>>
>> Maybe because to a large extent it's an ill-defined problem and once
>> they try to define it better, people seem to end up deciding they don't
>> really need to solve it any more?
>
> Or maybe because they are not able to solve it reliably. For
> instance, I'd like Viper state to be global instead of buffer-local.
> For this to work, I would have to know whenever the current active
> buffer changes and switch Viper state when needed. Or I could just
> prefer always switching to Normal state whenever I switch buffer.
>
How come I never received Stefan's e-mail?
--
Deniz Dogan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hook for "buffer switched"
2010-12-15 10:22 ` Deniz Dogan
@ 2010-12-15 10:33 ` egarrulo
2010-12-15 10:49 ` Deniz Dogan
2010-12-15 15:40 ` Peter Dyballa
1 sibling, 1 reply; 9+ messages in thread
From: egarrulo @ 2010-12-15 10:33 UTC (permalink / raw)
To: Deniz Dogan; +Cc: help-gnu-emacs
2010/12/15 Deniz Dogan <deniz.a.m.dogan@gmail.com>:
> 2010/12/15 Elena <egarrulo@gmail.com>:
>> On Dec 15, 5:07 am, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
>>> > Is there any hook that is run when a buffer is switched?
>>>
>>> I think generally the answer is "no", tho this question is ill-formed:
>>> it's not clear what you mean by switching buffer: do you mean "change
>>> the currently active buffer" (i.e. what is done by `set-buffer'), or
>>> "change the buffer displayed in the current window", or "select
>>> a different window showing a different buffer", or ...
>>
>> I would like to be able to handle the "change
>> the currently active buffer" case.
>>
>>
>>> > If not, why not?
>>>
>>> Maybe because to a large extent it's an ill-defined problem and once
>>> they try to define it better, people seem to end up deciding they don't
>>> really need to solve it any more?
>>
>> Or maybe because they are not able to solve it reliably. For
>> instance, I'd like Viper state to be global instead of buffer-local.
>> For this to work, I would have to know whenever the current active
>> buffer changes and switch Viper state when needed. Or I could just
>> prefer always switching to Normal state whenever I switch buffer.
>>
>
> How come I never received Stefan's e-mail?
>
> --
> Deniz Dogan
>
It seems there is some overlapping between help-gnu-emacs@gnu.org and
gnu.emacs.help.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hook for "buffer switched"
2010-12-15 10:33 ` egarrulo
@ 2010-12-15 10:49 ` Deniz Dogan
0 siblings, 0 replies; 9+ messages in thread
From: Deniz Dogan @ 2010-12-15 10:49 UTC (permalink / raw)
To: egarrulo; +Cc: help-gnu-emacs
2010/12/15 egarrulo <egarrulo@gmail.com>:
> It seems there is some overlapping between help-gnu-emacs@gnu.org and
> gnu.emacs.help.
>
How annoying.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hook for "buffer switched"
2010-12-15 10:22 ` Deniz Dogan
2010-12-15 10:33 ` egarrulo
@ 2010-12-15 15:40 ` Peter Dyballa
1 sibling, 0 replies; 9+ messages in thread
From: Peter Dyballa @ 2010-12-15 15:40 UTC (permalink / raw)
To: Deniz Dogan; +Cc: help-gnu-emacs, Elena
Am 15.12.2010 um 11:22 schrieb Deniz Dogan:
> How come I never received Stefan's e-mail?
Caching eMail server? Maybe you'll receive it next easter... (and
hopefully me too!)
--
Greetings
Pete
A morning without coffee is like something without something else.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hook for "buffer switched"
2010-12-15 9:02 ` Elena
2010-12-15 10:22 ` Deniz Dogan
@ 2010-12-15 15:48 ` Stefan Monnier
1 sibling, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2010-12-15 15:48 UTC (permalink / raw)
To: help-gnu-emacs
>> > Is there any hook that is run when a buffer is switched?
>> I think generally the answer is "no", tho this question is ill-formed:
>> it's not clear what you mean by switching buffer: do you mean "change
>> the currently active buffer" (i.e. what is done by `set-buffer'), or
>> "change the buffer displayed in the current window", or "select
>> a different window showing a different buffer", or ...
> I would like to be able to handle the "change
> the currently active buffer" case.
You do realize that this can happen a thousand times within a single
command, right? A lot of code does things like
(with-current-buffer some-other-buf
get-some-info-from-there)
which results in 2 changes of active buffer (once to some-other-buf and
another time to return to the previous buffer)?
It will also happen without any user action whenever Emacs receives
output from an "inferior process" (e.g. in *grep* or in *shell*, ...).
And it might do such a back&forth switch for every char received.
>> > If not, why not?
>> Maybe because to a large extent it's an ill-defined problem and once
>> they try to define it better, people seem to end up deciding they don't
>> really need to solve it any more?
> Or maybe because they are not able to solve it reliably. For
> instance, I'd like Viper state to be global instead of buffer-local.
> For this to work, I would have to know whenever the current active
> buffer changes and switch Viper state when needed. Or I could just
> prefer always switching to Normal state whenever I switch buffer.
[ I don't know Viper enough to understand what you intend to do, so
take the following with a grain of salt. ]
Then I think you don't really care about the active buffer (in the sense
of set-buffer), but only about "the buffer in the selected window when
Emacs is waiting for user input". So you can probably get what you want
via a post-command-hook that compares the current (window-buffer
(selected-window)) with the previous one.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-12-15 15:48 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-14 13:14 Hook for "buffer switched" Deniz Dogan
2010-12-14 13:18 ` Leo
[not found] <mailman.1.1292332531.794.help-gnu-emacs@gnu.org>
2010-12-15 5:07 ` Stefan Monnier
2010-12-15 9:02 ` Elena
2010-12-15 10:22 ` Deniz Dogan
2010-12-15 10:33 ` egarrulo
2010-12-15 10:49 ` Deniz Dogan
2010-12-15 15:40 ` Peter Dyballa
2010-12-15 15:48 ` Stefan Monnier
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.