Permalink
Browse files

Make :SearchNotes work properly without vim-shell (fixes #53)

This follows the initial suggestion of removing the try/catch construct.
I still haven't a clue what the hell is going on here, but I'm done
fighting Vim (script) and just want this to work now! :-)
  • Loading branch information...
1 parent 08b9747 commit e465a0a987dbacdf7291688215b8545f8584d409 @xolox committed Nov 4, 2015
Showing with 40 additions and 70 deletions.
  1. +0 −7 README.md
  2. +33 −39 autoload/xolox/notes.vim
  3. +7 −24 doc/notes.txt
View
@@ -376,12 +376,6 @@ If you write your git commit messages in Vim and want to use the notes file type
This is not a complete solution (there are more types of commit messages that the pattern above won't match) but that is outside the scope of this document. For inspiration you can take a look at the [runtime/filetype.vim] [filetype.vim] file in Vim's Mercurial repository.
-## Troubleshooting
-
-### Searching notes does not work
-
-There is a known problem where keyword searching of notes is broken when my [vim-shell plug-in] [shell] is not installed (even though vim-shell is supposed to be an optional dependency). The easiest way to work around this is to simply install the vim-shell plug-in, if that is an option for you. Alternatively you can help me debug the problem discussed in [issue 85] [85] :-).
-
## 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] [vim_online].
@@ -392,7 +386,6 @@ This software is licensed under the [MIT license] [mit].
© 2015 Peter Odding &lt;<peter@peterodding.com>&gt;.
-[85]: https://github.com/xolox/vim-session/issues/85
[ctrlwf]: http://vimdoc.sourceforge.net/htmldoc/windows.html#CTRL-W_f
[ctrlwgf]: http://vimdoc.sourceforge.net/htmldoc/windows.html#CTRL-W_gf
[edit]: http://vimdoc.sourceforge.net/htmldoc/editing.html#:edit
View
@@ -1,12 +1,12 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: November 1, 2015
+" Last Change: November 4, 2015
" 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.33.3'
+let g:xolox#notes#version = '0.33.4'
let g:xolox#notes#url_pattern = '\<\(mailto:\|javascript:\|\w\{3,}://\)\(\S*\w\)\+/\?'
let s:scriptdir = expand('<sfile>:p:h')
@@ -471,46 +471,40 @@ endfunction
function! xolox#notes#search(bang, input) " {{{1
" Search all notes for the pattern or keywords {input} (current word if none given).
- try
- let starttime = xolox#misc#timer#start()
- let input = a:input
+ let starttime = xolox#misc#timer#start()
+ let input = a:input
+ if input == ''
+ let input = s:tag_under_cursor()
if input == ''
- let input = s:tag_under_cursor()
- if input == ''
- call xolox#misc#msg#warn("notes.vim %s: No string under cursor", g:xolox#notes#version)
- return
- endif
+ call xolox#misc#msg#warn("notes.vim %s: No string under cursor", g:xolox#notes#version)
+ return
endif
- if input =~ '^/.\+/$'
- call xolox#misc#msg#debug("notes.vim %s: Performing pattern search (%s) ..", g:xolox#notes#version, input)
- call s:internal_search(a:bang, input, '', '')
- call s:set_quickfix_title([], input)
- else
- let keywords = split(input)
- let all_keywords = s:match_all_keywords(keywords)
- let any_keyword = s:match_any_keyword(keywords)
- call xolox#misc#msg#debug("notes.vim %s: Performing keyword search (%s) ..", g:xolox#notes#version, input)
- call s:internal_search(a:bang, all_keywords, input, any_keyword)
- if &buftype == 'quickfix'
- " Enable line wrapping in the quick-fix window.
- setlocal wrap
- " Resize the quick-fix window to 1/3 of the screen height.
- let max_height = &lines / 3
- execute 'resize' max_height
- " Make it smaller if the content doesn't fill the window.
- normal G$
- let preferred_height = winline()
- execute 'resize' min([max_height, preferred_height])
- normal gg
- call s:set_quickfix_title(keywords, '')
- endif
+ endif
+ if input =~ '^/.\+/$'
+ call xolox#misc#msg#debug("notes.vim %s: Performing pattern search (%s) ..", g:xolox#notes#version, input)
+ call s:internal_search(a:bang, input, '', '')
+ call s:set_quickfix_title([], input)
+ else
+ let keywords = split(input)
+ let all_keywords = s:match_all_keywords(keywords)
+ let any_keyword = s:match_any_keyword(keywords)
+ call xolox#misc#msg#debug("notes.vim %s: Performing keyword search (%s) ..", g:xolox#notes#version, input)
+ call s:internal_search(a:bang, all_keywords, input, any_keyword)
+ if &buftype == 'quickfix'
+ " Enable line wrapping in the quick-fix window.
+ setlocal wrap
+ " Resize the quick-fix window to 1/3 of the screen height.
+ let max_height = &lines / 3
+ execute 'resize' max_height
+ " Make it smaller if the content doesn't fill the window.
+ normal G$
+ let preferred_height = winline()
+ execute 'resize' min([max_height, preferred_height])
+ normal gg
+ call s:set_quickfix_title(keywords, '')
endif
- call xolox#misc#timer#stop("notes.vim %s: Searched notes in %s.", g:xolox#notes#version, starttime)
- catch /^Vim\%((\a\+)\)\=:E480/
- call xolox#misc#msg#warn("notes.vim %s: No matches", g:xolox#notes#version)
- catch
- call xolox#misc#msg#warn("notes.vim %s: Encountered error during search: %s (%s)", g:xolox#notes#version, v:exception, v:throwpoint)
- endtry
+ endif
+ call xolox#misc#timer#stop("notes.vim %s: Searched notes in %s.", g:xolox#notes#version, starttime)
endfunction
function! s:tag_under_cursor() " {{{2
View
@@ -52,11 +52,9 @@ Contents ~
3. VOoM |notes-voom|
4. Txtfmt |notes-txtfmt|
8. Using the notes file type for git commit messages |using-notes-file-type-for-git-commit-messages|
- 9. Troubleshooting |notes-troubleshooting|
- 1. Searching notes does not work |searching-notes-does-not-work|
- 10. Contact |notes-contact|
- 11. License |notes-license|
- 12. References |notes-references|
+ 9. Contact |notes-contact|
+ 10. License |notes-license|
+ 11. References |notes-references|
===============================================================================
*notes-introduction*
@@ -755,33 +753,19 @@ For inspiration you can take a look at the runtime/filetype.vim [17] file in
Vim's Mercurial repository.
===============================================================================
- *notes-troubleshooting*
-Troubleshooting ~
-
--------------------------------------------------------------------------------
- *searching-notes-does-not-work*
-Searching notes does not work ~
-
-There is a known problem where keyword searching of notes is broken when my
-vim-shell plug-in [14] is not installed (even though vim-shell is supposed to
-be an optional dependency). The easiest way to work around this is to simply
-install the vim-shell plug-in, if that is an option for you. Alternatively you
-can help me debug the problem discussed in issue 85 [18] :-).
-
-===============================================================================
*notes-contact*
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 [19].
+If you like the script please vote for it on Vim Online [18].
===============================================================================
*notes-license*
License ~
-This software is licensed under the MIT license [20]. © 2015 Peter Odding
+This software is licensed under the MIT license [19]. © 2015 Peter Odding
<peter@peterodding.com>.
===============================================================================
@@ -805,8 +789,7 @@ References ~
[15] http://www.vim.org/scripts/script.php?script_id=2657
[16] http://www.vim.org/scripts/script.php?script_id=2208
[17] https://code.google.com/p/vim/source/browse/runtime/filetype.vim?r=fbc1131f0ba5be4ec74fb2ccdfb3559b446a2b1e#778
-[18] https://github.com/xolox/vim-session/issues/85
-[19] http://www.vim.org/scripts/script.php?script_id=3375
-[20] http://en.wikipedia.org/wiki/MIT_License
+[18] http://www.vim.org/scripts/script.php?script_id=3375
+[19] http://en.wikipedia.org/wiki/MIT_License
vim: ft=help

0 comments on commit e465a0a

Please sign in to comment.