Skip to content

Commit

Permalink
Add :Pad search command
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoralesc committed Jun 10, 2015
1 parent ba47414 commit 7eded97
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 4 additions & 2 deletions autoload/pad.vim
Expand Up @@ -16,10 +16,12 @@ exe s:python . ' pad_plugin = pad.plugin.PadPlugin()'

function! pad#PadCmd(args, bang)
let arg_data = split(a:args, ' ')
if arg_data[0] =~ '\(new\|ls\|this\)'
if arg_data[0] =~ '\(new\|ls\|search\|this\)'
let l:args = join(arg_data[1:], ' ')
if arg_data[0] == 'ls'
execute s:python . " pad_plugin.ls('".l:args."', '".a:bang."')"
elseif arg_data[0] == 'search'
execute s:python . " pad_plugin.search('".l:args."', '".a:bang."')"
elseif arg_data[0] == 'new'
if a:bang != '!'
execute s:python . ' pad_plugin.new(text="'.l:args.'")'
Expand All @@ -42,7 +44,7 @@ function! pad#PadCmdComplete(A,L,P)
let cmd_args = split(a:L, ' ', 1)[1:]
echom string(cmd_args)
if len(cmd_args) == 1
let options = "ls\nnew"
let options = "ls\nnew\nsearch"
"only complete 'this' is g:pad#local_dir is set
if g:pad#local_dir != ''
let options .= "\nthis"
Expand Down
9 changes: 5 additions & 4 deletions doc/pad.txt
Expand Up @@ -60,15 +60,16 @@ The first line of the file is taken as a title, and highlighted accordingly.
If the note only spans one line, the text before a dot or a comma is taken as
the title instead. Line breaks are displayed as ↲.

`<leader>ss` in normal mode (default, global: `<Plug>(pad-search)`) also calls
`Pad ls`, but asks for a query to filter the notes before presenting the list.
Giving an empty query is equivalent to calling `Pad ls` without arguments.
*:Pad-search*
:Pad search (`<leader>ss` in normal mode, global: `<Plug>(pad-search)`) also
calls `Pad ls`, but it prompts for a query to filter the notes before
presenting the list. Giving an empty query is equivalent to calling `Pad ls`
without arguments.

By default, `Pad ls` won't show notes from the archive. To list them, you must
pass a bang to the command:

:Pad! ls

*:Pad-new*

- :Pad new (`<Shift><Escape>`, `<leader>n` in the terminal, global:
Expand Down
5 changes: 3 additions & 2 deletions pythonx/pad/plugin.py
Expand Up @@ -105,8 +105,9 @@ def search(self, query=None, use_archive=False):
"""
Prompt for a query and display a list of the matching notes.
"""
query = vim.eval('input(">>> ")')
self.display(query, use_archive)
if not query:
query = vim.eval('input(">>> ")')
self.display(query, use_archive == "!")
V + "redraw!"

@prevent_invalid_dir
Expand Down

0 comments on commit 7eded97

Please sign in to comment.