aboutsummaryrefslogtreecommitdiffstats
path: root/autoload
diff options
context:
space:
mode:
authorTeddy Wing2015-07-19 12:43:40 -0400
committerTeddy Wing2015-07-19 12:43:40 -0400
commit8dc2441f00eff079dc7a62147f84ec40ad73c75d (patch)
tree84f30fb0c1b27b9466d737d9dd7dbdbe6e1ed6bc /autoload
parent340cf5a64b97cc9f123a85953c7f5b9bf93d2a9e (diff)
downloadauditory.vim-8dc2441f00eff079dc7a62147f84ec40ad73c75d.tar.bz2
auditory#StoreUserMapping: Operate on a single mapping
Refactor to operate on one mapping passed in as an argument instead of the whole `s:mappings` dictionary. This will allow me to call the function inside `auditory#AssignMappings` and avoid having 2 `for` loops when 1 will suffice.
Diffstat (limited to 'autoload')
-rw-r--r--autoload/auditory.vim11
1 files changed, 6 insertions, 5 deletions
diff --git a/autoload/auditory.vim b/autoload/auditory.vim
index 0476631..4bfac77 100644
--- a/autoload/auditory.vim
+++ b/autoload/auditory.vim
@@ -468,13 +468,14 @@ endfunction
" If users have a custom mapping for any of the commands we need, store the
" mapping so we can map to it after playing audio and so we can restore the
" user's mappings when the plugin is toggled off.
-function! auditory#StoreUserMappings()
- for [key, value] in items(s:mappings)
- let l:map_from = has_key(value, 'map_from') ? value.map_from : key
+function! auditory#StoreUserMapping(map_from)
+ if !has_key(s:mappings[a:map_from], 'user_mapping')
+ let l:map_from = has_key(s:mappings[a:map_from], 'map_from') ?
+ \ s:mappings[a:map_from].map_from : a:map_from
let l:user_mapping = maparg(l:map_from)
if l:user_mapping
- let value.user_mapping = l:user_mapping
+ let s:mappings[a:map_from].user_mapping = l:user_mapping
endif
- endfor
+ endif
endfunction