Re: help me with sawfish-client bug.



On Thursday 22 October 2009 11:02:35 Teika Kazura wrote:
> Hi. Recently, I changed sawfish-client so that you can exit from the
> client session with ",quit". (Previously, it killed Sawfish WM.)

Why did you use exception handling for something this trivial?  It would 
have been simpler to do this:
(when (equal ",quit\n" input)
  (setq input nil))
and let normal control flow handle it from there as if ^D had been 
typed.

> But no, it failed. The installed one at /usr/bin/sawfish-client
> behaves just like the old one.

Works for me as long as one types ",quit" exactly, not any of the 
normally valid alternatives such as ", quit" or ",quit ".  A more exotic 
failure case is this:
(let ((quit 'lose))
  `(this should not
,quit
))

An alternative approach would be to modify the behaviour of ",quit" in 
Sawfish; see the attached patch.  Then no special input handling is 
needed in sawfish-client.  Unfortunately there is no way to redefine an 
interpreter command locally, hence the patch redefines ,quit globally.

-- 
	Timo Korvola		<URL:http://www.iki.fi/tkorvola>
diff --git a/scripts/sawfish-client.jl b/scripts/sawfish-client.jl
index 4b03cab..fea6d4a 100644
--- a/scripts/sawfish-client.jl
+++ b/scripts/sawfish-client.jl
@@ -100,6 +100,8 @@ sawfish comes with ABSOLUTELY NO WARRANTY; for details see the file COPYING\n"
 	     (let ((r (sawfish-client-eval
 		       `(progn
 			  (require 'rep.util.repl)
+                          (define-repl-command 'quit
+                            (lambda () (throw 'sawfish-client-exit)))
 			  (make-repl 'user)))))
 	       (let-fluids ((current-repl r))
 		 (write standard-output "\nEnter `,help' to list commands.\n")
@@ -107,9 +109,6 @@ sawfish comes with ABSOLUTELY NO WARRANTY; for details see the file COPYING\n"
 		   (let ((input (readline
 				 (format nil (if (repl-pending r) "" "%s> ")
 					 (repl-struct r)))))
-		     (when (equal ",quit\n" input)
-                       (throw 'bye nil)
-                       )
 		     (when input
 		       (let ((out (sawfish-client-eval
 				   `(progn
@@ -118,7 +117,9 @@ sawfish comes with ABSOLUTELY NO WARRANTY; for details see the file COPYING\n"
 					      (make-string-output-stream))
 					     (standard-error standard-output)
 					     (r ',r))
-					(cons (and (repl-iterate r ',input) r)
+					(cons (catch 'sawfish-client-exit
+                                                (and (repl-iterate r ',input)
+                                                     r))
 					      (get-output-stream-string
 					       standard-output)))))))
 			 (setq r (car out))
@@ -147,9 +148,7 @@ sawfish comes with ABSOLUTELY NO WARRANTY; for details see the file COPYING\n"
   (sawfish-client-eval
    `(repl-completions ',(fluid current-repl) ',w)))
 
-(catch 'bye
-  (main)
-  )
+(main)
 
 (write standard-output "Bye.\n")
 


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