Skip to content

Commit efab2ed

Browse files
committed
Bump version to 1.0.0
1 parent c929647 commit efab2ed

File tree

3 files changed

+38
-24
lines changed

3 files changed

+38
-24
lines changed

autoload/extract.vim

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
" Description: Extract selection to a new buffer
33
" Author: Alexander Skachko <alexander.skachko@gmail.com>
44
" Homepage: https://github.com/lucerion/vim-extract
5-
" Version: 0.4.0 (2016-09-19)
5+
" Version: 1.0.0 (2017-09-03)
66
" Licence: BSD-3-Clause
77
" ==============================================================
88

9-
func! extract#extract(selection, buffer_options)
9+
func! extract#extract(selection, buffer_options) abort
1010
if exists('g:loaded_buffr')
1111
call s:extract(a:selection, a:buffer_options)
1212
else
@@ -15,62 +15,66 @@ func! extract#extract(selection, buffer_options)
1515
endif
1616
endfunc
1717

18-
func! s:extract(selection, buffer_options)
18+
func! s:extract(selection, buffer_options) abort
1919
let l:selection = getline(a:selection.start_line, a:selection.end_line)
2020

2121
if a:selection.count
2222
call s:delete_lines(a:selection.start_line, a:selection.end_line)
2323
endif
24+
2425
call s:open_buffer(a:buffer_options)
26+
2527
if a:buffer_options.clear
2628
call s:clear_buffer()
2729
end
30+
2831
if a:selection.count
2932
call s:insert_selection(l:selection)
33+
3034
if g:extract_hidden
3135
call s:close_buffer()
3236
endif
3337
endif
3438
endfunc
3539

36-
func! s:open_buffer(buffer_options)
40+
func! s:open_buffer(buffer_options) abort
3741
let l:buffer_options = s:buffer_options(a:buffer_options)
3842
call buffr#open_or_create_buffer(l:buffer_options)
3943
call s:set_buffer_defaults(l:buffer_options)
4044
endfunc
4145

42-
func! s:close_buffer()
46+
func! s:close_buffer() abort
4347
silent exec 'close'
4448
endfunc
4549

46-
func! s:buffer_options(buffer_options)
50+
func! s:buffer_options(buffer_options) abort
4751
let l:default_buffer_options = {
4852
\ 'name': substitute(g:extract_buffer_name, '{filename}', expand('%:t'), 'g')
4953
\ }
5054

5155
return extend(l:default_buffer_options, a:buffer_options)
5256
endfunc
5357

54-
func! s:clear_buffer()
55-
silent exec 'normal! ggVGd'
58+
func! s:clear_buffer() abort
59+
call s:delete_lines(1, '$')
5660
endfunc
5761

58-
func! s:insert_selection(selection)
62+
func! s:insert_selection(selection) abort
5963
let l:last_line = line('$')
6064
if l:last_line == 1
6165
call append(0, a:selection)
62-
silent exec 'normal! Gdd'
66+
call s:delete_lines('$', '$')
6367
else
6468
call append(l:last_line, a:selection)
6569
silent exec 'normal! G'
6670
endif
6771
endfunc
6872

69-
func! s:delete_lines(start_line, end_line)
70-
exec a:start_line . ',' . a:end_line . ' delete'
73+
func! s:delete_lines(start_line, end_line) abort
74+
silent exec a:start_line . ',' . a:end_line . ' delete _'
7175
endfunc
7276

73-
func! s:set_buffer_defaults(buffer_options)
77+
func! s:set_buffer_defaults(buffer_options) abort
7478
setlocal buftype=nofile
7579
setlocal bufhidden=hide
7680
setlocal nobuflisted
@@ -84,27 +88,27 @@ func! s:set_buffer_defaults(buffer_options)
8488
augroup END
8589
endfunc
8690

87-
func! s:save_state()
91+
func! s:save_state() abort
8892
if expand('<afile>') == s:buffer_options.name && !s:is_buffer_empty()
8993
exec 'write /tmp/' . s:buffer_options.name
9094
endif
9195
endfunc
9296

93-
func! s:load_state()
97+
func! s:load_state() abort
9498
let l:file = '/tmp/' . s:buffer_options.name
9599
if expand('<afile>') == s:buffer_options.name && filereadable(l:file)
96100
if !s:buffer_options.clear
97101
call append(0, readfile(l:file))
98-
silent exec 'normal! Gdd'
102+
call s:delete_lines('$', '$')
99103
endif
100-
exec '!rm ' . l:file
104+
call delete(l:file)
101105
endif
102106
endfunc
103107

104-
func! s:is_buffer_empty()
108+
func! s:is_buffer_empty() abort
105109
return line('$') == 1 && getline(1) == '' ? 1 : 0
106110
endfunc
107111

108-
func! s:show_error(message)
112+
func! s:show_error(message) abort
109113
echohl ErrorMsg | echomsg a:message | echohl None
110114
endfunc

doc/vim-extract.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Author: Alexander Skachko <alexander.skachko@gmail.com>
44
Homepage: https://github.com/lucerion/vim-extract
5-
Version: 0.4.0 (2016-09-19)
5+
Version: 1.0.0 (2017-09-03)
66
Licence: BSD-3-Clause (see LICENSE)
77

88
===============================================================================
@@ -91,11 +91,20 @@ Default: 0
9191
===============================================================================
9292
CHANGELOG *vim-extract-changelog*
9393

94+
1.0.0 (2017-09-03)~
95+
96+
Changes
97+
* option g:extract_name renamed to g:extract_buffer_name
98+
* clear buffer before selection insert if command called with bang
99+
* restore buffer content if buffer closed without save
100+
94101
0.4.0 (2016-09-19)~
102+
95103
Changes
96104
* extract selection without opening the extract buffer option was added
97105

98106
0.3.0 (2016-03-27)~
107+
99108
vim-buffr plugin version 0.3 required
100109

101110
Changes
@@ -106,11 +115,13 @@ CHANGELOG *vim-extract-changelog*
106115
* g:extract_position option was removed
107116

108117
0.2.0 (2016-02-05)~
118+
109119
Changes
110120
* buffr#open function name was changed to buffr#open_or_create
111121
* Extract command was renamed to VExtract (vim-rails plugin conflict)
112122

113123
0.1.0 (2015-12-06)~
124+
114125
First release
115126

116127
===============================================================================

plugin/extract.vim

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
" Description: Extract selection to a new buffer
33
" Author: Alexander Skachko <alexander.skachko@gmail.com>
44
" Homepage: https://github.com/lucerion/vim-extract
5-
" Version: 0.4.0 (2016-09-19)
5+
" Version: 1.0.0 (2017-09-03)
66
" Licence: BSD-3-Clause
77
" ==============================================================
88

9-
if exists('g:loaded_extract') || &compatible || (v:version < 700)
9+
if exists('g:loaded_extract') || &compatible || v:version < 700
1010
finish
1111
endif
12+
let g:loaded_extract = 1
1213

1314
if !exists('g:extract_buffer_name')
1415
let g:extract_buffer_name = '_{filename}'
@@ -50,5 +51,3 @@ endfunc
5051

5152
comm! -nargs=* -range=0 -bang -complete=customlist,s:autocompletion Extr
5253
\ call s:extract(<line1>, <line2>, <count>, !empty('<bang>'), <f-args>)
53-
54-
let g:loaded_extract = 1

0 commit comments

Comments
 (0)