unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* HowTo: Run a hook when a buffer becomes "current"
@ 2015-12-16 16:37 raman
  2015-12-16 21:51 ` Nicolas Richard
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: raman @ 2015-12-16 16:37 UTC (permalink / raw)
  To: emacs-devel

I was looking for a way of running a function  when a buffer becomes
"current". I cant find any hooks in Emacs -- the closest is
buffer-list-update-hook -- but that gets called way too often including
when a buffer is buried, is visited transiently from within lisp code
etc.

Is there a hook that I'm missing, or  is advice the only fallback I have?
-- 



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-16 16:37 HowTo: Run a hook when a buffer becomes "current" raman
@ 2015-12-16 21:51 ` Nicolas Richard
  2015-12-16 23:04   ` David Kastrup
  2015-12-17  4:58 ` Richard Stallman
  2015-12-18  1:56 ` Karl Fogel
  2 siblings, 1 reply; 24+ messages in thread
From: Nicolas Richard @ 2015-12-16 21:51 UTC (permalink / raw)
  To: raman; +Cc: emacs-devel

raman <raman@google.com> writes:

> I was looking for a way of running a function  when a buffer becomes
> "current". I cant find any hooks in Emacs -- the closest is
> buffer-list-update-hook -- but that gets called way too often including
> when a buffer is buried, is visited transiently from within lisp code
> etc.

I think you're after window-configuration-change-hook, see
(info "(elisp) Window Hooks")

-- 
Nicolas



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-16 21:51 ` Nicolas Richard
@ 2015-12-16 23:04   ` David Kastrup
  2015-12-16 23:20     ` T.V Raman
  0 siblings, 1 reply; 24+ messages in thread
From: David Kastrup @ 2015-12-16 23:04 UTC (permalink / raw)
  To: Nicolas Richard; +Cc: emacs-devel, raman

Nicolas Richard <nrichard@ulb.ac.be> writes:

> raman <raman@google.com> writes:
>
>> I was looking for a way of running a function when a buffer becomes
>> "current". I cant find any hooks in Emacs -- the closest is
>> buffer-list-update-hook -- but that gets called way too often
>> including when a buffer is buried, is visited transiently from within
>> lisp code etc.
>
> I think you're after window-configuration-change-hook, see
> (info "(elisp) Window Hooks")

That would be for "selected", not "current".

-- 
David Kastrup



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-16 23:04   ` David Kastrup
@ 2015-12-16 23:20     ` T.V Raman
  0 siblings, 0 replies; 24+ messages in thread
From: T.V Raman @ 2015-12-16 23:20 UTC (permalink / raw)
  To: dak; +Cc: emacs-devel, nrichard, raman

For now, the only solution I've found is to advice select-window.

Interestingly, the documentation for select-window points you at
buffer-list-update-hook -- but it's likely that that hook's usage has
diverged since that documentation for select-window was written;  for
fun I tried this:

(defvar record nil)
(defun my-record-buffer () (push  (buffer-name)  record))
(add-hook 'buffer-list-update-hook #'my-record-buffer)

A single buffer switch causes a lot of things to get pushed there 

David Kastrup writes:
 > Nicolas Richard <nrichard@ulb.ac.be> writes:
 > 
 > > raman <raman@google.com> writes:
 > >
 > >> I was looking for a way of running a function when a buffer becomes
 > >> "current". I cant find any hooks in Emacs -- the closest is
 > >> buffer-list-update-hook -- but that gets called way too often
 > >> including when a buffer is buried, is visited transiently from within
 > >> lisp code etc.
 > >
 > > I think you're after window-configuration-change-hook, see
 > > (info "(elisp) Window Hooks")
 > 
 > That would be for "selected", not "current".
 > 
 > -- 
 > David Kastrup

-- 

-- 



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-16 16:37 HowTo: Run a hook when a buffer becomes "current" raman
  2015-12-16 21:51 ` Nicolas Richard
@ 2015-12-17  4:58 ` Richard Stallman
  2015-12-17 16:15   ` raman
  2015-12-18  1:56 ` Karl Fogel
  2 siblings, 1 reply; 24+ messages in thread
