Created
May 1, 2011 17:41
-
-
Save no6v/950671 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Earthquake::Input | |
def friends | |
@friends ||= [] | |
end | |
end | |
Earthquake.init do | |
output :friend_completion do |item| | |
next unless item["user"] | |
(friends << "@#{item["user"]["screen_name"]}").uniq! | |
end | |
input_filter do |text| | |
text.scan(/@[0-9A-Za-z_]+/) do |screen_name| | |
(friends << screen_name).uniq! | |
end | |
end | |
Readline.basic_word_break_characters = Readline.basic_word_break_characters.delete("@") | |
completion_proc = Readline.completion_proc | |
Readline.completion_proc = lambda do |text| | |
case text | |
when /^@/ | |
friends.grep(/^#{text}/) | |
else | |
completion_proc.call(text) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment