From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: call function in other window ? Date: Sat, 20 May 2017 18:27:34 -0700 (PDT) Message-ID: References: <0F7D0254-9A80-42BF-82EB-E09007BE3A39@gmail.com> <38f43e30-eeb0-427a-a885-fbd30d0d0d97@default> <26D747C5-FD5A-4810-938E-77DD21C6D2F9@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1495330089 26639 195.159.176.226 (21 May 2017 01:28:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 21 May 2017 01:28:09 +0000 (UTC) To: Jean-Christophe Helary , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun May 21 03:28:05 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 1dCFf9-0006nZ-Cl for geh-help-gnu-emacs@m.gmane.org; Sun, 21 May 2017 03:28:03 +0200 Original-Received: from localhost ([::1]:35946 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dCFfE-0003Mx-Rx for geh-help-gnu-emacs@m.gmane.org; Sat, 20 May 2017 21:28:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dCFeo-0003Mq-Cj for help-gnu-emacs@gnu.org; Sat, 20 May 2017 21:27:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dCFel-0000KP-8Y for help-gnu-emacs@gnu.org; Sat, 20 May 2017 21:27:42 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:28012) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dCFek-0000KA-Uu for help-gnu-emacs@gnu.org; Sat, 20 May 2017 21:27:39 -0400 Original-Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v4L1RaoD010050 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 21 May 2017 01:27:37 GMT Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id v4L1Rast006632 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 21 May 2017 01:27:36 GMT Original-Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v4L1RZKs018140; Sun, 21 May 2017 01:27:36 GMT In-Reply-To: <26D747C5-FD5A-4810-938E-77DD21C6D2F9@gmail.com> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 12.0.6767.5000 (x86)] X-Source-IP: aserv0021.oracle.com [141.146.126.233] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 141.146.126.69 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:113094 Archived-At: > >> Is there an argument to M-x... to call a function not in the current > >> buffer/window but in a different one (like the one targeted by "other > >> window" ? Or a different way to do that ? > > > > (defun foo (fn &rest args) > > (let ((win (next-window))) > > (when win (with-current-buffer (window-buffer win) > > =09 (apply fn args))))) >=20 > Thank you Drew. Wouldn't it be something that people use > frequently enough that is has its own function in Emacs ? If you think it's useful to add to Emacs, please file an enhancement request: `M-x report-emacs-bug' (that's for enhancement request too, not just bugs). The request will be considered, perhaps discussed, and someone will decide whether to grant it. I don't know whether others will find such a function useful. I haven't needed it. I imagine that most people who are going to write Lisp code to act on a buffer will know to use `with-current-buffer', and to get to the buffer of another window they will use `window-buffer'. Those are commonly used. Whether it is common to want to act on the buffer in `next-window' is something else. My guess is that such code is straightforward and short enough that it won't be thought very useful to have such a function predefined. But certainly if someone were going to do exactly that frequently (e.g. act on the buffer in the `next-window') then such a function could be handy. You pose that question: whether such a need is frequent. Dunno, but I don't think so.