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

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

bug#27569: delete-selection on yank via popup-menu


From: npostavs
Subject: bug#27569: delete-selection on yank via popup-menu
Date: Mon, 03 Jul 2017 19:36:07 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux)

Tak Kunihiro <tkk@misasa.okayama-u.ac.jp> writes:

> I want to yank via popup-menu with delete-selection-mode.
> Problem is yanking via popup-menu does not delete region.
>
> emacs -Q
> (defun popup-edit-menu ()
>  (interactive)
>  (popup-menu menu-bar-edit-menu))
> (define-key global-map [mouse-3] 'popup-edit-menu)
> (delete-selection-mode 1)
>
> 1. kill something
> 2. select text (activate region) to be replaced
> 3. choose yank in popup-menu via mouse-3
>
> Problem: Selected text by (2) is not deleted.
>
> I barely see problem is that on delete-selection-pre-hook,
> this-command is `popup-edit-menu' instead `yank'.
>
> Is there a way to solve the problem?

This seems to work, though I'm not sure if it's the right way.  Perhaps
`this-command' should be setq instead of let-bound?  Will running
pre-command-hook twice be a problem? etc...

--- i/lisp/menu-bar.el
+++ w/lisp/menu-bar.el
@@ -2360,6 +2360,8 @@ (defun popup-menu (menu &optional position prefix 
from-menu-bar)
       ;; `setup-specified-language-environment', for instance,
       ;; expects this to be set from a menu keymap.
       (setq last-command-event (car (last event)))
+      (let ((this-command cmd))
+        (run-hook 'pre-command-hook))
       ;; mouse-major-mode-menu was using `command-execute' instead.
       (call-interactively cmd))))





reply via email to

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