diff --git a/README.markdown b/README.markdown index 1a26159..05ac822 100644 --- a/README.markdown +++ b/README.markdown @@ -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. diff --git a/doc/fireplace.txt b/doc/fireplace.txt index e04ac4a..f766f46 100644 --- a/doc/fireplace.txt +++ b/doc/fireplace.txt @@ -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. diff --git a/plugin/fireplace.vim b/plugin/fireplace.vim index eba10ad..5d57867 100644 --- a/plugin/fireplace.vim +++ b/plugin/fireplace.vim @@ -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 FireplacePrintLast :exe print_last() nnoremap FireplacePrint :set opfunc=printopg@ xnoremap FireplacePrint :call printop(visualmode()) +nnoremap FireplaceCountPrint :call printop(v:count) nnoremap FireplaceFilter :set opfunc=filteropg@ xnoremap FireplaceFilter :call filterop(visualmode()) @@ -803,7 +813,7 @@ function! s:setup_eval() abort command! -buffer -bang -bar -count=1 Last exe s:Last(0, ) nmap cp FireplacePrint - nmap cpp FireplacePrintab + nmap cpp FireplaceCountPrint nmap c! FireplaceFilter nmap c!! FireplaceFilterab