From: Gerd Möllmann Date: Mon, 10 Feb 2025 06:55:43 +0000 (+0100) Subject: Add x-popup-menu-function X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9cacee68c83f0360acd3ed15381ab7ee7aeeb05c;p=emacs.git Add x-popup-menu-function * src/menu.c (x_popup_menu_1): If non-nil call x-popup-menu-function. (syms_of_menu): DEFSYM x-popup-menu-function, DEFVAR_LISP it. (cherry picked from commit 17bf6b9efe5c40dfa92fa5ec64a99162304395cd) --- diff --git a/src/menu.c b/src/menu.c index 0293328c832..a37cb359623 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1111,6 +1111,12 @@ into menu items. */) Lisp_Object x_popup_menu_1 (Lisp_Object position, Lisp_Object menu) { + if (!NILP (Vx_popup_menu_function)) + return run_hook_with_args (3, ((Lisp_Object[]) { + Qx_popup_menu_function, position, + menu}), + Ffuncall); + Lisp_Object keymap, tem, tem2 = Qnil; int xpos = 0, ypos = 0; Lisp_Object title; @@ -1614,6 +1620,7 @@ 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. @@ -1622,6 +1629,11 @@ won't be run if `x-popup-menu' fails or returns for some other reason (such as the keymap is invalid). */); 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'. */); + Vx_popup_menu_function = Qnil; + defsubr (&Sx_popup_menu); defsubr (&Sx_popup_dialog); defsubr (&Smenu_bar_menu_at_x_y);