help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: eval-last-sexp in other window


From: Pascal J. Bourguignon
Subject: Re: eval-last-sexp in other window
Date: Tue, 31 Mar 2009 09:53:34 +0200
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin)

Bob Babcock <wssddc@nospam.gis.net> writes:

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

At the very least, use let, not setq!

(defun last-sexp-other-window()
 "Get last sexp and run it in other window.
If there isn't another window, use current window."
   (interactive)
   (let ((ow-sexp (preceding-sexp)))
      (other-window 1)
      (eval ow-sexp)
      (other-window -1)))

-- 
__Pascal Bourguignon__


reply via email to

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