wmiirc-rumai

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

commit 8f1a726b306014e1857b6f65417674d517a3e4fa
parent 27c6404b638c73933caa92c39731063e5c6670a7
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date:   Thu, 31 Aug 2006 01:04:13 -0700

[project @ 27f1303761467e2c5af7aa84c0bfc40c7050ac74]

[project @ 14]
simplify usage of Client#with_tags

Diffstat:
wmii.rb | 14+++++++-------
wmiirc | 18++++++++++--------
2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/wmii.rb b/wmii.rb @@ -371,10 +371,10 @@ class Wmii @wm.write "#{@path}/tags", aTags.flatten.uniq.join(TAG_DELIMITER) end - # Invokes the given block with this client's tags and reapplies them to this client. - def with_tags # :yields: tags + # Do stuff (the given block) with this client's tags. + def with_tags &aBlock t = self.tags - yield t + t.instance_eval(&aBlock) self.tags = t end @@ -383,14 +383,14 @@ class Wmii end def select! - with_tags do |t| - t.unshift SELECTION_TAG + with_tags do + unshift SELECTION_TAG end end def unselect! - with_tags do |t| - t.delete SELECTION_TAG + with_tags do + delete SELECTION_TAG end end diff --git a/wmiirc b/wmiirc @@ -23,7 +23,6 @@ $: << File.dirname(__FILE__) require 'wmii' - WM = Wmii.instance # WM STARTUP @@ -211,17 +210,20 @@ SHORTCUTS = { # shortcuts for adding and removing tags of a client SHORTCUTS["#{SEND}equal,#{i}"] = SHORTCUTS["#{SEND}Shift-equal,#{i}"] = lambda do - tags = WM.read('/view/sel/sel/tags').split('+') - tags.push WM.read('/tags').split[k] || i - - WM.write '/view/sel/sel/tags', tags.uniq.join('+') + WM.current_client.with_tags do + push(WM.tags[k] || i) + end end SHORTCUTS["#{SEND}minus,#{i}"] = lambda do - tags = WM.read('/view/sel/sel/tags').split('+') + WM.current_client.with_tags do + delete(WM.tags[k] || i) + end + end - if tags.delete WM.read('/tags').split[k] || i - WM.write '/view/sel/sel/tags', tags.join('+') + SHORTCUTS["#{SEND}Shift-minus"] = lambda do + WM.current_client.with_tags do + delete WM.current_view.name end end end