From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: TheFlyingDutchman Newsgroups: gmane.emacs.help Subject: Re: Evaluate current line in Python mode? Date: Sat, 28 Aug 2010 16:49:20 -0700 (PDT) Organization: http://groups.google.com Message-ID: <6299fd09-5079-40f0-bfb4-4d4acdeb370d@x18g2000pro.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1291864220 25312 80.91.229.12 (9 Dec 2010 03:10:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Dec 2010 03:10:20 +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 04:10:15 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 1PQWtZ-0001qy-Hw for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 04:10:13 +0100 Original-Received: from localhost ([127.0.0.1]:41526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQWhL-0004YV-PL for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 21:57:35 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!x18g2000pro.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 30 Original-NNTP-Posting-Host: 76.199.66.239 Original-X-Trace: posting.google.com 1283039360 10913 127.0.0.1 (28 Aug 2010 23:49:20 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sat, 28 Aug 2010 23:49:20 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: x18g2000pro.googlegroups.com; posting-host=76.199.66.239; posting-account=9bWHAAoAAAAxSFC_2O_ssTETNW9NhMbW User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; AskTbBT5/5.8.0.12304),gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:181003 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:76518 Archived-At: I think this does what you asked for. You can add this to your .emacs (or init.el) file. It is currently set to work on F7 but that line can be changed move it to another key. But it appears from my usage that for a lot of Python lines, like function definitions and for loops, evaluating just one line doesn't work and then that negatively impacts subsequent line evaluations. (add-hook 'python-mode-hook 'my-python-next-statement) (defun my-python-next-statement () (interactive) (local-set-key (kbd "") 'my-python-next-statement) (if (string= mode-name "Python") (progn (python-next-statement) (beginning-of-line) (setq lineStart (point)) (end-of-line) (setq lineEnd (point)) (python-send-region lineStart lineEnd) ) (message "function only applies to Python mode") (beep) ) )