Change cpp from innermost to outermost

Closes #116.
This commit is contained in:
Tim Pope 2013-12-26 11:16:44 -05:00
parent f1b8096b3f
commit d3f7f2cf26
3 changed files with 17 additions and 7 deletions

View File

@ -67,7 +67,7 @@ cursor. `cqc` gives you a blank line in insert mode.
Standard stuff here. `:Eval` evaluates a range (`:%Eval` gets the whole
file), `:Require` requires a namespace with `:reload` (`:Require!` does
`:reload-all`), either the current buffer or a given argument. There's a `cp`
operator that evaluates a given motion (`cpp` for the expression under the
operator that evaluates a given motion (`cpp` for the outermost form under the
cursor). `cm` and `c1m` are similar, but they only run
`clojure.walk/macroexpand-all` and `macroexpand-1` instead of evaluating the
form entirely.

View File

@ -129,7 +129,7 @@ stack trace is loaded into the |location-list|. Use |:lopen| to view it.
*fireplace-cp*
cp{motion} Eval/print the code indicated by {motion}.
cpp Eval/print the inner-most expr at the cursor.
cpp Eval/print the outermost form at the cursor.
*fireplace-cpr*
cpr Eval a require :reload form.
@ -137,19 +137,19 @@ cpr Eval a require :reload form.
*fireplace-c!*
c!{motion} Eval/replace the code indicated by {motion}.
c!! Eval/replace the inner-most expr at the cursor.
c!! Eval/replace the innermost form at the cursor.
*fireplace-cm*
cm{motion} Fully macroexpand the code indicated by {motion}.
*fireplace-cmm*
cmm Fully macroexpand the inner-most expr at the cursor.
cmm Fully macroexpand the innermost form at the cursor.
*fireplace-c1m*
c1m{motion} Macroexpand the code indicated by {motion} once.
*fireplace-c1mm*
c1mm Macroexpand the inner-most expr at the cursor once.
c1mm Macroexpand the innermost form at the cursor once.
*fireplace-cqp*
cqp Bring up a prompt for code to eval/print.

View File

@ -584,7 +584,16 @@ function! s:opfunc(type) abort
try
set selection=inclusive clipboard-=unnamed clipboard-=unnamedplus
if a:type =~ '^\d\+$'
silent exe 'normal! ^v'.a:type.'$hy'
let open = '[[{(]'
let close = '[]})]'
call searchpair(open, '', close, 'r', g:fireplace#skip)
call setpos("']", getpos("."))
call searchpair(open, '', close, 'b', g:fireplace#skip)
while col('.') > 1 && getline('.')[col('.')-2] =~# '[#''`~@]'
normal! h
endwhile
call setpos("'[", getpos("."))
silent exe "normal! `[v`]y"
elseif a:type =~# '^.$'
silent exe "normal! `<" . a:type . "`>y"
elseif a:type ==# 'line'
@ -761,6 +770,7 @@ endfunction
nnoremap <silent> <Plug>FireplacePrintLast :exe <SID>print_last()<CR>
nnoremap <silent> <Plug>FireplacePrint :<C-U>set opfunc=<SID>printop<CR>g@
xnoremap <silent> <Plug>FireplacePrint :<C-U>call <SID>printop(visualmode())<CR>
nnoremap <silent> <Plug>FireplaceCountPrint :<C-U>call <SID>printop(v:count)<CR>
nnoremap <silent> <Plug>FireplaceFilter :<C-U>set opfunc=<SID>filterop<CR>g@
xnoremap <silent> <Plug>FireplaceFilter :<C-U>call <SID>filterop(visualmode())<CR>
@ -803,7 +813,7 @@ function! s:setup_eval() abort
command! -buffer -bang -bar -count=1 Last exe s:Last(<bang>0, <count>)
nmap <buffer> cp <Plug>FireplacePrint
nmap <buffer> cpp <Plug>FireplacePrintab
nmap <buffer> cpp <Plug>FireplaceCountPrint
nmap <buffer> c! <Plug>FireplaceFilter
nmap <buffer> c!! <Plug>FireplaceFilterab