]> git.eshelyaron.com Git - emacs.git/commitdiff
Add x-popup-menu-function
authorGerd Möllmann <gerd,moellmann@gmail.com>
Mon, 10 Feb 2025 06:55:43 +0000 (07:55 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 18 Feb 2025 08:59:55 +0000 (09:59 +0100)
* 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)

src/menu.c

index 0293328c8327f111965d3f8a78310e0f40909de7..a37cb359623e727a99476682750ed948d92b2de8 100644 (file)
@@ -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);