From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.help Subject: Re: how can I run commands when window displays a different buffer? Date: Sat, 28 Oct 2017 10:45:19 +0200 Message-ID: <59F4439F.60306@gmx.at> References: <59F32C2F.8020701@gmx.at> <87lgjw90k8.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1509180403 14019 195.159.176.226 (28 Oct 2017 08:46:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 28 Oct 2017 08:46:43 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Amos Bird Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 28 10:46:37 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e8MlC-00024k-Sa for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Oct 2017 10:46:31 +0200 Original-Received: from localhost ([::1]:60206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8MlI-0008Eh-KP for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Oct 2017 04:46:36 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8MkE-00080D-Mk for help-gnu-emacs@gnu.org; Sat, 28 Oct 2017 04:45:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8MkB-0007B4-L5 for help-gnu-emacs@gnu.org; Sat, 28 Oct 2017 04:45:30 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]:50368) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e8MkB-0007AK-B6 for help-gnu-emacs@gnu.org; Sat, 28 Oct 2017 04:45:27 -0400 Original-Received: from [192.168.1.100] ([46.125.250.27]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MOw4N-1e3i332SVr-006SdT; Sat, 28 Oct 2017 10:45:22 +0200 In-Reply-To: <87lgjw90k8.fsf@gmail.com> X-Provags-ID: V03:K0:7joSQV2B0QIfaWh40kc3Q0+vJeGPWSzhCGqYh9m7zAtPo+rezB8 Plh57z3ZiMUnJ2FMYhuSnOqw9l/ZyYKws5yXCgFk2oy1+ixNzHaFu2oGjpGVtT+2Ve8Gmvi tzvTfrhmB3huUkukXD8dhbPlGjfPlpde+adJrAjeYR1exbTFAivlle8dnI//jTcBFnMtc8W N6yxcMM52sVdnt34ONvgA== X-UI-Out-Filterresults: notjunk:1;V01:K0:0+ZD0zZITQw=:9g+gmoJIf1mMg9Ab3mRxVw cFOBYvVSEn4ZtFzqpEizjfoXb4os7kpB6fe3tr8udy80/37tajuT9BJL6AZstKm87dyaYPYji KhJmCB/xOIXnCtmMOLLEgenKJcrvmQ5nbabYgEWqk040GhfFMDBUN3uKOIBvo9Z8uqQiSeooR 97AmD4oIgnVQipZCLpf648DJtvt8BoEb1x5qA3hFuvm3ng2a+kpl6b9nxbtfyhXl5nxvrDIdQ RGUCzlsfzuxLTv8mY+iOQlyJZ9AN9rWPswGirdV7Abk4zHxBQoy4khpwkv2P3Tz7Mx8JpwLaf lAislEAin+hynpYHavLuCCT0uKm7yX/Z6vqIKJ/1znGoxw+d1BFB3RRSrMYcLi3tRey/6M/PZ YNO5xq0b94mwJ0QG3y0Urn3vF5ca2CQm6q+ql7v7fC2+aMMn/9vdwPW9hy9VZfgHOsmG3IaLn tsO1RMivNHzP1Io+J0yPjf8wnIeQhM3NAL/1Fdi3WyOBWzFK96j4oU6XJ91aA7IlbVgrQFLws 0bhLf4IFJAk728Y3OAwdASHLS8bSeB0sDCZD6DaejfcYjWYvkaYm2cvb6T+fCugyY0+B/E62k 7TUf7OFMnS+Hx6Nv0QJrCV9hvJXQcHsdL3Cq0t4JJuEbrUpDnDQTXhbCXNpntYWK62EwHj0WS 7yLgeBPyYKisEvD0LlkGPp0kbQ7eWM6CX3qzk1TtSEAv+ULIy2Zjl8nH113Rv7ZmduhbI0Q7l 8AAkK6GHyHMS39CAQupvM6UWNDGwJWcD/Rv09L5rOUbVng+KcThdLaFU+iPCxYQB4g4AJHsB X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.15.19 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:114671 Archived-At: > I was thinking the similar but cannot find a way to construct the > window-buffer associations. Do you mind giving me some hint :) The code below should do that. (defun update-window-buffer-list () (let ((old (frame-parameter nil 'window-buffer-list)) new this) (walk-window-tree (lambda (window) (let ((old-buffer (cdr (assq window old))) (new-buffer (window-buffer window))) (unless (eq old-buffer new-buffer) ;; The buffer of a previously existing window has changed or ;; a new window has been added to this frame. (ding)) (setq new (cons (cons window new-buffer) new))))) (set-frame-parameter nil 'window-buffer-list new))) (add-hook 'window-configuration-change-hook 'update-window-buffer-list) You can write a more destructive version using =E2=80=98setcdr=E2=80=99. martin