Screenshots in org-mode
; Change name to your needs.
(defun my-screenshot ()
"Take a screenshot into a unique-named file in the current buffer file
directory and insert a link to this file."
(interactive)
(setq filename
(concat
(make-temp-name
(file-name-directory (buffer-file-name))
)
".jpg"
)
)
(call-process "import" nil nil nil filename)
(insert (concat "[[" filename "]]"))
(org-display-inline-images)
)
This is how you use it:
- Make sure you have
importfrom the ImageMagick suite, check withwhich import. - Put code in a .el file in your
~/.emacs.d/directory (or anywhere else for that matter) - Evaluate the buffer with
M-x eval-buffer - Move to a org-mode file (or enable it with
M-x org-modein any other buffer) - Go to the position where you want to insert your screenshot and call that function with
M-x my-screenshot. - Your cursor will turn into a crosshair or something, now click on the window you want to capture.
- The image inserted at your cursor positiong
How does it work?
- Generate a filename, within the current working directory (usually the location of the file associated with current buffer)
- Call ImageMagick's
importtool, with that filename - Insert a link at the current cursor position
- Call the
org-display-inline-imagesfunction.
M-x org-display-inline-images to turn those into inline images as well. Export to PDF with C-c C-e d and watch the scaled down screenshots.
Trackbacks
Verwenden Sie den folgenden Link zur Rückverlinkung von Ihrer eigenen Seite:
http://praktikanten.brueckenschlaeger.org/trackbacks?article_id=387