Skip to content

Commit 7f86001

Browse files
committed
Turns out brute force is *much* faster than SQLite :-)
1 parent d5bdcf5 commit 7f86001

File tree

7 files changed

+214
-187
lines changed

7 files changed

+214
-187
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The notes.vim plug-in for the [Vim text editor] [vim] makes it easy to manage yo
1212
* **Searching notes:** `:SearchNotes keyword …` searches for keywords and `:SearchNotes /pattern/` searches for regular expressions
1313
* **Smart defaults:** Without an argument `:SearchNotes` searches for the word under the cursor (if the word starts with `@` that character will be included in the search, this means you can easily search for *@tagged* notes)
1414
* **Back-references:** The `:RelatedNotes` command find all notes referencing the current file
15-
* A [Python 2] [python] script is included that accelerates keyword searches using an [SQLite] [sqlite] database
15+
* A [Python 2] [python] script is included that accelerates keyword searches using a keyword index
1616
* The `:RecentNotes` command lists your notes by modification date, starting with the most recently edited note
1717
* **Navigating between notes:** The included file type plug-in redefines [gf] [gf] to jump between notes and the syntax script highlights note names as hyper links
1818
* **Writing aids:** The included file type plug-in contains mappings for automatic curly quotes, arrows and list bullets and supports completion of note titles using Control-X Control-U and completion of tags using Control-X Control-O
@@ -135,11 +135,11 @@ If you don't pass any arguments to the `:SearchNotes` command it will search for
135135

136136
These mappings are currently not enabled by default because they conflict with already useful key mappings, but if you have any suggestions for alternatives feel free to contact me through GitHub or at <peter@peterodding.com>.
137137

138-
#### Accelerated searching with Python and SQLite
138+
#### Accelerated searching with Python
139139

140-
After collecting a fair amount of notes (say more than 5 MB) you will probably start to get annoyed at how long it takes Vim to search through all of your notes. To make searching more scalable the notes plug-in includes a Python script which uses a full text index of your notes stored in an SQLite database.
140+
After collecting a fair amount of notes (say more than 5 MB) you will probably start to get annoyed at how long it takes Vim to search through all of your notes. To make searching more scalable the notes plug-in includes a Python script which uses a persistent full text index of your notes stored in a file.
141141

142-
The first time the Python script is run it will need to build the complete index which can take a few minutes, but after the index has been initialized updates and searches should be more or less instantaneous.
142+
The first time the Python script is run it will need to build the complete index which can take a moment, but after the index has been initialized updates and searches should be more or less instantaneous.
143143

144144
### The `:RelatedNotes` command
145145

@@ -187,7 +187,6 @@ This software is licensed under the [MIT license] [mit].
187187
[shell]: http://www.vim.org/scripts/script.php?script_id=3123
188188
[slate]: http://code.google.com/p/vim/source/browse/runtime/colors/slate.vim
189189
[split]: http://vimdoc.sourceforge.net/htmldoc/windows.html#:split
190-
[sqlite]: http://sqlite.org/
191190
[tabedit]: http://vimdoc.sourceforge.net/htmldoc/tabpage.html#:tabedit
192191
[update]: http://vimdoc.sourceforge.net/htmldoc/editing.html#:update
193192
[utl]: http://www.vim.org/scripts/script.php?script_id=293

autoload/xolox/notes.vim

Lines changed: 4 additions & 4 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 21, 2011
3+
" Last Change: November 22, 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.12.12'
9+
let g:xolox#notes#version = '0.14'
1010