From: Richard Stallman @ 2015-12-17  4:58 UTC (permalink / raw)
  To: raman; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I was looking for a way of running a function  when a buffer becomes
  > "current". I cant find any hooks in Emacs -- the closest is
  > buffer-list-update-hook -- but that gets called way too often including
  > when a buffer is buried, is visited transiently from within lisp code
  > etc.

This is one of the hooks I decided we should not have.  If changing
the current buffer, with set-buffer for instance, can affect execution
of code, you'll never be able to debug code when that hook is in use.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.




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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-17  4:58 ` Richard Stallman
@ 2015-12-17 16:15   ` raman
  2015-12-18  4:04     ` Richard Stallman
  0 siblings, 1 reply; 24+ messages in thread
From: raman @ 2015-12-17 16:15 UTC (permalink / raw)
  To: Richard Stallman; +Cc: emacs-devel

I specifically want to run a function when a function becomes current
and interactable by the user -- agreed that I dont want to run code in
the case of set-buffer. For now, an after advice on select-window does
nicely -- a select-window-hook would obviate the need for that advice 
-- 



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-16 16:37 HowTo: Run a hook when a buffer becomes "current" raman
  2015-12-16 21:51 ` Nicolas Richard
  2015-12-17  4:58 ` Richard Stallman
@ 2015-12-18  1:56 ` Karl Fogel
  2015-12-18  3:19   ` raman
  2 siblings, 1 reply; 24+ messages in thread
From: Karl Fogel @ 2015-12-18  1:56 UTC (permalink / raw)
  To: raman; +Cc: emacs-devel

raman <raman@google.com> writes:
>I was looking for a way of running a function  when a buffer becomes
>"current". I cant find any hooks in Emacs -- the closest is
>buffer-list-update-hook -- but that gets called way too often including
>when a buffer is buried, is visited transiently from within lisp code
>etc.
>
>Is there a hook that I'm missing, or  is advice the only fallback I have?

I'm curious what your larger goal is?

(Would want to know that before suggesting `select-buffer-hook' be created :-) ...)



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-18  1:56 ` Karl Fogel
@ 2015-12-18  3:19   ` raman
  2015-12-18 12:14     ` Marcin Borkowski
  0 siblings, 1 reply; 24+ messages in thread
From: raman @ 2015-12-18  3:19 UTC (permalink / raw)
  To: Karl Fogel; +Cc: emacs-devel

Hi Karl,
(good to hear from you:-))

 Thanks for the note.

I was implementing myself a new feature in  Emacspeak, though if it
works out it's not Emacspeak specific.

It's still WIP, so take it with a grain of salt -- 

1 line summary:

Adding "Soundscapes" -- quiet ambient  nature sounds, that  play in the
background, and change based on what I'm doing -- eg programming vs
communicating vs writing.

Take a look at the docs here 
http://tvraman.github.io/emacspeak/manual/soundscape.html#soundscape

--raman 

-- 



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-17 16:15   ` raman
@ 2015-12-18  4:04     ` Richard Stallman
  2015-12-18  4:20       ` raman
  0 siblings, 1 reply; 24+ messages in thread
From: Richard Stallman @ 2015-12-18  4:04 UTC (permalink / raw)
  To: raman; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I specifically want to run a function when a function becomes current
  > and interactable by the user -- agreed that I dont want to run code in
  > the case of set-buffer. For now, an after advice on select-window does
  > nicely -- a select-window-hook would obviate the need for that advice 

That too will cause trouble for debugging.  I think it is better
for interfaces to simply operate on whatever buffer you're typing at.

