all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
Cc: 27569@debbugs.gnu.org
Subject: bug#27569: delete-selection on yank via popup-menu
Date: Mon, 03 Jul 2017 19:36:07 -0400	[thread overview]
Message-ID: <87inj9hz4o.fsf@users.sourceforge.net> (raw)
In-Reply-To: <49D47C75-80AE-4F81-8713-D90574DB7CA6@misasa.okayama-u.ac.jp> (Tak Kunihiro's message of "Tue, 4 Jul 2017 08:15:12 +0900")

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	other threads:[~2017-07-03 23:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-03 23:15 bug#27569: delete-selection on yank via popup-menu Tak Kunihiro
2017-07-03 23:36 ` npostavs [this message]
2017-07-04 23:11   ` Tak Kunihiro
2017-07-11  7:59     ` Tak Kunihiro
2017-07-12  1:12       ` npostavs
2017-07-18  4:35         ` Tak Kunihiro
2017-07-18 10:43           ` npostavs
2017-07-22 14:40             ` npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87inj9hz4o.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=27569@debbugs.gnu.org \
    --cc=tkk@misasa.okayama-u.ac.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.