]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't call x-popup-function for non-tty frames
authorGerd Möllmann <gerd.moellmann@gmail.com>
Wed, 19 Feb 2025 07:33:32 +0000 (08:33 +0100)
committerEshel Yaron <me@eshelyaron.com>
Thu, 20 Feb 2025 21:43:14 +0000 (22:43 +0100)
* src/menu.c (x_popup_menu_1): Don't call x-popup-function for non-tty
frames
(syms_of_menu): Remove Qx_popup_menu_function because unused, extend doc
string of x-popup-menu-function.

(cherry picked from commit 23bf94a0111474419ca84145c8ede95c6915bd35)

src/menu.c

index 11a0a10d87db8861655a40f9d5b0a560d00c2fe1..d98135afbfd26389881d0eddc0e088326798f376 100644 (file)
@@ -1111,9 +1111,6 @@ into menu items.  */)
 Lisp_Object
 x_popup_menu_1 (Lisp_Object position, Lisp_Object menu)
 {
-  if (!NILP (Vx_popup_menu_function))
-    return calln (Vx_popup_menu_function, position, menu);
-
   Lisp_Object keymap, tem, tem2 = Qnil;
   int xpos = 0, ypos = 0;
   Lisp_Object title;
@@ -1411,8 +1408,13 @@ x_popup_menu_1 (Lisp_Object position, Lisp_Object menu)
      doesn't have its hooks set (e.g., in a batch session), because
      such a frame cannot display menus.  */
   if (!FRAME_INITIAL_P (f))
-    selection = FRAME_TERMINAL (f)->menu_show_hook (f, xpos, ypos, menuflags,
-                                                   title, &error_name);
+    {
+      if (FRAME_TERMCAP_P (f) && !NILP (Vx_popup_menu_function))
+       selection  = calln (Vx_popup_menu_function, position, menu);
+      else
+       selection = FRAME_TERMINAL (f)->menu_show_hook (f, xpos, ypos, menuflags,
+                                                       title, &error_name);
+    }
 
   unbind_to (specpdl_count, Qnil);
 
@@ -1617,7 +1619,6 @@ syms_of_menu (void)
 
   DEFSYM (Qhide, "hide");
   DEFSYM (Qx_pre_popup_menu_hook, "x-pre-popup-menu-hook");
-  DEFSYM (Qx_popup_menu_function, "x-popup-menu-function");
 
   DEFVAR_LISP ("x-pre-popup-menu-hook", Vx_pre_popup_menu_hook,
               doc: /* Hook run before `x-popup-menu' displays a popup menu.
@@ -1627,8 +1628,9 @@ won't be run if `x-popup-menu' fails or returns for some other reason
   Vx_pre_popup_menu_hook = Qnil;
 
   DEFVAR_LISP ("x-popup-menu-function", Vx_popup_menu_function,
-              doc: /* Function to call to pop up a menu.
-The function is called like `x-popup-menu'.  */);
+              doc : /* Function to call to pop up a menu.
+ The function is called like `x-popup-menu'.  This is currently only
+ used for frames on text terminals.  */);
   Vx_popup_menu_function = Qnil;
 
   defsubr (&Sx_popup_menu);