From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xavier Maillard Newsgroups: gmane.emacs.help Subject: Re: eval-last-sexp in other window Date: Tue, 31 Mar 2009 22:25:06 +0200 Organization: GNU's Not UNIX! Message-ID: <200903312025.n2VKP6hh017697@zogzog.maillard.mobi> Reply-To: Xavier Maillard NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1238531316 23648 80.91.229.12 (31 Mar 2009 20:28:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 31 Mar 2009 20:28:36 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Bob Babcock Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 31 22:29:54 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Lokam-0000w5-0k for geh-help-gnu-emacs@m.gmane.org; Tue, 31 Mar 2009 22:29:52 +0200 Original-Received: from localhost ([127.0.0.1]:49661 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LokZO-0001Qr-Eq for geh-help-gnu-emacs@m.gmane.org; Tue, 31 Mar 2009 16:28:26 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LokZ3-0001QY-3v for help-gnu-emacs@gnu.org; Tue, 31 Mar 2009 16:28:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LokZ1-0001QK-OG for help-gnu-emacs@gnu.org; Tue, 31 Mar 2009 16:28:03 -0400 Original-Received: from [199.232.76.173] (port=50007 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LokZ1-0001QH-Jm for help-gnu-emacs@gnu.org; Tue, 31 Mar 2009 16:28:03 -0400 Original-Received: from ded1.conovae.com ([88.191.52.166]:47591 helo=mf1.conovae.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LokZ1-0000tG-6o for help-gnu-emacs@gnu.org; Tue, 31 Mar 2009 16:28:03 -0400 Original-Received: by mf1.conovae.net (Postfix, from userid 10) id E50C5260119; Tue, 31 Mar 2009 22:24:19 +0200 (CEST) Original-Received: from zogzog.maillard.mobi (IDENT:1000@localhost [127.0.0.1]) by zogzog.maillard.mobi (8.14.3/8.13.8) with ESMTP id n2VKP6eR017698; Tue, 31 Mar 2009 22:25:06 +0200 Original-Received: (from xma@localhost) by zogzog.maillard.mobi (8.14.3/8.13.8/Submit) id n2VKP6hh017697; Tue, 31 Mar 2009 22:25:06 +0200 In-reply-to: message from Bob Babcock on Tue, 31 Mar 2009 04:42:01 +0000 User-Agent: Rmail GNU emacs 23.0 on Slackware 12.2.0 Jabber-ID: xma01@jabber.fr Original-References: X-UUCPssh-Information: Please contact the ISP for more information X-UUCPssh: Found to be clean X-UUCPssh-SpamCheck: not spam, SpamAssassin (not cached, score=-4.399, required 6, autolearn=not spam, ALL_TRUSTED -1.80, BAYES_00 -2.60) X-UUCPssh-From: xma@gnu.org X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:63424 Archived-At: pjb@informatimago.com (Pascal J. Bourguignon) wrote in news:87d4bzbfky.fsf@galatea.local: >> Is there a way to have eval-last-sexp (typically bound to C-xC-e) run >> in a different window? This would be convenient when developing a >> macro that reformats text - I want the part of the macro I'm testing >> to be applied to the file being reformatted, not to my macro. > > You may use M-: to apply a form to the current buffer. > > > Otherwise: > > (with-current-buffer (get-buffer "The Other Buffer Name") > (do-what-you-want)) C-x C-e Thanks. After several false starts, I have a simple macro that seems to do what I want: (defun last-sexp-other-window() "Get last sexp and run it in other window. If there isn't another window, use current window." (interactive) (setq ow-sexp (preceding-sexp)) (other-window 1) (eval ow-sexp) (other-window -1) ) Why not use let instead of setq ? Xavier -- http://www.gnu.org http://www.april.org http://www.lolica.org