From 17fa70c3bbf0ede1f9160244b01b76c7400c3262 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerd=20M=C3=B6llmann?= Date: Wed, 19 Feb 2025 08:33:32 +0100 Subject: [PATCH] Don't call x-popup-function for non-tty frames * 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 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/menu.c b/src/menu.c index 11a0a10d87d..d98135afbfd 100644 --- a/src/menu.c +++ b/src/menu.c @@ -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); -- 2.39.5