From 52c16f83b6781c83676507c165e69aaad0a3b2fd Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 11 Jul 2017 21:09:10 -0400 Subject: [PATCH v2] Let delete-selection-mode work with popup-menu commands (Bug#27569) * lisp/menu-bar.el (popup-menu): Run `pre-command-hook' with `this-command' set to the selected command. --- lisp/menu-bar.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 9c7bcffbaa..107043b501 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -2360,6 +2360,10 @@ (defun popup-menu (menu &optional position prefix from-menu-bar) ;; `setup-specified-language-environment', for instance, ;; expects this to be set from a menu keymap. (setq last-command-event (car (last event))) + ;; Update `this-command' and run `pre-command-hook' so that + ;; things like `delete-selection-pre-hook' will work correctly. + (setq this-command cmd) + (run-hook 'pre-command-hook) ;; mouse-major-mode-menu was using `command-execute' instead. (call-interactively cmd)))) -- 2.11.1