guns / vim-sexp

Precision Editing for S-expressions
MIT License
612 stars 33 forks source link

visual mode mappings are created indiscriminately #9

Closed justinmk closed 9 years ago

justinmk commented 9 years ago

Many of the default g:sexp_mappings do not make sense in visual mode (correct me if I'm wrong). To avoid visual-mode mappings, extra configuration steps are needed.

If I configure sexp mappings like this:

let g:sexp_mappings = { 'sexp_insert_at_list_head': '<I' }

vim-sexp creates nmap and xmap mappings, but sexp_insert_at_list_head is not really useful in visual-mode.

In order to avoid this, I must do this:

nmap <I     <Plug>(sexp_insert_at_list_head)
let g:sexp_mappings = { 'sexp_insert_at_list_head': '' }

Perhaps the plugin could be more discriminating about which maps it creates in visual-mode.

guns commented 9 years ago

Hi Justin,

Okay, that sounds right. I am going to remove the visual mode mappings from sexp_insert_at_list_{head,tail} as well as from sexp_splice_list.

The other problem (g:sexp_mappings is not very flexible) should probably be addressed by documenting the process of disabling the default mapping system (let g:sexp_filetypes = '') and listing the current default <Plug> mappings that can be copied, pasted, and edited to taste.

Thank you!

guns commented 9 years ago

Many of the default g:sexp_mappings do not make sense in visual mode

Just re-read this; I believe the rest of the visual mode mappings have explicit visual mode behaviour (which might be subtle, but useful), but I may have missed something. Is there another mapping that you find unnecessary?

justinmk commented 9 years ago

Thanks!.

Is there another mapping that you find unnecessary?

slurp/barf seem superfluous in visual-mode:

sexp_emit_head_element
sexp_emit_tail_element
sexp_capture_prev_element
sexp_capture_next_element
guns commented 9 years ago

slurp/barf seem superfluous in visual-mode:

If you slurp/barf while in visual mode, the parent compound form remains visually selected! I think that's cool, but I guess YMMV

justinmk commented 9 years ago

True, I didn't think of that. I'll see if I can find a use for it. It is not traditional for Vim operations, though, as you know, so perhaps I questioned it too much out of habit.

guns commented 9 years ago

It is not traditional for Vim operations

Yes, this is true. I'm not actually a very traditional Vimmer, so this doesn't bother me too much. I totally understand how it might feel irksome to others, though.

In light of this, I've added documentation on replacing the whole g:sexp_mappings system with a standard autocmd approach:

https://github.com/guns/vim-sexp/blob/b4398689f7483b01684044ab6b55bf369744c9b3/doc/vim-sexp.txt#L460-L589

This isn't news to you, of course, but it does list all the mappings created by vim-sexp in a convenient, copy-pastable format. I suspect you may prefer to handle the mappings this way.

I promise never to break backwards compatibility without at least a ~year of deprecation notice.

Thanks again for reporting!

justinmk commented 9 years ago

I was indeed wanting something like that while I was adjusting my mappings. Thanks again!