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 the paste file in conemu for faster turnaround #446

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

djha-skin
Copy link
Contributor

@djha-skin djha-skin commented Sep 11, 2024

This PR changes conemu to use the paste file instead of the windows clipboard. This can make it slightly faster if the clipboard is configured to use a subprocess like powershell.

Changes:

  • The slime#common#write_paste_file now returns the name of the paste file to which it wrote, so that slime#resolve#config doesn't have to be called twice, once in the conemu#send and once in the write_paste_file method.
  • The case where the paste file isn't written is checked.
  • The paste file has the S flag set, which tells vim not to bother calling fsync() on the file, for faster write speeds. This makes sense. The file doesn't contain anything that needs to persist across reboots.
  • ConEMU writes to the paste file and uses that instead.

This change has been "tested on my machine" and works.

Copy link
Owner

@jpalardy jpalardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hI @djhaskin987

thanks for the PR — I've left some comments inline

Comment on lines +28 to +33
let paste_file = slime#config#resolve("paste_file")
let result = writefile(lines, paste_file, 'bS')
if result != 0
echoerr "Couldn't write to slime paste file."
endif
return paste_file
Copy link
Owner

@jpalardy jpalardy Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my initial reaction was resolve is probably too fast to benchmark (it's not in some inner loop) 🤔

but looking at the call sites, it wouldn't hurt to return paste_file -- so I think I'm OK with that 👍

I like checking for a writefile error, how about avoiding the result var? (it's only used for the if)

Suggested change
let paste_file = slime#config#resolve("paste_file")
let result = writefile(lines, paste_file, 'bS')
if result != 0
echoerr "Couldn't write to slime paste file."
endif
return paste_file
let paste_file = slime#config#resolve("paste_file")
if writefile(lines, paste_file, 'bS') != 0
echoerr "Couldn't write to slime paste file."
endif
return paste_file

let @* = tmp
" Use the selection register to send text to ConEmu using the slime paste file
let paste_file = slime#common#write_paste_file(a:text)
call slime#common#system("conemuc -guimacro:%s pastefile 2 %s", [a:config["HWND"], paste_file])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all in all, I'm surprised that using the pastefile would be faster than the clipboard … 🤔


The paste file has the S flag set, which tells vim not to bother calling fsync() on the file

The file doesn't contain anything that needs to persist across reboots.

That wasn't my understanding of fsync — doesn't that create a race-condition if we

  1. write (but skip flush)
  2. turn around and read the file

?


another concern is that the pastefile sticks around, holding on to your last slime send — I'm not sure everybody feels comfortable with that, so I've been avoiding it when possible (only screen was still using it, because there were no other choice 😮‍💨 )

@jpalardy
Copy link
Owner

jpalardy commented Oct 6, 2024

@djhaskin987

any thoughts on this?

Copy link

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants