Navigation Menu

Skip to content

Commit

Permalink
Trust search-notes.py when it says there are no matches
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Nov 25, 2011
1 parent 576333a commit 78c4cd7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
18 changes: 10 additions & 8 deletions autoload/xolox/notes.vim
Expand Up @@ -6,7 +6,7 @@
" 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.16'
let g:xolox#notes#version = '0.16.1'

function! xolox#notes#shortcut() " {{{1
" The "note:" pseudo protocol is just a shortcut for the :Note command.
Expand Down Expand Up @@ -553,19 +553,19 @@ endfunction

function! s:run_scanner(keywords, matches) " {{{2
" Try to run scanner.py script to find notes matching {keywords}.
let output = s:python_command(a:keywords)
if !empty(output)
call extend(a:matches, split(output, '\n'))
let lines = s:python_command(a:keywords)
if type(lines) == type([])
call extend(a:matches, lines)
return 1
endif
endfunction

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

function! s:python_command(...) " {{{2
Expand All @@ -585,10 +585,12 @@ function! s:python_command(...) " {{{2
if v:shell_error
call xolox#misc#msg#warn("notes.vim %s: Search script failed with output: %s", g:xolox#notes#version, output)
else
return output
let lines = split(output, "\n")
if !empty(lines) && lines[0] == 'Python works fine!'
return lines[1:]
endif
endif
endif
return ''
endfunction

" Getters for filenames & titles of existing notes. {{{2
Expand Down
3 changes: 2 additions & 1 deletion misc/notes/search-notes.py
Expand Up @@ -3,7 +3,7 @@
# Python script for fast text file searching using keyword index on disk.
#
# Author: Peter Odding <peter@peterodding.com>
# Last Change: November 24, 2011
# Last Change: November 25, 2011
# URL: http://peterodding.com/code/vim/notes/
# License: MIT
#
Expand Down Expand Up @@ -39,6 +39,7 @@ def __init__(self):
self.update_index()
if self.dirty:
self.save_index()
print "Python works fine!"
if self.keyword_filter is not None:
self.list_keywords(self.keyword_filter)
else:
Expand Down

0 comments on commit 78c4cd7

Please sign in to comment.