Context menu related fixes (bug#64980)

* etc/PROBLEMS: Suggest how to keep context menus open on Lucid.

* lisp/mouse.el (context-menu-mode-map): Bind [mouse-3] to
'ignore' instead of 'nil' to not fallback to the default binding.
(mouse--drag-start-event): Remove unused variable.
(mouse-undouble-last-event): Remove unused function.
This commit is contained in:
Juri Linkov 2025-09-16 19:48:43 +03:00
parent e568f44b54
commit bd194c9a57
2 changed files with 10 additions and 24 deletions

View file

@ -2012,6 +2012,15 @@ Very long popup menus cannot be shown in their entirety, and don't have
a scroll bar to scroll them vertically. Lucid does not support this
feature. A workaround is to use other toolkits (GTK, LessTif, etc.).
*** In Emacs built with Lucid cannot keep context menus open.
After enabling context-menu-mode, when the menu is opened by
<down-mouse-3>, it closes right away when the right mouse button
is released. It's possible to keep the context menu open
after releasing the mouse button by disabling XInput 2 support:
./configure --with-x-toolkit=lucid --without-xinput2
*** Emacs running under X Window System does not handle mouse clicks.
*** 'emacs -geometry 80x20' finds a file named '80x20'.

View file

@ -687,7 +687,7 @@ Some context functions add menu items below the separator."
(defvar context-menu-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [mouse-3] nil)
(define-key map [mouse-3] #'ignore)
(define-key map [down-mouse-3] context-menu-entry)
(define-key map [menu] #'context-menu-open)
(if (featurep 'w32)
@ -1520,8 +1520,6 @@ point determined by `mouse-select-region-move-to-beginning'."
(eq mouse-last-region-end (region-end))
(eq mouse-last-region-tick (buffer-modified-tick))))
(defvar mouse--drag-start-event nil)
(defun mouse-set-region (click)
"Set the region to the text dragged over, and copy to kill ring.
This should be bound to a mouse drag event.
@ -2064,27 +2062,6 @@ If MODE is 2 then do the same for lines."
(if (numberp (posn-point posn))
(push-mark (posn-point posn) t t))))
(defun mouse-undouble-last-event (events)
(let* ((index (1- (length events)))
(last (nthcdr index events))
(event (car last))
(basic (event-basic-type event))
(old-modifiers (event-modifiers event))
(modifiers (delq 'double (delq 'triple (copy-sequence old-modifiers))))
(new
(if (consp event)
;; Use reverse, not nreverse, since event-modifiers
;; does not copy the list it returns.
(cons (event-convert-list (reverse (cons basic modifiers)))
(cdr event))
event)))
(setcar last new)
(if (and (not (equal modifiers old-modifiers))
(key-binding (apply #'vector events)))
t
(setcar last event)
nil)))
;; Momentarily show where the mark is, if highlighting doesn't show it.
(defun mouse-set-mark (click)