What would you like to use select-window-hook to do?  Let's look for
some way to achieve the ultimate goal.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.




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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-18  4:04     ` Richard Stallman
@ 2015-12-18  4:20       ` raman
  2015-12-18  9:30         ` David Kastrup
                           ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: raman @ 2015-12-18  4:20 UTC (permalink / raw)
  To: Richard Stallman; +Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:
I just sent a short follow-up to Karl's note, but here is a more
detailed explanation.


I'm implementing  myself something I'm calling "SoundScapes" --I'm
building it within  Emacspeak but it may well be useful more generally.

I got tired of having to listen to text-to-speech all day long and
wanted to see if having soft nature sounds in the background helped.

I didn't want to get distracted from what I'm working on by having to
select music that plays in the background  etc -- and I discovered this
package http://boodler.org -- that lets me play a variety of soft nature
sounds in the  background.

so i  wrote myself  module soundscape.el 
Code: github.io/tvraman/emacspeak (lisp/soundscape.el) -- docs are here:
http://tvraman.github.io/emacspeak/manual/soundscape.html

I divided the types of things I do  into categories:
(things I do == things I do in Emacs since I dont use anything else)

Communicate: mail, gnus, twitter, jabber  etc 
Program (prog-mode covers them all)
text-mode (write content)
special-mode: applications written in Emacs 
web: eww, w3

Then I created a mapping from modes to soundscapes (think mode -> mood) 
and finally, i  attached myself to select-mode-hook to switch the
soundscape that is playing. 

My first attempt at doing this failed badly -- I tried attaching myself
to buffer-list-update-hook -- it fails because that hook gets called way
too often.

I'm not wedded to the advice on select-window;
-- all  I want is to be able to attach my soundscape-update-hook to
the right point in Emacs so that when a buffer becomes current, the set
of playing SoundScapes automatically change (both killing off
soundscapes that are now irrelevant vs starting ones that are now
relevant per the context.

--Raman 
any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > I specifically want to run a function when a function becomes current
>   > and interactable by the user -- agreed that I dont want to run code in
>   > the case of set-buffer. For now, an after advice on select-window does
>   > nicely -- a select-window-hook would obviate the need for that advice 
>
> That too will cause trouble for debugging.  I think it is better
> for interfaces to simply operate on whatever buffer you're typing at.
>
> What would you like to use select-window-hook to do?  Let's look for
> some way to achieve the ultimate goal.

-- 



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-18  4:20       ` raman
@ 2015-12-18  9:30         ` David Kastrup
  2015-12-18 16:15           ` raman
  2015-12-19  4:37         ` Richard Stallman
  2015-12-22 17:47         ` John Wiegley
  2 siblings, 1 reply; 24+ messages in thread
From: David Kastrup @ 2015-12-18  9:30 UTC (permalink / raw)
  To: raman; +Cc: Richard Stallman, emacs-devel

raman <raman@google.com> writes:

> I divided the types of things I do  into categories:
> (things I do == things I do in Emacs since I dont use anything else)
>
> Communicate: mail, gnus, twitter, jabber  etc 
> Program (prog-mode covers them all)
> text-mode (write content)
> special-mode: applications written in Emacs 
> web: eww, w3
>
> Then I created a mapping from modes to soundscapes (think mode -> mood) 
> and finally, i  attached myself to select-mode-hook to switch the
> soundscape that is playing. 

Sounds to me as if you want to hook in the mode line update.  Which then
becomes more of a mood line update.

-- 
David Kastrup



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-18  3:19   ` raman
@ 2015-12-18 12:14     ` Marcin Borkowski
  2015-12-18 16:18       ` raman
  0 siblings, 1 reply; 24+ messages in thread
From: Marcin Borkowski @ 2015-12-18 12:14 UTC (permalink / raw)
  To: raman; +Cc: Karl Fogel, emacs-devel



On 2015-12-18, at 04:19, raman <raman@google.com> wrote:

> 1 line summary:
>
> Adding "Soundscapes" -- quiet ambient  nature sounds, that  play in the
> background, and change based on what I'm doing -- eg programming vs
> communicating vs writing.

Raman, that sounds really, really cool!

Will it be possible to install e.g. Emms' playlists as soundscapes?

> Take a look at the docs here 
> http://tvraman.github.io/emacspeak/manual/soundscape.html#soundscape
>
> --raman 

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-18  9:30         ` David Kastrup
@ 2015-12-18 16:15           ` raman
  0 siblings, 0 replies; 24+ messages in thread
From: raman @ 2015-12-18 16:15 UTC (permalink / raw)
  To: David Kastrup; +Cc: Richard Stallman, emacs-devel

David Kastrup <dak@gnu.org> writes:

mode-line-update ->mood-line-update:-)

Eventually I think that is correct if this whole thing actually and
proves useful in the sense:

For someone who can see the screen and configures emacs window layout to
reflect the current activity, the mood is best computed from the set of
visible windows/frames -- and there, latching on to mode-line might be
the right thing. For now I 'm keeping it simple by only looking at the
current buffer -- 
>
>> I divided the types of things I do  into categories:
>> (things I do == things I do in Emacs since I dont use anything else)
>>
>> Communicate: mail, gnus, twitter, jabber  etc 
>> Program (prog-mode covers them all)
>> text-mode (write content)
>> special-mode: applications written in Emacs 
>> web: eww, w3
>>
>> Then I created a mapping from modes to soundscapes (think mode -> mood) 
>> and finally, i  attached myself to select-mode-hook to switch the
>> soundscape that is playing. 
>
> Sounds to me as if you want to hook in the mode line update.  Which then
> becomes more of a mood line update.

-- 



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-18 12:14     ` Marcin Borkowski
@ 2015-12-18 16:18       ` raman
  2015-12-18 17:06         ` David Kastrup
  0 siblings, 1 reply; 24+ messages in thread
