Skip to content

Commit

Permalink
TITLEとかCATEGORYとかマジでおかしかったので直した
Browse files Browse the repository at this point in the history
  • Loading branch information
moznion committed Jan 31, 2014
1 parent 2a5dca2 commit b879076
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions autoload/hateblo.vim
Expand Up @@ -2,10 +2,13 @@ let s:save_cpo = &cpo
set cpo&vim

function! hateblo#createEntry(is_draft)
let l:title = s:get_title()
let b:contents_beginning_line = 1 " XXX suxxs!

let l:title = s:get_title()
let l:category = s:get_category()
let l:lines = s:format_lines(getline('1', '$'))
let l:content = join(l:lines, "\n")
let l:lines = s:format_lines(getline(b:contents_beginning_line, '$'))
let l:content = join(l:lines, "\n")

if s:ask('Post?')
call s:create(l:title, l:content, l:category, a:is_draft)
redraw
Expand All @@ -16,7 +19,7 @@ function! hateblo#createEntry(is_draft)
endif
endfunction

function! hateblo#updateEntry(silent)
function! hateblo#updateEntry()
call s:check_buffer()
let l:title = s:get_title()
let l:category = s:get_category()
Expand Down Expand Up @@ -206,6 +209,8 @@ function! s:get_title()
let l:title_line = getline(1)

if l:title_line[0:len(s:title_prefix)-1] ==# s:title_prefix
" `TITLE: foobar` is on the top of line
let b:contents_beginning_line += 1
return s:strip_whitespace(l:title_line[len(s:title_prefix):])
elseif exists('b:hateblo_entry_title') && b:hateblo_entry_title != ''
return b:hateblo_entry_title
Expand All @@ -220,9 +225,11 @@ function! s:get_title()
endfunction

function! s:get_category()
let l:category_line = getline(2)
let l:category_line = getline(b:contents_beginning_line)

if l:category_line[0:len(s:category_prefix)-1] ==# s:category_prefix
" `CATEGORY: Perl, Ruby` is on the top of line
let b:contents_beginning_line += 1
let l:category_str = s:strip_whitespace(l:category_line[len(s:category_prefix):])
elseif exists("b:hateblo_category_str") && b:hateblo_category_str != ''
let l:category_str = b:hateblo_category_str
Expand Down
2 changes: 1 addition & 1 deletion plugin/hateblo.vim
Expand Up @@ -38,7 +38,7 @@ let g:hateblo_vim['edit_command'] = get(g:hateblo_vim, 'edit_command', 'edit')
command! -nargs=0 HatebloCreate call hateblo#createEntry('no')
command! -nargs=0 HatebloCreateDraft call hateblo#createEntry('yes')
command! -nargs=0 HatebloList call hateblo#listEntry()
command! -nargs=0 HatebloUpdate call hateblo#updateEntry(0)
command! -nargs=0 HatebloUpdate call hateblo#updateEntry()
command! -nargs=0 HatebloDelete call hateblo#deleteEntry()

let g:loaded_hateblo = 1
Expand Down

0 comments on commit b879076

Please sign in to comment.