From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: raman Newsgroups: gmane.emacs.devel Subject: Re: HowTo: Run a hook when a buffer becomes "current" Date: Thu, 17 Dec 2015 20:20:08 -0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1450412453 11772 80.91.229.3 (18 Dec 2015 04:20:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Dec 2015 04:20:53 +0000 (UTC) Cc: emacs-devel@gnu.org To: Richard Stallman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 18 05:20:45 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a9mX6-0003s2-2m for ged-emacs-devel@m.gmane.org; Fri, 18 Dec 2015 05:20:44 +0100 Original-Received: from localhost ([::1]:58333 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9mX5-0006Xl-35 for ged-emacs-devel@m.gmane.org; Thu, 17 Dec 2015 23:20:43 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9mWj-0006WV-GG for emacs-devel@gnu.org; Thu, 17 Dec 2015 23:20:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9mWf-0004lu-H7 for emacs-devel@gnu.org; Thu, 17 Dec 2015 23:20:21 -0500 Original-Received: from mail-pa0-x232.google.com ([2607:f8b0:400e:c03::232]:34059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9mWf-0004k4-BO for emacs-devel@gnu.org; Thu, 17 Dec 2015 23:20:17 -0500 Original-Received: by mail-pa0-x232.google.com with SMTP id wq6so53675051pac.1 for ; Thu, 17 Dec 2015 20:20:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=Av3eGwNj1P9qLYipry8lehzorHP670cfEmg8X7b+vTM=; b=Z20syZEmM1HR4+LfzR2shz5f5Meu8osRJXIiJFuSpq706BLWN8TaKiD1M1EVl69ETv jCA3cBZdeso8uh79/zjTtnaUbmiWppREJ+pHOnwW7Ocd/+ql5AMcFbJvBJ8qCHlHgfn6 VmLPAB4dAzN+6+8F2ij1GqP6cASIvm9l1Plw9fXZ4UuyA37sqRoMCyLSGxCRiHx/MoFN NZzG0CwTX7sG/Rh4uj9z5Tf7HoDSl2pcQKMj1erDShF98Hiy5DzcRsBOeSdUKV2jHg3j AxKKnDsXpWU+B0bgP9UF1XMRU1qkvR+slVtdObYd9/+RAUoFeVY65djiK95T4Iku8O11 AwSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=Av3eGwNj1P9qLYipry8lehzorHP670cfEmg8X7b+vTM=; b=fBAdrcH1IR0+j0eHilyUxpAIgdIG++lslNFnQsgmrwDWFRkqbB1BXwEt+aY+3ha/YY Kw73FHasO9G4E+VGDd6H4ZEFiZJ940TvQjHphB3E/d0vih4GjBF6+iq758Cth5BUyTGt prAC8p85iGImPiARGF38px1ckfeRSLtDXo2pdNbylI3gYRUS9YWVFHF9l06ju2bVf7Fl 4i8CnhIq6uFxMDRvbOq30mM/3uGLd3T/FuZmxtfViR4fMIo/boI/JrUlKDODqjfeoQxM a3ZCQDHqwmqTq+SY1klulgtzVP/8lpEsXT+FZhoPw6Fy9iWUkC62QatVUJD5GuudaqU5 UCTg== X-Gm-Message-State: ALoCoQl+2xyMetofBCqJTFqI+n5f5CPjeZ/9eQJSultMxPMr332BpkKPwpie4YPqMBWaIkowaRoaCOYcOYzKcB/nXWVSq/kZAw== X-Received: by 10.66.120.200 with SMTP id le8mr2085899pab.61.1450412415540; Thu, 17 Dec 2015 20:20:15 -0800 (PST) Original-Received: from raman-glaptop2 (c-73-170-121-60.hsd1.ca.comcast.net. [73.170.121.60]) by smtp.gmail.com with ESMTPSA id o17sm14399757pfa.66.2015.12.17.20.20.11 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 17 Dec 2015 20:20:13 -0800 (PST) In-Reply-To: (Richard Stallman's message of "Thu, 17 Dec 2015 23:04:53 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::232 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:196448 Archived-At: Richard Stallman 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. --