Add filename expansions to defer commands

This commit is contained in:
Talia 2020-09-29 13:19:24 +02:00
parent 9744203353
commit c2fb46bcee

View file

@ -17,6 +17,10 @@ function Defer(command, callback)
\ })
endfun
function s:expand(string)
return substitute(a:string, '%[:a-z]*', '\=expand(submatch(0))', 'g')
endfun
function s:echo(message)
echom a:message
endfun
@ -25,6 +29,6 @@ function s:notify(message)
call Defer('notify-send "Vim" "'.a:message.'"', { b -> 0 })
endfun
comm -complete=shellcmd -nargs=* Defer call Defer(<q-args>, { r -> 0 })
comm -complete=shellcmd -nargs=* DeferEcho call Defer(<q-args>, { result -> <SID>echo("Deferred job completed (".(result['tend']-result['tstart'])."s): ".<q-args>) })
comm -complete=shellcmd -nargs=* DeferNotify call Defer(<q-args>, { result -> <SID>notify("Deferred job completed (".(result['tend']-result['tstart'])."s):\n$ ".<q-args>) })
comm -complete=shellcmd -nargs=* Defer call Defer(s:expand(<q-args>), { r -> 0 })
comm -complete=shellcmd -nargs=* DeferEcho call Defer(s:expand(<q-args>), { result -> <SID>echo("Deferred job completed (".(result['tend']-result['tstart'])."s): ".s:expand(<q-args>)) })
comm -complete=shellcmd -nargs=* DeferNotify call Defer(s:expand(<q-args>), { result -> <SID>notify("Deferred job completed (".(result['tend']-result['tstart'])."s):\n$ ".s:expand(<q-args>)) })