From a5e9b6c85c15ad9b8ce011171412fa5766d39e02 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 19 Jul 2015 11:19:06 -0400 Subject: autoload/auditory.vim: Reenable visual mode 'x' mapping Needed to come up with a way to add it to the `mappings` dictionary without overriding the existing normal mode 'x' mapping. Prefixed it with `v_` for the dictionary key so that it doesn't conflict, but that could easily be the start of a mapping (for whatever reason), so added a `map_from` field to make it explicit what we're mapping from in cases where the dict key is unclear. Also added another field to the dict to specify a custom mapping command. It will default to `nnoremap` as that's the one we use for most of our commands, but you can change it if you need another mode as we do for this visual 'x' mapping. --- autoload/auditory.vim | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/autoload/auditory.vim b/autoload/auditory.vim index 4980ba5..79ac524 100644 --- a/autoload/auditory.vim +++ b/autoload/auditory.vim @@ -412,10 +412,12 @@ let s:mappings['x'] = { \ 'audio': '/Resources/Normal_Mode/Delete.wav', \ 'map_to': "exec 'normal!' v:count1 . 'x'", \ } -" let s:mappings['x'] = { -" \ 'audio': '/Resources/Normal_Mode/Delete.wav', -" \ 'map_to': "exec 'normal!' v:count1 . 'x'", -" \ } +let s:mappings['v_x'] = { + \ 'audio': '/Resources/Normal_Mode/Delete.wav', + \ 'map_command': 'vnoremap', + \ 'map_from': 'x', + \ 'map_to': "exec 'normal!' v:count1 . 'x'", +\ } " nnoremap d :call auditory#Play('/Resources/Normal_Mode/Delete.wav') \| exec 'normal!' v:count1 . 'd' " nnoremap d :set opfunc=d \| call auditory#Play('/Resources/Normal_Mode/Delete.wav') \| exec 'normal!' v:count1 . @g @@ -439,7 +441,13 @@ function! auditory#AssignNormalModeMappings() " Otherwise to exit command mode. let l:pipe = match(value.map_to, 'exec') !=# -1 ? ' \| ' : '' - execute 'nnoremap ' . key . + " Default to nnoremap + let l:cmd = has_key(value, 'map_command') ? value.map_command : 'nnoremap' + + " If `map_from` is specified, we can't rely on `key` to provide it + let l:map_from = has_key(value, 'map_from') ? value.map_from : key + + execute l:cmd . ' ' . l:map_from . \ ' :call auditory#Play("' . value.audio . '")' . \ l:pipe . value.map_to endfor -- cgit v1.2.3