From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Amos Bird Newsgroups: gmane.emacs.help Subject: Re: how can I run commands when window displays a different buffer? Date: Sat, 28 Oct 2017 16:56:23 +0800 Message-ID: <87fua38xc8.fsf@gmail.com> References: <59F32C2F.8020701@gmx.at> <87lgjw90k8.fsf@gmail.com> <59F4439F.60306@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1509181023 26999 195.159.176.226 (28 Oct 2017 08:57:03 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 28 Oct 2017 08:57:03 +0000 (UTC) User-Agent: mu4e 0.9.19; emacs 25.3.1 Cc: help-gnu-emacs@gnu.org To: martin rudalics Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 28 10:56:54 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 1e8MvD-0005f9-8a for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Oct 2017 10:56:51 +0200 Original-Received: from localhost ([::1]:60224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8MvI-0001Gf-UK for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Oct 2017 04:56:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8Mus-0001GZ-18 for help-gnu-emacs@gnu.org; Sat, 28 Oct 2017 04:56:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8Mup-0005qA-WD for help-gnu-emacs@gnu.org; Sat, 28 Oct 2017 04:56:30 -0400 Original-Received: from mail-pf0-x233.google.com ([2607:f8b0:400e:c00::233]:45926) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e8Mup-0005pO-ON for help-gnu-emacs@gnu.org; Sat, 28 Oct 2017 04:56:27 -0400 Original-Received: by mail-pf0-x233.google.com with SMTP id d28so6684419pfe.2 for ; Sat, 28 Oct 2017 01:56:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=U8NS8eltI+Q9MXkXzCIZ7GvyL2MKOptNLlVmSYzqnWs=; b=ftX5nyduf43UhM/eggWy3nTSrmG1ZEgQxSww1tLOp5DjYMbjUOyl7N7dXaWYMYzFiy NCI/i8YYuCsV6gRNipdP1Pcqjh27N9CxFnFsDUili4ZpjYpyVgGjlDJV9sCmC+Fe5cBy 1ZK7IL34ukn/sUUQR2YTCYFxf4vq4TCTnxji+PLpG1qb9M2o/1ESAyY9ZCZkderdcIvt xCSb2i9oFnF3L6DTTlQwKMz+ylEm/If6ilpm0d2qLqRTBmfs4B5qXzl5PsTWvSzSQ+8F 20fzI04B+7lVGuMF0yR/xCfdMsZ//EMVm1V2mEQ9R/xELAZ0lmDELEyc7Nq939sFPIbu LTlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=U8NS8eltI+Q9MXkXzCIZ7GvyL2MKOptNLlVmSYzqnWs=; b=kPG6O95EmRzzitieVKbXW0x0fwMziE7gP5h+fx9hNAxTXKHs/Fft0115oaf/BLvNQR klCGkkG7WBc+B3IkqO/75ludyjFhLw4DgxHgaXKsLnGrI1Lj1NQk4vf7SXUhzrBtPftY fMeqjDheNktBrO76PTHL3MEjAOZcHgK6VtBArAp9xEuDWZIKs6upDEw1qj/C/Ws1xJlL O8q4mH2LaJDfGeEUsqzM4l5FIkxlMu+V4ROHMsrPWf0PQS/7NXuobT1PdP7Lc6MfuoYT oHMIijcnhDItNLvUA0PXrRZMkiL9ZpTIb9NgjCiiWh3425lhsqML2Rxzi29VSSqiarf1 ik/g== X-Gm-Message-State: AMCzsaU54v1SfERvzUrdt5Sr9z6+hmXG0mM2hnWLmxkkevXUvjbrIfNr og9uOXx2C4Q9fJcmL1tbaOI= X-Google-Smtp-Source: ABhQp+R3sfnHy72q981HGUN1tvFDvdsXRhnGpA/ymhT3bqCX1Gnj0zOHPbhXD98dC43R90Ofu7LEgg== X-Received: by 10.99.99.65 with SMTP id x62mr2526743pgb.221.1509180986649; Sat, 28 Oct 2017 01:56:26 -0700 (PDT) Original-Received: from localhost ([2604:180:3:28::c542]) by smtp.gmail.com with ESMTPSA id u197sm21539844pgb.33.2017.10.28.01.56.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 28 Oct 2017 01:56:26 -0700 (PDT) In-reply-to: <59F4439F.60306@gmx.at> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::233 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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:114672 Archived-At: Hi martin, This works pretty well. Thank you! regards, martin rudalics writes: >> 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 ‘setcdr’. > > martin -- Amos Bird amosbird@gmail.com