From 17cc3c6fe451d2512f2a53f9680a5c776a4f3d02 Mon Sep 17 00:00:00 2001 From: Stephen Berman Date: Wed, 9 Jul 2025 10:59:13 +0200 Subject: [PATCH] Amend last change to 'kill-this-buffer' * lisp/menu-bar.el (kill-this-buffer): Take using window tool bar into account (bug#78809). (cherry picked from commit 8b86978895b2dacce2830de0cdc680a00b274b58) --- lisp/menu-bar.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 8e9b9b11038..21d70b9e642 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -2203,9 +2203,16 @@ to invoke a similar command with `M-x', use `kill-current-buffer'." ;; This colossus of a conditional is necessary to account for the wide ;; variety of this command's callers. (if (let ((lce last-command-event)) - (eq (if (atom lce) ; Selected menu item. - lce - (car lce)) ; Clicked tool bar icon. + (eq (cond + ((atom lce) ; Selected menu item. + lce) + ((mouse-event-p lce) ; Clicked window tool bar icon. + ;; Code from window-tool-bar--call-button. + (let* ((posn (event-start lce)) + (str (posn-string posn))) + (get-text-property (cdr str) 'tool-bar-key (car str)))) + (t + (car lce))) ; Clicked tool bar icon. 'kill-buffer)) (if (let* ((window (or (posn-window (event--posn-at-point)) last-event-frame -- 2.39.5