ffevotte / isend-mode.el Goto Github PK
View Code? Open in Web Editor NEWInteractively send parts of an Emacs buffer to an interpreter
Interactively send parts of an Emacs buffer to an interpreter
I use the variable isend-skip-empty-lines
, which makes walking through long scripts easy. I would also like to skip comment lines (# in bash). Is there something like isend-skip-comment-lines
?
Hi, I have been using isend-mode
with ansi-term
terminals in Emacs very happily for several years now and after upgrading IPython to the latest version 5.0 it stopped working. It looks like they moved away from pyreadline
to something called prompt_toollkit
.
Any thoughts on what could be going on ?
As I reported in this other issue #6 I am having problems getting isend to work with the latest IPython 5 terminal. I thought this would be a good opportunity for me to try contribute to this great package, since it has been a life saver since I started using it!
I have a relatively basic knowledge of Elisp, but I was able to follow most of the logic in isend-mode.el
. I suspect part of the problem that I am having is coming from what's being sent to the terminal, since the IPython 5 interpreter works perfectly fine otherwise running within my ansi-term buffers.
The key seems to be these lines: https://github.com/ffevotte/isend-mode.el/blob/master/isend-mode.el#L278-L282 which read:
(cond
;; Terminal buffer: specifically call `term-send-input'
;; to handle both the char and line modes of `ansi-term'.
((eq major-mode 'term-mode)
(term-send-input))
What does (eq major-mode 'term-mode)
do? Is it a comparison to make sure that it's a term-mode
before we invoke term-send-input
?
How does term-send-input
know what to send to what buffer? I know that it's wrapped up within two statements:
(with-temp-buffer
...(with-current-buffer destination
... where destination holds the buffer we associate beforehand.Also, how can I test interactively sending a simple string to a given buffer (called "ipy" in my case) where I have an IPython terminal running?
With isend-skip-empty-lines
set to t
, when I run C-RET
on an empty line, it is still sent to the shell. I looked at the code to try and fix it myself, but I'm not familiar enough with elisp to completely understand what you're doing, so I figured I'd let you know it wasn't working (for me at least). This is on Cocoa emacs on OSX, version 24.2.1.
I'm doing:
(add-to-list 'load-path "~/.emacs.d/isend-mode.el") |
(require 'isend)
And I'm getting:
eval-buffer: Cannot open load file: not a directory, isend
It almost works with shell, ansi-term, eshell but why not vterm?
I'm using isend
in a Python buffer, with isend-default-python-setup
, and it seems to be unable to deal with indentation when sending a region.
it removes any of whitespace preceding it, in this case 8 spaces, and it works
it complains that I'm sending multiple statements
gives a message regarding tabs and spaces, even though all of the indentation uses spaces.
Hi,
Say you have the following in foo.sh (with ansi-term as associated buffer):
cd
ls
If the point is before the 'c' or between 'c' and 'd', the cd command is executed on C-RET. But if the point is after 'd', for example when navigating to the end of the line with 'C-e' (or simply moving the point there with the arrow keys), then the ls command is executed. It would be great if there was an option to allow you to also execute the cd command in this case, which would also be how, for example, ESS (Emacs Speaks Statistics) works.
Thanks & cheers,
Marius
This is a fantastic Emacs extension. Can the user change the keyboard binding for isend-send-line-function
and isend-send-region-function
?
After #9, everything works fine.
Although i use %paste, there seems to be some problems with cpaste.
First top level ipython input (i.e. not %cpaste input) doesn't understand "\n". That is fixed in the code below.
Second it is hard to deal with indent levels. I don't have a easy fix for that.
Feel free to close this issue, its just here for reference.
Note: This issue is a follow up on this StackOverflow thread
@ffevotte You mentioned there is a way of sending %paste
commands to an IPython session (which would effectively make the IPython interpreter run the most recent item in the kill ring) . I think you said there is a hook we can use for this, but I could not find the info on the documentation. Would you mind elaborating more on this? Thanks!
For reference: I git cloned the repository and am working on the ipython
branch and with the most recent commit as of today (Jan. 24, 2013):
commit 8bf12cfb81bb64977b682f47e4140e774bc000d1
Author: François Févotte <[email protected]>
Date: Tue Dec 18 11:03:41 2012 +0100
Prepared packaging with MELPA
this would be really neat for working with repls, I would set this up my self but I kinda suck with emacs lisp. I still might try, and would appriciate being pointed in the right direction at least.
Since commit 55244c3, isend doesn't work with emacs 26.1 anymore. M-x isend-send
gives the following error:
isend-send: Symbol’s value as variable is void: term-last-input-start
Since this commit is a major rewrite (for emacs 27, it seems), is support for stable/previous emacs versions planned? Otherwise, you might consider setting the required emacs version in the package header.
It would be great to modify isend-send()
so that the last line of the function:
;; Move point to the next line
(isend--next-line))
is optional depending on a boolean variable the user can set. I am trying to learn elisp but I am still unsure how to do this. Any thoughts?
I found this article which includes some recommended modifications to isend-mode.el
.
Specifically it recommends defining advice
for isend. Quoting literally:
But there is another annoying problem, isend only sends the code to a
specified buffer, but the code won’t be executed automatically.With the following advice (with an advice you could run some commands before/after a specified function is invoked), after sending code, Emacs will switch to the destination buffer, execute the code that is sent and switch back to the original buffer.
1: (defadvice isend-send (after advice-run-code-sent activate compile) 2: "Execute whatever sent to the (Python) buffer" 3: (interactive) 4: (let ((old-buf (buffer-name))) 5: (progn 6: (switch-to-buffer isend--command-buffer) 7: (goto-char (point-max)) 8: (comint-send-input) 9: (switch-to-buffer old-buf))))
What do you think of this suggest this @ffevotte ? Is it really needed?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.