From: raman @ 2015-12-18 16:18 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Karl Fogel, emacs-devel

Marcin Borkowski <mbork@mbork.pl> writes:
Re installing emms playlists as soundscapes -- I dont see why not --
take a look at the code -- should be easy to do.

One reason I eventually landed on randomly repeating nature sounds: With
music playlists, streaming radio etc -- the media that is playing
changes  without being in lock-step with what you're doing.

My intuition (completely unproven at this point) is that such switches
were actually preventing me from focusing fully on my current
activity -- and where I was fully focused, the change in music as the
result of one track ending and another starting actually took my focus
away.

The reason I built this prototype where those changes are in lock-step
with my own activity changes wer   specifically to mitigate that.
That said, this is all still conjecture that will either be proven or
disproven by usage over time.

emacspeak/lisp/soundscape.el should be runnable in vanilla Emacs -- let
me know if you happen to try it and hit any issues 

> On 2015-12-18, at 04:19, raman <raman@google.com> wrote:
>
>> 1 line summary:
>>
>> Adding "Soundscapes" -- quiet ambient  nature sounds, that  play in the
>> background, and change based on what I'm doing -- eg programming vs
>> communicating vs writing.
>
> Raman, that sounds really, really cool!
>
> Will it be possible to install e.g. Emms' playlists as soundscapes?
>
>> Take a look at the docs here 
>> http://tvraman.github.io/emacspeak/manual/soundscape.html#soundscape
>>
>> --raman 
>
> Best,

-- 



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-18 16:18       ` raman
@ 2015-12-18 17:06         ` David Kastrup
  2015-12-18 18:13           ` Marcin Borkowski
  0 siblings, 1 reply; 24+ messages in thread
From: David Kastrup @ 2015-12-18 17:06 UTC (permalink / raw)
  To: raman; +Cc: Karl Fogel, emacs-devel

raman <raman@google.com> writes:

> Marcin Borkowski <mbork@mbork.pl> writes:
> Re installing emms playlists as soundscapes -- I dont see why not --
> take a look at the code -- should be easy to do.
>
> One reason I eventually landed on randomly repeating nature sounds: With
> music playlists, streaming radio etc -- the media that is playing
> changes  without being in lock-step with what you're doing.
>
> My intuition (completely unproven at this point) is that such switches
> were actually preventing me from focusing fully on my current
> activity -- and where I was fully focused, the change in music as the
> result of one track ending and another starting actually took my focus
> away.

Well, I'm a musician in some reasonable sense of the word.  Any music is
distracting me from programming.  And the better, the worse.

-- 
David Kastrup



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-18 17:06         ` David Kastrup
@ 2015-12-18 18:13           ` Marcin Borkowski
  2015-12-18 18:28             ` T.V Raman
  0 siblings, 1 reply; 24+ messages in thread
From: Marcin Borkowski @ 2015-12-18 18:13 UTC (permalink / raw)
  To: David Kastrup; +Cc: Karl Fogel, emacs-devel, raman



On 2015-12-18, at 18:06, David Kastrup <dak@gnu.org> wrote:

> raman <raman@google.com> writes:
>
>> Marcin Borkowski <mbork@mbork.pl> writes:
>> Re installing emms playlists as soundscapes -- I dont see why not --
>> take a look at the code -- should be easy to do.
>>
>> One reason I eventually landed on randomly repeating nature sounds: With
>> music playlists, streaming radio etc -- the media that is playing
>> changes  without being in lock-step with what you're doing.
>>
>> My intuition (completely unproven at this point) is that such switches
>> were actually preventing me from focusing fully on my current
>> activity -- and where I was fully focused, the change in music as the
>> result of one track ending and another starting actually took my focus
>> away.
>
> Well, I'm a musician in some reasonable sense of the word.  Any music is
> distracting me from programming.  And the better, the worse.

