Permalink
Browse files

Version 0.6.0

- add the possibility to restrict note listing to tags
- respect pinned notes in note index
- set initial number of notes to load to 100
- add config option to specify a preferred filetype
- add modifydate to update_note() function
  • Loading branch information...
1 parent ee17a36 commit 3850fac394df9c6d2f7789caee0991fa31b60b66 @mrtazz mrtazz committed with Sep 30, 2012
Showing with 95 additions and 31 deletions.
  1. +8 −0 CHANGELOG.md
  2. +37 −8 README
  3. +15 −7 README.md
  4. +33 −15 autoload/simplenote.vim
  5. +2 −1 plugin/simplenote.vim
View
@@ -1,5 +1,13 @@
# Changelog
+## 0.6.0 (09/30/2012)
+
+- add the possibility to restrict note listing to tags
+- respect pinned notes in note index
+- set initial number of notes to load to 100
+- add config option to specify a preferred filetype
+- add modifydate to update_note() function
+
## 0.5.0 (06/03/2012)
- make pretty formatting for note list
View
45 README
@@ -19,25 +19,56 @@ If you don't want to have the credentials in your `vimrc` (if you manage it
with git for example), you can just set the variables in a different file (like
`~/.simplenoterc`) and source it with `source ~/.simplenoterc` in your `vimrc`.
+By default all notes are treated as plain text. If you usually write all of
+your notes in some other format (like markdown or restructured text) you can
+set `g:SimplenoteFiletype` to the preferred vim filetype.
+
## Usage
The plugin provides several commands to interact with your Simplenote account.
In order to retrieve a list of your notes execute
- :Simplenote -l
+ :Simplenote -l X
+ :Simplenote -l todo,shopping
-This opens a new scratch buffer with a line-wise listing of your notes. You can
-navigate through these with the arrow keys and enter a note on hitting
-`Return`. Now that you see the content of the note, you can interact with this
-specific note:
+Where X is the number of notes to retrieve; omit X to retrieve all. This opens
+a new scratch buffer with a line-wise listing of your notes. With `let
+g:SimplenoteListHeight=X` set, the scratch buffer will come up X lines tall.
+Alternatively when `let g:SimplenoteVertical=1` is set, it is opened as a
+vertical rather than horizontal split window. You can also pass a comma
+separated list of tags. This will only list notes which have at least one of
+those tags. You can then navigate through the with the arrow keys and enter a
+note on hitting `Return`. Now that you see the content of the note, you can
+interact with this specific note:
:Simplenote -u
updates the content of the current note with the content of the current buffer.
+The buffer write command `:w` is also mapped to update the current note.
If you want to delete the note, execute
:Simplenote -d
-This moves the current note to the trash.
+This moves the current note to the trash. If you want to completely delete a
+note, use
+
+ :Simplenote -D
+
+as it will directly delete the note and not only move it to the trash.
+There also exists a command to create new notes.
+
+ :Simplenote -n
+
+creates a new note with the contents of the current buffer. Once the note is
+created, `:Simplenote -u` updates the newly created note, also with the
+contents of the current buffer.
+Tagging notes is also supported. If you enter
+
+ :Simplenote -t
+
+on a buffer containing a valid note, you get an input dialog, prefilled with
+existing comma-separated tags for the note, which you can then edit. Tags have
+to be comma separated and hitting `Enter` will then update the note with the
+new tag list.
## Dependencies
Version 2 of the SimpleNote API relies heavily on JSON. As JSON and VimL don't
@@ -54,7 +85,6 @@ add these lines (with the correct values) to your `.vimrc`:
## Development
-- [Planned features](http://www.pivotaltracker.com/projects/288621)
- [Bugs and issue tracker](https://github.com/mrtazz/simplenote.vim/issues)
## Contribute
@@ -72,4 +102,3 @@ which I took as a basis to learn how to write vim plugins.
[3]: http://github.com/tpope
[4]: http://github.com/scrooloose
[5]: http://github.com/tpope/vim-pathogen
-
View
@@ -17,18 +17,26 @@ If you don't want to have the credentials in your `vimrc` (if you manage it
with git for example), you can just set the variables in a different file (like
`~/.simplenoterc`) and source it with `source ~/.simplenoterc` in your `vimrc`.
+By default all notes are treated as plain text. If you usually write all of
+your notes in some other format (like markdown or restructured text) you can
+set `g:SimplenoteFiletype` to the preferred vim filetype.
+
## Usage
The plugin provides several commands to interact with your Simplenote account.
In order to retrieve a list of your notes execute
:Simplenote -l X
-
-Where X is the number of notes to retrieve; omit X to retrieve all.
-This opens a new scratch buffer with a line-wise listing of your notes. When
-`let g:SimplenoteVertical=1` is set, the scratch buffer is opened as a vertical
-rather than a horizontal split window. You can then navigate through the notes
-with the arrow keys and enter a note on hitting `Return`. Now that you see the
-content of the note, you can interact with this specific note:
+ :Simplenote -l todo,shopping
+
+Where X is the number of notes to retrieve; omit X to retrieve all. This opens
+a new scratch buffer with a line-wise listing of your notes. With `let
+g:SimplenoteListHeight=X` set, the scratch buffer will come up X lines tall.
+Alternatively when `let g:SimplenoteVertical=1` is set, it is opened as a
+vertical rather than horizontal split window. You can also pass a comma
+separated list of tags. This will only list notes which have at least one of
+those tags. You can then navigate through the with the arrow keys and enter a
+note on hitting `Return`. Now that you see the content of the note, you can
+interact with this specific note:
:Simplenote -u
View
@@ -4,13 +4,6 @@
" Author: Daniel Schauenberg <d@unwiredcouch.com>
" WebPage: http://github.com/mrtazz/simplenote.vim
" License: MIT
-" Usage:
-" :Simplenote -l => list all notes
-" :Simplenote -u => update a note from buffer
-" :Simplenote -d => move note to trash
-" :Simplenote -n => create new note from buffer
-" :Simplenote -D => delete note in current buffer
-" :Simplenote -t => tag note in current buffer
"
"
@@ -45,6 +38,13 @@ else
let s:vbuff = 0
endif
+" line height
+if exists("g:SimplenoteListHeight")
+ let s:lineheight = g:SimplenoteListHeight
+else
+ let s:lineheight = 0
+endif
+
if (s:user == "") || (s:password == "")
let errmsg = "Simplenote credentials missing. Set g:SimplenoteUsername and "
@@ -94,7 +94,15 @@ function! s:ScratchBuffer()
setlocal bufhidden=hide
setlocal noswapfile
setlocal cursorline
- setlocal filetype=txt
+ if exists("g:SimplenoteFiletype")
+ exe "setlocal filetype=" . g:SimplenoteFiletype
+ else
+ setlocal filetype=txt
+ endif
+
+ if (s:vbuff == 0) && (s:lineheight > 0)
+ exe "resize " . s:lineheight
+ endif
endfunction
@@ -129,7 +137,7 @@ except ImportError:
AUTH_URL = 'https://simple-note.appspot.com/api/login'
DATA_URL = 'https://simple-note.appspot.com/api2/data'
INDX_URL = 'https://simple-note.appspot.com/api2/index?'
-NOTE_FETCH_LENGTH = 20
+NOTE_FETCH_LENGTH = 100
class Simplenote(object):
""" Class for interacting with the simplenote web service """
@@ -224,8 +232,12 @@ class Simplenote(object):
if note.has_key("tags"):
note["tags"] = [unicode(t, 'utf-8') for t in note["tags"]]
+
# determine whether to create a new note or updated an existing one
if note.has_key("key"):
+ # set modification timestamp in milli-seconds since epoch
+ note["modifydate"] = int(round(time.time() * 1000))
+
url = '%s/%s?auth=%s&email=%s' % (DATA_URL, note["key"],
self.get_token(), self.username)
else:
@@ -571,22 +583,28 @@ class SimplenoteVimInterface(object):
else:
print "Update failed.: %s" % note["key"]
- def list_note_index_in_scratch_buffer(self, qty=float("inf")):
+ def list_note_index_in_scratch_buffer(self, qty=float("inf"), tags=[]):
""" get all available notes and display them in a scratchbuffer """
# Initialize the scratch buffer
self.scratch_buffer()
vim.command("setlocal modifiable")
# clear global note id storage
buffer = vim.current.buffer
note_list, status = self.simplenote.get_note_list(qty)
+ if (len(tags) > 0):
+ note_list = [n for n in note_list if (n["deleted"] != 1 and
+ len(set(n["tags"]).intersection(tags)) > 0)]
+ else:
+ note_list = [n for n in note_list if n["deleted"] != 1]
+
# set global notes index object to notes
if status == 0:
note_titles = []
notes = self.get_notes_from_keys([n['key'] for n in note_list])
- notes.sort(key=lambda k: k['modifydate'])
+ notes.sort(key=lambda k: (('pinned' in k['systemtags']), k['modifydate']))
notes.reverse()
- note_titles = [self.format_title(n) for n in notes if n["deleted"] != 1]
- self.note_index = [n["key"] for n in notes if n["deleted"] != 1]
+ note_titles = [self.format_title(n) for n in notes]
+ self.note_index = [n["key"] for n in notes]
buffer[:] = note_titles
else:
@@ -650,9 +668,9 @@ optionsexist = True if (float(vim.eval("a:0"))>=1) else False
if param == "-l":
if optionsexist:
try:
- interface.list_note_index_in_scratch_buffer(int(float(vim.eval("a:1"))))
+ interface.list_note_index_in_scratch_buffer(qty=int(vim.eval("a:1")))
except:
- interface.list_note_index_in_scratch_buffer()
+ interface.list_note_index_in_scratch_buffer(tags=vim.eval("a:1").split(","))
else:
interface.list_note_index_in_scratch_buffer()
View
@@ -4,9 +4,10 @@
" Author: Daniel Schauenberg <d@unwiredcouch.com>
" WebPage: http://github.com/mrtazz/simplenote.vim
" License: MIT
-" Version: 0.5.0
+" Version: 0.6.0
" Usage:
" :Simplenote -l X => list X number of notes; omit X to list all
+" :Simplenote -l tags,moretags => list notes which feature one of the tags
" :Simplenote -u => update a note from buffer
" :Simplenote -d => move note to trash
" :Simplenote -n => create new note from buffer

0 comments on commit 3850fac

Please sign in to comment.