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

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

Re: Screenshots, frame shots straight from Emacs


From: Jean Louis
Subject: Re: Screenshots, frame shots straight from Emacs
Date: Fri, 2 Jul 2021 15:50:11 +0300
User-agent: Mutt/2.0.7+183 (3d24855) (2021-05-28)

* Emanuel Berg via Users list for the GNU Emacs text editor 
<help-gnu-emacs@gnu.org> [2021-07-02 00:02]:
> Jean Louis wrote:
> 
> > External program is dependency.
> >
> > Emacs has internal function for it,.
> 
> It does? The only thing I can find is
> `message-insert-screenshot'. It uses what's in
> `message-screenshot-command', which here is ("import" "png:-")
> 
> That's a command? Not in the interactive function sense,
> at least.

You responded on the function: (x-export-frames nil (or
frameshot-format 'png)))

so watch for it below:

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

(defvar frameshot-format 'png
  "Default frame shot format")

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