[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Context menus and mouse-3 [was: Changes for emacs 28]
From: |
Stefan Monnier |
Subject: |
Re: Context menus and mouse-3 [was: Changes for emacs 28] |
Date: |
Tue, 15 Sep 2020 09:11:20 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Richard Stallman [2020-09-15 00:35:58] wrote:
> [[[ To any NSA and FBI agents reading my email: please consider ]]]
> [[[ whether defending the US Constitution against all enemies, ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> > We don't need to choose, since we can get a context menu on
> > `down-mouse-3` and 'mouse-save-then-kill' on `mouse-3`.
>
> Have you tried doing that? How does it work in practice?
Here's the code I'm using:
(let ((default-context-menu
`(menu-item ,(purecopy "Menu Bar") ignore
:filter (lambda (_)
(if (zerop (or (frame-parameter nil 'menu-bar-lines) 0))
(mouse-menu-bar-map)
(mouse-menu-major-mode-map))))))
(global-set-key [C-down-mouse-3] default-context-menu)
(global-set-key [context-menu] default-context-menu))
(global-set-key [down-mouse-3] #'mouse-maybe-context-menu)
(defun mouse-maybe-context-menu (event)
"Bring up a context menu for a long click.
See `mouse-long-click-time' and `mouse-context-menu-function'."
(interactive "@e")
(if (let ((track-mouse t)) (sit-for (/ mouse-long-click-time 1000.0)))
(push (cons 'context-menu (cdr event)) unread-command-events)))
It's not good enough for `master` (IIRC the sit-for tends to return nil
immediately in some circumstances), but I didn't pursue this any further
given the lack of interest at the time. I can't think of any reason why
it should be hard to fix.
Stefan
- Re: Context menus and mouse-3 [was: Changes for emacs 28], (continued)
- Re: Context menus and mouse-3 [was: Changes for emacs 28], tomas, 2020/09/14
- Re: Context menus and mouse-3 [was: Changes for emacs 28], Thibaut Verron, 2020/09/14
- Re: Context menus and mouse-3 [was: Changes for emacs 28], Göktuğ Kayaalp, 2020/09/14
- Re: Context menus and mouse-3 [was: Changes for emacs 28], tomas, 2020/09/14
- Re: Context menus and mouse-3 [was: Changes for emacs 28], Thibaut Verron, 2020/09/14
- RE: Context menus and mouse-3 [was: Changes for emacs 28], Drew Adams, 2020/09/14
- Re: Context menus and mouse-3 [was: Changes for emacs 28], Eli Zaretskii, 2020/09/14
- RE: Context menus and mouse-3 [was: Changes for emacs 28], Drew Adams, 2020/09/14
- Re: Context menus and mouse-3 [was: Changes for emacs 28], tomas, 2020/09/14
- Re: Context menus and mouse-3 [was: Changes for emacs 28], Richard Stallman, 2020/09/15
- Re: Context menus and mouse-3 [was: Changes for emacs 28],
Stefan Monnier <=
- Re: Context menus and mouse-3 [was: Changes for emacs 28], Tak Kunihiro, 2020/09/19
- Re: Context menus and mouse-3 [was: Changes for emacs 28], Tak Kunihiro, 2020/09/19
Re: Context menus and mouse-3 [was: Changes for emacs 28], Eli Zaretskii, 2020/09/14
Re: Context menus and mouse-3 [was: Changes for emacs 28], Göktuğ Kayaalp, 2020/09/14