changeset 2135:0634d08c28d1

(syms_of_xmenu): Set up Qmenu_enable. (single_keymap_panes): Test menu-enable property of symbol to decide whether to include it in the menu.
author Richard M. Stallman <rms@gnu.org>
date Thu, 11 Mar 1993 08:09:52 +0000
parents b275e1b50542
children 17ab6ed0f98b
files src/xmenu.c
diffstat 1 files changed, 37 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/xmenu.c	Thu Mar 11 07:55:27 1993 +0000
+++ b/src/xmenu.c	Thu Mar 11 08:09:52 1993 +0000
@@ -70,6 +70,7 @@
 #define	ButtonReleaseMask ButtonReleased
 #endif /* not HAVE_X11 */
 
+Lisp_Object Qmenu_enable;
 Lisp_Object xmenu_show ();
 extern int x_error_handler ();
 
@@ -399,6 +400,9 @@
 
 syms_of_xmenu ()
 {
+  Qmenu_enable = intern ("menu-enable");
+
+  staticpro (&Qmenu_enable);
   defsubr (&Sx_popup_menu);
 }
 
@@ -516,12 +520,24 @@
 	      item2 = XCONS (item1)->car;
 	      if (XTYPE (item2) == Lisp_String)
 		{
-		  Lisp_Object tem;
-		  tem = Fkeymapp (Fcdr (item1));
+		  Lisp_Object def, tem;
+		  Lisp_Object enabled;
+
+		  def = Fcdr (item1);
+		  enabled = Qt;
+		  if (XTYPE (def) == Lisp_Symbol)
+		    {
+		      /* No property, or nil, means enable.
+			 Otherwise, enable if value is not nil.  */
+		      tem = Fget (def, Qmenu_enable);
+		      if (!NILP (tem))
+			enabled = Feval (tem);
+		    }
+		  tem = Fkeymapp (def);
 		  if (XSTRING (item2)->data[0] == '@' && !NILP (tem))
-		    pending_maps = Fcons (Fcons (Fcdr (item1), item2),
+		    pending_maps = Fcons (Fcons (def, item2),
 					  pending_maps);
-		  else
+		  else if (!NILP (enabled))
 		    {
 		      (*names)[*p_ptr][i] = (char *) XSTRING (item2)->data;
 		      /* The menu item "value" is the key bound here.  */
@@ -547,11 +563,25 @@
 		  if (XTYPE (item2) == Lisp_String)
 		    {
 		      Lisp_Object tem;
-		      tem = Fkeymapp (Fcdr (item1));
+		      Lisp_Object def;
+		      Lisp_Object enabled;
+
+		      def = Fcdr (item1);
+		      enabled = Qt;
+		      if (XTYPE (def) == Lisp_Symbol)
+			{
+			  tem = Fget (def, Qmenu_enable);
+			  /* No property, or nil, means enable.
+			     Otherwise, enable if value is not nil.  */
+			  if (!NILP (tem))
+			    enabled = Feval (tem);
+			}
+
+		      tem = Fkeymapp (def);
 		      if (XSTRING (item2)->data[0] == '@' && !NILP (tem))
-			pending_maps = Fcons (Fcons (Fcdr (item1), item2),
+			pending_maps = Fcons (Fcons (def, item2),
 					      pending_maps);
-		      else
+		      else if (!NILP (enabled))
 			{
 			  (*names)[*p_ptr][i] = (char *) XSTRING (item2)->data;
 			  /* The menu item "value" is the key bound here.  */