diff options
| author | Stephen Blott | 2015-01-21 19:35:24 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2015-01-21 22:24:31 +0000 | 
| commit | c4735264f46fdc62020c81bd8ff6f67ebd1dad9a (patch) | |
| tree | 98b6d4a3e01a2b7a71eacec3e2acacb843a8ea60 /lib/utils.coffee | |
| parent | 0ec38c1050b00845abaa2faa9f56d04c9d2b8992 (diff) | |
| download | vimium-c4735264f46fdc62020c81bd8ff6f67ebd1dad9a.tar.bz2 | |
Edit mode: first working visual mode.
Diffstat (limited to 'lib/utils.coffee')
| -rw-r--r-- | lib/utils.coffee | 14 | 
1 files changed, 14 insertions, 0 deletions
| diff --git a/lib/utils.coffee b/lib/utils.coffee index 661f7e84..f8eb5457 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -152,6 +152,20 @@ Utils =    # locale-sensitive uppercase detection    hasUpperCase: (s) -> s.toLowerCase() != s +  # Allow a function call to be suppressed.  Use Utils.suppress.unlessSuppressed to call a function, unless it +  # is suppressed via the given key.  Use Utils.suppressor.suppress to call a function while suppressing the +  # given key. +  suppressor: do -> +    suppressed = {} + +    suppress: (key, func) -> +      suppressed[key] = if suppressed[key]? then suppressed[key] + 1 else 1 +      func() +      suppressed[key] -= 1 + +    unlessSuppressed: (key, func) -> +      func() unless suppressed[key]? and 0 < suppressed[key] +  # This creates a new function out of an existing function, where the new function takes fewer arguments. This  # allows us to pass around functions instead of functions + a partial list of arguments.  Function::curry = -> | 
