From: Stephen Berman Date: Wed, 9 Jul 2025 08:59:13 +0000 (+0200) Subject: Amend last change to 'kill-this-buffer' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=17cc3c6fe451d2512f2a53f9680a5c776a4f3d02;p=emacs.git 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) --- 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