Skip to content

Instantly share code, notes, and snippets.

@mattn
Created February 28, 2012 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/1930167 to your computer and use it in GitHub Desktop.
Save mattn/1930167 to your computer and use it in GitHub Desktop.
twitvim: add client name
Index: twitvim.vim
===================================================================
--- twitvim.vim (revision 253)
+++ twitvim.vim (working copy)
@@ -2584,6 +2584,9 @@
" Twitter user name: from start of line to first colon.
syntax match twitterUser /^.\{-1,}:/
+ " Twitter client: following time next.
+ syntax match twitterClient /\[[^\]]\+\]\ze\|[^|]\+|$/
+
" Use the bars to recognize the time but hide the bars.
syntax match twitterTime /|[^|]\+|$/ contains=twitterTimeBar
syntax match twitterTimeBar /|/ contained
@@ -2605,6 +2608,7 @@
syntax match twitterTitleStar /\*$/ contained
highlight default link twitterUser Identifier
+ highlight default link twitterClient Special
highlight default link twitterTime String
highlight default link twitterTimeBar Ignore
highlight default link twitterTitle Title
@@ -2842,8 +2846,9 @@
let text = s:convert_entity(s:get_status_text(item))
endif
let pubdate = s:time_filter(s:xml_get_element(item, 'created_at'))
+ let source = substitute(s:convert_entity(s:xml_get_element(item, 'source')), '<[^>]\+>', '', 'g')
- return user.': '.text.' |'.pubdate.'|'
+ return user.': '.text.' ['.source.']|'.pubdate.'|'
endfunction
" Get in-reply-to from a status element. If this is a retweet, use the id of
@@ -5182,7 +5187,9 @@
call add(s:curbuffer.statuses, status)
call add(s:curbuffer.inreplyto, get(item, 'in_reply_to_status_id_str', ''))
- call add(text, user.': '.line.' |'.pubdate.'|')
+ let source = substitute(s:convert_entity(s:time_filter(get(item, 'source', ''))), '<[^>]\+>', '', 'g')
+
+ call add(text, user.': '.line.' ['.source.']|'.pubdate.'|')
endfor
call s:twitter_wintext(text, "timeline")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment