Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tmux bracketed paste #265

Merged
merged 1 commit into from
Oct 23, 2020
Merged

Conversation

carlocab
Copy link
Contributor

@carlocab carlocab commented Oct 22, 2020

Fixes #262, KristofferC/OhMyREPL.jl#224, #194 (comment)
Related to #254

I tried looking for terminal applications that don't support bracketed paste #254 (comment) but haven't managed to find any. Playing around a little bit with it Python hasn't revealed any problems either.

@jpalardy
Copy link
Owner

hi @carlocab

I've been running this patch (manually) for a few weeks now, I don't see bad side-effects.

Let's merge it for now, and see what comes up.

@jpalardy jpalardy merged commit 55f4d26 into jpalardy:master Oct 23, 2020
@carlocab
Copy link
Contributor Author

Great! If it helps allay any worries you have, tmux is soon making bracketed-paste the default behaviour for <Prefix>-]:

https://github.com/tmux/tmux/blob/9a5b2c93a7129a6e6e74e4b6d4c2c78dd568b8d4/CHANGES#L13

@kdauria
Copy link

kdauria commented Oct 24, 2020

I don't quite understand why, but this change broke my usual workflow. Within a tmux session inside of an ubuntu20.04 docker container, I send commands from vim to ipython. With the latest commit (dein#add('jpalardy/vim-slime'))

Screen Shot 2020-10-24 at 9 54 14 AM

When I manually deleted the two dashes causing the syntax error and then press Enter to issue the commands, the ipython terminal just hangs forever.

With an older commit (dein#add('jpalardy/vim-slime', { 'rev': 'e7b3cb0bb55a6ca65b218d7e825d9aac71d60638' }))

Screen Shot 2020-10-24 at 9 47 36 AM

It seems like with this update that the cpaste -q is no longer needed?

@carlocab
Copy link
Contributor Author

@kdauria Ugh, sorry about that. What happens if you remove %cpaste -q and -- entirely?

I don't use IPython much, but from my (admittedly limited, and possibly mistaken) understanding is that %paste and %cpaste were early implementations of bracketed-paste before terminal apps started supporting it. I suspect you should now be able to get by without %cpaste with the new update, but unfortunately, it will also break any old code you have.

@kdauria
Copy link

kdauria commented Oct 24, 2020

Thanks @carlocab . I'll try fiddling around with this line:

return ["%cpaste -q\n", g:slime_dispatch_ipython_pause, a:text, "--\n"]

@carlocab
Copy link
Contributor Author

Thanks @carlocab . I'll try fiddling around with this line:

return ["%cpaste -q\n", g:slime_dispatch_ipython_pause, a:text, "--\n"]

@kdauria

Yes, I think that should do it! I think you'll want to keep the \n at the end, but with that, your snippet should execute fine. I'm not sure how it'll handle indentation though.

If you have a code snippet with indentation I could play with to see what works, please do share it so I can try to test it out too.

@carlocab
Copy link
Contributor Author

carlocab commented Oct 24, 2020

Ok, now that I think about it playing around with that line will probably affect users who aren't using tmux.

It might be better to just deactivate bracketed paste if g:slime_python_ipython = 1. The master branch currently works for me in Python even if that variable is not set.

@kdauria
Copy link

kdauria commented Oct 24, 2020

@carlocab I gave it a try. https://github.com/kdauria/vim-slime/pull/1

I'm stuck on how to send a carriage return in ipython in order to "submit" the commands. I tried adding in my vim config, but that didn't work.

    xmap <Leader>e <Plug>SlimeRegionSend<CR>
    nmap <Leader>e <Plug>SlimeParagraphSend<CR>

FWIW, I really like the bracketed paste. It seems to be less buggy and also allows ipython to do syntax highlighting.

@carlocab
Copy link
Contributor Author

Yea, I got stuck on the same thing. I tried looking up how to get IPython to read a character as a carriage return, but no luck.

@carlocab
Copy link
Contributor Author

A potential, but possibly ugly, solution would be for TmuxSend not to invoke the -p flag, but to wrap the text it sends with the bracketed-paste escape codes directly. This would get around the problem of bracketed-paste eating the \n after %cpaste and --, and should in theory exhibit identical behaviour elsewhere.

However, I don't know what %cpaste does with those escape codes. I'll try to carve out time tomorrow to try it out.

@jpalardy
Copy link
Owner

reverted 10e8c2b

Klafyvel added a commit to Klafyvel/vim-slime that referenced this pull request Dec 26, 2021
jpalardy pushed a commit that referenced this pull request Dec 26, 2021
* A trade-off for #265, allowing to have bracketed-paste in tmux as an option.

* Introduce g:slime_bracketed_paste rather than using the config dict.

Co-authored-by: Hugo Levy-Falk <hugo@klafyvel.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vim-slime seems to append a "]" character to julia list comprehension lines
3 participants