aboutsummaryrefslogtreecommitdiffstats
path: root/open.vim
diff options
context:
space:
mode:
authorPeter Odding <peter@peterodding.com>2013-04-28 15:08:19 +0200
committerPeter Odding <peter@peterodding.com>2013-04-28 15:08:19 +0200
commita7ed49ed589cfe5f84bfeda317d03a874002e1a9 (patch)
treead03ea51d3b2d9154e630c19f3dc2d68f1ddfbd7 /open.vim
parenta744d4c5f0c6086251aab66ec68cb9299869b1e9 (diff)
downloadvim-easytags-a7ed49ed589cfe5f84bfeda317d03a874002e1a9.tar.gz
Change the repository layout to that of a proper Vim plug-in
Diffstat (limited to 'open.vim')
-rw-r--r--open.vim70
1 files changed, 0 insertions, 70 deletions
diff --git a/open.vim b/open.vim
deleted file mode 100644
index 1fb24e0..0000000
--- a/open.vim
+++ /dev/null
@@ -1,70 +0,0 @@
-" Vim auto-load script
-" Author: Peter Odding <peter@peterodding.com>
-" Last Change: November 21, 2011
-" URL: http://peterodding.com/code/vim/misc/
-
-if !exists('s:version')
- let s:version = '1.1'
- let s:enoimpl = "open.vim %s: %s() hasn't been implemented for your platform! If you have suggestions, please contact peter@peterodding.com."
- let s:handlers = ['gnome-open', 'kde-open', 'exo-open', 'xdg-open']
-endif
-
-function! xolox#misc#open#file(path, ...)
- if xolox#misc#os#is_win()
- try
- call xolox#shell#open_with_windows_shell(a:path)
- catch /^Vim\%((\a\+)\)\=:E117/
- let command = '!start CMD /C START "" %s'
- silent execute printf(command, xolox#misc#escape#shell(a:path))
- endtry
- return
- elseif has('macunix')
- let cmd = 'open ' . shellescape(a:path) . ' 2>&1'
- call s:handle_error(cmd, system(cmd))
- return
- else
- for handler in s:handlers + a:000
- if executable(handler)
- call xolox#misc#msg#debug("open.vim %s: Using '%s' to open '%s'.", s:version, handler, a:path)
- let cmd = shellescape(handler) . ' ' . shellescape(a:path) . ' 2>&1'
- call s:handle_error(cmd, system(cmd))
- return
- endif
- endfor
- endif
- throw printf(s:enoimpl, s:script, 'xolox#misc#open#file')
-endfunction
-
-function! xolox#misc#open#url(url)
- let url = a:url
- if url !~ '^\w\+://'
- if url !~ '@'
- let url = 'http://' . url
- elseif url !~ '^mailto:'
- let url = 'mailto:' . url
- endif
- endif
- if has('unix') && !has('gui_running') && $DISPLAY == ''
- for browser in ['lynx', 'links', 'w3m']
- if executable(browser)
- execute '!' . browser fnameescape(url)
- call s:handle_error(browser . ' ' . url, '')
- return
- endif
- endfor
- endif
- call xolox#misc#open#file(url, 'firefox', 'google-chrome')
-endfunction
-
-function! s:handle_error(cmd, output)
- if v:shell_error
- let message = "open.vim %s: Failed to execute program! (command line: %s%s)"
- let output = strtrans(xolox#misc#str#trim(a:output))
- if output != ''
- let output = ", output: " . string(output)
- endif
- throw printf(message, s:version, a:cmd, output)
- endif
-endfunction
-
-" vim: et ts=2 sw=2 fdm=marker