emacs-devel
[Top][All Lists]
Advanced

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

Re: mouse-drag-and-drop-region


From: martin rudalics
Subject: Re: mouse-drag-and-drop-region
Date: Sun, 03 Dec 2017 11:06:44 +0100

I have found some time to look into this again and encountered a few
additional problems.

One is that when a user has three windows - T at the top of a frame, M
in the middle and B at the bottom of the frame - and wants to drag a
region from T to B.  In this case the position of M's point will
inevitably change although the user probably had no intentions to do
that.  So we should make sure to restore the point of any window that
might be affected by the drag.

Another one is that when a user has set `scroll-margin' to some non-zero
value, any window involved in the drag may scroll in order to move that
window's point out of the scroll margin.  This may affect unrelated
windows (as in the TMB example above) but also the window where the drag
started.

We could use the trick of `mouse-drag-track' to bind `scroll-margin' to
zero but this might not work if a user has made this variable
buffer-local (note that `mouse-drag-track' never leaves the current
buffer so it has no such problem).

So I think that we should remember for each window on the involved frame
its start and point positions and restore them unless the window is the
one where the drop happened.  I attached a patch for this which also
restores the cursor type of every window.  The patch includes all your
latest changes (so it should apply against the repository version) and
is largely untested but should give you the idea what to do.

Please consider also the following four bindings in `mouse-drag-track':

         (echo-keystrokes 0)

         (make-cursor-line-fully-visible nil)

         ;; Suppress automatic hscrolling, because that is a nuisance
         ;; when setting point near the right fringe (but see below).
         (auto-hscroll-mode-saved auto-hscroll-mode)

         (old-track-mouse track-mouse)

Maybe they are useful for you as well (a lot of experience went into the
coding of that function).

Also please consider to restrict the size of the tooltip shown (think of
someone who wants to drag the entire text of a buffer).  I think
`mouse-drag-and-drop-region-show-tooltip' should optionally allow to
specify a number giving the maximum length of the string which I would
divide into one half for the beginning of the text, one half for the end
and ellipses in between.

Finally, please think of how to embed your function into other packages:
For example, how would a user drag file names from one dired buffer to
another in order to copy or move the associated files from one directory
to another?  Can we accomodate an exit function to do the pasting job?

Thanks, martin

Attachment: mouse.el.diff
Description: Text document


reply via email to

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