Screenshot Function
I have always had the goal of being able to document something at the speed of thought. For me part of this means being able to easily take screenshots from within Emacs. Specifically, I want functions for window, region and full screen screenshots. It is something that is particularly important for things like this blog but also just generally important for documenting information that is better described with a picture. I had written a functions for this but I could not find them. Instead I decided to compromise and use an external package I have known about called escr. It is the only package I could find that could do window, region and frame screenshots for Emacs.
I install it via package.el
in 110-init-package.el by adding it to
package-vc-selected-packages and relying on
package-vc-install-selected-packages.
(setq package-vc-selected-packages '((completion-preview :url "https://git.sr.ht/~eshel/completion-preview")
(emacs-wallpaper :url "https://github.com/Luis-Henriquez-Perez/emacs-wallpaper" :branch "mine")
(escr :url "https://github.com/Luis-Henriquez-Perez/escr")
(evil-easymotion :url "https://github.com/Luis-Henriquez-Perez/evil-easymotion" :branch "master")
(on :url "https://github.com/ajgrf/on.el")
(outli :url "https://github.com/jdtsmith/outli")
(zone-matrix :url "https://github.com/ober/zone-matrix" :branch "master")))
(package-vc-install-selected-packages)
This is my configuration for it in 130-init-escr.el. I do not do much. I
just declare and autoload the main escr
commands and set the directory where
screenshots will go.
(require '050-base)
(opt! escr-screenshot-directory (expand-file-name "~/Pictures"))
(declare-function escr-region-screenshot "escr")
(declare-function escr-window-screenshot "escr")
(declare-function escr-frame-screenshot "escr")
(autoload #'escr-region-screenshot "escr" nil t 'function)
(autoload #'escr-window-screenshot "escr" nil t 'function)
(autoload #'escr-frame-screenshot "escr" nil t 'function)
Of course, I also added keybindings for the commands it uses.
(bind! oo-app-map "s r" #'escr-region-screenshot)
(bind! oo-app-map "s f" #'escr-frame-screenshot)
(bind! oo-app-map "s w" #'escr-window-screenshot)