TextMate Ruby代码段检索
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TextMate Ruby代码段检索相关的知识,希望对你有一定的参考价值。
#!/usr/bin/ruby $: << ENV['TM_SUPPORT_PATH'] + '/lib' require "cgi" require "ui" require "xmlrpc/client" unless ENV['SNIPPLR_KEY'] TextMate::UI.alert(:critical, "Snipplr error", "Please first set your 'SNIPPLR_KEY' in Preferences > Advanced > Shell Variables.") exit end TextMate::UI.request_string(:title => "Get Snippet from Snipplr", :prompt => "Enter tags to search for:", :button1 => "Search") do |tag| begin snippet_list = server.call('snippet.list', ENV['SNIPPLR_KEY'], tag) rescue # fall through end unless snippet_list and snippet_list.length > 0 TextMate::UI.alert(:warning, "Snipplr result", "No snippets for '#{tag}' found.") else items = {} snippet_list.each { |r| items[r['title']] = r['id'] } TextMate::UI.request_item(:items => items.keys.sort, :title => "Snipplr result", :prompt => "Choose", :string => "Select which snippet to paste") do |item| begin snippet = server.call('snippet.get', items[item]) rescue TextMate::UI.alert(:critical, "Snipplr error", "Could not retrieve '#{item}'.") end end end end
以上是关于TextMate Ruby代码段检索的主要内容,如果未能解决你的问题,请参考以下文章