unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: master 396355f: Re-fix charset issues when yanking non-plain-text elements
@ 2021-11-11 11:19 Eli Zaretskii
  2021-11-11 11:54 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2021-11-11 11:19 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

>    (let ((data (gui-backend-get-selection (or type 'PRIMARY)
>                                           (or data-type 'STRING))))
>      (when (and (stringp data)
> -	       (setq data-type (get-text-property 0 'foreign-selection data)))
> +               ;; If this text property is set, then the data needs to
> +               ;; be decoded -- otherwise it has already been decoded
> +               ;; by the lower level functions.
> +               (get-text-property 0 'foreign-selection data))

The old code took the data-type from the value of the
foreign-selection property, but now we disregard that.  Is that on
purpose?

> +                    ;; Guess at the charset for types like text/html
> +                    ;; -- it can be anything, and different
> +                    ;; applications use different encodings.
> +                    ((string-match-p "\\`text/" (symbol-name data-type))
> +                     (decode-coding-string
> +                      data (car (detect-coding-string data))))

Did you really need the explicit call to detect-coding-string?  AFAIR,
decode-coding-string does that automatically if needed.  Did that fail
in some case?



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: master 396355f: Re-fix charset issues when yanking non-plain-text elements
  2021-11-11 11:19 master 396355f: Re-fix charset issues when yanking non-plain-text elements Eli Zaretskii
@ 2021-11-11 11:54 ` Lars Ingebrigtsen
  2021-11-11 14:05   ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-11-11 11:54 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> The old code took the data-type from the value of the
> foreign-selection property, but now we disregard that.  Is that on
> purpose?

Yes.  That made even binary data (like images) be mis-decoded.

Perhaps the logic here should be changed altogether -- and make all the
backend selection functions do the decoding themselves (since the
Windows one does it).

>> +                    ;; Guess at the charset for types like text/html
>> +                    ;; -- it can be anything, and different
>> +                    ;; applications use different encodings.
>> +                    ((string-match-p "\\`text/" (symbol-name data-type))
>> +                     (decode-coding-string
>> +                      data (car (detect-coding-string data))))
>
> Did you really need the explicit call to detect-coding-string?  AFAIR,
> decode-coding-string does that automatically if needed.  Did that fail
> in some case?

Can you give a nil to decode-coding-string as the coding system?  It's
not documented.

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: master 396355f: Re-fix charset issues when yanking non-plain-text elements
  2021-11-11 11:54 ` Lars Ingebrigtsen
@ 2021-11-11 14:05   ` Eli Zaretskii
  2021-11-12  2:45     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2021-11-11 14:05 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: emacs-devel@gnu.org
> Date: Thu, 11 Nov 2021 12:54:17 +0100
> 
> >> +                    ;; Guess at the charset for types like text/html
> >> +                    ;; -- it can be anything, and different
> >> +                    ;; applications use different encodings.
> >> +                    ((string-match-p "\\`text/" (symbol-name data-type))
> >> +                     (decode-coding-string
> >> +                      data (car (detect-coding-string data))))
> >
> > Did you really need the explicit call to detect-coding-string?  AFAIR,
> > decode-coding-string does that automatically if needed.  Did that fail
> > in some case?
> 
> Can you give a nil to decode-coding-string as the coding system?  It's
> not documented.

If by nil you means "don't know", then I think you should use
'undecided instead.  That's exactly what 'undecided means.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: master 396355f: Re-fix charset issues when yanking non-plain-text elements
  2021-11-11 14:05   ` Eli Zaretskii
@ 2021-11-12  2:45     ` Lars Ingebrigtsen
  2021-11-12  8:55       ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-11-12  2:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> If by nil you means "don't know", then I think you should use
> 'undecided instead.  That's exactly what 'undecided means.

That doesn't seem to be documented anywhere near this function (i.e.,
not in the doc string or in the "Explicit Encoding and Decoding" node in
the manual).

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: master 396355f: Re-fix charset issues when yanking non-plain-text elements
  2021-11-12  2:45     ` Lars Ingebrigtsen
@ 2021-11-12  8:55       ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2021-11-12  8:55 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: emacs-devel@gnu.org
> Date: Fri, 12 Nov 2021 03:45:46 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > If by nil you means "don't know", then I think you should use
> > 'undecided instead.  That's exactly what 'undecided means.
> 
> That doesn't seem to be documented anywhere near this function (i.e.,
> not in the doc string or in the "Explicit Encoding and Decoding" node in
> the manual).

It does now.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-12  8:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-11 11:19 master 396355f: Re-fix charset issues when yanking non-plain-text elements Eli Zaretskii
2021-11-11 11:54 ` Lars Ingebrigtsen
2021-11-11 14:05   ` Eli Zaretskii
2021-11-12  2:45     ` Lars Ingebrigtsen
2021-11-12  8:55       ` Eli Zaretskii

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).