Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Define version as variable, include in messages

  • Loading branch information...
commit 42ed86b486acb2bce138c8f4b8970b08c46161ab 1 parent 42ad155
@xolox authored
View
2  README.md
@@ -53,4 +53,4 @@ If you have questions, bug reports, suggestions, etc. the author can be contacte
## License
This software is licensed under the [MIT license](http://en.wikipedia.org/wiki/MIT_License).
2010 Peter Odding &lt;<peter@peterodding.com>&gt;.
2011 Peter Odding &lt;<peter@peterodding.com>&gt;.
View
25 autoload/xolox/pyref.vim
@@ -1,8 +1,9 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: May 25, 2011
+" Last Change: September 4, 2011
" URL: http://peterodding.com/code/vim/pyref/
+let g:xolox#pyref#version = '0.7.4'
let s:script = expand('<sfile>:p:~')
function! xolox#pyref#enable() " {{{1
@@ -101,7 +102,7 @@ function! xolox#pyref#lookup(identifier) " {{{1
endfunction
function! s:try_lookup(lines, pattern) " {{{1
- call xolox#misc#msg#debug("%s: Trying to match pattern %s", s:script, a:pattern)
+ call xolox#misc#msg#debug("pyref.vim %s: Trying to match pattern %s", g:xolox#pyref#version, a:pattern)
let index = match(a:lines, a:pattern)
if index >= 0
let url = split(a:lines[index], '\t')[1]
@@ -111,8 +112,8 @@ function! s:try_lookup(lines, pattern) " {{{1
endfunction
function! s:show_match(url) " {{{1
- let python_docs = s:get_option('pyref_python')
- let django_docs = s:get_option('pyref_django')
+ let python_docs = xolox#misc#option#get('pyref_python')
+ let django_docs = xolox#misc#option#get('pyref_django')
let url = a:url
if url =~ '^http://docs\.python\.org/' && isdirectory(python_docs)
let url = substitute(url, '^http://docs\.python\.org', 'file://' . python_docs, '')
@@ -123,21 +124,11 @@ function! s:show_match(url) " {{{1
call xolox#misc#open#url(url)
endfunction
-function! s:get_option(name) " {{{1
- if exists('b:' . a:name)
- return eval('b:' . a:name)
- elseif exists('g:' . a:name)
- return eval('g:' . a:name)
- else
- return ""
- endif
-endfunction
-
function! s:find_index() " {{{1
let abspath = fnamemodify(g:pyref_index, ':p')
if !filereadable(abspath)
- let msg = "%s: The index file doesn't exist or isn't readable! (%s)"
- call xolox#misc#msg#warn(msg, s:script, index)
+ let msg = "pyref.vim %s: The index file doesn't exist or isn't readable! (%s)"
+ call xolox#misc#msg#warn(msg, g:xolox#pyref#version, index)
return
endif
return abspath
@@ -148,7 +139,7 @@ function! s:read_index() " {{{1
try
return readfile(indexfile)
catch
- call xolox#misc#msg#warn("%s: Failed to read index file! (%s)", s:script, indexfile)
+ call xolox#misc#msg#warn("pyref.vim %s: Failed to read index file! (%s)", g:xolox#pyref#version, indexfile)
return []
endtry
endfunction
View
46 doc/pyref.txt
@@ -16,7 +16,7 @@ text cursor. The lookup works by scanning through a special index file which
is included in the ZIP archive below, but you can also create/update the index
yourself using the Python script spider.py [4].
-==============================================================================
+===============================================================================
*pyref-install-usage*
Install & usage ~
@@ -27,23 +27,21 @@ restart Vim and execute the command ':helptags ~/.vim/doc' (use ':helptags
press the '<F1>' key on something interesting. If it doesn't work or you want
to change how it works, see the options documented below.
-------------------------------------------------------------------------------
- *g:pyref_mapping-option*
-The 'g:pyref_mapping' option ~
+-------------------------------------------------------------------------------
+The *g:pyref_mapping* option
If you press '<F1>' and nothing happens you're probably using a terminal that
doesn't pass '<F1>' through to Vim. In this case you can change the key
-mapping by setting the global variable 'g:pyref_mapping' according to the
+mapping by setting the global variable |g:pyref_mapping| according to the
syntax expected by Vim's ':imap' and ':nmap' commands:
>
:let g:pyref_mapping = 'K'
-Note that setting 'g:pyref_mapping' won't change the key mapping in existing
+Note that setting |g:pyref_mapping| won't change the key mapping in existing
buffers.
-------------------------------------------------------------------------------
- *g:pyref_python-option*
-The 'g:pyref_python' option ~
+-------------------------------------------------------------------------------
+The *g:pyref_python* option
This option is useful when you don't always have a reliable internet
connection available while coding. Most Linux distributions have an
@@ -56,15 +54,14 @@ documentation:
The above package puts the documentation in '/usr/share/doc/python2.6/html/'
which happens to be the default path checked by the 'pyref.vim' script. If
you've installed the documentation in a different location you can change the
-global variable 'g:pyref_python', e.g.:
+global variable |g:pyref_python|, e.g.:
>
:let g:pyref_python = $HOME . '/docs/python'
-------------------------------------------------------------------------------
- *g:pyref_django-option*
-The 'g:pyref_django' option ~
+-------------------------------------------------------------------------------
+The *g:pyref_django* option
-This option works like 'g:pyref_python' but allows you to configure the path
+This option works like |g:pyref_python| but allows you to configure the path
to your local Django documentation. On Ubuntu [8] and Debian [9] you can
execute the following command to install the Django documentation:
>
@@ -73,25 +70,24 @@ execute the following command to install the Django documentation:
In this case you shouldn't have to change anything because 'pyref.vim' is
already configured to be compatible with the 'python-django-doc' package.
-------------------------------------------------------------------------------
- *g:pyref_index-option*
-The 'g:pyref_index' option ~
+-------------------------------------------------------------------------------
+The *g:pyref_index* option
If you don't like the default location of the index file you can change it by
-setting the global variable 'g:pyref_index'. A leading '~' in the
-'g:pyref_index' variable is expanded to your current home directory ('$HOME'
+setting the global variable |g:pyref_index|. A leading '~' in the
+|g:pyref_index| variable is expanded to your current home directory ('$HOME'
on UNIX, '%USERPROFILE%' on Windows). Be aware that when you change the
-'g:pyref_index' option automatic updates using the |getscript| plug-in won't
+|g:pyref_index| option automatic updates using the |getscript| plug-in won't
update the index file anymore!
-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
*pyref-general-note-about-options*
General note about options ~
You can change the above options permanently by putting the relevant ':let'
statements in your |vimrc| script.
-==============================================================================
+===============================================================================
*pyref-contact*
Contact ~
@@ -100,14 +96,14 @@ contacted at peter@peterodding.com. The latest version is available at
http://peterodding.com/code/vim/pyref/ and http://github.com/xolox/vim-pyref.
If you like the script please vote for it on Vim Online [10].
-==============================================================================
+===============================================================================
*pyref-license*
License ~
-This software is licensed under the MIT license [11]. Copyright 2010 Peter
+This software is licensed under the MIT license [11]. Copyright 2011 Peter
Odding <peter@peterodding.com>.
-==============================================================================
+===============================================================================
*pyref-references*
References ~
View
6 plugin/pyref.vim
@@ -1,14 +1,12 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: May 25, 2011
+" Last Change: September 4, 2011
" URL: http://peterodding.com/code/vim/pyref/
-" License: MIT
-" Version: 0.7.3
" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3104 1 :AutoInstall: pyref.zip
-" Don't source the plug-in when its already been loaded or &compatible is set.
+" Don't source the plug-in when it's already been loaded or &compatible is set.
if &cp || exists('g:loaded_pyref')
finish
else
Please sign in to comment.
Something went wrong with that request. Please try again.