On Sat, May 29, 2010 at 05:08:21PM +0200, Uli Schlachter wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > Am 29.05.2010 10:57, Perry Hargrave wrote: > > if its done after setting > > > >>> origin_tag.screen = nil > > > > then we know > > > >>> oscr_tags[1] ~= origin_tag > > > > no? > > No > > The garbage collector only runs some times, not permanently. In theory you can > never be sure some garbage was collected unless you explicitly call the > garbage > collector and let it collect stuff. > > Also, even if it were to run, it wouldn't collect the tag since it is still > references by the oscr_tags table. The garbage collector does NOT magically > remove stuff from your tables. Ever.
Uli = 65535 Perry = 3 okokok... I think we need to do something different for this fallback_tag problem. It was kind of a throw in for me at the last minute and after rethinking and your advices maybe another function would be useful. (attached) then both delete and move_screen could use this function, and its form of taking 'unacceptable' tags as a table could be more flexible. -- perry
>From 284c223009de46326a3c846d235146e3afb3b85a Mon Sep 17 00:00:00 2001 From: Perry Hargrave <[email protected]> Date: Sat, 29 May 2010 10:54:04 -0700 Subject: [PATCH] tag.lua: find_fallback() returns a suitable fallback tag find_fallback(s, t): Looks for a tag on screen 's' and not in 't'. This function is meant to be useful for e.g. delete() and move_screen() to find a suitable fallback tag. --- lib/awful/tag.lua.in | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in index ada5bc9..deb8893 100644 --- a/lib/awful/tag.lua.in +++ b/lib/awful/tag.lua.in @@ -49,6 +49,18 @@ function add(name, props) return newtag end +--- Find a suitable fallback tag. +-- @param screen The screen number to look for a tag on. [mouse.screen] +-- @param target A table of tags we consider unacceptable. [{selected()}] +function find_fallback(screen, invalids) + local scr = screen or capi.mouse.screen + local t = invalids or {selected()} + + for _, v in pairs(capi.screen[scr]:tags()) do + if not util.table.hasitem(t, v) then return v end + end +end + --- Delete a tag. -- @param target_tag Optional tag object to delete, [tag.selected()] -- @param fallback_tag Tag to assign stickied tags to. [screen[]:tags()[1]] -- 1.7.1
