help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Screenshots, frame shots straight from Emacs


From: Jean Louis
Subject: Screenshots, frame shots straight from Emacs
Date: Wed, 23 Jun 2021 12:31:10 +0300
User-agent: Mutt/2.0.7+183 (3d24855) (2021-05-28)

As you like screenshots, here is one way to generate Emacs frame shots
straight from Emacs without using external programs:

(defvar frameshot-directory "~/Media/Pictures/Screenshots/"
  "Default directory for frame shots")

(defvar frameshot-format 'png
  "Default frame shot format, could be 'jpg or 'svg, inspect the
  function `x-export-frames'")

(defun frameshot ()
  "Save Emacs frame as frame shot.

Directory is determined by variable `frameshot-directory' and if
not defined, it will be saved in the `$HOME' directory."
  (interactive)
  (let* ((image (x-export-frames nil (or frameshot-format 'png)))
         (base-directory (or frameshot-directory (getenv "HOME")))
         (directory (concat (file-name-as-directory base-directory) 
(format-time-string "%Y/%m/%Y-%m-%d/")))
         (file (concat directory (format-time-string "Screenshot-%Y-%m-%d-%T.") 
(symbol-name frameshot-format))))
    (make-directory directory t)
    (with-temp-file file
      (insert image))
    (find-file directory)
    (message "Frame shot saved as `%s'" file)))

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]