From 5bb2b3a3307d3d36b539caecf1955fceaa010e0c Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 16 Dec 2017 21:49:40 +0100 Subject: open_tmux_split: Remove filename first argument The filename isn't useful to us any more since we can't open the FIFO directly from Vim (`vim $fifo`). But, in order to be able to close Vim after writing without it complaining that we haven't written the buffer to a file, we need to appease it by giving it a random filename. --- vimput.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vimput.pl b/vimput.pl index ad6dea3..e76da3d 100644 --- a/vimput.pl +++ b/vimput.pl @@ -38,7 +38,7 @@ sub write_input { # Open a Tmux split containing a Vim instance editing the vimput_file. sub open_tmux_split { - my ($filename, $fifo) = @_; + my ($fifo) = @_; if (!$ENV{TMUX}) { print 'no tmux'; # TODO: Replace with Irssi print @@ -46,8 +46,10 @@ sub open_tmux_split { return; } + my $random_unused_filename = tmpnam(); + # my $command = "vim ${\vimput_file}"; - my $command = "vim -c 'set buftype=acwrite' -c 'read ${\vimput_file}' -c '1 delete _' -c 'autocmd BufWriteCmd :write $fifo | set nomodified' $filename"; + my $command = "vim -c 'set buftype=acwrite' -c 'read ${\vimput_file}' -c '1 delete _' -c 'autocmd BufWriteCmd :write $fifo | set nomodified' $random_unused_filename"; system('tmux', 'split-window', $command); } @@ -188,7 +190,7 @@ if ($pid == 0) { # print $command_handle $fifo_path; close $command_handle; - open_tmux_split('rando', $fifo_path); + open_tmux_split($fifo_path); mkfifo($fifo_path, 0600) or die $!; -- cgit v1.2.3