Skip to content

Commit

Permalink
search-notes.py: Give a friendly message when the keyword index is in…
Browse files Browse the repository at this point in the history
…itialized
  • Loading branch information
xolox committed Nov 24, 2011
1 parent 679f785 commit 38056ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 10 additions & 3 deletions autoload/xolox/notes.vim
@@ -1,12 +1,12 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
" Last Change: November 23, 2011
" Last Change: November 24, 2011
" URL: http://peterodding.com/code/vim/notes/

" Note: This file is encoded in UTF-8 including a byte order mark so
" that Vim loads the script using the right encoding transparently.

let g:xolox#notes#version = '0.14.2'
let g:xolox#notes#version = '0.14.3'

function! xolox#notes#shortcut() " {{{1
" The "note:" pseudo protocol is just a shortcut for the :Note command.
Expand Down Expand Up @@ -551,7 +551,11 @@ function! s:run_scanner(keywords, matches) " {{{2
endfunction

function! xolox#notes#keyword_complete(arglead, cmdline, cursorpos) " {{{2
return split(s:python_command('--list=' . a:arglead), '\n')
let first_run = !filereadable(g:notes_indexfile)
if first_run | call inputsave() | endif
let keywords = split(s:python_command('--list=' . a:arglead), '\n')
if first_run | call inputrestore() | endif
return keywords
endfunction

function! s:python_command(...) " {{{2
Expand All @@ -564,6 +568,9 @@ function! s:python_command(...) " {{{2
let arguments = map([script] + options + a:000, 'xolox#misc#escape#shell(v:val)')
let command = join([python] + arguments)
call xolox#misc#msg#debug("notes.vim %s: Executing external command %s", g:xolox#notes#version, command)
if !filereadable(xolox#misc#path#absolute(g:notes_indexfile))
call xolox#misc#msg#info("notes.vim %s: Building keyword index (this might take a while) ..", g:xolox#notes#version)
endif
let output = xolox#misc#str#trim(system(command))
if v:shell_error
call xolox#misc#msg#warn("notes.vim %s: Search script failed with output: %s", g:xolox#notes#version, output)
Expand Down
8 changes: 6 additions & 2 deletions misc/notes/search-notes.py
@@ -1,7 +1,11 @@
#!/usr/bin/env python

# Copyright 2011 Peter Odding <peter@peterodding.com>
# This program is licensed under the MIT license.
# Python script for fast text file searching using keyword index on disk.
#
# Author: Peter Odding <peter@peterodding.com>
# Last Change: November 24, 2011
# URL: http://peterodding.com/code/vim/notes/
# License: MIT
#
# This Python script can be used by the notes.vim plug-in to perform fast
# keyword searches in the user's notes. It has two advantages over just using
Expand Down

0 comments on commit 38056ee

Please sign in to comment.