[Top][All Lists]

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

Re: HowTo: Run a hook when a buffer becomes "current"

From: raman
Subject: Re: HowTo: Run a hook when a buffer becomes "current"
Date: Thu, 17 Dec 2015 20:20:08 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Richard Stallman <address@hidden> 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:

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.

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.


reply via email to

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