aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Ruderich <simon@ruderich.org>2010-10-08 20:58:22 +0000
committerSimon Ruderich <simon@ruderich.org>2010-10-08 20:58:22 +0000
commitd2263ffcb0d32517a60c3093e87702179cff5a9d (patch)
treec6f9dd980ba849fd399a9cb7db06fcda15652a4a
parentvim_mode: Update TODO file. (diff)
downloadirssi-scripts-d2263ffcb0d32517a60c3093e87702179cff5a9d.tar.gz
irssi-scripts-d2263ffcb0d32517a60c3093e87702179cff5a9d.zip
vim_mode: Add :mkv[imrc].
Diffstat (limited to '')
-rw-r--r--vim-mode/vim_mode.pl26
1 files changed, 26 insertions, 0 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl
index 3a2bdec..f18fb09 100644
--- a/vim-mode/vim_mode.pl
+++ b/vim-mode/vim_mode.pl
@@ -73,6 +73,7 @@
# {file} not supported
# * Mappings: :map - display custom mappings
# :map {lhs} {rhs} - add mapping
+# * Save mappings: :mkv[imrc] - like in Vim, but [file] not supported
# * Substitute: :s/// - i and g are supported as flags, only /// can be
# used as separator, uses Perl regex instead of
# Vim regex
@@ -383,6 +384,8 @@ my $commands_ex
map => { char => ':map', func => \&ex_map, type => C_EX },
source => { char => ':source', func => \&ex_source, type => C_EX },
so => { char => ':so', func => \&ex_source, type => C_EX },
+ mkvimrc => { char => ':mkvimrc', func => \&ex_mkvimrc, type => C_EX },
+ mkv => { char => ':mkv', func => \&ex_mkvimrc, type => C_EX },
};
# MAPPINGS
@@ -1700,6 +1703,29 @@ sub ex_source {
}
}
+sub ex_mkvimrc {
+ # :mkv[imrc], [file] not supported
+
+ my $vim_moderc = Irssi::get_irssi_dir(). '/vim_moderc';
+ if (-f $vim_moderc) {
+ return _warn_ex('mkvimrc', "$vim_moderc already exists");
+ }
+
+ open my $file, '>', $vim_moderc or return;
+
+ # copied from ex_map()
+ foreach my $key (sort keys %$maps) {
+ my $map = $maps->{$key};
+ my $cmd = $map->{cmd};
+ if (defined $cmd) {
+ next if $map->{char} eq $cmd->{char}; # skip default mappings
+ print $file "$map->{char} $cmd->{char}\n";
+ }
+ }
+
+ close $file;
+}
+
sub _warn_ex {
my ($command, $description) = @_;
my $message = "Error in ex-mode command $command";