wmiirc-rumai

git clone git://oldgit.suckless.org/wmiirc-rumai/
Log | Files | Refs | README | LICENSE

commit 38d836592bc0141021fffc6c2a0cb6c542fa4bbc
parent e1ee817fc09a9a1638575f42e524e6af25264842
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date:   Tue, 12 May 2009 00:25:12 -0700

remove need for verbose !ruby/regexp YAML directive

match regexps against Client#props instead of #label

Diffstat:
config.rb | 15++++++++++++---
config.yaml | 10+++++-----
2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/config.rb b/config.rb @@ -267,11 +267,20 @@ def load_config config_file event 'CreateClient' do |client_id| client = Client.new(client_id) - if label = client.label.read rescue nil + unless defined? @client_tags_by_regexp + # compile the regular expression only once + pairs = CONFIG['display']['client'].to_a.map {|k,v| + [eval(k, TOPLEVEL_BINDING, "#{config_file}:display:client:#{k}"), v] + } + + @client_tags_by_regexp = Hash[*pairs.flatten] + end + + if label = client.props.read rescue nil catch :found do - CONFIG['display']['client'].each do |regexp, target| + @client_tags_by_regexp.each do |regexp, tags| if label =~ regexp - client.tags = target + client.tags = tags throw :found end end diff --git a/config.yaml b/config.yaml @@ -68,13 +68,13 @@ display: ## # Mapping of clients to views they must appear on: # - # !ruby/regexp '<client label>' : <tags to apply> + # <client props regular expression> : <tags to apply> # client: - !ruby/regexp '/\b(xconsole|alsamixer|XMMS|Sonata)\b/' : 1 - !ruby/regexp '/\b(Buddy List|XChat|WeeChat)\b/' : chat - !ruby/regexp '/\b(Liferea|GMail)\b/' : mail - !ruby/regexp '/\bRestore (Previous )?Session\b/' : web + /\b(xconsole|alsamixer|XMMS|Sonata)\b/ : 1 + /^pidgin:|:WeeChat\b/ : chat + /\b(Liferea|GMail)\b/ : mail + /:(Firefox|Gran Paradiso):.*\bRestore\b.*\bSession\b/ : web ## # Self-refreshing buttons on the status bar.