Skip to content

Commit 38056ee

Browse files
committed
search-notes.py: Give a friendly message when the keyword index is initialized
1 parent 679f785 commit 38056ee

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

autoload/xolox/notes.vim

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
" Vim auto-load script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: November 23, 2011
3+
" Last Change: November 24, 2011
44
" URL: http://peterodding.com/code/vim/notes/
55

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

9-
let g:xolox#notes#version = '0.14.2'
9+
let g:xolox#notes#version = '0.14.3'
1010

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

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

557561
function! s:python_command(...) " {{{2
@@ -564,6 +568,9 @@ function! s:python_command(...) " {{{2
564568
let arguments = map([script] + options + a:000, 'xolox#misc#escape#shell(v:val)')
565569
let command = join([python] + arguments)
566570
call xolox#misc#msg#debug("notes.vim %s: Executing external command %s", g:xolox#notes#version, command)
571+
if !filereadable(xolox#misc#path#absolute(g:notes_indexfile))
572+
call xolox#misc#msg#info("notes.vim %s: Building keyword index (this might take a while) ..", g:xolox#notes#version)
573+
endif
567574
let output = xolox#misc#str#trim(system(command))
568575
if v:shell_error
569576
call xolox#misc#msg#warn("notes.vim %s: Search script failed with output: %s", g:xolox#notes#version, output)

misc/notes/search-notes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/usr/bin/env python
22

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

0 commit comments

Comments
 (0)