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

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

Re: Evaluate current line in Python mode?


From: TheFlyingDutchman
Subject: Re: Evaluate current line in Python mode?
Date: Wed, 08 Dec 2010 15:26:35 -0000
User-agent: G2/1.0

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 "<f7>") '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) ) )



reply via email to

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