bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#41788: 28.0.50; emacsclient -t doesn't work with vipe from moreutils


From: Lars Ingebrigtsen
Subject: bug#41788: 28.0.50; emacsclient -t doesn't work with vipe from moreutils
Date: Mon, 06 Jun 2022 16:49:38 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Andreas Schwab <schwab@linux-m68k.org> writes:

> It's not emacsclient that is complaining, it just displays the error
> raised by emacs.  But it is hard to guess what's going on without
> knowing the exact command line.

/usr/bin/vipe is just a Perl script, so it's easy to hack.  Let's see...
it just calls:

emacsclient -t /tmp/KtLHpMIm4T

I've included the entire vipe script below.

#!/usr/bin/perl

use warnings;
use strict;
use File::Temp q{tempfile};
use Getopt::Long;

$/=undef;

my $suffix = "";
if (! GetOptions("suffix=s" => \$suffix)) {
        die "Usage: $0 [--suffix=extension]\n";
}
$suffix = ".$suffix" if $suffix =~ m/^[^.]/;

my ($fh, $tmp)=tempfile(UNLINK => 1, SUFFIX => $suffix);
die "cannot create tempfile" unless $fh;
if (! -t STDIN) {
        print ($fh <STDIN>) || die "write temp: $!";
}
close $fh;
close STDIN;
open(STDIN, "</dev/tty") || die "reopen stdin: $!";
open(OUT, ">&STDOUT") || die "save stdout: $!";
close STDOUT;
open(STDOUT, ">/dev/tty") || die "reopen stdout: $!";

my @editor="vi";
if (-x "/usr/bin/editor") {
        @editor="/usr/bin/editor";
}
if (exists $ENV{EDITOR}) {
        @editor=split(' ', $ENV{EDITOR});
}
if (exists $ENV{VISUAL}) {
        @editor=split(' ', $ENV{VISUAL});
}
my $ret=system(@editor, $tmp);
if ($ret != 0) {
        die "@editor exited nonzero, aborting\n";
}

open (IN, $tmp) || die "$0: cannot read $tmp: $!\n";
print (OUT <IN>) || die "write failure: $!";
close IN;


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]