emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tab-bar: Defining another mouse-button binding?


From: Adam Porter
Subject: tab-bar: Defining another mouse-button binding?
Date: Tue, 07 Sep 2021 04:37:29 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Hi Juri, et al,

I've been trying to bind other mouse buttons, like mouse-2, to different
commands on the tab-bar tabs, but I've not been able to figure out how.
The comments at the top of tab-bar.el say:

;; The normal global binding for [tab-bar] (below) uses the value of
;; `tab-bar-map' as the actual keymap to define the tab bar.  Modes may
;; either bind items under the [tab-bar] prefix key of the local map to
;; add to the global bar or may set `tab-bar-map' buffer-locally to
;; override it.

I may be just missing some knowledge, but despite my best efforts, I
wasn't able to understand this.  From what I can tell by reading the
source code, the tab-bar tabs are actually stored as a keymap in the
variable tab-bar-map, which is recreated on every redisplay; so that
variable is not actually a user-modifiable keymap that can be used to
assign new actions to clicks on the tabs.

The function `tab-bar--format-tab' (unfortunately, lacking a docstring,
despite its apparently important purpose) seems to construct a
keymap-like or binding-like structure (I'm not an expert on keymaps),
and it inlines interactive lambdas for the mouse click actions (though
it doesn't specify mouse-1, and "C-h k [mouse-1]" on the tab bar
indicates that it's mapped to `ignore', so it's not obvious how that
works).

I guess this unconventional system is necessary for performance reasons,
and it seems to work well.  But does this mean that I can't bind
additional mouse-click actions on the tabs?  Or am I missing something
obvious?  :)

Thanks,
Adam




reply via email to

[Prev in Thread] Current Thread [Next in Thread]