Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xenops-image-handle-paste not working in linux! #24

Closed
OmarAshkar opened this issue Jun 27, 2021 · 11 comments
Closed

xenops-image-handle-paste not working in linux! #24

OmarAshkar opened this issue Jun 27, 2021 · 11 comments

Comments

@OmarAshkar
Copy link
Contributor

OmarAshkar commented Jun 27, 2021

Hi,
I am trying to the function xenops-image-hande-paste in OS. I am using xfce, doom emacs, xclip 0.13 and xfce4-screenshot.

I got no messages or errors, just nothing!

Any help is highly appreciated.

Thanks!

@dandavison
Copy link
Owner

dandavison commented Jun 27, 2021

Hi @OmarAshkar. Could you tell me the version of xenops that you have installed? I don't have a linux machine to hand to test this with your setup, but this is supposed to be working; see my comment here: #19 (comment)

@OmarAshkar
Copy link
Contributor Author

I have reviewed your code quickly and I think it should work. I will try to debug when I have time. Thank you!

@OmarAshkar
Copy link
Contributor Author

Ok, on my debugging I found that this let chuck does not get executed at all.

xenops/lisp/xenops-image.el

Lines 104 to 112 in 4994ae4

(let ((file-name-suggestion
(xenops-image-suggest-file-name
(format "-%s.%s" (substring (sha1 (f-read-bytes temp-file)) 0 4) "png"))))
(setq output-file
(read-file-name "Save image as: "
(or xenops-image-directory default-directory)
nil nil file-name-suggestion))
(when (file-exists-p output-file) (error "File exists: %s" output-file))
(copy-file temp-file output-file t)))

I got the image written to me tmp directory, but no prompt for a name or anything!

@dandavison
Copy link
Owner

dandavison commented Jun 29, 2021

Is it a problem with emacs not finding your xclip executable? What do you get if you evaluate (executable-find "xclip") in emacs? If nil then perhaps your exec-path needs to be adjusted so that it contains the directory containing your xclip executable.

@OmarAshkar
Copy link
Contributor Author

No, xclip function is evaluated and temporary image is written in /tmp/ directory. I debugged the code line by line, the function xenops-image-suggest-file-name was never invoked!

@dandavison
Copy link
Owner

dandavison commented Jun 29, 2021

Ok, on my debugging I found that this let chuck does not get executed at all.

OK, so it must be the case that both these return nil, correct?

xenops/lisp/xenops-image.el

Lines 102 to 103 in 4994ae4

(when (or (xenops-image-write-clipboard-image-to-file--pngpaste temp-file)
(xenops-image-write-clipboard-image-to-file--xclip temp-file))

If so, that implies that either (executable-find "xclip") is nil, or the exit-status of the xclip subprocess is non-zero. Is that correct so far? So is xclip generating the image but returning a non-zero exit-status?

Is the image that is written to /tmp a valid image, or empty? Do you have an executable named pngpaste?

@OmarAshkar
Copy link
Contributor Author

You are right on that. I found that the image is empty! (executable-find "xclip") is NOT nil.
I think it's the exit-status!

And no I don't have pngpaste. I don't know if you have any ideas!

@dandavison
Copy link
Owner

dandavison commented Jun 29, 2021

OK cool, I think we should be able to get to the bottom of this then. What I would do is run the xclip command from the command line, outside emacs, and see what's going wrong. (I'm sure you know, in bash you can check the exit status with echo $?). So you want to run the command that this lisp code corresponds to:

(call-process "xclip" nil `(:file ,temp-file) nil "-t" "image/png" "-o")

It sounds like you're using edebug, so perhaps you could edebug that function, and just before emacs evaluates that line, find the value of the variable temp-file, and then switch to a terminal and run the xclip command is in the shell, using whatever temp-file is as the file path.

@dandavison
Copy link
Owner

More generally, outside emacs, can you copy image data to the clipboard and confirm that you can use xclip -t image/png -o > img.png to write the image to disk?

(That works for me on MacOS, after I start a terminal using the program XQuartz.)

@OmarAshkar
Copy link
Contributor Author

Right, Thanks! I have fixed the xclip flags and corrected in this PR #25.

Check it out! Thanks!

@dandavison
Copy link
Owner

Thanks a lot. I've merged that and it should be automatically picked up by MELPA in the next few hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants