[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: call function in other window ?

From: Drew Adams
Subject: RE: call function in other window ?
Date: Sat, 20 May 2017 18:27:34 -0700 (PDT)

> >> 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]