Skip to content

Commit

Permalink
Fix a stupid bug in search-notes.py (and clean it up a little)
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Apr 18, 2013
1 parent 2098494 commit b75f9ab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion 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.17'
let g:xolox#notes#version = '0.17.1'
let s:scriptdir = expand('<sfile>:p:h')

function! xolox#notes#init() " {{{1
Expand Down
40 changes: 21 additions & 19 deletions 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: January 18, 2012
# Last Change: April 18, 2013
# URL: http://peterodding.com/code/vim/notes/
# License: MIT
#
Expand All @@ -16,6 +16,24 @@
#
# For more information about the Vim plug-in see http://peterodding.com/code/vim/notes/.

"""
Usage: search-notes.py [OPTIONS] KEYWORD...
Search a directory of plain text files using a full text index,
updated automatically during each invocation of the program.
Valid options include:
-l, --list=SUBSTR list keywords matching substring
-d, --database=FILE set path to keywords index file
-n, --notes=DIR set directory with user notes
-e, --encoding=NAME set character encoding of notes
-v, --verbose make more noise
-h, --help show this message and exit
For more information see http://peterodding.com/code/vim/notes/
"""

# Standard library modules.
import fnmatch
import getopt
Expand Down Expand Up @@ -156,7 +174,7 @@ def delete_note(self, filename):
self.message("Forgetting %s ..", filename)
del self.index['files'][filename]
for kw in self.index['keywords']:
filter(lambda x: x != filename, self.index['keywords'][kw])
self.index['keywords'][kw] = [x for x in self.index['keywords'][kw] if x != filename]
self.dirty = True

def search_index(self, keywords):
Expand Down Expand Up @@ -217,23 +235,7 @@ def message(self, msg, *args):
sys.stderr.write((msg + "\n") % args)

def usage(self):
print '''
search-notes [OPTIONS] KEYWORD...
Search a directory of plain text files using a full text index,
updated automatically during each invocation of the program.
Valid options include:
-l, --list=SUBSTR list keywords matching substring
-d, --database=FILE set path to keywords index file
-n, --notes=DIR set directory with user notes
-e, --encoding=NAME set character encoding of notes
-v, --verbose make more noise
-h, --help show this message and exit
For more information see http://peterodding.com/code/vim/notes/
'''.strip()
print __doc__.strip()

if __name__ == '__main__':
NotesIndex()
Expand Down

0 comments on commit b75f9ab

Please sign in to comment.