From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Evaluate current line in Python mode?
Date: Sat, 28 Aug 2010 13:10:05 -0700 (PDT) [thread overview]
Message-ID: <c1f0ea5d-d305-4c84-805f-010e374dc54e@x24g2000pro.googlegroups.com> (raw)
In-Reply-To: mailman.3.1283024747.17543.help-gnu-emacs@gnu.org
On Aug 28, 12:45 pm, Michael Hannon <jm_han...@yahoo.com> wrote:
> 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, <menu-bar> <ESS> <ESS Eval> <Eval
> 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" = 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.
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:
〈Elisp Wrapper For Perl Scripts〉 http://xahlee.org/emacs/elisp_perl_wrapper.html
it's just 5 lines of elisp.
Xah ∑ http://xahlee.org/ ☄
next parent reply other threads:[~2010-08-28 20:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.3.1283024747.17543.help-gnu-emacs@gnu.org>
2010-08-28 20:10 ` Xah Lee [this message]
2010-08-28 23:49 ` Evaluate current line in Python mode? TheFlyingDutchman
2010-08-28 19:45 Michael Hannon
2010-08-29 8:02 ` Andreas Röhler
2010-08-29 8:37 ` Thierry Volpiatto
2010-08-30 10:43 ` Andreas Röhler
2010-08-30 12:36 ` Thierry Volpiatto
2010-08-30 16:17 ` Andreas Röhler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c1f0ea5d-d305-4c84-805f-010e374dc54e@x24g2000pro.googlegroups.com \
--to=xahlee@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).