|
1 | 1 | " Vim auto-load script
|
2 | 2 | " Author: Peter Odding <peter@peterodding.com>
|
3 |
| -" Last Change: May 14, 2013 |
| 3 | +" Last Change: May 16, 2013 |
4 | 4 | " URL: http://peterodding.com/code/vim/notes/
|
5 | 5 |
|
6 | 6 | " Note: This file is encoded in UTF-8 including a byte order mark so
|
7 | 7 | " that Vim loads the script using the right encoding transparently.
|
8 | 8 |
|
9 |
| -let g:xolox#notes#version = '0.20.1' |
| 9 | +let g:xolox#notes#version = '0.21' |
10 | 10 | let s:scriptdir = expand('<sfile>:p:h')
|
11 | 11 |
|
12 | 12 | call xolox#misc#compat#check('notes', 3)
|
@@ -57,6 +57,11 @@ function! xolox#notes#init() " {{{1
|
57 | 57 | if !exists('g:notes_tagsindex')
|
58 | 58 | let g:notes_tagsindex = xolox#misc#path#merge(localdir, 'tags.txt')
|
59 | 59 | endif
|
| 60 | + " Define the default location for the file containing the most recent note's |
| 61 | + " filename. |
| 62 | + if !exists('g:notes_recentindex') |
| 63 | + let g:notes_recentindex = xolox#misc#path#merge(localdir, 'recent.txt') |
| 64 | + endif |
60 | 65 | " Define the default action when a note's filename and title are out of sync.
|
61 | 66 | if !exists('g:notes_title_sync')
|
62 | 67 | " Valid values are "no", "change_title", "rename_file" and "prompt".
|
@@ -531,75 +536,6 @@ function! xolox#notes#related(bang) " {{{1
|
531 | 536 | call xolox#misc#timer#stop("notes.vim %s: Found related notes in %s.", g:xolox#notes#version, starttime)
|
532 | 537 | endfunction
|
533 | 538 |
|
534 |
| -function! xolox#notes#recent(bang, title_filter) " {{{1 |
535 |
| - call xolox#misc#msg#info("notes.vim %s: Generating overview of recent notes ..", g:xolox#notes#version) |
536 |
| - " Show generated note listing all notes by last modified time. |
537 |
| - let starttime = xolox#misc#timer#start() |
538 |
| - let bufname = '[Recent Notes]' |
539 |
| - " Prepare a buffer to hold the list of recent notes. |
540 |
| - call xolox#misc#buffer#prepare({ |
541 |
| - \ 'name': bufname, |
542 |
| - \ 'path': xolox#misc#path#merge($HOME, bufname)}) |
543 |
| - " Filter notes by pattern (argument)? |
544 |
| - let notes = [] |
545 |
| - let title_filter = '\v' . a:title_filter |
546 |
| - for [fname, title] in items(xolox#notes#get_fnames_and_titles(0)) |
547 |
| - if title =~? title_filter |
548 |
| - call add(notes, [getftime(fname), title]) |
549 |
| - endif |
550 |
| - endfor |
551 |
| - " Start note with "You have N note(s) [matching filter]". |
552 |
| - let readme = "You have " |
553 |
| - if empty(notes) |
554 |
| - let readme .= "no notes" |
555 |
| - elseif len(notes) == 1 |
556 |
| - let readme .= "one note" |
557 |
| - else |
558 |
| - let readme .= len(notes) . " notes" |
559 |
| - endif |
560 |
| - if a:title_filter != '' |
561 |
| - let quote_format = xolox#notes#unicode_enabled() ? '‘%s’' : "`%s'" |
562 |
| - let readme .= " matching " . printf(quote_format, a:title_filter) |
563 |
| - endif |
564 |
| - " Explain the sorting of the notes. |
565 |
| - if empty(notes) |
566 |
| - let readme .= "." |
567 |
| - elseif len(notes) == 1 |
568 |
| - let readme .= ", it's listed below." |
569 |
| - else |
570 |
| - let readme .= ". They're listed below grouped by the day they were edited, starting with your most recently edited note." |
571 |
| - endif |
572 |
| - " Add the generated text to the buffer. |
573 |
| - call setline(1, ["Recent notes", "", readme]) |
574 |
| - " Reformat the text in the buffer to auto-wrap. |
575 |
| - normal Ggqq |
576 |
| - " Sort, group and format the list of (matching) notes. |
577 |
| - let last_date = '' |
578 |
| - let list_item_format = xolox#notes#unicode_enabled() ? ' • %s' : ' * %s' |
579 |
| - call sort(notes) |
580 |
| - call reverse(notes) |
581 |
| - let lines = [] |
582 |
| - for [ftime, title] in notes |
583 |
| - let date = xolox#notes#friendly_date(ftime) |
584 |
| - if date != last_date |
585 |
| - call add(lines, '') |
586 |
| - call add(lines, substitute(date, '^\w', '\u\0', '') . ':') |
587 |
| - let last_date = date |
588 |
| - endif |
589 |
| - call add(lines, printf(list_item_format, title)) |
590 |
| - endfor |
591 |
| - " Add the formatted list of notes to the buffer. |
592 |
| - call setline(line('$') + 1, lines) |
593 |
| - " Load the notes file type. |
594 |
| - call xolox#notes#set_filetype() |
595 |
| - let &l:statusline = bufname |
596 |
| - " Change the status line |
597 |
| - " Lock the buffer contents. |
598 |
| - call xolox#misc#buffer#lock() |
599 |
| - " And we're done! |
600 |
| - call xolox#misc#timer#stop("notes.vim %s: Generated %s in %s.", g:xolox#notes#version, bufname, starttime) |
601 |
| -endfunction |
602 |
| - |
603 | 539 | " Miscellaneous functions. {{{1
|
604 | 540 |
|
605 | 541 | function! xolox#notes#find_directories(include_shadow_directory) " {{{2
|
|
0 commit comments