basyura's blog

あしたになったらほんきだす。

2009-04-15から1日間の記事一覧

hatena.vim を読む その15

vim

function! s:HtmlUnescape(string) " HTMLエスケープを解除 " 引数で与えられた変数を設定 let string = a:string " 実態参照が無くなるなるまでループ while match(string, '&#\d\+;') != -1 " 実態参照対象の数値を抜き出す let num = matchstr(string, '&…

hatena.vim を読む その14

vim

function! HatenaPost(base_url,user,cookie_file,diary,body_file) " body_file が空の場合 if a:body_file == "" " 添付ファイルを生成する let body_file=tempname() " 新しいウィンドウを作成してテンプファイルを編集する execute 'new '.body_file " …

hatena.vim を読む その13

vim

function! s:HatenaUpdate(...) " 更新する " 日時を取得 " バッファスコープのそれぞれの変数が存在しない場合は終了 if !exists('b:hatena_login_info') || !exists('b:year') || !exists('b:month') || !exists('b:day') || !exists('b:day_title') || !e…

hatena.vim を読む その12

vim

function! s:HatenaParseContent(content) " タイトルを抽出 let diary_title = matchstr( a:content, '<title>\zs.\{-}\ze</title>') " 日付タイトルを取得 let day_title = matchstr( a:content, '

hatena.vim を読む その11

vim

"指定先から一日分のエントリを取得。 "return: dictionary { " diary_title, day_title, timestamp, rkm, body, fenc "} function! HatenaLoadContent(base_url,user,year,month,day,cookie_file) " 編集ページを取得 " curl -k --silent "http://d.hatena.…

hantea.vim を読む その10

vim

function! s:HatenaEdit(...) " 編集する " ログイン " b:hatena_lgin_info (バッファ内変数) が存在しない場合 if !exists('b:hatena_login_info') " ログイン処理を呼び出す let hatena_login_info = s:HatenaLogin() " ログイン情報が無い場合は終了 if !…

hatena.vim を読む その9

vim

" ユーザIDを引数に取るログイン関数定義 function! HatenaLogin(user) " ユーザIDを保持 let hatena_user=a:user " URL とユーザを取得 let [base_url, user] = s:GetBaseURLAndUser(hatena_user) " テンプファイルを生成 let tmpfile = tempname() " クッ…

hatena.vim を読む その8

vim

" ログイン関数定義 function! s:HatenaLogin() " g:hatena_user の長さが 0 の場合 " (.vimrc (または .gvimrc 等) に " let g:hatena_user='basyura' の定義が無い場合) if !strlen(g:hatena_user) " ユーザに ID の入力を求める " その際に補完候補(custo…

hatena.vim を読む その7

vim

let s:curl_cmd = 'curl -k --silent' if exists('g:chalice_curl_options') " http://d.hatena.ne.jp/smeghead/20070709/hatenavim let s:curl_cmd = s:curl_cmd . ' ' . g:chalice_curl_options endif let s:hatena_login_url = 'https://www.hatena.ne.jp…

hatena.vim を読む その6

vim

" 常に `ちょっとした更新' にする? (1: 常にちょっとした更新) if !exists('g:hatena_always_trivial') let g:hatena_always_trivial = 0 endif let g:hatena_syntax_html = 1 if !g:hatena_hold_cookie autocmd VimLeave * call delete(b:hatena_login_in…

hatena.vim を読む その5

vim

" スクリプトのベースディレクトリ (クッキーの保存に使われるだけ) if !exists('g:hatena_base_dir') let g:hatena_base_dir = substitute(expand('<sfile>:p:h'), '[/\\]plugin$', '', '') endif if !exists('g:hatena_base_dir') g:hatena_base_dir が存在しない</sfile>…

hatena.vim を読む その4

vim

" はてなのユーザID if !exists('g:hatena_user') let g:hatena_user = '' endif " サブアカなども含めたIDのリスト if !exists('g:hatena_users') if g:hatena_user != '' let g:hatena_users = [g:hatena_user] else let g:hatena_users = [] endif endif …

hatena.vim を読む その3

vim

nnoremap <Leader>he :HatenaEdit<CR> nnoremap ノーマルモードのコマンド定義 he :HatenaEdit *<Leader>* *mapleader* マップコマンドで特別な文字列 "<Leader>" を使用すると、その部分が変数 "mapleader" に設定された文字列で置き換わります。"mapleader" が空文字列のときや 設定さ</leader></leader></cr></leader>…