Permalink
Browse files

Merge branch 'master' of https://github.com/xolox/vim-misc

  • Loading branch information...
2 parents de1aa03 + 0b1c06e commit 35be6852ae2a486f2253240ea31c0101b9b19b12 @xolox committed Aug 27, 2011
Showing with 43 additions and 20 deletions.
  1. +20 −9 autoload/xolox/misc/README.md
  2. +7 −8 autoload/xolox/misc/open.vim
  3. +14 −1 autoload/xolox/misc/option.vim
  4. +2 −2 autoload/xolox/misc/str.vim
@@ -1,13 +1,24 @@
# Miscellaneous auto-load Vim scripts
-The git repository at <http://github.com/xolox/vim-misc> contains Vim scripts
-that are used by most of the [Vim plug-ins I've written] [plugins] yet don't
-really belong with any single one. I'm hoping to include this repository as a
-git submodule in my other repositories so that I only have to maintain these
-files in one place.
-
-For lack of a better place: I hereby release these scripts under the MIT
-license, in other words feel free to do with them as you please but don't
-misrepresent this work as your own.
+The git repository at <http://github.com/xolox/vim-misc> contains Vim scripts that are used by most of the [Vim plug-ins I've written] [plugins] yet don't really belong with any single one. I include this repository as a subdirectory of my plug-in repositories using the following commands:
+
+ $ git remote add -f vim-misc https://github.com/xolox/vim-misc.git
+ $ git merge -s ours --no-commit vim-misc/master
+ $ git read-tree --prefix=autoload/xolox/misc/ -u vim-misc/master
+ $ git commit -m "Merge vim-misc repository as subdirectory"
+
+To update a plug-in repository to the latest versions of the miscellaneous auto-load scripts I execute the following command:
+
+ $ git pull -s subtree vim-misc master
+
+## Contact
+
+If you have questions, bug reports, suggestions, etc. the author can be contacted at <peter@peterodding.com>. The latest version is available at <http://peterodding.com/code/vim/misc> and <http://github.com/xolox/vim-misc>.
+
+## License
+
+This software is licensed under the [MIT license](http://en.wikipedia.org/wiki/MIT_License).
+© 2011 Peter Odding &lt;<peter@peterodding.com>&gt;.
+
[plugins]: http://peterodding.com/code/vim/
@@ -1,12 +1,11 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: May 25, 2011
+" Last Change: June 18, 2011
" URL: http://peterodding.com/code/vim/misc/
-if !exists('s:script')
- let s:script = expand('<sfile>:p:~')
- let s:enoimpl = "%s: %s() hasn't been implemented for your platform!"
- let s:enoimpl .= " If you have suggestions, please contact peter@peterodding.com."
+if !exists('s:version')
+ let s:version = '1.0'
+ 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
@@ -26,7 +25,7 @@ function! xolox#misc#open#file(path, ...)
else
for handler in s:handlers + a:000
if executable(handler)
- call xolox#misc#msg#debug("%s: Using `%s' to open %s", s:script, handler, a:path)
+ 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
@@ -59,12 +58,12 @@ endfunction
function! s:handle_error(cmd, output)
if v:shell_error
- let message = "%s: Failed to execute program! (command line: %s%s)"
+ 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:script, a:cmd, output)
+ throw printf(message, s:version, a:cmd, output)
endif
endfunction
@@ -1,8 +1,21 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: March 15, 2011
+" Last Change: June 27, 2011
" URL: http://peterodding.com/code/vim/misc/
+function! xolox#misc#option#get(name, ...)
+ if exists('b:' . a:name)
+ " Buffer local variable.
+ return eval('b:' . a:name)
+ elseif exists('g:' . a:name)
+ " Global variable.
+ return eval('g:' . a:name)
+ elseif exists('a:1')
+ " Default value.
+ return a:1
+ endif
+endfunction
+
" Functions to parse multi-valued Vim options like &tags and &runtimepath.
function! xolox#misc#option#split(value)
@@ -1,12 +1,12 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: March 15, 2011
+" Last Change: June 14, 2011
" URL: http://peterodding.com/code/vim/misc/
" Trim whitespace from start and end of string.
function! xolox#misc#str#trim(s)
- return substitute(a:s, '^\s*\(.\{-}\)\s*$', '\1', '')
+ return substitute(a:s, '^\_s*\(.\{-}\)\_s*$', '\1', '')
endfunction
" vim: ts=2 sw=2 et

0 comments on commit 35be685

Please sign in to comment.