stefandtw / quickfix-reflector.vim

Change code right in the quickfix window
MIT License
340 stars 19 forks source link

only init when editing imminent #15

Closed Konfekt closed 8 years ago

Konfekt commented 8 years ago

As follow-up to

https://github.com/stefandtw/quickfix-reflector.vim/issues/6

and

https://github.com/stefandtw/quickfix-reflector.vim/issues/14

How about only setting the qf-buffer title, if g:qf_modifiable=0, when the qf buffer is made modifiable ? That would entail making s:OnQuickfixInit() public though.

stefandtw commented 8 years ago

What is the reason? Are you doing operations based on the buffer name? Or is it simply that you don't like quickfix-reflector in the name when you don't edit the quickfix list? In that case, the easiest solution would be to remove the -reflector in the buffer names and simply call a buffer quickfix-<buffer-number>.

Konfekt commented 8 years ago

Yeah, no urge, but it would be least intrusive, and more robust. For example, a proper command :initQf would make quickfix-reflector work independent of previously triggered of autocmds.

stefandtw commented 8 years ago

I prefer the on-by-default approach. I feel this one of the charms of quickfix-reflector, the simplicity to use it without extra commands and mappings. So I don't really like adding commands, even if they are optional.

I do agree it's best not to be intrusive if possible. I removed the -reflector in the buffer names to make them a little more neutral.

Konfekt commented 8 years ago

Ok, the idea was that instead of a mapping such as

    autocmd FileType qf nnoremap <silent><buffer> r :set modifiable<cr>:nunmap <lt>buffer> r<CR>

(noting that let g:qf_modifiable=0) something like ... r :QFreflectorInit<cr> would be more effectual, but I understand g:qf_modifiable=0 was more of a concession contrary to the spirit of the plugin.

stefandtw commented 8 years ago

Exactly. Anyway, thanks for clarifying and for your interest in the plugin!

Konfekt commented 8 years ago

If I may reopen? An init function would still be appreciated. One reason is that scrolling through open buffers in an open window, say by mappings mapped to :bn/p with an open quickfix-list below, will open the quick-fix window buffer. An init function is the cleanest solution in many ways, and adding an autoinit option, enabled by default, will leave everything backwards compatible.

Konfekt commented 8 years ago

Another quirk: When opening vim as a viewer, say by vim -R/M, then opening the quickfix window, for example after (vim)grepping, throws an error that the quickfix buffer is not modifiable.

stefandtw commented 8 years ago

Regarding the init function. Even if I wanted to implement the functionality, it would cause some tricky situations and would need a lot of test cases or rather an extension of the current tests to make sure things work properly. I don't want to support that.

About scrolling through open buffers. Are you sure this is caused by quickfix-reflector? I tried this using vim -u NONE. Simply a :copen, changing back to the first window, and :bn opens the quickfix buffer in the first window.

The error message in your last comment should be fixed now.

Konfekt commented 8 years ago

Ok, thanks for fixing the viewer (-M) issue.

Open file.txt in vim, then :grep ..., then cwindow and now return to the window of file.txt. Then :bn is the quickfix-...` buffer.

Isn't this simply the buflist property that should be switched off?

stefandtw commented 8 years ago

My point was: This is the default behaviour in Vim. It's not caused by quickfix-reflector. Even without the plugin, the quickfix buffer has buflisted set.

Konfekt commented 8 years ago

Still (inconsitently) doesn't show up on :bn. With qf-reflector it does.

stefandtw commented 8 years ago
vim -u NONE
:e foo.txt
:grep 'line' foo.txt
<C-w><C-w>
:bn

This happens: 2

Konfekt commented 8 years ago

There's something fishy, here, with vim -u:

stefandtw commented 8 years ago

Oh, I forgot to add :copen after the grep command in my description. Indeed :grep does not open the quickfix window on its own.

However, I still get buflisted in the quickfix window.

Konfekt commented 8 years ago

Ok, I will check again. In any case, an

autocmd Filetype * setlocal nobuflisted

is fine.