From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Matthias Pfeifer Newsgroups: gmane.emacs.help Subject: Re: How do i say it in emacs lisp Date: Mon, 28 Nov 2016 11:50:32 +0000 Message-ID: References: , <20161128092100.GA23484@tuxteam.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1480345240 28306 195.159.176.226 (28 Nov 2016 15:00:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 28 Nov 2016 15:00:40 +0000 (UTC) To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 28 16:00:32 2016 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 1cBNPz-00060A-PD for geh-help-gnu-emacs@m.gmane.org; Mon, 28 Nov 2016 16:00:32 +0100 Original-Received: from localhost ([::1]:59279 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBNQ3-0003UM-Am for geh-help-gnu-emacs@m.gmane.org; Mon, 28 Nov 2016 10:00:35 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBKSM-0002t4-S1 for help-gnu-emacs@gnu.org; Mon, 28 Nov 2016 06:50:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBKSI-00047g-Ji for help-gnu-emacs@gnu.org; Mon, 28 Nov 2016 06:50:46 -0500 Original-Received: from blu004-omc4s6.hotmail.com ([65.55.111.145]:55923) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cBKSI-00045n-DZ for help-gnu-emacs@gnu.org; Mon, 28 Nov 2016 06:50:42 -0500 Original-Received: from EUR02-VE1-obe.outbound.protection.outlook.com ([65.55.111.137]) by BLU004-OMC4S6.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Mon, 28 Nov 2016 03:50:38 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=kdTktb8XZM/lcgAm0V6L99bopb9vrG1gucAXdXCiDMY=; b=XSDBqNl65jidTCFodtP/fYQBOrO1qoaTvXXHbnzVvz/mz7/IwL3Trt6wNsLcxEaQ4fVqdzABVues8tzt7LIp09+KSmyrrW5GbnUrCXQQEOWC0XnXDQYbsKDWQU4I09IEkAxtSFgdFkh26NKIb3cIPpNCns+KWvgRmAWEgiMlRXKiPWLJYgGyRvZGNSzOmRQvdwViJo6kmHXsK2hzuCcemxRhJpuFGswSD/4iEtmpWgx6pSEOuERrQzRmMGGXQDJ2ThwkZEGYuVAoH5j2bsZ4CjzBoceC6wXmLj+2fG0IcmxWbIPp2h8+/r5/MW3LabOS631lPt+4+Wj+MDUhqFKz0Q== Original-Received: from HE1EUR02FT054.eop-EUR02.prod.protection.outlook.com (10.152.10.58) by HE1EUR02HT209.eop-EUR02.prod.protection.outlook.com (10.152.10.190) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.734.4; Mon, 28 Nov 2016 11:50:33 +0000 Original-Received: from VI1PR0601MB2015.eurprd06.prod.outlook.com (10.152.10.55) by HE1EUR02FT054.mail.protection.outlook.com (10.152.11.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.734.4 via Frontend Transport; Mon, 28 Nov 2016 11:50:32 +0000 Original-Received: from VI1PR0601MB2015.eurprd06.prod.outlook.com ([10.166.142.137]) by VI1PR0601MB2015.eurprd06.prod.outlook.com ([10.166.142.137]) with mapi id 15.01.0747.015; Mon, 28 Nov 2016 11:50:32 +0000 Thread-Topic: How do i say it in emacs lisp Thread-Index: AQHSSO9pzf3//s0bIEu1qr2wyZM8g6DuH5gAgAAZ4iw= In-Reply-To: <20161128092100.GA23484@tuxteam.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: gnu.org; dkim=none (message not signed) header.d=none; gnu.org; dmarc=none action=none header.from=outlook.com; x-incomingtopheadermarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:8039; Count:39 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [vamdHhQPyWuv4Z12Ei1P6e17hBwKBXOr] x-incomingheadercount: 39 x-eopattributedmessage: 0 x-microsoft-exchange-diagnostics: 1; HE1EUR02HT209; 7:b9o03Gp4dktnQASr6QSavbK6hz3xtUlGj+v7gHz9jeB28eCqVJ5rvxzDuOJ56DC5CZhpp0Z+yAIfDEpAw4XsurCpqh++sXxIcmHCOgzYQfCCX9z1RVxjgdF6bSyIibBX+ZDYOmhdJ9OXhQQQVE/DSO+rn95Cn4Qxwd3aL5LX86mLvQm/u3RxI8wnfO6Bjd7BEilUV7cDjPSISdZ/xhdjNiz11k5d+dOLuUJ/Ryabp7gB5kLQuaORgjYlGUfPlWHLrXG726In1fAUY2L2dARKgNbApPmKWMYyc5xNrcqMBTS+oVDSLMcdHNew1/rOIP82uCcWjwWmxGbL45gBhXoXCkMCXvwTcg0e917eo4I6+X8= x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(10019020)(98900003); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1EUR02HT209; H:VI1PR0601MB2015.eurprd06.prod.outlook.com; FPR:; SPF:None; LANG:en; x-ms-office365-filtering-correlation-id: cfd0a949-116c-4534-f28a-08d41784c202 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(1601124038)(1603103113)(1601125047); SRVR:HE1EUR02HT209; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(432015012)(82015046); SRVR:HE1EUR02HT209; BCL:0; PCL:0; RULEID:; SRVR:HE1EUR02HT209; x-forefront-prvs: 01401330D1 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Nov 2016 11:50:32.2456 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR02HT209 X-OriginalArrivalTime: 28 Nov 2016 11:50:38.0257 (UTC) FILETIME=[A306F210:01D2496D] X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 65.55.111.145 X-Mailman-Approved-At: Mon, 28 Nov 2016 09:59:48 -0500 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:111819 Archived-At: Hi Tomas, thanks for the general clarification. I was suspecting hooks to be the way = to go. However I was running in some sort of recursion (i guess) until i fi= gured out to temporarily set my hook to nil. This is what I fiddled togethe= r: My plan is to have a package called "neotree" update it's buffer wheneve= r another window's buffer is switched and the selected frame's configuratio= n matches a certain layout. Let me try to re-phrase: When the current frame= hosts two windows. And any of these windows is showing the neotree buffer = and other window's buffers is switched then I want neotree to go to the buf= fers file. Here is my elisp: (defun mp:neotree-updater () (when (eq 2 (length (window-list))) (let* ((wnd-0 (nth 0 (window-list))) (wnd-1 (nth 1 (window-list))) (buf-0 (window-buffer wnd-0)) (buf-1 (window-buffer wnd-1)) (neo-buf nil) (other-buf nil) (neo-wnd nil) (other-wnd nil) (filename nil) (neo-buffer (get-buffer " *NeoTree*"))) (when (and neo-buffer (or (eq buf-0 neo-buffer) (eq buf-1 neo-buffer))) (progn (if (eq buf-0 neo-global--buffer) (setq neo-buf buf-0 other-buf buf-1 neo-wnd wnd-0 other-wnd wnd-1) (setq neo-buf buf-1 other-buf buf-0 neo-wnd wnd-1 other-wnd wnd-0)) (setq filename (buffer-file-name other-buf)) (when (and filename (file-exists-p filename)) (progn (setq mp:neotree-go-to-dir filename) (let ((buffer-list-update-hook buffer-list-update-hook)) (neotree-find filename) (select-window other-wnd))))))))) ;; (add-hook 'buffer-list-update-hook 'mp:neotree-updater) ;; (remove-hook 'buffer-list-update-hook 'mp:neotree-updater) It seems to be working the way I expected it. Second opinion is welcome :-) Matthias Pfeifer