Subject: bug#41343: tab-bar-mode: Close tab on mouse-2 click

From: Juri Linkov <[email-masked]>
Date: Wed, 04 Aug 2021 23:13:12 +0300

>> > Please consider adding a binding to close a tab in tab-bar-mode by
>> > clicking on it using the middle mouse button (mouse-2).
>> 
>> Here's the patch that implements mouse-2 tab closing:
>
> Do we really have to hard-code the mouse button this way, including
> explicit values in C?  Why is that necessary or justified?

In tab-line.el it was very easy to bind mouse-2 to close the tab:

  (defvar tab-line-tab-map
    (let ((map (make-sparse-keymap)))
      (define-key map [tab-line mouse-1] 'tab-line-select-tab)
      (define-key map [tab-line mouse-2] 'tab-line-close-tab)

But it's impossible to do the same for the menu-bar and the tool-bar
and so in the tab-bar too.

There is no other way to bind mouse-2 to close the tab
that would work in X, xterm, console, w32, w32term.

Ot do you mean adding an integer variable that holds
a number of the mouse button used to close the tab?
For example, tab-bar-close-tab-mouse-button = 2.