Subject: bug#66420: remove the omnipresent 'Services' sub-menu from all pop-up menus (macOS)

From: Mattias Engdegård <[email-masked]>
Date: Mon, 9 Oct 2023 14:03:42 +0200

On macOS, once a selection has been made, every pop-up menu includes a 'Services' sub-menu from then on.
It contains items such as 'Search with Google' and 'Add to Music as a Spoken Track'.
It's always completely out of place and very annoying.

The buffer menu? It's there. Any menu activated by clicking on the mode line? It's there. Selecting a value in variable customisation? It's there.

The only place where it might be remotely appropriate is the context-menu-mode menu, if enabled, but then only if we actually have an active selection. I'm going to ignore this for the time being since it's much less important than getting rid of it where it doesn't belong.

The patch below removes it. The property is documented to be present in macOS 10.6 and above, which is fairly old (Snow Leopard).

--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -768,6 +768,9 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
                             pressure: 0];
 
   context_menu_value = -1;
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
+  self.allowsContextMenuPlugIns = NO;
+#endif
   [NSMenu popUpContextMenu: self withEvent: event forView: view];
   retVal = context_menu_value;
   context_menu_value = 0;