reddit / emacs
How to Take a Selection Screenshot
BeholderVee · 2022-06-12 09:04
I'm sorry for a potentially silly question, but I'm new to Emacs, just trying it out.
I installed Doom Emacs and 'm liking it so far, despite the learning curve, but I need to be able to take a screenshot of selected text. I've found org-screenshot-take, but it's limited by the size of my screen. What I'd like is to be able to make a large image of my entire selection. I've used Atom before, it had a package that did just that. I haven't really used VScode, but out of curiosity I checked it out, and it has CodeSnap, which also does exactly what I need.
I tried looking on the internet, and there are some packages that maybe do what I want, but I tried installing one, and it's complaining about "transient 0.2.0" being unavailable. I tried looking that up, but I don't feel like I'm savvy enough to solve this issue.
Is there a simpler solution I'm missing? Thank you in advance.
​
EDIT:
I've found a hacky workaround. Following /u/egoweaver's link I'm able to take an .svg screenshot. While it's still limited by screen size, I can zoom way out in Emacs, and since it's a vector image, I can just enlarge it and crop it in Gimp. This way is far from elegant and requires several times the amount of time it does in Atom or VScode, but it's all I got so far.
Still, if anyone knows a package that does exactly what I need - I would be very grateful.
Kaligule · 2022-06-12 10:27
Honestly I don't quite understand what it is you want. An image of text? Should it look exactly like on your screen or should it be beautified in some way? How should it behave if the selected text doesn't fill a whole line? Why would you prefer an image of text over just copying it?
BeholderVee · 2022-06-12 11:13
Just a plain screenshot of the text, but large enough so that it fits the entire selection, even if it doesn't fit on the screen. I don't really care how it behaves if there is too little text, I'm interested in capturing an entire file.
I need it to send text through a messenger. Sending it as a message messes up the formatting, and sending a text file is not as convenient to view on a phone.
Maybe it's a weird thing to do, but it's been very convenient for me while I was using Atom.
Kaligule · 2022-06-12 11:30
Hmm, could you send the file as an attachment or so? Personally I think I would go crazy if someone sent me an image of text ( which I can't save or select anything from it)
BeholderVee · 2022-06-12 11:47
Well, it's been working very well for me, as well as the recipient of the images. Yeah, there are alternative ways of sending the text, but I'd still like to know the answer to my original questions: whether there is a way to take a screenshot of an entire text file in Emacs.
I might look deeper into the "transient" issue, but I thought I'd ask whether there was a simpler solution first. I'm not even sure if the package in question can take such a screenshot, its documentation on Github is rather brief.
desgreech · 2022-06-12 12:27
Haven't tried it before, but I think this package can do what you want:
https://github.com/tecosaur/screenshot
BeholderVee · 2022-06-12 13:24
Yes, that's the one that gave me the "transient" error.
I managed to install the transient package, also managed to get the screenshot command to appear, but when I try it it's giving me a "no key for screenshot--set-line-numbers-p" error.
Looking it up online brings up a Github issue, but the fixes from the thread don't seem to work for me. Maybe I'm doing something wrong.
repelliuss · 2022-06-12 17:26
Yeah, I get this too. Try going to the source file and then do `eval-buffer`. Though, this package is not capable of capturing long regions as far as my experience with it
hmeh922 · 2022-06-12 21:06
Serious question, have you tried taking a screenshot of the text? With your operating system? Why does it have to be from Emacs?
globalcandyamnesia · 2022-06-12 21:58
I think the issue is that the screen is smaller than the text they want to make a screenshot of
_martini97 · 2022-06-12 22:10
If I’m not mistaken, EMacs has a builtin function which generates a svg image of the current buffer
egoweaver · 2022-06-12 22:41
Maybe this would be what you are looking for but your Emacs needs to be built `--with-cairo`.
https://www.reddit.com/r/emacs/comments/idz35e/comment/g2c2c6y/
BeholderVee · 2022-06-13 05:05
I tried doing that after reading the Github thread, it didn't seem to do anything. Not sure if I did it correctly, I just cd'd to the .el file's directory in Emacs and typed :eval-buffer. No result, not even a message.
BeholderVee · 2022-06-13 05:26
Just tried it, unfortunately, it too only takes a screenshot of what fits on the screen, not the entire file.
BeholderVee · 2022-06-13 05:28
It seems to also be limited by the size of the screen.
repelliuss · 2022-06-13 06:17
You should open the source file, should be named `screenshot.el`, and use `M-x eval-buffer` on it, not on the directory. 'Eval' means the evaluation of the Elisp code and directory contents are irrelevant
BeholderVee · 2022-06-13 06:33
Ah, I see, thank you.
Just did that, got two errors: Transient and Posframe are not installable.
olymk2 · 2022-06-14 09:01
Not built in but I think imagemagick can generate an image from text, I would imagine it would be possible to send the region to image magick and have it and generate the image you could also use a command to copy the content to the clipboard. But another approach use an external tool if there is one that achieves a similar goal