Interesting.

My subjective feeling is that some music distracts me more: namely,
vocal more than instrumental, and unknown more than known.

I also did some measurements (a long time ago), and it turned out that
music and learning did not go well together.

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-18 18:13           ` Marcin Borkowski
@ 2015-12-18 18:28             ` T.V Raman
  2015-12-18 20:12               ` Drew Adams
  0 siblings, 1 reply; 24+ messages in thread
From: T.V Raman @ 2015-12-18 18:28 UTC (permalink / raw)
  To: mbork; +Cc: kfogel, dak, emacs-devel, raman

In general, soft nature sounds eg light-rain, soft waves, wind -- that
repeat  in a pseudo-random pattern appear to work well in this regard
-- the repetition actually appears to aid in concentration. Anyway,
try out boodler.org -- it's a python package and is fun to play with.

Marcin Borkowski writes:
 > 
 > 
 > On 2015-12-18, at 18:06, David Kastrup <dak@gnu.org> wrote:
 > 
 > > raman <raman@google.com> writes:
 > >
 > >> Marcin Borkowski <mbork@mbork.pl> writes:
 > >> Re installing emms playlists as soundscapes -- I dont see why not --
 > >> take a look at the code -- should be easy to do.
 > >>
 > >> One reason I eventually landed on randomly repeating nature sounds: With
 > >> music playlists, streaming radio etc -- the media that is playing
 > >> changes  without being in lock-step with what you're doing.
 > >>
 > >> My intuition (completely unproven at this point) is that such switches
 > >> were actually preventing me from focusing fully on my current
 > >> activity -- and where I was fully focused, the change in music as the
 > >> result of one track ending and another starting actually took my focus
 > >> away.
 > >
 > > Well, I'm a musician in some reasonable sense of the word.  Any music is
 > > distracting me from programming.  And the better, the worse.
 > 
 > Interesting.
 > 
 > My subjective feeling is that some music distracts me more: namely,
 > vocal more than instrumental, and unknown more than known.
 > 
 > I also did some measurements (a long time ago), and it turned out that
 > music and learning did not go well together.
 > 
 > Best,
 > 
 > -- 
 > Marcin Borkowski
 > http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
 > Faculty of Mathematics and Computer Science
 > Adam Mickiewicz University

-- 

-- 



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

* RE: HowTo: Run a hook when a buffer becomes "current"
  2015-12-18 18:28             ` T.V Raman
@ 2015-12-18 20:12               ` Drew Adams
  0 siblings, 0 replies; 24+ messages in thread
From: Drew Adams @ 2015-12-18 20:12 UTC (permalink / raw)
  To: raman, mbork; +Cc: kfogel, dak, emacs-devel

Don't y'all think it might be time to move this to the tangents list?



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-18  4:20       ` raman
  2015-12-18  9:30         ` David Kastrup
@ 2015-12-19  4:37         ` Richard Stallman
  2015-12-19 16:43           ` raman
  2015-12-22 17:47         ` John Wiegley
  2 siblings, 1 reply; 24+ messages in thread
From: Richard Stallman @ 2015-12-19  4:37 UTC (permalink / raw)
  To: raman; +Cc: emacs-devel

You could arrange a timer to tell the soundscape program
once a second or so which buffer is selected.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.




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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-19  4:37         ` Richard Stallman
@ 2015-12-19 16:43           ` raman
  2015-12-19 17:07             ` Dmitry Gutov
  0 siblings, 1 reply; 24+ messages in thread
From: raman @ 2015-12-19 16:43 UTC (permalink / raw)
  To: Richard Stallman; +Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

Which would be far harder to debug :-)

--8<---------------cut here---------------start------------->8---

> You could arrange a timer to tell the soundscape program
> once a second or so which buffer is selected.
--8<---------------cut here---------------end--------------->8---

-- 



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-19 16:43           ` raman
@ 2015-12-19 17:07             ` Dmitry Gutov
  2015-12-20  3:07               ` raman
  0 siblings, 1 reply; 24+ messages in thread
From: Dmitry Gutov @ 2015-12-19 17:07 UTC (permalink / raw)
  To: raman, Richard Stallman; +Cc: emacs-devel

