From: David De La Harpe Golden <david@harpegolden.net>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: 6774@debbugs.gnu.org, Angelo Graziosi <angelo.graziosi@alice.it>
Subject: bug#6774: Cut and paste with C-w/mouse-2 not working?
Date: Mon, 02 Aug 2010 21:30:30 +0100 [thread overview]
Message-ID: <4C572AE6.7070104@harpegolden.net> (raw)
In-Reply-To: <87y6coby49.fsf@stupidchicken.com>
On 02/08/10 20:41, Chong Yidong wrote:
> David De La Harpe Golden<david@harpegolden.net> writes:
>
>> Yes, there's a problem here - I guess emacs is keeping primary bound
>> to a span that's become zero-length. Again.
>
> After thinking about this, my opinion is that the Emacs command
> loop---or rather prepare_to_modify_buffer in insdel.c---should make a
> copy of the primary selection before running before-change-functions.
> Then, deactivate-mark should check if the resulting string is empty;
> and, if so, set the primary to that saved copy.
>
> I haven't looked at your branch; is this the approach you implemented?
Not reallym, though my branch certainly ended up altering the command
loop to save a copy of the primary selection before commands - doing
that where you say may be more selective to commands that are going to
modify, and therefore more efficient.
Does your way work properly in a multi-window context on its own,
though? I suspect not -that it will deactivate-mark on "boring"
restored active regions (see below) and set the selection to the
"boring" region, confounding user expectations, because the restored
region could be non-empty.
So I'll try and have a go explaining the key points of the branch, then,
bearing in mind it was focussed mostly on making multi-window/frame
stuff work, and the zero length fixes came along for the ride.
On the whole, grabbing it locally and giving it a go may be worthwhile,
might be faster than reading the below!
At this stage, the sheer length of the explanation below suggests the
approach is just too ugly. I may be stuck in a rut on it
(the trouble is it _does_ give quite nice results...).
Just doing it eagerly may be better. However, one of the non-efficiency
reasons for the laziness was because certain gestures in emacs are
really effectively "long running commands" that you can stop and switch
to another application in the middle of (track-mouse...), and something
happening purely before/after commands can leave the region stale, and
the laziness skirted that.
The thing is, if you use focus-follows-mouse between frames, or mouse
autoselect-window between emacs windows, you select_window without going
through "normal channels", so trying to do _anything_ smart in
deactivate-mark tends to break - e.g. the mark is being deactivated in a
window different to the last window bound to the selection. The selx
branch just forces the selection to a string if it's lazy-bound to a
window and emacs still owns it on deactivate mark.
1. Introduce a save/restore of mark and mark-active state as well as
point on select_window window switching. The restore would be
controversial, but could easily be made optional - the saving is the
important bit for our purposes, the restore is a "new feature". This bit
might be independently a nice feature, at least.
2. Allow selections to be lazy-bound to window rather than buffer. (this
is unfinished - in both window and buffer cases should really walk the
selection_alist and force the lazy selections before deletion of the
window/buffer. When the selection is bound to a window, it is the span
between the window-mark and window-point.
3. Introduce a x-force-lazy-selection to force a selection to a string
if it is lazy-bound to a buffer. This is currently only a placeholder
inefficient implementation, doing it even if unnecessary (i.e. selection
is already a string), it could be made more efficient by checking if
forcing is necessary - but owing to the split of the code between C and
Lisp, that would probably mean moving it to C.
4. Introduce a notion of the region being "interesting" or "boring". If
a region is zero-length _or_ matching the saved boring region extent,
consider it boring.
6. make select_window set the region boring when it restores the region.
This preserves temporal ordering of selection with respect to user
explicit selection actions rather than programmatic restores.
5. If select-active-region is called, test if the region is interesting.
If it isn't (boring/zero), don't select, just set a
"select-active-region-maybe" flag. If it isn't boring, set it to the
current window.
6. Before each command in the command loop, if select-active-region
maybe, check again if the region is interesting.
7. Force the primary selection (ideally this would be more efficient as
in 3), effectively freezing off a string.
8. After each command, call select-active-region again to check if the
region is interesting and "thaw".
9. In deactivate mark, force the selection in case it's lazy. Since we
can't actually tell if we're in the window that the selection was bound
to, it's _un_safe to use buffer-substring, have to go through
x-force-lazy-selection.
next prev parent reply other threads:[~2010-08-02 20:30 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-01 22:04 bug#6774: Cut and paste with C-w/mouse-2 not working? Angelo Graziosi
2010-08-02 4:12 ` David De La Harpe Golden
[not found] ` <4C56C8F0.2010104@alice.it>
2010-08-02 14:52 ` David De La Harpe Golden
2010-08-02 19:41 ` Chong Yidong
2010-08-02 20:30 ` David De La Harpe Golden [this message]
2010-08-02 20:33 ` David De La Harpe Golden
2010-08-02 20:53 ` David De La Harpe Golden
2010-08-02 20:59 ` Chong Yidong
2010-08-02 21:35 ` David De La Harpe Golden
2010-08-02 22:26 ` David De La Harpe Golden
2010-08-05 2:20 ` Chong Yidong
2010-08-05 23:50 ` David De La Harpe Golden
2010-08-06 7:43 ` Eli Zaretskii
2010-08-06 9:13 ` Stefan Monnier
2010-08-06 10:50 ` Eli Zaretskii
2010-08-06 12:21 ` Kenichi Handa
2010-08-06 13:17 ` Jan Djärv
2010-08-06 20:23 ` David De La Harpe Golden
2010-08-06 20:17 ` David De La Harpe Golden
2010-08-06 15:28 ` Chong Yidong
2010-08-06 21:05 ` David De La Harpe Golden
2010-08-07 19:50 ` Chong Yidong
2010-08-07 23:05 ` David De La Harpe Golden
2010-08-09 2:55 ` Chong Yidong
2010-08-09 11:43 ` Stefan Monnier
2010-08-09 17:19 ` Jan Djärv
2010-08-10 7:29 ` Stefan Monnier
2010-08-10 14:01 ` Jan Djärv
2010-08-10 15:54 ` Stefan Monnier
2010-08-10 17:59 ` Jan Djärv
2010-08-11 7:46 ` Stefan Monnier
2010-08-11 16:06 ` Jan Djärv
2010-08-11 20:17 ` Stefan Monnier
2010-08-11 21:26 ` Jan Djärv
2010-08-11 21:32 ` Stefan Monnier
2010-08-12 3:54 ` Kenichi Handa
2010-08-12 7:43 ` Jan Djärv
2010-08-12 7:51 ` Kenichi Handa
2010-08-12 8:29 ` Stefan Monnier
2010-08-12 12:14 ` Kenichi Handa
2010-08-12 16:09 ` Stefan Monnier
2010-08-12 17:11 ` Jan Djärv
2010-08-13 10:38 ` Stefan Monnier
2010-08-13 11:29 ` Eli Zaretskii
2010-08-13 6:18 ` Kenichi Handa
2010-08-13 10:40 ` Stefan Monnier
2010-08-16 8:16 ` Kenichi Handa
2010-08-16 8:51 ` Jan Djärv
2010-08-17 1:44 ` Kenichi Handa
2010-08-17 5:52 ` Jan Djärv
2010-08-17 7:17 ` Eli Zaretskii
2010-08-17 8:24 ` Jan Djärv
2010-08-17 10:26 ` Eli Zaretskii
2010-08-17 11:43 ` Kenichi Handa
2010-08-17 12:14 ` Stefan Monnier
2010-08-17 12:57 ` Kenichi Handa
2010-08-18 7:24 ` Stefan Monnier
2010-08-17 20:59 ` David De La Harpe Golden
2010-08-18 7:25 ` Stefan Monnier
2010-08-07 23:08 ` Angelo Graziosi
[not found] ` <mailman.23.1280783288.5118.bug-gnu-emacs@gnu.org>
2010-08-03 14:34 ` Miles Bader
2010-08-03 15:15 ` David De La Harpe Golden
2010-08-03 15:31 ` Miles Bader
2010-08-03 15:45 ` David De La Harpe Golden
2010-08-03 16:02 ` Miles Bader
2010-08-04 18:02 ` Stefan Monnier
2010-08-04 18:25 ` Drew Adams
2010-08-04 21:10 ` David De La Harpe Golden
2010-08-04 21:36 ` Drew Adams
2010-08-05 0:17 ` Chong Yidong
2010-08-05 0:24 ` Drew Adams
2010-08-05 0:33 ` Chong Yidong
2010-08-05 0:40 ` Drew Adams
2010-08-02 13:33 ` Angelo Graziosi
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=4C572AE6.7070104@harpegolden.net \
--to=david@harpegolden.net \
--cc=6774@debbugs.gnu.org \
--cc=angelo.graziosi@alice.it \
--cc=cyd@stupidchicken.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 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.