From 8a0fd42b1df21aa9bd1c9d6f8b169d060ea8db6e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 16 Aug 2015 02:43:09 -0400 Subject: Add function and command to toggle mappings * Create `auditory#ToggleMappings()` that turns sounds on if they're off and off if they're on * Create an `:AuditoryToggle` command that runs the toggle function in a more user-friendly callable way With a toggle command, turning Auditory on or off can be as simple as hitting 1 custom mapping. With our previous `AuditoryOn` and `AuditoryOff`, you would have to use 2 mappings: 1 for on and another for off. --- autoload/auditory.vim | 11 +++++++++++ plugin/auditory.vim | 1 + 2 files changed, 12 insertions(+) diff --git a/autoload/auditory.vim b/autoload/auditory.vim index ffa2b1e..e914a03 100644 --- a/autoload/auditory.vim +++ b/autoload/auditory.vim @@ -538,3 +538,14 @@ function! auditory#Unmap() call auditory#UnmapInsert() endfunction + + +function! auditory#ToggleMappings() + if g:auditory_on + call auditory#Unmap() + let g:auditory_on = 0 + else + call auditory#AssignMappings() + let g:auditory_on = 1 + endif +endfunction diff --git a/plugin/auditory.vim b/plugin/auditory.vim index 39ae283..378fd39 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -18,6 +18,7 @@ endif command! AuditoryOn call auditory#AssignMappings() command! AuditoryOff call auditory#Unmap() +command! AuditoryToggle call auditory#ToggleMappings() command! AuditoryToggleGalaxyFarFarAway call auditory#ToggleGalaxyFarFarAway() -- cgit v1.2.3