Here is a patch that simply includes notepad.exe as a default.
This makes the tests pass on Windows and provides the most basic
EDITOR feature.
It needs Text::ParseWords on Windows now (and I think it would be a good idea to use this in general). That module has been in core since Perl 5.
I've also added documentation on how to support Notepad++ as an example. The same example
also works with git, so I think it is a good default.
From 9ee1936d12ccfb7e8122a8bc657073d7cd18418a Mon Sep 17 00:00:00 2001
From: Max Maischein <corion@corion.net>
Date: Fri, 28 Jul 2017 23:54:46 +0200
Subject: [PATCH] Make module work on Win32
---
lib/Proc/InvokeEditor.pm | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/lib/Proc/InvokeEditor.pm b/lib/Proc/InvokeEditor.pm
index 3cc01d9..1ac9ce0 100644
--- a/lib/Proc/InvokeEditor.pm
+++ b/lib/Proc/InvokeEditor.pm
@@ -37,7 +37,7 @@ $VERSION = '1.07';
@DEFAULT_EDITORS = ( $ENV{'VISUAL'}, $ENV{'EDITOR'}, '/usr/bin/vi',
'/bin/vi', '/bin/ed',
- map({ can_run($_) } qw(vi ed))
+ map({ can_run($_) } qw(vi ed notepad.exe))
);
sub new {
@@ -158,7 +158,14 @@ sub first_usable {
my @path = File::Spec->path;
EDITORS: foreach my $editor (@editors) {
next unless defined $editor;
- my @editor_bits = split /\s+/, $editor;
+ my @editor_bits;
+ if( $^O =~ /mswin/i ) {
+ require Text::ParseWords;
+ $editor =~ s!\\!\\\\!g; # quote path for shellwords
+ @editor_bits = Text::ParseWords::shellwords($editor);
+ } else {
+ @editor_bits = split /\s+/, $editor;
+ };
next unless defined $editor_bits[0];
if (File::Spec->file_name_is_absolute($editor_bits[0])
and -x $editor_bits[0]) {
@@ -374,6 +381,15 @@ This specifies a filename suffix to be used when the editor is launched - this
can be useful if the data in the file is of a particular type and you want to
trigger an editor's syntax highlighting mode.
+=head1 WINDOWS SUPPORT
+
+On Windows, the parsing is a bit different and uses shell parsing respecting
+double quoted paths as the first item for the editor.
+
+The following might work to use Notepad++ as your editor with this module or C<git>
+
+ set EDITOR="c:\Program Files\Notepad++\notepad++.exe" -multiInst -nosession -notabbar
+
=head1 TODO
=over 4
--
2.5.0.windows.1