From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bob Babcock Newsgroups: gmane.emacs.help Subject: Re: eval-last-sexp in other window Date: Tue, 31 Mar 2009 04:42:01 +0000 Organization: FlashNewsgroups.com Message-ID: References: <87d4bzbfky.fsf@galatea.local> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1238488846 2428 80.91.229.12 (31 Mar 2009 08:40:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 31 Mar 2009 08:40:46 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 31 10:42:04 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 1LoZXo-00032V-Gz for geh-help-gnu-emacs@m.gmane.org; Tue, 31 Mar 2009 10:42:04 +0200 Original-Received: from localhost ([127.0.0.1]:47191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LoZWR-00034V-2i for geh-help-gnu-emacs@m.gmane.org; Tue, 31 Mar 2009 04:40:39 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news2.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7yQUZ7CaYQxA!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Xnews/2006.08.24 Original-X-Complaints-To: abuse@flashnewsgroups.com Original-Lines: 27 Original-X-Trace: 31f2349d19f19c740dc9117980 Original-Xref: news.stanford.edu gnu.emacs.help:168123 X-Mailman-Approved-At: Tue, 31 Mar 2009 04:39:36 -0400 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:63413 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) ) This doesn't call the debugger on error, but that's ok.