Screenshots in org-mode

Angelegt von niklas Sun, 28 Nov 2010 19:43:00 GMT

A nice feature for emacs org-mode just went over the mailing list:

; 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:

  1. Make sure you have import from the ImageMagick suite, check with which import.
  2. Put code in a .el file in your ~/.emacs.d/ directory (or anywhere else for that matter)
  3. Evaluate the buffer with M-x eval-buffer
  4. Move to a org-mode file (or enable it with M-x org-mode in any other buffer)
  5. Go to the position where you want to insert your screenshot and call that function with M-x my-screenshot.
  6. Your cursor will turn into a crosshair or something, now click on the window you want to capture.
  7. The image inserted at your cursor positiong

How does it work?

  1. Generate a filename, within the current working directory (usually the location of the file associated with current buffer)
  2. Call ImageMagick's import tool, with that filename
  3. Insert a link at the current cursor position
  4. Call the org-display-inline-images function.
If you want to customize that link, or insert custom links to images, just do 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

Leave a comment

Comments