diff src/gui.c @ 286:57709be46d1b r21-0b41

Import from CVS: tag r21-0b41
author cvs
date Mon, 13 Aug 2007 10:35:03 +0200
parents c5d627a313b1
children e11d67e05968
line wrap: on
line diff
--- a/src/gui.c	Mon Aug 13 10:34:15 2007 +0200
+++ b/src/gui.c	Mon Aug 13 10:35:03 2007 +0200
@@ -26,6 +26,7 @@
 #include <config.h>
 #include "lisp.h"
 #include "gui.h"
+#include "bytecode.h"		/* for struct Lisp_Compiled_Function */
 
 Lisp_Object Q_active, Q_suffix, Q_keys, Q_style, Q_selected;
 Lisp_Object Q_filter, Q_config, Q_included;
@@ -63,6 +64,36 @@
   return (*p == '!' || *p == ':' || *p == '\0');
 }
 
+/* Massage DATA to find the correct function and argument.  Used by
+   popup_selection_callback() and the msw code. */
+void
+get_callback (Lisp_Object data, Lisp_Object *fn, Lisp_Object *arg)
+{
+  if (SYMBOLP (data)
+      || (COMPILED_FUNCTIONP (data)
+	  && XCOMPILED_FUNCTION (data)->flags.interactivep)
+      || (EQ (XCAR (data), Qlambda)
+	  && !NILP (Fassq (Qinteractive, Fcdr (Fcdr (data))))))
+    {
+      *fn = Qcall_interactively;
+      *arg = data;
+    }
+  else if (CONSP (data))
+    {
+      *fn = Qeval;
+      *arg = data;
+    }
+  else
+    {
+      *fn = Qeval;
+      *arg = list3 (Qsignal,
+		    list2 (Qquote, Qerror),
+		    list2 (Qquote, list2 (build_translated_string
+					  ("illegal callback"),
+					  data)));
+    }
+}
+
 /*
  * Initialize the gui_item structure by setting all (GC-protected)
  * fields to their default values. The defaults are t for :active and