Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eval visual selection #87

Closed
matthias-margush opened this issue Jan 23, 2019 · 2 comments
Closed

Eval visual selection #87

matthias-margush opened this issue Jan 23, 2019 · 2 comments

Comments

@matthias-margush
Copy link
Contributor

matthias-margush commented Jan 23, 2019

When I'm demoing code, I like to visually select what I'm eval-ing, so it's clearer on the screen. I didn't see anything like that yet in vim-iced (or if it's there, let me know.) I added this to my config based on the example in :help :map-operator. Would this be useful to have in vim-iced?

function! ClojureEval(type, ...)
	let sel_save = &selection
	let &selection = "inclusive"
	let reg_save = @@
	if a:0  " Invoked from Visual mode, use '< and '> marks.
		silent exe "normal! `<" . a:type . "`>y"
	elseif a:type == 'line'
		silent exe "normal! '[V']y"
	elseif a:type == 'block'
		silent exe "normal! `[\<C-V>`]y"
	else
		silent exe "normal! `[v`]y"
	endif

	call iced#nrepl#eval#repl(@@)

	let &selection = sel_save
	let @@ = reg_save
endfunction

vnoremap <silent> <buffer> (my key binding) :<c-u>call ClojureEval(visualmode(), 1)<cr>
@liquidz
Copy link
Owner

liquidz commented Jan 24, 2019

@matthias-margush Sounds good!

We have 2 function to evaluate codes.

So we need 2 functions to evaluate visual selection.

@liquidz
Copy link
Owner

liquidz commented Mar 5, 2019

@liquidz liquidz closed this as completed Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants