Skip to content

Commit 8f4db8e

Browse files
committed
g:extract_default_position option added
1 parent c301abe commit 8f4db8e

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

autoload/extract.vim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ func! extract#extract(selection, buffer_options) abort
1010
if exists('g:loaded_buffr')
1111
call s:extract(a:selection, a:buffer_options)
1212
else
13-
call s:show_error('Please, install vim-buffr')
14-
return
13+
call s:show_error('Please, install vim-buffr') | return
1514
endif
1615
endfunc
1716

doc/vim-extract.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,33 @@ COMMANDS *vim-extract-commands*
6767
===============================================================================
6868
OPTIONS *vim-extract-options*
6969

70+
*g:extract_default_position*
71+
72+
Default extract buffer position.
73+
74+
Possible values: 'top', 'bottom', 'left', 'right', 'tab'
75+
Default value: 'top'
76+
7077
*g:extract_buffer_name*
7178

7279
Extract buffer name pattern. {filename} will be replaced with the
7380
current file name. This option will be used if :Extr command was called
7481
without 'name' argument.
7582

76-
Default: '_{filename}'
83+
Default value: '_{filename}'
7784

7885
*g:extract_append*
7986

8087
Append selection to the end of the extract buffer (1) or clear the extract
8188
buffer before insertation (0).
8289

83-
Default: 1
90+
Default value: 1
8491

8592
*g:extract_hidden*
8693

8794
Extract selection without opening the extract buffer.
8895

89-
Default: 0
96+
Default value: 0
9097

9198
===============================================================================
9299
CHANGELOG *vim-extract-changelog*

plugin/extract.vim

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ if !exists('g:extract_hidden')
1919
let g:extract_hidden = 0
2020
endif
2121

22-
let s:allowed_args = ['-top', '-bottom', '-left', '-right', '-tab']
22+
if !exists('g:extract_default_position')
23+
let g:extract_default_position = 'top'
24+
endif
25+
26+
let s:allowed_position_args = ['-top', '-bottom', '-left', '-right', '-tab']
2327

2428
func! s:autocompletion(input, command_line, cursor_position) abort
2529
return filter(s:allowed_args, 'v:val =~ a:input')
@@ -33,17 +37,15 @@ func! s:extract(start_line, end_line, count, clear, ...) abort
3337
\ }
3438
let l:buffer_options = { 'clear': a:clear }
3539

36-
let l:name_args_filter = 'index(s:allowed_args, v:val) < 0'
37-
let l:name_args = filter(copy(a:000), l:name_args_filter)
40+
let l:name_args = filter(copy(a:000), 'index(s:allowed_position_args, v:val) < 0')
3841
if len(l:name_args)
3942
let l:buffer_options.name = join(l:name_args)
4043
endif
4144

42-
let l:position_args_filter = 'index(s:allowed_args, v:val) >= 0'
43-
let l:position_args = filter(copy(a:000), l:position_args_filter)
45+
let l:buffer_options.position = g:extract_default_position
46+
let l:position_args = filter(copy(a:000), 'index(s:allowed_position_args, v:val) >= 0')
4447
if len(l:position_args)
45-
let l:position_arg = get(l:position_args, -1)
46-
let l:buffer_options.position = substitute(l:position_arg, '-', '', 'g')
48+
let l:buffer_options.position = substitute(l:position_args[-1], '-', '', 'g')
4749
endif
4850

4951
call extract#extract(l:selection, l:buffer_options)

0 commit comments

Comments
 (0)