From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Hannon Newsgroups: gmane.emacs.help Subject: Evaluate current line in Python mode? Date: Sat, 28 Aug 2010 12:45:42 -0700 (PDT) Message-ID: <950559.18533.qm@web55007.mail.re4.yahoo.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1283024775 18100 80.91.229.12 (28 Aug 2010 19:46:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 28 Aug 2010 19:46:15 +0000 (UTC) To: gnu-emacs help Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 28 21:46:14 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 1OpRLv-0007TI-Qu for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Aug 2010 21:46:12 +0200 Original-Received: from localhost ([127.0.0.1]:34685 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OpRLv-000104-9E for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Aug 2010 15:46:11 -0400 Original-Received: from [140.186.70.92] (port=54605 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OpRLV-0000zv-Jp for help-gnu-emacs@gnu.org; Sat, 28 Aug 2010 15:45:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OpRLU-0001Tr-5M for help-gnu-emacs@gnu.org; Sat, 28 Aug 2010 15:45:45 -0400 Original-Received: from web55007.mail.re4.yahoo.com ([206.190.58.141]:21132) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OpRLU-0001Tm-3A for help-gnu-emacs@gnu.org; Sat, 28 Aug 2010 15:45:44 -0400 Original-Received: (qmail 18564 invoked by uid 60001); 28 Aug 2010 19:45:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1283024742; bh=y99/JvDRZk+iTV3cldaiPtcEULORtgeSJg18uAqnzjI=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=R5Fl2ljcKYr/814h8wPrGMBhfX7dCitD4E0pxJ5Ub2qxTRAjdrh93X5CnKB5QlyGCEy7SyU5fbtgmDjZmYmwWloKzSs3ZueBS1Tkgze0+h1pp+tfma9NKNLF4U+qWWkHN8h3Z24wNpIbZQPOQAxUG1J5yf24Lxl/i88Rh/KmZa8= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=vkerq/t8dpSj5gQAsBI7Uvbg8q3RiloS2vwOFtCKbu/UVoPiBilRUOg5JumHVMZuhfm3ibnli4Twolii3f2cPa3ODta6lB4fcjBZ1mAEXvTsg+5XHftH2qz3AwKqHYmXFlpjeC9CbQCCE4+8+s8odeCYs0I0tz/drbdZy1OIqOM=; X-YMail-OSG: gwbNEBoVM1kxo9TGvNlHv1_U0JBorLLqPtcK7of.2tQ7AKs xhtrkrbBChJb5KnkmM.kQMaD0wyto7Gc03Dxmoyxk4s71aq522dRdvStIlGF lnqgB7wQbSBuH6mVAgZ3MnIU0pXD7hX6TW_6jSaTzF4_MqjstGP4VHIuapRY 3PE89jjymGdAuTNoyRmoOh88kyDC00ynjR5svDxLGAWsVM4qMNkIKy3AgR9_ l2P7ZboRhGsR7lqSX5sHdDMJ74TYk5Cm15UWyrTFpRW52CGmuE6DrFPr5AON xEge7ttEgW7wK3fCcNFnR6nQlabN_U_QavdUOQ2ljAW83xgWHpjpqnw-- Original-Received: from [24.2.51.220] by web55007.mail.re4.yahoo.com via HTTP; Sat, 28 Aug 2010 12:45:42 PDT X-Mailer: YahooMailRC/470 YahooMailWebService/0.8.105.279950 X-detected-operating-system: by eggs.gnu.org: FreeBSD 6.x (1) 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:74823 Archived-At: Greetings. I use Emacs for, among other things, running Python code and R code. In both modes (Python and ESS "Emacs Speaks Statistics") there is a function bound to the sequence: C-c C-n Both functions advance to the next line of code in the buffer, i.e., skipping blank lines, comment lines, etc. In ESS mode the function bound to C-c C-n also (by default) sends the current line to R for evaluation. I find this to be very convenient as a way 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 evaluation, 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. I understand that the source code is available, and that I'm free to hack away to my heart's content. I just don't have the skills at Emacs/Lisp required to do such a thing in a finite amount of time. Thanks and best wishes, -- Mike Python mode =========== 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. Stop at end of buffer. Return count of statements left to move. ---------- ESS mode ======== 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, . (ess-eval-line-and-step &optional SIMPLE-NEXT EVEN-EMPTY INVISIBLY) Evaluate the current line visibly and step to the "next" line. "next" = the next line with non-comment code _unless_ SIMPLE-NEXT is non-nil, possibly via prefix arg. If 2nd arg EVEN-EMPTY [prefix as well], also send empty lines. When the variable `ess-eval-empty' is non-nil both SIMPLE-NEXT and EVEN-EMPTY are interpreted as true.