Using this reddit post as inspiration, I am trying to create a screenshot-svg command using the following config:

(defun screenshot-svg ()
  "Save a screenshot of the current frame as an SVG image.
Saves to a temp file and puts the filename in the kill ring."
  (let* ((filename (make-temp-file "Emacs" nil ".svg"))
         (data (x-export-frames nil 'svg)))
    (with-temp-file filename
      (insert data))
    (kill-new filename)
    (message filename)))

However, when I try to run the screenshot-svg command, I get the message let*: Symbol’s function definition is void: x-export-frames, and nothing seems to happen. How do I check if x-export-frames is available on my build? What do I need to do to get this working? Are there any other ways to get svg screenshots on emacs?

EDIT: I am using OSX, so I am also wondering if Cairo, or something similar is available for OSX?

  • 1
    How do do you check: do M-x describe-function (usually bound to C-hf) and see if x-export-frames offers anything. What you need to do: compile emacs (version 27.1) with cairo support. – Fran Burstall Dec 9 '20 at 9:10
  • Thanks @FranBurstall - yes, I can now confirm that x-export-frames is not available on my system. I should have specified that I am running OSX (have updated question), and am trying to find out if it is possible to compile with cairo on OSX (or if there is an alternative) – Fergie Dec 9 '20 at 10:14
  • 1
    You can check if the function is available using (fboundp 'x-export-frames). AFAIK there's no macOS build of Emacs with cairo. – Clément Dec 11 '20 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.