[sawfish] prompt stuff



commit 534ed2b8c9fb1413689f2d413a90176fd7ded962
Author: chrisb <zanghar freenet de>
Date:   Mon Sep 21 18:06:05 2009 +0200

    prompt stuff

 ChangeLog                             |    3 ++
 lisp/sawfish/wm/util/prompt-extras.jl |    2 +-
 lisp/sawfish/wm/util/prompt.jl        |   49 +++++++++++++++++++-------------
 3 files changed, 33 insertions(+), 21 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c6f14c5..70ecd6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2009-09-21  Christopher Bratusek <zanghar freenet de>
+	* lisp/sawfish/wm/util/prompt.jl: temporary solution of previous work [Jeremy Hankins]
+
 2009-09-20  Christopher Bratusek <zanghar freenet de>
 	* lisp/sawfish/wm/ext/fdo-menu.jl: use define instead of defun
 	                                   changed name of a few variables
diff --git a/lisp/sawfish/wm/util/prompt-extras.jl b/lisp/sawfish/wm/util/prompt-extras.jl
index 675639c..88c519d 100644
--- a/lisp/sawfish/wm/util/prompt-extras.jl
+++ b/lisp/sawfish/wm/util/prompt-extras.jl
@@ -127,7 +127,7 @@ Unless DONT-VALIDATE is t, only a member of PROMPT-LIST will be returned."
 
 (define (prompt-for-string #!optional title start)
   (let ((prompt-completion-fun prompt-complete-filename)
-	(prompt-validation-fun (lambda (#!rest) nil)))
+	(prompt-validation-fun nil))
     (prompt (or title "Enter string: ") start)))
 
 (define (prompt-for-number #!optional title)
diff --git a/lisp/sawfish/wm/util/prompt.jl b/lisp/sawfish/wm/util/prompt.jl
index 845a90b..23d2e86 100644
--- a/lisp/sawfish/wm/util/prompt.jl
+++ b/lisp/sawfish/wm/util/prompt.jl
@@ -1,5 +1,5 @@
 ;; prompt.jl -- read line from user
-;; Time-stamp: <2000-02-25 22:02:54 tjp>
+;; Time-stamp: <Fri Sep 18 12:09:45 CDT 2009>
 ;;
 ;; Copyright (C) 2008 Sergey I. Sharybin <sharybin nm ru>
 ;; Copyright (C) 2000 Topi Paavola <tjp iki fi>
@@ -107,10 +107,10 @@ displayed. See the `display-message' function for more details.")
 
   (defvar prompt-result nil)
   (defvar prompt-prompt nil)
-  (defvar prompt-completion-fun (lambda (#!rest) nil))
-  (defvar prompt-validation-fun (lambda (#!rest) nil))
-  (defvar prompt-abbrev-fun (lambda (#!rest) nil))
-  (defvar prompt-display-fun (lambda (#!rest) nil))
+  (defvar prompt-completion-fun nil)
+  (defvar prompt-validation-fun nil)
+  (defvar prompt-abbrev-fun nil)
+  (defvar prompt-display-fun nil)
   (defvar prompt-position 0)
   (defvar prompt-completion-position nil)
   (defvar prompt-completions nil)
@@ -119,6 +119,15 @@ displayed. See the `display-message' function for more details.")
   (defvar prompt-saved nil)
   (defvar prompt-attr nil)
 
+  ;; Compilation hack: ensure that the compiler doesn't complain when
+  ;; these are treated like functions and passed values.
+  (eval-when-compile
+    (setq prompt-completion-fun (lambda (#!rest) nil)
+          prompt-validation-fun (lambda (#!rest) nil)
+          prompt-abbrev-fun (lambda (#!rest) nil)
+          prompt-display-fun (lambda (#!rest) nil)))
+
+
 ;; From merlin
 ;; But maybe better if we'd include this util?
 
@@ -142,7 +151,7 @@ displayed. See the `display-message' function for more details.")
 
   (defun prompt-accept ()
     "End input and accept current string."
-    (let ((result (if (not (prompt-validation-fun prompt-result))
+    (let ((result (if (not prompt-validation-fun)
 		      prompt-result
 		    (prompt-validation-fun prompt-result))))
       (if result
@@ -259,7 +268,7 @@ displayed. See the `display-message' function for more details.")
 		(if (= new prompt-completion-position)
 		    0
 		  new)))
-      (when (prompt-completion-fun prompt-result)
+      (when prompt-completion-fun
 	(let
 	    (compl)
 	  (setq prompt-completions (prompt-completion-fun prompt-result))
@@ -288,14 +297,14 @@ displayed. See the `display-message' function for more details.")
 	(concat (and (/= prompt-completion-position 0) "[...]\n")
 		(apply concat (mapcar (lambda (x)
 					(format nil "%s\n"
-						(if (prompt-abbrev-fun x)
+						(if prompt-abbrev-fun
 						    (prompt-abbrev-fun x)
 						  x)))
 				      compl))
 		continued))))
 
   (defun prompt-update-display ()
-    (let ((result (if (prompt-display-fun prompt-result)
+    (let ((result (if prompt-display-fun
 		      (prompt-display-fun prompt-result)
 		   prompt-result))
 	 (completions (prompt-format-completions)))
@@ -355,17 +364,17 @@ displayed. See the `display-message' function for more details.")
 	 (display-message nil)))))
 
   (defun prompt-for-symbol (#!optional title predicate validator)
-    (let ((prompt-completion-fun
-	      (lambda (x)
-		(mapcar symbol-name
-			(apropos (concat ?^ (quote-regexp x)) predicate))))
-	     (prompt-validation-fun
-	      (lambda (x)
-		(let
-		    ((symbol (intern x)))
-		  (if validator
-		      (and (validator symbol) symbol)
-		    symbol)))))
+    (let ((prompt-completion-fun 
+	   (lambda (x)
+	     (mapcar symbol-name
+		     (apropos (concat ?^ (quote-regexp x)) predicate))))
+	  (prompt-validation-fun
+	   (lambda (x)
+	     (let
+		 ((symbol (intern x)))
+	       (if validator
+		   (and (validator symbol) symbol)
+		 symbol)))))
       (prompt title)))
 
   (defun prompt-for-function (#!optional title)



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