Re: Some stuff to discuss about



On Sunday 27 September 2009 23:11:50 Matthew Love wrote:
> Perhaps adding a new function in frames.jl similar to
> 'set-frame-part-value that would remove a frame-part key would
> be a nice route.

I was thinking more along the lines of the alist package in Emacs.  
Guile and MIT Scheme also have functions for deleting from association 
lists, unfortunately with different names (neither R5RS nor CLTL define 
such functions).  On the other hand I had forgotten that we have not 
only delete but delete-if, which comes in handy here.

> Something like the following should work:

Something like it.  You can't just ignore the return value from delete: 
if the car is deleted, it won't show up as a destructive modification.  
I came up with the following patch.  Manual update not included - I am 
not quite sure if it makes sense to export the function like this or as 
a version for only removing overrides.

-- 
	Timo Korvola		<URL:http://www.iki.fi/tkorvola>
From dab077a55d95367b11c87572113bd79b7acbec0b Mon Sep 17 00:00:00 2001
From: Timo Korvola <tkorvola iki fi>
Date: Mon, 28 Sep 2009 00:59:52 +0300
Subject: [PATCH] Proper alist deletion in update-frame-font-color.

---
 lisp/sawfish/wm/frames.jl |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/lisp/sawfish/wm/frames.jl b/lisp/sawfish/wm/frames.jl
index 9c65c2e..77a3333 100644
--- a/lisp/sawfish/wm/frames.jl
+++ b/lisp/sawfish/wm/frames.jl
@@ -51,6 +51,7 @@
 	     add-frame-class
 	     frame-class-removed-p
 	     set-frame-part-value
+	     remove-frame-part-value
 	     def-frame-class
 	     define-frame-class
 	     update-frame-font-color))
@@ -167,11 +168,14 @@ that overrides settings set elsewhere.")
   (define (update-frame-font-color)
     (if use-custom-font-color
 	(mapc (lambda (fc)
-		(set-frame-part-value fc 'foreground (list frame-font-inactive-color frame-font-active-color) 't)) (list 'title 'tab))
-      (mapc (lambda (fc)
-	      (rplacd (assoc 'foreground (assoc fc override-frame-part-classes)) nil)
-	      (rplaca (assoc 'foreground (assoc fc override-frame-part-classes)) nil)) (list 'title 'tab)))
-    (mapc (lambda (x) (rebuild-frame x)) (managed-windows)))
+		(set-frame-part-value fc 'foreground
+                                      (list frame-font-inactive-color
+                                            frame-font-active-color)
+                                      t))
+              '(title 'tab))
+      (mapc (lambda (fc) (remove-frame-part-value fc 'foreground t))
+            '(title tab)))
+    (mapc rebuild-frame (managed-windows)))
 
   (defvar theme-update-interval 60
     "Number of seconds between checking if theme files have been modified.")
@@ -574,6 +578,13 @@ deciding which frame type to ask a theme to generate.")
 	(set var (cons (cons class (list (cons key value)))
 		       (symbol-value var))))))
 
+  (define (remove-frame-part-value class key #!optional override)
+    (let* ((fpcs (if override override-frame-part-classes frame-part-classes))
+           (item (assq class fpcs)))
+      (when item
+        (setcdr item (delete-if (lambda (it) (eq (car it) key))
+                                (cdr item))))))
+
   ;; (def-frame-class shade-button '((cursor . foo) ...)
   ;;   (bind-keys shade-button-keymap
   ;;     "Button1-Off" 'toggle-window-shaded))
-- 
1.6.3.3



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]