alastair, your new patch looks good. i'm glad to see some of the really ugly
and questionable code in select-x.c going away and getting cleaned up.
i have some comments below, but the first thing is that it's important that you
get us a patch, [and quickly!] that is similar to your select.3.diff and as
clean as possible but has no new features in it, so that we can apply it to the
source tree and fix the problems people are seeing under X. after that, we
won't have to rush so much and can flesh out the new features and iron out the
bugs before we apply to the source tree.
new the comments:
the one thing i noticed [mostly a matter of style], is that when you call a lisp
function from C, normally you declare a symbol such as Qselect_convert_out to
hold the symbol instead of calling intern each time.
as for the correct behavior at kill-buffer time, the intended semantics of X
selections depends on the selection name -- PRIMARY and SECONDARY are expected
to be ephemeral selections that merely represent the contents of the primary and
secondary text region and are asserted automatically when a region is dragged
out; this allows for the classic X cut/paste behavior where you simply drag out
a region, move the mouse to another app, and click with the middle button
somewhere, and the text goes there. Since PRIMARY and SECONDARY are attached to
regions and automatically change as the region changes [because data is never
passed until a client requests it], then certainly the selection should be
disowned when the text containing the region [not just the buffer] is deleted.
You see, the selection mechanism was actually intended to be a sort of
interprocess communication mechanism between two processes, with a bit of
hand-holding from the OS. Later on the CLIPBOARD selection name and associated
behavior was grafted onto this system. You see, there's a problem here: if
program A posts data to the clipboard, all that means is that they grab the
ownership of it. when others want the data, they ask it from A. Now the data
on the clipboard is supposed to conceptually be "permanent" and independent of
who sent it, and it should be possible to be notified automatically whenever the
clipboard changes; but this doesn't work so well as long as A continues to own
the data -- if A changes the data, no one knows until they ask for it, and if A
dies, the clipboard data is lost, and the selection mechanism has no solution
for all of these problems. So in a typical Motif system, there's normally a
separate process called the "clipboard manager" that sits out there and jumps
through hoops to simulate the normal clipboard behavior: the normal state is
that the clipboard manager owns the clipboard [remember, this is nothing more
than the selection arbitrarily named CLIPBOARD], and when someone else grabs the
clipboard, the clipboard manager immediately requests the data from the new
owner, and then grabs the clipboard back again. this way the clipboard manager
[assuming it never dies] always has the clipboard data even if the owner of the
data dies, and the clipboard manager always knows when there's a new clipboard
entry coming in.
anyway, what this all means is that if the selection in question is PRIMARY or
SECONDARY, we should certainly disown it when the buffer containing it is
killed. [Although in fact it should be disowned whenever the extent holding the
zmacs region gets detached or destroyed; there's already some nasty kludgy code
in there to do something like this and you may not want to look at it quite
yet]. if the selection in question is CLIPBOARD, then we should NOT disown the
selection, but instead extract the data if it wasn't already. [this applies, of
course, on windows too once deferred clipboarding is implemented.]
"Alastair J. Houghton" wrote:
OK. There were some *very* silly problems, especially in the
X code, which was attempting to hack with selection-alist
(an internal variable of select.c). I *think* this should
solve most of the problems I've been hearing about. In
particular, the _EMACS_INTERNAL selection type has gone,
for good I hope. I haven't tested it on X yet (will do, as
soon as I download a new set of sources from the
repository) - apologies for this, but I know it works (and
fixes a few things) on Windows, so I'll send it out *now*
and then have another go at building on X.
The new selection code is still a work in progress - there
are several things still to do as far as I can see; next on
the list is a set of functions for encoding and decoding
binary data, so that the existing code in select-x.c that
decodes the binary data can be moved into Lisp, where it
belongs.
Regards,
Alastair.
lisp/ChangeLog:
2000-07-15 Alastair J. Houghton <ajhoughton(a)lineone.net>
* select.el (select-convert-from-text): New.
* select.el (select-convert-from-length): New.
* select.el (select-convert-from-integer): New.
* select.el (select-convert-from-identity): New.
* select.el (select-convert-from-filename): New.
* select.el (selection-converter-in-alist): Use them.
New converter functions for X.
* select.el (get-selection): Removed comment.
* select.el (own-selection): Removed append code - I thought
I'd already done this, but apparently not...
* select.el: Changed comment about TIMESTAMP.
* select.el (select-convert-in): New.
* select.el (select-convert-out): New.
New functions that get used by select.c.
* select.el (select-buffer-killed-default): New.
* select.el (select-buffer-killed-text): New.
* select.el (selection-buffer-killed-alist): New.
New list and functions that get called if a relevant selection
exists and a buffer gets killed.
* select.el (select-convert-to-targets):
* select.el (select-convert-to-identity): Removed.
* select.el (select-convert-from-identity): Removed.
* select.el (select-converter-out-alist):
Removed _EMACS_INTERNAL selection type.
* x-select.el (xselect-kill-buffer-hook): Removed.
* x-select.el (xselect-kill-buffer-hook-1): Removed.
Removed this X-specific nonesense. Use the generic support
in select.el instead.
src/ChangeLog:
2000-07-15 Alastair J. Houghton <ajhoughton(a)lineone.net>
* select.h (selection-alist): Removed declaration.
* select.h (get_local_selection):
* select.c (get_local_selection):
Made static.
* select.h (convert_selection): Removed declaration.
* select.c (convert_selection): Removed.
This function belongs in Lisp.
* select.h (select_convert_in): Declare.
* select.h (select_convert_out): Declare.
* select.c (select_convert_in): New.
* select.c (select_convert_out): New.
New conversion functions for other files to call.
* select.h (select_notify_buffer_kill): Declare.
* select.c (select_notify_buffer_kill): New.
New functions that get called from kill-buffer.
* buffer.c (kill-buffer): Call select_notify_buffer_kill, rather than
X-specific lisp code.
* select.h: Declare some of the lisp-visible functions for
external use.
* select.c (clean_local_selection_data): Removed. This was
a disgusting function, and previously should have been in
select-x.c in any case. The functionality is now provided
in select-convert-from-integer (select.el).
* select.c (available-selection-types): Fixed stupidity where
INTEGER and ATOM got added twice. Also add STRING when we see an
extent.
* select.c (get-selection-internal): Removed symbol stripping. No
longer causes conversion when data comes from the internal cache.
* select.c (syms_of_select): Added new functions.
* select-x.c (motif_clipboard_cb): Use select_convert_out. Rewrote
error checking - previously this called abort!
* select-x.c (x_own_selection): Changed comment.
* select-x.c (x_handle_selection_request): Use select_convert_out.
Don't mess with selection-alist; it's an internal variable of select.c.
* select-x.c (x_get_foreign_selection): Use select_convert_in.
* select-x.c (x_handle_selection_clear): Use get-selection-timestamp,
rather than messing with selection-alist.
* select-msw.c (mswindows_get_foreign_selection):
Use TO_INTERNAL_FORMAT rather than hacking.
--
____________________________________________________________
Alastair Houghton ajhoughton(a)lineone.net
--------------------------------------------------------------------------------
Name: select.3.diff
select.3.diff Type: unspecified type (application/octet-stream)
Encoding: quoted-printable
--
Ben
In order to save my hands, I am cutting back on my mail. I also write
as succinctly as possible -- please don't be offended. If you send me
mail, you _will_ get a response, but please be patient, especially for
XEmacs-related mail. If you need an immediate response and it is not
apparent in your message, please say so. Thanks for your understanding.
See also
http://www.666.com/ben/chronic-pain/