Coder Social home page Coder Social logo

Comments (4)

yangsheng6810 avatar yangsheng6810 commented on August 12, 2024 1

Thanks. Works like a charm!
// Test is done on i3wm on Xorg.

from emacs.

masm11 avatar masm11 commented on August 12, 2024

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.

from emacs.

yangsheng6810 avatar yangsheng6810 commented on August 12, 2024

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.

from emacs.

masm11 avatar masm11 commented on August 12, 2024

I fixed on feature/pgtk in savannah. Please test it.

from emacs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.