unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Jean-Christophe Helary <jean.christophe.helary@gmail.com>,
	help-gnu-emacs@gnu.org
Subject: RE: call function in other window ?
Date: Sat, 20 May 2017 18:27:34 -0700 (PDT)	[thread overview]
Message-ID: <c137e4a4-b7b9-448e-b704-1cc72c9c0dc7@default> (raw)
In-Reply-To: <26D747C5-FD5A-4810-938E-77DD21C6D2F9@gmail.com>

> >> 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)
> > 	  (apply fn args)))))
> 
> 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.



  parent reply	other threads:[~2017-05-21  1:27 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-20 15:35 call function in other window ? Jean-Christophe Helary
2017-05-20 20:25 ` Drew Adams
2017-05-20 22:43   ` Jean-Christophe Helary
2017-05-20 23:50     ` Emanuel Berg
2017-05-21  1:27     ` Drew Adams [this message]
2017-05-21  1:58       ` Emanuel Berg
2017-05-21  2:39     ` Jean-Christophe Helary
2017-05-21 10:07       ` Emanuel Berg
2017-05-21 10:16         ` Jean-Christophe Helary
2017-05-21 10:50           ` Joost Kremers
2017-05-21 11:08             ` Jean-Christophe Helary
2017-05-21 13:52               ` Emanuel Berg
2017-05-21 15:05               ` Eli Zaretskii
2017-05-21 15:14                 ` Jean-Christophe Helary
2017-05-21 15:56                   ` Emanuel Berg
2017-05-22  6:39                     ` Jean-Christophe Helary
2017-05-22 21:18                       ` Emanuel Berg
2017-05-22 22:26                         ` Jean-Christophe Helary
2017-05-22 22:42                           ` Kaushal Modi
2017-05-23  0:20                             ` Emanuel Berg
2017-05-23  0:19                           ` Emanuel Berg
2017-05-23  7:10                             ` tomas
2017-05-23  7:44                               ` Emanuel Berg
2017-05-23  7:57                                 ` tomas
2017-05-23  8:14                                   ` Emanuel Berg
2017-05-23  8:54                                     ` tomas
2017-05-23 12:58                                       ` Emanuel Berg
2017-05-23 13:03                                         ` Jean-Christophe Helary
2017-05-23 13:14                                           ` Emanuel Berg
2017-05-23 19:18                                             ` tomas
2017-05-23 20:25                               ` Tomas Nordin
2017-05-23 21:02                                 ` John Ankarström
2017-05-24 19:40                                   ` Emanuel Berg
2017-05-24  7:26                                 ` tomas
2017-05-21 15:59                   ` Eli Zaretskii
2017-05-21 22:58                   ` Drew Adams
     [not found]                   ` <<83tw4enqtl.fsf@gnu.org>
2017-05-21 23:00                     ` Drew Adams
2017-05-21 13:48           ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c137e4a4-b7b9-448e-b704-1cc72c9c0dc7@default \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=jean.christophe.helary@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).