1111
function! xolox#notes#shortcut() " {{{1
1212
" The "note:" pseudo protocol is just a shortcut for the :Note command.
@@ -551,7 +551,7 @@ function! s:run_scanner(keywords, matches) " {{{2
551551
if !(executable(python) && filereadable(scanner))
552552
call xolox#misc#msg#debug("notes.vim %s: The %s script isn't executable.", g:xolox#notes#version, scanner)
553553
else
554-
let arguments = [scanner, g:notes_indexfile, g:notes_directory, a:keywords]
554+
let arguments = [scanner, '--database', g:notes_indexfile, '--notes', g:notes_directory, a:keywords]
555555
call map(arguments, 'xolox#misc#escape#shell(v:val)')
556556
let output = xolox#misc#str#trim(system(join([python] + arguments)))
557557
if !v:shell_error
@@ -582,7 +582,7 @@ function! xolox#notes#get_fnames(include_shadow_notes) " {{{3
582582
let starttime = xolox#misc#timer#start()
583583
let pattern = xolox#misc#path#merge(g:notes_directory, '*')
584584
let listing = glob(xolox#misc#path#absolute(pattern))
585-
call extend(s:cached_fnames, split(listing, '\n'))
585+
call extend(s:cached_fnames, filter(split(listing, '\n'), 'filereadable(v:val)'))
586586
let s:have_cached_names = 1
587587
call xolox#misc#timer#stop('notes.vim %s: Cached note filenames in %s.', g:xolox#notes#version, starttime)
588588
endif

doc/notes.txt

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ notes in Vim:
3838
- Back-references: The |:RelatedNotes| command find all notes referencing the
3939
current file
4040

41-
- A Python 2 [1] script is included that accelerates keyword searches using an
42-
SQLite [2] database
41+
- A Python 2 [1] script is included that accelerates keyword searches using a
42+
keyword index
4343

4444
- The |:RecentNotes| command lists your notes by modification date, starting
4545
with the most recently edited note
@@ -57,15 +57,15 @@ notes in Vim:
5757
highlighting using blocks marked with '{{{type … }}}' which allows you to
5858
embed highlighted code and configuration snippets in your notes
5959

60-
Here's a screen shot of the syntax mode using the slate [3] color scheme:
60+
Here's a screen shot of the syntax mode using the slate [2] color scheme:
6161

62-
Syntax mode screen shot, see reference [4]
62+
Syntax mode screen shot, see reference [3]
6363

6464
===============================================================================
6565
*notes-install-usage*
6666
Install & usage ~
6767

68-
Unzip the most recent ZIP archive [5] file inside your Vim profile directory
68+
Unzip the most recent ZIP archive [4] file inside your Vim profile directory
6969
(usually this is '~/.vim' on UNIX and '%USERPROFILE%\vimfiles' on Windows),
7070
restart Vim and execute the command ':helptags ~/.vim/doc' (use ':helptags
7171
~\vimfiles\doc' instead on Windows). To get started execute |:Note| or ':edit
@@ -257,16 +257,16 @@ already useful key mappings, but if you have any suggestions for alternatives
257257
feel free to contact me through GitHub or at peter@peterodding.com.
258258

259259
-------------------------------------------------------------------------------
260-
Accelerated searching with Python and SQLite ~
260+
*notes-accelerated-searching-with-python*
261+
Accelerated searching with Python ~
261262

262263
After collecting a fair amount of notes (say more than 5 MB) you will probably
263264
start to get annoyed at how long it takes Vim to search through all of your
264265
notes. To make searching more scalable the notes plug-in includes a Python
265-
script which uses a full text index of your notes stored in an SQLite
266-
database.
266+
script which uses a persistent full text index of your notes stored in a file.
267267

268268
The first time the Python script is run it will need to build the complete
269-
index which can take a few minutes, but after the index has been initialized
269+
index which can take a moment, but after the index has been initialized
270270
updates and searches should be more or less instantaneous.
271271

272272
-------------------------------------------------------------------------------
@@ -317,14 +317,14 @@ If for any reason you want to recreate the list of tags you can execute the
317317
===============================================================================
318318
Other plug-ins that work well with the notes plug-in ~
319319

320-
- The utl.vim [6] universal text linking plug-in enables links between your
320+
- The utl.vim [5] universal text linking plug-in enables links between your
321321
notes, other local files and remote resources like web pages
322322

323-
- My shell.vim [7] plug-in also enables easy navigation between your notes and
323+
- My shell.vim [6] plug-in also enables easy navigation between your notes and
324324
environment like local files and directories, web pages and e-mail
325325
addresses
326326

327-
- The VOoM [8] outlining plug-in should work well for notes if you use the
327+
- The VOoM [7] outlining plug-in should work well for notes if you use the
328328
Markdown style headers starting with '#', however it has been reported that
329329
this combination may not always work so well in practice (sometimes losing
330330
notes!)
@@ -336,28 +336,27 @@ Contact ~
336336
If you have questions, bug reports, suggestions, etc. the author can be
337337
contacted at peter@peterodding.com. The latest version is available at
338338
http://peterodding.com/code/vim/notes/ and http://github.com/xolox/vim-notes.
339-
If you like the script please vote for it on Vim Online [9].
339+
If you like the script please vote for it on Vim Online [8].
340340

341341
===============================================================================
342342
*notes-license*
343343
License ~
344344

345-
This software is licensed under the MIT license [10]. Copyright 2011 Peter
345+
This software is licensed under the MIT license [9]. Copyright 2011 Peter
346346
Odding <peter@peterodding.com>.
347347

348348
===============================================================================
349349
*notes-references*
350350
References ~
351351

352352
[1] http://python.org/
353-
[2] http://sqlite.org/
354-
[3] http://code.google.com/p/vim/source/browse/runtime/colors/slate.vim
355-
[4] http://peterodding.com/code/vim/notes/syntax.png
356-
[5] http://peterodding.com/code/vim/downloads/notes.zip
357-
[6] http://www.vim.org/scripts/script.php?script_id=293
358-
[7] http://www.vim.org/scripts/script.php?script_id=3123
359-
[8] http://www.vim.org/scripts/script.php?script_id=2657
360-
[9] http://www.vim.org/scripts/script.php?script_id=3375
361-
[10] http://en.wikipedia.org/wiki/MIT_License
353+
[2] http://code.google.com/p/vim/source/browse/runtime/colors/slate.vim
354+
[3] http://peterodding.com/code/vim/notes/syntax.png
355+
[4] http://peterodding.com/code/vim/downloads/notes.zip
356+
[5] http://www.vim.org/scripts/script.php?script_id=293
357+
[6] http://www.vim.org/scripts/script.php?script_id=3123
358+
[7] http://www.vim.org/scripts/script.php?script_id=2657
359+
[8] http://www.vim.org/scripts/script.php?script_id=3375
360+
[9] http://en.wikipedia.org/wiki/MIT_License
362361

363362
vim: ft=help

misc/notes/scanner.py

Lines changed: 0 additions & 149 deletions
This file was deleted.

0 commit comments

Comments
 (0)