Emacs 27.1 自身截屏功能

Emacs 27.1 可以借助 Cairo 实现截屏自身的功能。需要在编译时指定 Cairo 库:

./configure --prefix=/usr/local --with-cairo

自定义函数:

;; 来源:https://www.reddit.com/r/emacs/comments/idz35e/emacs_27_can_take_svg_screenshots_of_itself/g2c2c6y/

(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)))

M-x screenshot-svg,即可将当前 Emacs 窗口截屏并保存到临时目录中。