From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: Evaluate current line in Python mode? Date: Sat, 28 Aug 2010 13:10:05 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1291861699 17041 80.91.229.12 (9 Dec 2010 02:28:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Dec 2010 02:28:19 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 09 03:28:11 2010 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.69) (envelope-from ) id 1PQWEr-00026K-56 for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 03:28:09 +0100 Original-Received: from localhost ([127.0.0.1]:55924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQWEq-0000yo-4X for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 21:28:08 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!x24g2000pro.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 83 Original-NNTP-Posting-Host: 67.180.85.8 Original-X-Trace: posting.google.com 1283026206 30807 127.0.0.1 (28 Aug 2010 20:10:06 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sat, 28 Aug 2010 20:10:06 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: x24g2000pro.googlegroups.com; posting-host=67.180.85.8; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.127 Safari/533.4, gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:181002 comp.emacs:100400 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:76477 Archived-At: On Aug 28, 12:45=C2=A0pm, Michael Hannon wrote: > Greetings. =C2=A0I use Emacs for, among other things, running Python code= and R > code. =C2=A0In both modes (Python and ESS "Emacs Speaks Statistics") ther= e is a > function bound to the sequence: > > =C2=A0 =C2=A0 C-c C-n > > Both functions advance to the next line of code in the buffer, i.e., skip= ping > blank lines, comment lines, etc. > > In ESS mode the function bound to C-c C-n also (by default) sends the cur= rent > line to R for evaluation. =C2=A0I find this to be very convenient as a wa= y to watch > calculations "evolve". > > It's possible to do something similar in Python mode by selecting the > current line and then sending the region (C-c C-r) to Python for evaluati= on, > but this is a bit cumbersome. > > Can anybody suggest a way to graft the ESS-mode behavior onto Python mode= ? > I've appended the high-level descriptions of both functions. =C2=A0I unde= rstand > that the source code is available, and that I'm free to hack away to my > heart's content. =C2=A0I just don't have the skills at Emacs/Lisp require= d to do > such a thing in a finite amount of time. > > Thanks and best wishes, > > -- Mike > > =C2=A0 =C2=A0 Python mode > =C2=A0 =C2=A0 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > C-c C-n runs the command python-next-statement, which is an > interactive compiled Lisp function. > > It is bound to C-c C-n. > > (python-next-statement &optional COUNT) > > Go to start of next statement. > With argument COUNT, do it COUNT times. =C2=A0Stop at end of buffer. > Return count of statements left to move. > > ---------- > > =C2=A0 =C2=A0 ESS mode > =C2=A0 =C2=A0 =3D=3D=3D=3D=3D=3D=3D=3D > > C-c C-n runs the command ess-eval-line-and-step, which is an > interactive compiled Lisp function in `ess-inf.el'. > > It is bound to C-c C-n, C-c C-e C-n, line & step>. > > (ess-eval-line-and-step &optional SIMPLE-NEXT EVEN-EMPTY INVISIBLY) > > Evaluate the current line visibly and step to the "next" line. > "next" =3D the next line with non-comment code _unless_ SIMPLE-NEXT is no= n-nil, > possibly via prefix arg. =C2=A0If 2nd arg EVEN-EMPTY [prefix as well], > also send empty lines. =C2=A0 =C2=A0When the variable `ess-eval-empty' is= non-nil > both SIMPLE-NEXT and EVEN-EMPTY are interpreted as true. i haven't coded python for few years and havn't used ess MODE, but if all you need is to send the region to python to eval and display the output in buffer, that's pretty easy. I wrote a tutorial about this here: =E3=80=88Elisp Wrapper For Perl Scripts=E3=80=89 http://xahlee.org/emacs/el= isp_perl_wrapper.html it's just 5 lines of elisp. Xah =E2=88=91 http://xahlee.org/ =E2=98=84