On 02/08/10 19:32, Uli Schlachter wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Am 30.07.2010 17:54, Ignas Anikevicius wrote:
   Hello everybody,

It seems that the question of dyn tagging in awesome is getting a bit
rusty... :) I have corrected the patch according to Ulis wishes, so
maybe it will be better?

On 13/07/10 19:08, Uli Schlachter wrote:
What if fallback_tag == nil and the client is not sticky? It won't be attached
to any tags after this.

Which makes me wonder... Can that happen at all? The only way for fallback_tag
to be nil is because find_fallback() found nothing. This can only happen if
there is no other tag on this screen, but there was an "if" above which checked
for this already, no?
I think, that everything should be good. Although it is not very nice to
have a test in different functions, so I made it thrice bullet proof. :)
I guess it should be good.

Tell me if it is otherwise (It is my first contribution, although very
small, so I am happy to receive any critics or suggestions).

Cheers,
Ignas A. (gns_ank)

Hi,

I tried merging your patch:

$ git am -s /tmp/1.patch
Patch format detection failed.

Looking more closely at the file, I noticed that it's the output of "git show".
Could you instead send us a file from "git format-patch"?

"git format-patch HEAD^.." should do the trick.

Cheers,
Uli
- -- - - Buck, when, exactly, did you lose your mind?
- - Three months ago. I woke up one morning married to a pineapple.
   An ugly pineapple... But I loved her!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEcBAEBCAAGBQJMVwE8AAoJECLkKOvLj8sGmDcH/ibIhs8MP96asw54ZZdPspZ6
ML0o0sayL7jhZUisU+bGX/5QA9OpNvGYl0p7GrIXr32haYvjD6afrkk9INYQ2YAw
XuKTj5lkKrrpNzl8zA0p84AHKy4IF3gxdj0nisTqsk83VKKt+hq/lxDqPRuPKib0
M/Too62mA83ieOIihqmHh9MnfniHFa/RNWt1RkrR3JQb66t3oBbTu8aEe/c6G+8c
Mitvq7jVGxnJzLrOAvP+gl4FwZvBXaBSyZqbO03QXecbRYQ6UxeJ6/dGS4W1GVO3
DUNKQ7uBFO4UH42AZObaCw4XXpF9XrtHeoAFWxYmcbI9W2pRQ+JOlIkw+NH4O2g=
=9kdV
-----END PGP SIGNATURE-----

Here you go... everything should be fine. In case not, I am ready to fix any issues.

Cheers,
Ignas
>From b2daec5050e16b7dcb86013e245a10cb7311d4d6 Mon Sep 17 00:00:00 2001
From: Ignas Anikevicius (gns_ank) <anikevic...@gmail.com>
Date: Mon, 2 Aug 2010 20:25:30 +0200
Subject: [PATCH] Delete func for awful, which was initially written by Perry 
Hargrave, Modified by Aneesh Kumar and prepared for mergin by me. Delete func 
also employs find_fallback func, which was written by Aneesh. This should 
complete the set of function for providing minimal dyn tagging capabilities to 
awful.

---
 lib/awful/tag.lua.in |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in
index af1b043..4a86932 100644
--- a/lib/awful/tag.lua.in
+++ b/lib/awful/tag.lua.in
@@ -96,6 +96,74 @@ function new(names, screen, layout)
     return tags
 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. [selectedlist(scr)]
+function find_fallback(screen, invalids)
+    local scr = screen or capi.mouse.screen
+    local t = invalids or selectedlist(scr)
+
+    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. [selected()]
+-- @param fallback_tag Tag to assign stickied tags to. [~selected()]
+-- @return Returns true if the tag is successfully deleted, nil otherwise.
+-- If there are no clients exclusively on this tag then delete it. Any
+-- stickied clients are assigned to the optional 'fallback_tag'.
+-- If after deleting the tag there is no selected tag, try and restore from
+-- history or select the first tag on the screen.
+function delete(target_tag, fallback_tag)
+    -- abort if no tag is passed or currently selected
+    local target_tag = target_tag or selected()
+    if target_tag == nil then return end
+
+    local ntags = #capi.screen[target_tag.screen]:tags()
+    local target_scr = target_tag.screen
+
+    -- We can't use the target tag as a fallback.
+    local fallback_tag = fallback_tag
+    if fallback_tag == target_tag then return end
+
+    -- No fallback_tag provided, try and get one.
+    if fallback_tag == nil then
+        fallback_tag = find_fallback(target_scr, {target_tag})
+    end
+
+    -- Abort if we would have un-tagged clients.
+    local clients = target_tag:clients()
+    if ( #clients > 0 and ntags <= 1 ) or fallback_tag == nil then return end
+
+    -- Move the clients we can off of this tag.
+    for _, c in pairs(clients) do
+
+        -- If a client has only this tag, or stickied clients with
+        -- nowhere to go, abort.
+        if (not c.sticky and #c:tags() == 1) or
+                                    (c.sticky and fallback_tag == nil) then
+            return
+        else
+            c:tags({fallback_tag})
+        end
+    end
+
+    -- delete the tag
+    target_tag.screen = nil
+
+    -- If no tags are visible, try and view one.
+    if selected(target_scr) == nil and ntags > 0 then
+        history.restore()
+        if selected(target_scr) == nil then
+            capi.screen[target_scr]:tags()[1].selected = true
+        end
+    end
+
+    return true
+end
+
 --- Update the tag history.
 -- @param obj Screen object.
 function history.update(obj)
-- 
1.7.2.1

Reply via email to