Allow to disable the default search engines. #20

Merged
merged 1 commit into from Mar 13, 2013

Conversation

Projects
None yet
2 participants
@inkarkat
Contributor

inkarkat commented Mar 13, 2013

With the current definition of g:openbrowser_search_engines in the autoload script, one has to :runtime that in order to disable all default search engines, which is against the autoload idea of lazy loading. By moving the default search engine definitions to the plugin script, it becomes possible to easily turn them off without runtime penalty:

" I do not want any of the default search engines.
runtime! plugin/openbrowser.vim
let g:openbrowser_search_engines = {}

Apart from that, there's no change in the behavior of the config variable: Earlier definitions from a .vimrc are still added with preference.

Allow to disable the default search engines.
With the current definition of g:openbrowser_search_engines in the autoload script, one has to :runtime that in order to disable all default search engines, which is against the autoload idea of lazy loading. By moving the default search engine definitions to the plugin script, it becomes possible to easily turn them off without runtime penalty:

" I do not want any of the default search engines.
runtime! plugin/openbrowser.vim
let g:openbrowser_search_engines = {}

Apart from that, there's no change in the behavior of the config variable: Earlier definitions from a .vimrc are still added with preference.
@tyru

This comment has been minimized.

Show comment Hide comment
@tyru

tyru Mar 13, 2013

Owner

hm, I didn't think about disabling search engines.
Why do you want to disable search engines?

Owner

tyru commented Mar 13, 2013

hm, I didn't think about disabling search engines.
Why do you want to disable search engines?

@tyru

This comment has been minimized.

Show comment Hide comment
@tyru

tyru Mar 13, 2013

Owner

well, I'm positively thinking to support this :)
I just want to know why you want to disable search engines.

Owner

tyru commented Mar 13, 2013

well, I'm positively thinking to support this :)
I just want to know why you want to disable search engines.

@inkarkat

This comment has been minimized.

Show comment Hide comment
@inkarkat

inkarkat Mar 13, 2013

Contributor

I have no use for e.g. baidu, wikipedia-jp, verycd, and I have defined different keywords for google (the shorter gg) and others. The default search engines clutter the user interface when <Tab>-completing search engines.

Contributor

inkarkat commented Mar 13, 2013

I have no use for e.g. baidu, wikipedia-jp, verycd, and I have defined different keywords for google (the shorter gg) and others. The default search engines clutter the user interface when <Tab>-completing search engines.

@tyru

This comment has been minimized.

Show comment Hide comment
@tyru

tyru Mar 13, 2013

Owner

@inkarkat I see :)
I'll prepare for a way to disable existing search engines.

Thanks for your code.
but I don't like to place global variables section in one place.
(I don't like to place global variables section in plugin/openbrowser.vim)
so I'll think about an another solution, and suggest the solution to you in this issue.

Owner

tyru commented Mar 13, 2013

@inkarkat I see :)
I'll prepare for a way to disable existing search engines.

Thanks for your code.
but I don't like to place global variables section in one place.
(I don't like to place global variables section in plugin/openbrowser.vim)
so I'll think about an another solution, and suggest the solution to you in this issue.

@inkarkat

This comment has been minimized.

Show comment Hide comment
@inkarkat

inkarkat Mar 13, 2013

Contributor

I don't like to place global variables section in plugin/openbrowser.vim

Why? Are you worried about the few bytes of memory? This is common practice, seen in many / most plugins. In fact, what you're doing (deferring the definition until the autoload script is sourced) is the strange exception. Integrating with a plugin, or defining custom mappings around it is much easier when you can rely on its config being defined.

Contributor

inkarkat commented Mar 13, 2013

I don't like to place global variables section in plugin/openbrowser.vim

Why? Are you worried about the few bytes of memory? This is common practice, seen in many / most plugins. In fact, what you're doing (deferring the definition until the autoload script is sourced) is the strange exception. Integrating with a plugin, or defining custom mappings around it is much easier when you can rely on its config being defined.

@tyru

This comment has been minimized.

Show comment Hide comment
@tyru

tyru Mar 13, 2013

Owner

Why? Are you worried about the few bytes of memory?

No.
I worried about readability.

In fact, what you're doing (deferring the definition until the autoload script is sourced) is the strange exception

Indeed.
if you think it is confusable, it might had better to move all global variables to plugin/openbrowser.vim, including g:openbrowser_search_engines.

Owner

tyru commented Mar 13, 2013

Why? Are you worried about the few bytes of memory?

No.
I worried about readability.

In fact, what you're doing (deferring the definition until the autoload script is sourced) is the strange exception

Indeed.
if you think it is confusable, it might had better to move all global variables to plugin/openbrowser.vim, including g:openbrowser_search_engines.

tyru added a commit that referenced this pull request Mar 13, 2013

Merge pull request #20 from inkarkat/allow-no-default-search-engines
Allow to disable the default search engines.

@tyru tyru merged commit 4eb42ef into tyru:master Mar 13, 2013

@tyru

This comment has been minimized.

Show comment Hide comment
@tyru

tyru Mar 13, 2013

Owner

Moved all variables, too.

Owner

tyru commented Mar 13, 2013

Moved all variables, too.

@tyru

This comment has been minimized.

Show comment Hide comment
@tyru

tyru Mar 13, 2013

Owner

oops...
sorry for confusion & wrong words.

wrong: I don't like to place global variables section in
plugin/openbrowser.vim
right: I don't like to serarate global variables sections in
plugin/openbrowser.vim and autoload/openbrowser.vim

I had moved all global variables into plugin/openbrowser.vim because I don't
like to serarate global variables sections.

Owner

tyru commented Mar 13, 2013

oops...
sorry for confusion & wrong words.

wrong: I don't like to place global variables section in
plugin/openbrowser.vim
right: I don't like to serarate global variables sections in
plugin/openbrowser.vim and autoload/openbrowser.vim

I had moved all global variables into plugin/openbrowser.vim because I don't
like to serarate global variables sections.

@inkarkat

This comment has been minimized.

Show comment Hide comment
@inkarkat

inkarkat Mar 14, 2013

Contributor

Ah, moving all variables into the plugin script is even better! Now you're consistent with most other plugins. Thanks a lot!

Contributor

inkarkat commented Mar 14, 2013

Ah, moving all variables into the plugin script is even better! Now you're consistent with most other plugins. Thanks a lot!

@tyru

This comment has been minimized.

Show comment Hide comment
@tyru

tyru Mar 14, 2013

Owner

:)

Owner

tyru commented Mar 14, 2013

:)

@inkarkat inkarkat deleted the inkarkat:allow-no-default-search-engines branch May 31, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment