unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Weiner <rsw@gnu.org>
To: Tak Kunihiro <homeros.misasa@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Emacs 26: Code that fixes mouse-drag-and-drop-region to work across frames
Date: Mon, 16 Oct 2017 10:13:30 -0400	[thread overview]
Message-ID: <CA+OMD9g_MwFt3PhSzr1r2FFRkD7qOkn0vS9Yw8muf7TGQroVJQ@mail.gmail.com> (raw)
In-Reply-To: <CA+OMD9jUodjVgL5a3uooDbWPmoTTLvU4UZ6S4_H=gkg1d1zTYg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2907 bytes --]

On Mon, Oct 16, 2017 at 9:45 AM, Robert Weiner <rsw@gnu.org> wrote:

> On Fri, Oct 13, 2017 at 5:57 AM, Tak Kunihiro <homeros.misasa@gmail.com>
> wrote:
>
>> I tried the revised `mouse-drag-and-drop-region' on Emacs -Q 26.0.90 on
>> macOS 10.9.5.  I can drag text within a frame but cannot do so among
>> frames.  I think I miss something.  Do you have idea?
>>
>
> ​The yellow visual rectangle of the text being dragged seems to get stuck
> at the source frame but if you continue your drag and release in another
> frame with a non-read-only buffer, your text should be properly dropped
> there.  Is this what you did?  Try it a couple different times to ensure
> there is not some initialization warm up problem.
>

​I see the issue now; the standard Emacs code does not handle cross-frame
drags well.  Replace the mouse-set-point function from mouse.el with the
version below and then the yellow rectangle of text will follow you to the
drag release frame and your drag-and-drops should work as you expect (with
the mouse-drag-and-drop-region changes from before).  -- Bob​

(defun mouse-set-point (event &optional promote-to-region)
  "Move point to the position clicked on with the mouse.
This should be bound to a mouse click event type.
If PROMOTE-TO-REGION is non-nil and event is a multiple-click,
select the corresponding element around point, with the resulting position
of
point determined by `mouse-select-region-move-to-beginning'."
  (interactive "e\np")
  (let ((start-w-or-f (posn-window (event-start event)))
(end-w-or-f   (posn-window (event-end event))))
    (if (framep start-w-or-f)
(with-selected-frame start-w-or-f (setq start-w-or-f (selected-window))))
    (if (framep end-w-or-f)
(with-selected-frame end-w-or-f (setq end-w-or-f (selected-window))))
    (if (and (window-minibuffer-p start-w-or-f)
     (not (minibuffer-window-active-p start-w-or-f)))
;; Select the ending frame only, not the window pressed within.
(select-frame (window-frame end-w-or-f))
      ;; Give temporary modes such as isearch a chance to turn off.
      (run-hooks 'mouse-leave-buffer-hook)
      (if (and promote-to-region (> (event-click-count event) 1))
  (progn (mouse-set-region event)
(when (and (boundp 'mouse-select-region-move-to-beginning)
    mouse-select-region-move-to-beginning)
   (when (> (posn-point (event-start event)) (region-beginning))
     (exchange-point-and-mark))))
;; Use event-end in case called from mouse-drag-region.
;; If EVENT is a click, event-end and event-start give same value.
(if (and (window-minibuffer-p end-w-or-f)
(not (minibuffer-window-active-p end-w-or-f)))
    ;; Select the ending frame only, not the window pressed within.
    (select-frame (window-frame end-w-or-f))
  (condition-case ()
      (posn-set-point (event-end event))
    (error (select-frame (window-frame end-w-or-f)))))))))

[-- Attachment #2: Type: text/html, Size: 6714 bytes --]

  reply	other threads:[~2017-10-16 14:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-12 16:27 Emacs 26: Code that fixes mouse-drag-and-drop-region to work across frames Robert Weiner
2017-10-12 16:42 ` Robert Weiner
2017-10-12 17:11   ` Robert Weiner
2017-10-13  9:57 ` Tak Kunihiro
2017-10-16 13:45   ` Robert Weiner
2017-10-16 14:13     ` Robert Weiner [this message]
2017-10-19  0:43       ` Tak Kunihiro
2017-10-26 22:07         ` Robert Weiner
2017-11-01  2:04           ` Tak Kunihiro
2017-11-01 15:24             ` Robert Weiner
2017-11-01 17:16               ` Alan Third
2017-11-01 20:18                 ` Robert Weiner
2017-11-01 20:41                   ` Robert Weiner
2017-11-02  9:51                     ` martin rudalics
2017-11-02 19:00                       ` Robert Weiner
2017-11-02 20:16                         ` martin rudalics

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=CA+OMD9g_MwFt3PhSzr1r2FFRkD7qOkn0vS9Yw8muf7TGQroVJQ@mail.gmail.com \
    --to=rsw@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=homeros.misasa@gmail.com \
    --cc=rswgnu@gmail.com \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).