On 12/19/2015 06:43 PM, raman wrote:

> Which would be far harder to debug :-)

Not really. Timers are pretty easy to debug.



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-19 17:07             ` Dmitry Gutov
@ 2015-12-20  3:07               ` raman
  0 siblings, 0 replies; 24+ messages in thread
From: raman @ 2015-12-20  3:07 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Richard Stallman, emacs-devel

Dmitry Gutov <dgutov@yandex.ru> writes:


  
>
>> Which would be far harder to debug :-)
>
> Not really. Timers are pretty easy to debug.
>
So are hooks . And for that matter so is advice   -- given that you can easily activate, deactivate, enable or disable advice forms.> On 12/19/2015 06:43 PM, raman wrote:

-- 



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-18  4:20       ` raman
  2015-12-18  9:30         ` David Kastrup
  2015-12-19  4:37         ` Richard Stallman
@ 2015-12-22 17:47         ` John Wiegley
  2015-12-22 18:19           ` raman
  2 siblings, 1 reply; 24+ messages in thread
From: John Wiegley @ 2015-12-22 17:47 UTC (permalink / raw)
  To: raman; +Cc: Richard Stallman, emacs-devel

>>>>> raman  <raman@google.com> writes:

> I'm implementing myself something I'm calling "SoundScapes" --I'm building
> it within Emacspeak but it may well be useful more generally.

I really like the idea of soundscapes, Raman.

As a first approximation -- that is, before requiring a new hook to try out
the utility of your idea -- I'd recommend using a timer that checks the buffer
of the currently selected window is.

I doubt it's even desirable to change the music instantly whenever the buffer
changes; in some cases, that could become quite jarring. A timer not only
solves your problem quite simply, but allows for customization opportunities
like "cross-fading" after you know that the user has been in the new buffer
for X milliseconds. This would prevent quick Org capture buffers from
disrupting the music of my Gnus summary buffer, for example.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



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

* Re: HowTo: Run a hook when a buffer becomes "current"
  2015-12-22 17:47         ` John Wiegley
@ 2015-12-22 18:19           ` raman
  0 siblings, 0 replies; 24+ messages in thread
From: raman @ 2015-12-22 18:19 UTC (permalink / raw)
  To: Richard Stallman; +Cc: emacs-devel

John,

thanks for the  reply:-)

For now I've implemented  it with an advice on select-window --- and am
working on the Soundscapes themselves.

When I've made more progress, I'll write up what I learn re Emacs'
facilities for doing something like this -- email discussions tend to
drift after a while.

What I've learnt so far:

1. hook buffer-list-update-hook doesn't match its documentation --
2. select-window doc-string recommends the above hook and likely needs
to be updated 

Re fading in and out rather than abruptly switching:

My first "get it working" idea killed and started new processes when
switching.

Next I tried stop-process which turns out be disfunctional on Linux --
so I'm now writing myself a more sophisticated Boodler Agent that
handles the fade-in/fade-out.

Anyway it's proving a fun holiday hack:-)
-- 



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

end of thread, other threads:[~2015-12-22 18:19 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-16 16:37 HowTo: Run a hook when a buffer becomes "current" raman
2015-12-16 21:51 ` Nicolas Richard
2015-12-16 23:04   ` David Kastrup
2015-12-16 23:20     ` T.V Raman
2015-12-17  4:58 ` Richard Stallman
2015-12-17 16:15   ` raman
2015-12-18  4:04     ` Richard Stallman
2015-12-18  4:20       ` raman
2015-12-18  9:30         ` David Kastrup
2015-12-18 16:15           ` raman
2015-12-19  4:37         ` Richard Stallman
2015-12-19 16:43           ` raman
2015-12-19 17:07             ` Dmitry Gutov
2015-12-20  3:07               ` raman
2015-12-22 17:47         ` John Wiegley
2015-12-22 18:19           ` raman
2015-12-18  1:56 ` Karl Fogel
2015-12-18  3:19   ` raman
2015-12-18 12:14     ` Marcin Borkowski
2015-12-18 16:18       ` raman
2015-12-18 17:06         ` David Kastrup
2015-12-18 18:13           ` Marcin Borkowski
2015-12-18 18:28             ` T.V Raman
2015-12-18 20:12               ` Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).