Skip to content

Commit

Permalink
Turns out brute force is *much* faster than SQLite :-)
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Nov 22, 2011
1 parent d5bdcf5 commit 7f86001
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 187 deletions.
9 changes: 4 additions & 5 deletions README.md
Expand Up @@ -12,7 +12,7 @@ The notes.vim plug-in for the [Vim text editor] [vim] makes it easy to manage yo
* **Searching notes:** `:SearchNotes keyword …` searches for keywords and `:SearchNotes /pattern/` searches for regular expressions
* **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)
* **Back-references:** The `:RelatedNotes` command find all notes referencing the current file
* A [Python 2] [python] script is included that accelerates keyword searches using an [SQLite] [sqlite] database
* A [Python 2] [python] script is included that accelerates keyword searches using a keyword index
* The `:RecentNotes` command lists your notes by modification date, starting with the most recently edited note
* **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
* **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
Expand Down Expand Up @@ -135,11 +135,11 @@ If you don't pass any arguments to the `:SearchNotes` command it will search for

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>.

#### Accelerated searching with Python and SQLite
#### Accelerated searching with Python

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.
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.

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.
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.

### The `:RelatedNotes` command

Expand Down Expand Up @@ -187,7 +187,6 @@ This software is licensed under the [MIT license] [mit].
[shell]: http://www.vim.org/scripts/script.php?script_id=3123
[slate]: http://code.google.com/p/vim/source/browse/runtime/colors/slate.vim
[split]: http://vimdoc.sourceforge.net/htmldoc/windows.html#:split
[sqlite]: http://sqlite.org/
[tabedit]: http://vimdoc.sourceforge.net/htmldoc/tabpage.html#:tabedit
[update]: http://vimdoc.sourceforge.net/htmldoc/editing.html#:update
[utl]: http://www.vim.org/scripts/script.php?script_id=293
Expand Down
8 changes: 4 additions & 4 deletions autoload/xolox/notes.vim
@@ -1,12 +1,12 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
" Last Change: November 21, 2011
" Last Change: November 22, 2011
" URL: http://peterodding.com/code/vim/notes/

" 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.12.12'
let g:xolox#notes#version = '0.14'

function! xolox#notes#shortcut() " {{{1
" The "note:" pseudo protocol is just a shortcut for the :Note command.
Expand Down Expand Up @@ -551,7 +551,7 @@ function! s:run_scanner(keywords, matches) " {{{2
if !(executable(python) && filereadable(scanner))
call xolox#misc#msg#debug("notes.vim %s: The %s script isn't executable.", g:xolox#notes#version, scanner)
else
let arguments = [scanner, g:notes_indexfile, g:notes_directory, a:keywords]
let arguments = [scanner, '--database', g:notes_indexfile, '--notes', g:notes_directory, a:keywords]
call map(arguments, 'xolox#misc#escape#shell(v:val)')
let output = xolox#misc#str#trim(system(join([python] + arguments)))
if !v:shell_error
Expand Down Expand Up @@ -582,7 +582,7 @@ function! xolox#notes#get_fnames(include_shadow_notes) " {{{3
let starttime = xolox#misc#timer#start()
let pattern = xolox#misc#path#merge(g:notes_directory, '*')
let listing = glob(xolox#misc#path#absolute(pattern))
call extend(s:cached_fnames, split(listing, '\n'))
call extend(s:cached_fnames, filter(split(listing, '\n'), 'filereadable(v:val)'))
let s:have_cached_names = 1
call xolox#misc#timer#stop('notes.vim %s: Cached note filenames in %s.', g:xolox#notes#version, starttime)
endif
Expand Down
45 changes: 22 additions & 23 deletions doc/notes.txt
Expand Up @@ -38,8 +38,8 @@ notes in Vim:
- Back-references: The |:RelatedNotes| command find all notes referencing the
current file

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

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

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

Syntax mode screen shot, see reference [4]
Syntax mode screen shot, see reference [3]

===============================================================================
*notes-install-usage*
Install & usage ~

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

-------------------------------------------------------------------------------
Accelerated searching with Python and SQLite ~
*notes-accelerated-searching-with-python*
Accelerated searching with Python ~

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.
script which uses a persistent full text index of your notes stored in a file.

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
index which can take a moment, but after the index has been initialized
updates and searches should be more or less instantaneous.

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

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

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

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

===============================================================================
*notes-license*
License ~

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

===============================================================================
*notes-references*
References ~

[1] http://python.org/
[2] http://sqlite.org/
[3] http://code.google.com/p/vim/source/browse/runtime/colors/slate.vim
[4] http://peterodding.com/code/vim/notes/syntax.png
[5] http://peterodding.com/code/vim/downloads/notes.zip
[6] http://www.vim.org/scripts/script.php?script_id=293
[7] http://www.vim.org/scripts/script.php?script_id=3123
[8] http://www.vim.org/scripts/script.php?script_id=2657
[9] http://www.vim.org/scripts/script.php?script_id=3375
[10] http://en.wikipedia.org/wiki/MIT_License
[2] http://code.google.com/p/vim/source/browse/runtime/colors/slate.vim
[3] http://peterodding.com/code/vim/notes/syntax.png
[4] http://peterodding.com/code/vim/downloads/notes.zip
[5] http://www.vim.org/scripts/script.php?script_id=293
[6] http://www.vim.org/scripts/script.php?script_id=3123
[7] http://www.vim.org/scripts/script.php?script_id=2657
[8] http://www.vim.org/scripts/script.php?script_id=3375
[9] http://en.wikipedia.org/wiki/MIT_License

vim: ft=help
149 changes: 0 additions & 149 deletions misc/notes/scanner.py

This file was deleted.

0 comments on commit 7f86001

Please sign in to comment.