Skip to content

Commit

Permalink
Merge pull request #125 from tyru/deprecate-sp-blank-vars
Browse files Browse the repository at this point in the history
Deprecate g:caw_{hat,zero}pos_sp_blank
  • Loading branch information
tyru authored Mar 24, 2020
2 parents 26d53c8 + 91ead39 commit 4f449af
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 28 deletions.
4 changes: 1 addition & 3 deletions autoload/caw/actions/hatpos.vim
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ function! s:hatpos.get_comment_line(lnum, options) abort
" NOTE: min_indent_num is byte length. not display width.
let min_indent_num = get(a:options, 'min_indent_num', -1)
let line = getline(a:lnum)
let sp = line =~# '^\s*$' ?
\ self.get_var('sp_blank') :
\ self.get_var('sp', '', [a:lnum])
let sp = self.get_var('sp', '', [a:lnum])

let comments = self.comment_database.get_comments()
if empty(comments)
Expand Down
4 changes: 1 addition & 3 deletions autoload/caw/actions/zeropos.vim
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ endfunction
" vint: next-line -ProhibitUnusedVariable
function! s:zeropos.get_comment_line(lnum, options) abort
let line = getline(a:lnum)
let caw_zeropos_sp = line =~# '^\s*$' ?
\ self.get_var('sp_blank') :
\ self.get_var('sp', '', [a:lnum])
let caw_zeropos_sp = self.get_var('sp', '', [a:lnum])

let comments = self.comment_database.get_comments()
if empty(comments)
Expand Down
19 changes: 0 additions & 19 deletions doc/caw.txt
Original file line number Diff line number Diff line change
Expand Up @@ -481,15 +481,6 @@ g:caw_hatpos_sp
Inserted string after comment with |<Plug>(caw:hatpos:comment)|.

NOTE: An old variable name was |g:caw_i_sp|.
See |caw-faq-3| why I renamed the keymapping.

*g:caw_hatpos_sp_blank* *g:caw_i_sp_blank*
g:caw_hatpos_sp_blank
(Default: "")
Inserted string after comment with |<Plug>(caw:hatpos:comment)|.
but applied only if a current line is blank line.

NOTE: An old variable name was |g:caw_i_sp_blank|.
See |caw-faq-3| why I renamed the keymapping.

*g:caw_hatpos_startinsert_at_blank_line*
Expand Down Expand Up @@ -559,15 +550,6 @@ g:caw_zeropos_sp
Inserted string after comment with |<Plug>(caw:zeropos:comment)|.

NOTE: An old variable name was |g:caw_I_sp|.
See |caw-faq-3| why I renamed the keymapping.

*g:caw_zeropos_sp_blank* *g:caw_I_sp_blank*
g:caw_zeropos_sp_blank
(Default: "")
Inserted string after comment with |<Plug>(caw:zeropos:comment)|.
but applied only if a current line is blank line.

NOTE: An old variable name was |g:caw_I_sp_blank|.
See |caw-faq-3| why I renamed the keymapping.

}}}
Expand Down Expand Up @@ -725,7 +707,6 @@ A. Because old keymappings and variables' names are hard to understand.
e.g.:
* |<Plug>(caw:i:toggle)| and |<Plug>(caw:tildepos:toggle)| were changed
to |<Plug>(caw:hatpos:toggle)|.
* |g:caw_I_sp_blank| was changed to |g:caw_zeropos_sp_blank|.

hatpos
The keymappings do actions for the position where ^ command moves to.
Expand Down
13 changes: 11 additions & 2 deletions plugin/caw.vim
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,23 @@ function! s:def(name, value) abort
let g:[a:name] = get(g:, a:name, a:value)
endfunction

if exists('g:caw_hatpos_sp_blank')
echohl WarningMsg
echomsg 'g:caw_hatpos_sp_blank is deprecated. please use g:caw_hatpos_sp instead.'
echohl None
endif
if exists('g:caw_zeropos_sp_blank')
echohl WarningMsg
echomsg 'g:caw_zeropos_sp_blank is deprecated. please use g:caw_zeropos_sp instead.'
echohl None
endif

call s:def_deprecated('caw_hatpos_sp', ' ')
call s:def_deprecated('caw_hatpos_sp_blank', ' ')
call s:def_deprecated('caw_hatpos_startinsert_at_blank_line', 1)
call s:def_deprecated('caw_hatpos_skip_blank_line', 0)
call s:def_deprecated('caw_hatpos_align', 1)

call s:def_deprecated('caw_zeropos_sp', ' ')
call s:def_deprecated('caw_zeropos_sp_blank', ' ')
call s:def_deprecated('caw_zeropos_startinsert_at_blank_line', 1)
call s:def_deprecated('caw_zeropos_skip_blank_line', 0)
call s:def_deprecated('caw_zeropos_align', 1)
Expand Down
2 changes: 1 addition & 1 deletion test/actions/dollarpos.vim
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function! s:suite.uncomment_many_sp() abort
call s:assert.equals(getline(1, '$'), ['printf("hello\n");'])
endfunction

function! s:suite.uncomment_many_sp_blank() abort
function! s:suite.uncomment_many_sp_whitespaces() abort
" set up
setlocal filetype=c
call setline(1, ['printf("hello\n"); //'])
Expand Down

0 comments on commit 4f449af

Please sign in to comment.