all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
To: npostavs@users.sourceforge.net
Cc: 27569@debbugs.gnu.org, tkk@misasa.okayama-u.ac.jp
Subject: bug#27569: delete-selection on yank via popup-menu
Date: Wed, 05 Jul 2017 08:11:28 +0900 (JST)	[thread overview]
Message-ID: <20170705.081128.918140452192114950.tkk@misasa.okayama-u.ac.jp> (raw)
In-Reply-To: <87inj9hz4o.fsf@users.sourceforge.net>

>> 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-hooks 'pre-command-hook))
>        ;; mouse-major-mode-menu was using `command-execute' instead.
>        (call-interactively cmd))))

Although I cannot comment on what you worry, it works well for me.
Thank you for the fix.





  reply	other threads:[~2017-07-04 23:11 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
2017-07-04 23:11   ` Tak Kunihiro [this message]
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=20170705.081128.918140452192114950.tkk@misasa.okayama-u.ac.jp \
    --to=tkk@misasa.okayama-u.ac.jp \
    --cc=27569@debbugs.gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /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.