From 78c4cd76d6b0f7fb4b33825d75c1409fe5952007 Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Fri, 25 Nov 2011 18:12:34 +0100 Subject: [PATCH] Trust search-notes.py when it says there are no matches --- autoload/xolox/notes.vim | 18 ++++++++++-------- misc/notes/search-notes.py | 3 ++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/autoload/xolox/notes.vim b/autoload/xolox/notes.vim index edb5fa9..d337c54 100644 --- a/autoload/xolox/notes.vim +++ b/autoload/xolox/notes.vim @@ -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. @@ -553,9 +553,9 @@ 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 @@ -563,9 +563,9 @@ 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 @@ -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 diff --git a/misc/notes/search-notes.py b/misc/notes/search-notes.py index c1cb34c..c73c487 100755 --- a/misc/notes/search-notes.py +++ b/misc/notes/search-notes.py @@ -3,7 +3,7 @@ # Python script for fast text file searching using keyword index on disk. # # Author: Peter Odding -# Last Change: November 24, 2011 +# Last Change: November 25, 2011 # URL: http://peterodding.com/code/vim/notes/ # License: MIT # @@ -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: