Make __fisher_key_bindings_undo smarter. Close #121.

Until now key_bindings.fish only allowed simple bind <args>
staments and would fail for conditional statements, etc.
pull/445/head
Jorge Bucaran 8 years ago
parent e1e49ceaff
commit 3308240929
No known key found for this signature in database
GPG Key ID: E54BA3C0E646DB30

@ -1,17 +1,11 @@
function __fisher_key_bindings_disable -a plugin user_key_bindings
fish_indent < $fisher_binds \
| __fisher_key_bindings_undo $plugin \
| source
fish_indent < $fisher_binds | __fisher_key_bindings_undo $plugin | source ^ /dev/null
__fisher_key_bindings_delete $plugin \
> $fisher_binds.tmp \
< $fisher_binds
__fisher_key_bindings_delete $plugin > $fisher_binds.tmp < $fisher_binds
command mv -f $fisher_binds.tmp $fisher_binds
if test ! -s $fisher_binds
debug "Remove fisherman key bindings '%s'" "$user_key_bindings"
sed -i.tmp '/__fisher_key_bindings/d' $user_key_bindings
command rm -f $user_key_bindings.tmp
end

@ -1,3 +1,3 @@
function __fisher_key_bindings_undo -a plugin
sed -n "/##$plugin##/,/##$plugin##/{s/bind /bind -e /p;};"
sed -n "/##$plugin##/,/##$plugin##/{s/^ *bind /bind -e /p;};"
end

@ -1,6 +1,6 @@
##foo##
echo bind foo
bind foo
##foo##
##bar##
echo bind bar
bind bar
##bar##

@ -7,6 +7,10 @@ function -S setup
set -g fisher_binds $path/fisher_key_bindings.fish
function bind
printf "%s\n" "bind $argv"
end
for plugin in foo bar baz
__fisher_key_bindings_disable $plugin $path/user_key_bindings.fish >> $path/key_bindings_log
end
@ -14,6 +18,7 @@ end
function -S teardown
rm -rf $path
functions -e bind
end
test "$TESTNAME - Remove bindings from fisher key bindings file"

Loading…
Cancel
Save