Skip Menu |

This queue is for tickets about the Proc-InvokeEditor CPAN distribution.

Report information
The Basics
Id: 30623
Status: resolved
Priority: 0/
Queue: Proc-InvokeEditor

People
Owner: MSTEVENS [...] cpan.org
Requestors: tbooth [...] ceh.ac.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in:
  • 0.02
  • 0.03
  • 1.00
  • 1.01
Fixed in: (no value)



Subject: feature suggestion
Date: Fri, 09 Nov 2007 17:59:28 +0000
To: bug-Proc-InvokeEditor [...] rt.cpan.org
From: Tim Booth <tbooth [...] ceh.ac.uk>
Hi, The module has been around for years and does exectly what it says on the tin. However, one thing I found handy to add was a feature enabling specifying the extension on the temporary file - (eg .xml) The motivation for this is that the editor (Vim in my case) can use this as a hint for syntax hilighting and the like when editing the buffer. Patch is pretty trivial as the Tempfile module does all the work already: tbooth@barsukas[new]sudo diff -u /usr/share/perl5/Proc/InvokeEditor.pm /usr/share/perl5/Proc/InvokeEditor.pm.new --- /usr/share/perl5/Proc/InvokeEditor.pm 2001-09-17 21:26:18.000000000 +0100 +++ /usr/share/perl5/Proc/InvokeEditor.pm.new 2007-11-09 17:55:50.000000000 +0000 @@ -101,6 +101,7 @@ sub edit { my $self = shift; my $arg = shift; + my $suff = shift; # if the argument supplied is a reference to an array of lines, # join it together based on the input record separator if (ref($arg) eq 'ARRAY') { @@ -108,9 +109,9 @@ } my $result; if (ref($self)) { - $result = _edit($arg, $self->{'editors'}, $self->{'cleanup'}); + $result = _edit($arg, $self->{'editors'}, $self->{'cleanup'}, $suff); } else { - $result = _edit($arg, \@DEFAULT_EDITORS, 1); + $result = _edit($arg, \@DEFAULT_EDITORS, 1, $suff); } if (wantarray) { my @result = split m|$/|, $result; @@ -164,6 +165,8 @@ my $string = shift; my $er = shift; my $unlink = shift; + my $suff = shift; + assert(ref($er) eq 'ARRAY'); assert(defined $unlink); my @editors = @$er; @@ -171,8 +174,11 @@ my $chosen_editor = first_usable(undef, $er); + my @suff; + @suff = (SUFFIX => $suff) if $suff; + # get a temp file, and write the text to it - my ($fh, $filename) = tempfile(UNLINK => $unlink); + my ($fh, $filename) = tempfile(UNLINK => $unlink, @suff); print $fh $string; close $fh or die "Couldn't close tempfile [$filename]; $!"; # start the editor Any takers? TIM -- This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system.
I like the idea, I'm going to apply either this or something very like it when I get a chance.
Fixed in 1.02 - The uploaded file Proc-InvokeEditor-1.02.tar.gz has entered CPAN as file: $CPAN/authors/id/M/MS/MSTEVENS/Proc-InvokeEditor-1.02.tar.gz size: 6132 bytes md5: 2fc29eeaa8ad8a58417ff3cc16af9077 No action is required on your part Request entered by: MSTEVENS (Michael Stevens) Request entered on: Sun, 16 Dec 2007 21:38:25 GMT Request completed: Sun, 16 Dec 2007 21:39:29 GMT