Skip to content

Commit cdcb8dc

Browse files
committed
Use abort for functions
1 parent b8230c8 commit cdcb8dc

File tree

4 files changed

+18
-24
lines changed

4 files changed

+18
-24
lines changed

autoload/executor.vim

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let s:previous_buffer = ''
1111
let s:positions = ['top', 'bottom', 'left', 'right', 'tab']
1212
let s:default_position = 'bottom'
1313

14-
func! executor#exec(start_line, end_line, open_result, ...)
14+
func! executor#exec(start_line, end_line, open_result, ...) abort
1515
if !exists('g:loaded_buffr')
1616
call s:show_error('Please, install vim-buffr plugin first') | return
1717
endif
@@ -23,23 +23,23 @@ func! executor#exec(start_line, end_line, open_result, ...)
2323
call executor#async#exec(l:command, l:selection, a:open_result)
2424
else
2525
call executor#default#exec(l:command, l:selection, a:open_result)
26-
end
26+
endif
2727
endfunc
2828

29-
func! executor#open_result(result, command)
29+
func! executor#open_result(result, command) abort
3030
let l:buffer_name = s:buffer_name(a:command)
3131
call s:open_buffer(l:buffer_name)
3232
call append(0, a:result)
3333
silent normal! Gddgg
3434
endfunc
3535

36-
func! s:open_buffer(buffer_name)
36+
func! s:open_buffer(buffer_name) abort
3737
let l:buffer_name = a:buffer_name
3838

3939
if g:executor_reuse_buffer
4040
if len(s:previous_buffer)
4141
let l:buffer_name = s:previous_buffer
42-
end
42+
endif
4343
let s:previous_buffer = a:buffer_name
4444
endif
4545

@@ -54,7 +54,7 @@ func! s:open_buffer(buffer_name)
5454
endif
5555
endfunc
5656

57-
func! s:buffer_name(command)
57+
func! s:buffer_name(command) abort
5858
let l:name = g:executor_buffer_name
5959
let l:name = substitute(l:name, '{command}', a:command, 'g')
6060
let l:name = substitute(l:name, '{filename}', expand('%:t'), 'g')
@@ -63,15 +63,11 @@ func! s:buffer_name(command)
6363
return l:name
6464
endfunc
6565

66-
func! s:buffer_position()
67-
if index(s:positions, g:executor_position) < 0
68-
return s:default_position
69-
else
70-
return g:executor_position
71-
endif
66+
func! s:buffer_position() abort
67+
return index(s:positions, g:executor_position) < 0 ? s:default_position : g:executor_position
7268
endfunc
7369

74-
func! s:set_buffer_defaults()
70+
func! s:set_buffer_defaults() abort
7571
setlocal buftype=nofile
7672
setlocal bufhidden=wipe
7773
setlocal nobuflisted

autoload/executor/async.vim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
" Licence: BSD-3-Clause
88
" ===========================================================================
99

10-
func! executor#async#exec(command, selection, open_result)
10+
func! executor#async#exec(command, selection, open_result) abort
1111
let s:command = a:command
1212
let s:result = []
1313
let s:open_result = a:open_result
1414
call s:execute(a:command, a:selection)
1515
endfunc
1616

17-
func! s:execute(command, selection)
17+
func! s:execute(command, selection) abort
1818
let l:command = a:command
1919

2020
if len(a:selection) == 1 && !empty(a:selection[0])
@@ -32,12 +32,12 @@ func! s:execute(command, selection)
3232
\ })
3333
endfunc
3434

35-
func! s:out_callback(channel, data)
35+
func! s:out_callback(channel, data) abort
3636
call add(s:result, a:data)
3737
endfunc
3838

39-
func! s:exit_callback(job, status)
39+
func! s:exit_callback(job, status) abort
4040
if s:open_result
4141
call executor#open_result(s:result, s:command)
42-
end
42+
endif
4343
endfunc

autoload/executor/default.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
" Licence: BSD-3-Clause
88
" ===========================================================================
99

10-
func! executor#default#exec(command, selection, open_result)
10+
func! executor#default#exec(command, selection, open_result) abort
1111
let l:result = s:execute(a:command, a:selection)
1212
if a:open_result
1313
call executor#open_result(split(l:result, "\n"), a:command)
1414
endif
1515
endfunc
1616

17-
func! s:execute(command, selection)
17+
func! s:execute(command, selection) abort
1818
if !len(a:selection) || (len(a:selection) == 1 && empty(a:selection[0]))
1919
return system(a:command)
2020
endif

plugin/executor.vim

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
if exists('g:loaded_executor') || &compatible || v:version < 700
1111
finish
1212
endif
13+
let g:loaded_executor = 1
1314

1415
if !exists('g:executor_position')
1516
let g:executor_position = 'bottom'
@@ -27,7 +28,4 @@ if !exists('g:executor_exec_async')
2728
let g:executor_exec_async = 1
2829
endif
2930

30-
comm! -nargs=+ -bang -range=0 -complete=shellcmd Exec
31-
\ call executor#exec(<line1>, <line2>, empty('<bang>'), <q-args>)
32-
33-
let g:loaded_executor = 1
31+
comm! -nargs=+ -bang -range=0 -complete=shellcmd Exec call executor#exec(<line1>, <line2>, empty('<bang>'), <q-args>)

0 commit comments

Comments
 (0)