From 04c85f338642179c6626755559ad0ecff72cfa45 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Fri, 25 Dec 2020 22:56:15 +0100 Subject: [PATCH] Add SVG screenshot function --- config.org | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/config.org b/config.org index a311728..4364681 100644 --- a/config.org +++ b/config.org @@ -3,6 +3,7 @@ - [[#misc][Misc]] - [[#lexical-bindings][Lexical bindings]] - [[#dir-local-variables][Dir local variables]] + - [[#taking-svg-screenshots][Taking SVG screenshots]] - [[#theme][Theme]] - [[#main-theme][Main theme]] - [[#dark-theme-toggle][Dark theme toggle]] @@ -57,6 +58,24 @@ some projects. (setq enable-dir-local-variables nil) #+END_SRC +** Taking SVG screenshots + +Since Emacs 27, we can take SVG screenshots! Emacs needs to be built with +=cairo= to support this. + +#+begin_src emacs-lisp +(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." + (interactive) + (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))) +#+end_src + * Theme ** Main theme