emacs-devel
[Top][All Lists]
Advanced

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

Re: Yanking as HTML


From: Lars Ingebrigtsen
Subject: Re: Yanking as HTML
Date: Sun, 30 Oct 2016 12:25:37 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

[Uhm, I sent a message with NUL characters that was apparently dropped
by the GNU mail servers, so I'm resending.  Apologies if this shows up
twice.] 

Yuri Khan <address@hidden> writes:

> On Sun, Oct 30, 2016 at 5:43 PM, Lars Ingebrigtsen <address@hidden> wrote:
>
>> (gui-get-selection 'CLIPBOARD 'TARGETS)
>> => [TIMESTAMP TARGETS MULTIPLE SAVE_TARGETS UTF8_STRING
>> COMPOUND_TEXT TEXT STRING]
>>
>> Hm...  so it lacks the "text/html" target that xclip -o -t TARGETS
>> lists?
>
> Your xclip invocation targets the PRIMARY selection (by default) while
> the elisp snippet examines CLIPBOARD. This might be a reason for the
> difference you observe.

(gui-get-selection 'PRIMARY 'TARGETS)
=> [TIMESTAMP TARGETS MULTIPLE text/html text/_moz_htmlcontext 
text/_moz_htmlinfo UTF8_STRING COMPOUND_TEXT TEXT STRING text/x-moz-url-priv]

Oh, yeah, there it is.

(x-get-selection-internal 'PRIMARY 'text/html)
=>
#("<div class=\"entry-meta\">
                                                <span class=\"meta-prep 
meta-prep-author\">BY</span> <span class=\"author vcard\"><a class=\"url fn n\" 
href=\"http://www.tcj.com/author/josselin-moneyron/\"; title=\"View all posts by 
Josselin Moneyron\">Josselin Moneyron</a></span> <span class=\"entry-date\">Oct 
27, 2016</span>                                 </div>" 0 620 
(foreign-selection STRING))

Fun!  Apparently the support for doing this is in Emacs already, but it
needs some tweaking (the selection is in utf-16 or something and needs
decoding before usage?), so the main issue is really one of user
interface and not the low-level support (that much).

[And when I eval-ed this in Emacs, I got a NUL byte before each ASCII
character, which seems to indicate UTF-16.]

> Note that, in general, it is impossible to correctly copy-paste styled
> HTML between documents:
>
> * If you paste only the HTML, half the users will complain that “what
> you get” in the target document differs from “what you see” of the
> source document.

Well...  People know that Emacs isn't a wysiwyg editor, so I don't think
that is a complaint that will be common.  The complaint will be 50% "why
is it outputting all this HTML junk into my buffer?" and 50% "why isn't
it outputting any HTML into my buffer?"  :-)

So creating a user interface that for this that annoys the least number
of people is what's important.

And it could even be a total opt-in thing, like a global minor mode
like, er, `clever-yank-mode'.

What about drag-and-drop?  Is that basically the same as selections?  If
I were to drag an image from Firefox to this Message mode buffer, is it
feasible to make that do something useful?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



reply via email to

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