bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#70086: Mouse clicks in tab-bar don't call commands bound in keymap p


From: Adam Porter
Subject: bug#70086: Mouse clicks in tab-bar don't call commands bound in keymap properties
Date: Sun, 31 Mar 2024 11:15:06 -0500
User-agent: Mozilla Thunderbird

Hi Juri,

On 3/30/24 13:16, Juri Linkov wrote:
In my listen.el package on GNU ELPA, I'm trying to make mouse clicks in the
`global-mode-string' construct work when `mode-line-misc-info' is shown in
the tab-bar by including `tab-bar-format-global' in `tab-bar-format'.  I'm
including this construct in the `global-mode-string':


   `(listen-mode (:propertize listen-mode-lighter
                              keymap ,listen-mode-lighter-map))

Thanks for the request.  If possible could you send a minimal test case
to see what exactly do you need.

Sure, the following code in a clean Emacs config seems to demonstrate the problem:

  (require 'cl-lib)

  (defvar tab-bar-ecm-keymap
    (let ((map (make-sparse-keymap)))
      (define-key map [tab-bar mouse-1] (lambda (&rest _)
                                          (interactive)
(message "tab-bar-ecm-lighter clicked with mouse-1")))
      map))

  (defvar tab-bar-ecm-lighter "TAB-BAR-ECM-LIGHTER")

  (define-minor-mode tab-bar-ecm-mode "DOCSTRING"
    :global t
    (let ((lighter `(tab-bar-ecm-mode
(:propertize tab-bar-ecm-lighter keymap ,tab-bar-ecm-keymap))))
      (if tab-bar-ecm-mode
          (progn
            (cl-pushnew lighter global-mode-string :test #'equal)
            (unless (memq 'tab-bar-format-global tab-bar-format)
              (cl-callf append tab-bar-format '(tab-bar-format-global))))
        (cl-callf2 remove lighter global-mode-string))))

Evaluate that code and then enable `tab-bar-mode' and `tab-bar-ecm-mode'. Then you can see that "C-h k" followed by a click on the "TAB-BAR-ECM-LIGHTER" text in the tab-bar shows that the anonymous command is bound to that sequence, yet clicking the text doesn't call it.

And the same should work on `tab-line-format' as well.

I haven't tried that, but sure, sounds good to me.  :)

Indeed, events on the tab-bar have a different design where
`tab-bar--event-to-item' should be used to get a bound command.
You can see an example in `tab-bar-mouse-down-1' that uses
(if (functionp (nth 1 item)) (call-interactively (nth 1 item))
to call an arbitrary command.

I see, thanks.

--Adam





reply via email to

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