[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 3dae236: Fix charset issues in text/html yanking
From: |
Lars Ingebrigtsen |
Subject: |
master 3dae236: Fix charset issues in text/html yanking |
Date: |
Sun, 7 Nov 2021 19:15:11 -0500 (EST) |
branch: master
commit 3dae236eb252452fff7faea0611e4f1798759e08
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Fix charset issues in text/html yanking
* lisp/yank-media.el (yank-media--get-selection): Use
gui-backend-get-selection instead of the higher-level function
which guesses wrong on the charset on many types.
(yank-media): Fix the case where there's only one match.
---
lisp/yank-media.el | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/lisp/yank-media.el b/lisp/yank-media.el
index 66eb234..6d0d0b1 100644
--- a/lisp/yank-media.el
+++ b/lisp/yank-media.el
@@ -48,7 +48,7 @@ the `register-yank-media-handler' mechanism."
;; We have a handler in the current buffer; if there's just
;; matching type, just call the handler.
(if (length= all-types 1)
- (funcall (cdar all-types)
+ (funcall (cdar all-types) (caar all-types)
(yank-media--get-selection (caar all-types)))
;; More than one type the user for what type to insert.
(let ((type
@@ -77,15 +77,16 @@ the `register-yank-media-handler' mechanism."
(gui-get-selection 'CLIPBOARD 'TARGETS)))
(defun yank-media--get-selection (type)
- (when-let ((data (gui-get-selection 'CLIPBOARD type)))
- (when-let ((charset (get-text-property 0 'charset data)))
- (setq data (encode-coding-string data charset)))
- ;; Some programs add a nul character at the end of text/*
- ;; selections. Remove that.
- (when (and (string-match-p "\\`text/" (symbol-name type))
- (zerop (elt data (1- (length data)))))
- (setq data (substring data 0 (1- (length data)))))
- data))
+ (let ((selection-coding-system 'binary))
+ (when-let ((data (gui-backend-get-selection 'CLIPBOARD type)))
+ (when (string-match-p "\\`text/" (symbol-name type))
+ ;; Some programs add a nul character at the end of text/*
+ ;; selections. Remove that.
+ (when (zerop (elt data (1- (length data))))
+ (setq data (substring data 0 (1- (length data)))))
+ (setq data (decode-coding-string
+ data (car (detect-coding-string data)))))
+ data)))
;;;###autoload
(defun register-yank-media-handler (types handler)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 3dae236: Fix charset issues in text/html yanking,
Lars Ingebrigtsen <=