mileszs / ack.vim

Vim plugin for the Perl module / CLI script 'ack'
Other
3.08k stars 396 forks source link

Allows to modify defaul options during program run #152

Open Czaki opened 9 years ago

Czaki commented 9 years ago

In some projects I would be able to exclude some files and folders from ack request. After I read your documentation I think that this change is good option to allow this. (helpfull with local vimrc plugins)

ches commented 9 years ago

Hi, thanks for your patch. Your suggestion makes sense to me, without it I'm not really sure why g:ack_default_options even exists, since you could put options that you want always into the g:ackprg setting itself (perhaps it's to be able to leave options like --column out of :AckFile, though there is already code to deal with that to some degree). So I agree that being able to change it at runtime makes it more useful.

Would you mind rebasing your branch? The location of the let l:ackprg_run line has moved, no other change in its behavior. And you can remove the line from plugin/ack.vim instead of commenting it out, please.

Thanks!

Konfekt commented 9 years ago

Regardant use cases, the nomenclature is just misleading. I assumed that the prg option should only contain the program name 'ag' and its parameters had to go into the options option.

ches commented 9 years ago

Regardant use cases, the nomenclature is just misleading. I assumed that the prg option should only contain the program name 'ag' and its parameters had to go into the options option.

Including more than just the executable name in g:ackprg makes sense if you consider that 'grepprg' works the same way, but I agree that it's potentially confusing for both g:ackprg and g:ack_default_options to be public configurable variables. Documentation could perhaps be more clear as @Konfekt said in #139, but docs aren't the answer if there isn't a strong reason for one of the settings to exist at all.

I'll give some thought to removing g:ack_default_options completely and just applying the options that the plugin currently uses after trying to detect whether ack or ack-grep is available. If people want to customize the arguments, they can include them in a custom g:ackprg value, which could be done in a local vimrc (or manually at runtime) as well. Personally I already do this with let g:ackprg = "ag --vimgrep" and it's all dandy.