Closed yangsheng6810 closed 3 years ago
I confirmed org-download-clipboard works on pgtk emacs.
I executed wl-copy -t image/png < test2.png
on a terminal, and
did M-x org-download-clipboard on pgtk emacs.
My fault. I only tested the telega
method, and thought org-download-clipboard
would have the same problem. After checking the code, it turns out org-download
uses shell command (wl-paste/xclip/convert/pngpaste) to get the clipboard. On the other hand, telega-chatbuf-attach-clipboard
uses gui-get-selection
provided by Emacs with the following code snippet:
(defun telega-chatbuf-attach-clipboard (doc-p)
"Attach clipboard image to the chatbuf as photo.
If `\\[universal-argument]' is given, then attach clipboard as document."
(interactive "P")
(let* ((selection-coding-system 'no-conversion) ;for rawdata
(temporary-file-directory telega-temp-dir)
(tmpfile (telega-temp-name "clipboard" ".png"))
(coding-system-for-write 'binary))
(if (eq system-type 'darwin)
(progn
;; NOTE: On MacOS, try extracting clipboard using pngpaste
(unless (executable-find "pngpaste")
(error "Please install pngpaste to paste images"))
(unless (= 0 (telega-screenshot-with-pngpaste tmpfile))
(error "No image in CLIPBOARD")))
(write-region (or (gui-get-selection 'CLIPBOARD 'image/png)
(error "No image in CLIPBOARD"))
nil tmpfile nil 'quiet))
(telega-chatbuf--attach-tmp-photo tmpfile doc-p)))
On a normal Emacs branch, when there is image in the clipboard, (gui-get-selection 'CLIPBOARD 'image/png)
would return a string of the image. But on pgtk emacs, it returns nil
.
BTW, a quick ripgrep shows this also affects emacs-slack.
I fixed on feature/pgtk in savannah. Please test it.
Thanks. Works like a charm! // Test is done on i3wm on Xorg.
Non-pgtk branch of Emacs supports retrieving the image copied to the clipboard. For example, in
telega
, I can usetelega-chatbuf-attach-clipboard
to attach an image I just copied. Another example would be inorg-download
, which inserts the image in clipboard in anorg-mode
buffer. However, in pgtk branch, this feature is not supported. An attempt to retrieve an image from the clipboard receives nothing.