Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Allow to disable the default search engines. #20

Merged
merged 1 commit into from

2 participants

@inkarkat

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.

@inkarkat inkarkat 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.
5ae5ed3
@tyru
Owner

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

@tyru
Owner

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

@inkarkat

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
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.

@inkarkat

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
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.

@tyru tyru merged commit 4eb42ef into tyru:master
@tyru
Owner

Moved all variables, too.

@tyru
Owner
@inkarkat

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

@tyru
Owner
@inkarkat inkarkat deleted the inkarkat:allow-no-default-search-engines branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 13, 2013
  1. @inkarkat

    Allow to disable the default search engines.

    inkarkat authored
    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.
This page is out of date. Refresh to see the latest.
Showing with 29 additions and 25 deletions.
  1. +0 −25 autoload/openbrowser.vim
  2. +29 −0 plugin/openbrowser.vim
View
25 autoload/openbrowser.vim
@@ -109,31 +109,6 @@ if !exists('g:openbrowser_default_search')
let g:openbrowser_default_search = 'google'
endif
-let g:openbrowser_search_engines = extend(
-\ get(g:, 'openbrowser_search_engines', {}),
-\ {
-\ 'alc': 'http://eow.alc.co.jp/{query}/UTF-8/',
-\ 'askubuntu': 'http://askubuntu.com/search?q={query}',
-\ 'baidu': 'http://www.baidu.com/s?wd={query}&rsv_bp=0&rsv_spt=3&inputT=2478',
-\ 'blekko': 'http://blekko.com/ws/+{query}',
-\ 'cpan': 'http://search.cpan.org/search?query={query}',
-\ 'duckduckgo': 'http://duckduckgo.com/?q={query}',
-\ 'github': 'http://github.com/search?q={query}',
-\ 'google': 'http://google.com/search?q={query}',
-\ 'google-code': 'http://code.google.com/intl/en/query/#q={query}',
-\ 'php': 'http://php.net/{query}',
-\ 'python': 'http://docs.python.org/dev/search.html?q={query}&check_keywords=yes&area=default',
-\ 'twitter-search': 'http://twitter.com/search/{query}',
-\ 'twitter-user': 'http://twitter.com/{query}',
-\ 'verycd': 'http://www.verycd.com/search/entries/{query}',
-\ 'vim': 'http://www.google.com/cse?cx=partner-pub-3005259998294962%3Abvyni59kjr1&ie=ISO-8859-1&q={query}&sa=Search&siteurl=www.vim.org%2F#gsc.tab=0&gsc.q={query}&gsc.page=1',
-\ 'wikipedia': 'http://en.wikipedia.org/wiki/{query}',
-\ 'wikipedia-ja': 'http://ja.wikipedia.org/wiki/{query}',
-\ 'yahoo': 'http://search.yahoo.com/search?p={query}',
-\ },
-\ 'keep'
-\)
-
if !exists('g:openbrowser_open_filepath_in_vim')
let g:openbrowser_open_filepath_in_vim = 1
endif
View
29 plugin/openbrowser.vim
@@ -37,6 +37,35 @@ let g:__openbrowser_platform = {
\ 'macunix': s:is_macunix,
\}
+" Global Variables {{{
+let g:openbrowser_search_engines = extend(
+\ get(g:, 'openbrowser_search_engines', {}),
+\ {
+\ 'alc': 'http://eow.alc.co.jp/{query}/UTF-8/',
+\ 'askubuntu': 'http://askubuntu.com/search?q={query}',
+\ 'baidu': 'http://www.baidu.com/s?wd={query}&rsv_bp=0&rsv_spt=3&inputT=2478',
+\ 'blekko': 'http://blekko.com/ws/+{query}',
+\ 'cpan': 'http://search.cpan.org/search?query={query}',
+\ 'duckduckgo': 'http://duckduckgo.com/?q={query}',
+\ 'github': 'http://github.com/search?q={query}',
+\ 'google': 'http://google.com/search?q={query}',
+\ 'google-code': 'http://code.google.com/intl/en/query/#q={query}',
+\ 'php': 'http://php.net/{query}',
+\ 'python': 'http://docs.python.org/dev/search.html?q={query}&check_keywords=yes&area=default',
+\ 'twitter-search': 'http://twitter.com/search/{query}',
+\ 'twitter-user': 'http://twitter.com/{query}',
+\ 'verycd': 'http://www.verycd.com/search/entries/{query}',
+\ 'vim': 'http://www.google.com/cse?cx=partner-pub-3005259998294962%3Abvyni59kjr1&ie=ISO-8859-1&q={query}&sa=Search&siteurl=www.vim.org%2F#gsc.tab=0&gsc.q={query}&gsc.page=1',
+\ 'wikipedia': 'http://en.wikipedia.org/wiki/{query}',
+\ 'wikipedia-ja': 'http://ja.wikipedia.org/wiki/{query}',
+\ 'yahoo': 'http://search.yahoo.com/search?p={query}',
+\ },
+\ 'keep'
+\)
+
+" }}}
+
+
" Interfaces {{{
" For backward compatibility,
Something went wrong with that request. Please try again.