Subject: | Term::ReadLine::Perl should not use $ENV{EDITOR} |
The subject says it all. Term::ReadLine::Perl uses the value of $ENV{EDITOR}
to determine which editing mode (emacs or vi) should be used. This is
contrary to the original GNU readline, where the editing mode is by
default "emacs", regardless of the EDITOR environment variable.
The attached patch fixes this problem. Additionaly, it is possible now to use
PERL_RL="Perl mode=vi" to set the vi editing mode via environment variable.
Regards,
Slaven
#
#
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'patch' program with this file as input.
#
#### End of Preamble ####
#### Patch data follows ####
diff -up '/home/slavenr/.cpan/build/Term-ReadLine-Perl-1.0203/ReadLine/readline.pm' '/home/slavenr/tmp/Term-ReadLine-Perl-1.0203/ReadLine/readline.pm'
Index: ./ReadLine/readline.pm
--- ./ReadLine/readline.pm Sat May 25 03:21:12 2002
+++ ./ReadLine/readline.pm Wed Apr 7 15:00:27 2004
@@ -16,10 +16,11 @@
## Call rl_set to set mode variables yourself, as in
## &readline'rl_set('TcshCompleteMode', 'On');
##
-## If $ENV{EDITOR} is a string containing the substring 'vi', we start in vi
-## input mode; otherwise start in emacs mode. To override this behavior, do
+## By default we start in emacs mode, regardless of the value of
+## $ENV{EDITOR}. To override this behavior, do
## &readline::rl_set('EditingMode', 'vi');
## or &readline::rl_set('EditingMode', 'emacs');
+## or add " mode=vi" to the PERL_RL environment variable.
##
## Call rl_basic_commands to set your own command completion, as in
## &readline'rl_basic_commands('print', 'list', 'quit', 'run', 'status');
@@ -71,7 +72,7 @@ $VERSION = $VERSION = '1.0203';
## Changed subs:
##
## * preinit(): Initialize new keymaps and other data structures.
-## Use $ENV{EDITOR} to set startup mode.
+## Use $ENV{PERL_RL} to set startup mode.
##
## * init(): Sets the global *KeyMap, since &F_ReReadInitFile
## may have changed the key map.
@@ -1010,8 +1011,10 @@ sub preinit
ord('E') => q{.\s*\S*(?=\S)|.?\s*(?=\s$)},
};
- my $default_mode =
- (defined $ENV{EDITOR} and $ENV{EDITOR} =~ /vi/) ? 'vi' : 'emacs';
+ my $default_mode = 'emacs';
+ if (defined $ENV{PERL_RL} && $ENV{PERL_RL} =~ / mode=vi/) {
+ $default_mode = 'vi';
+ }
*KeyMap = $var_EditingMode = $var_EditingMode{$default_mode};
diff -up '/home/slavenr/.cpan/build/Term-ReadLine-Perl-1.0203/test.pl' '/home/slavenr/tmp/Term-ReadLine-Perl-1.0203/test.pl'
Index: ./test.pl
--- ./test.pl Sat Mar 30 23:34:00 2002
+++ ./test.pl Wed Apr 7 15:00:21 2004
@@ -1,6 +1,6 @@
# Give an argument to use stdin, stdout instead of console
# If argument starts with /dev, use it as console
-BEGIN{ $ENV{PERL_RL} = 'Perl' }; # Do not test TR::Gnu !
+BEGIN{ $ENV{PERL_RL} =~ s/^\w*/Perl/; }; # Do not test TR::Gnu, but preserve any additional options
use Term::ReadLine;
use Carp;
#### End of Patch data ####
#### ApplyPatch data follows ####
# Data version : 1.0
# Date generated : Wed Apr 7 15:04:05 2004
# Generated by : makepatch 2.00_12*
# Recurse directories : Yes
# Excluded files : (\A|/).*\~\Z
# (\A|/).*\.a\Z
# (\A|/).*\.bak\Z
# (\A|/).*\.BAK\Z
# (\A|/).*\.elc\Z
# (\A|/).*\.exe\Z
# (\A|/).*\.gz\Z
# (\A|/).*\.ln\Z
# (\A|/).*\.o\Z
# (\A|/).*\.obj\Z
# (\A|/).*\.olb\Z
# (\A|/).*\.old\Z
# (\A|/).*\.orig\Z
# (\A|/).*\.rej\Z
# (\A|/).*\.so\Z
# (\A|/).*\.Z\Z
# (\A|/)\.del\-.*\Z
# (\A|/)\.make\.state\Z
# (\A|/)\.nse_depinfo\Z
# (\A|/)core\Z
# (\A|/)tags\Z
# (\A|/)TAGS\Z
# p 'ReadLine/readline.pm' 116579 1081342827 0100664
# p 'test.pl' 1027 1081342821 0100444
#### End of ApplyPatch data ####
#### End of Patch kit [created: Wed Apr 7 15:04:05 2004] ####
#### Patch checksum: 87 3647 55388 ####
#### Checksum: 105 4271 41400 ####