[Top][All Lists]

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

Re: [O] [Orgmode] Automatic screenshot insertion

From: François Pinard
Subject: Re: [O] [Orgmode] Automatic screenshot insertion
Date: Mon, 09 Jan 2012 15:22:27 -0500
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.3 (gnu/linux)

Eric S Fraga <address@hidden> writes:

> address@hidden (François Pinard) writes:

> Thanks!  However, if I give it a directory name, the function fails
> with "Cannot create image file" in the mini-buffer.  [...]  In
> summary, if I give it an existing file name, that works; if I give it
> a non-existing file name, that also works.  It only fails if I give it
> a directory.

Hi, Eric.  Sorry.  Here is a quick correction for that problem.  This is
only this week that I plan to use that function for actual work; last
week was rather an exploration of the capability of various tools.  Of
course, do not hesitate if you see that I goofed elsewhere! :-).

Thanks, François

(defun fp-org-image (name)
  "Insert a link to an already existing image, or else to a screenshot.
The screenshot is either taken to the given non-existing file name,
or added into the given directory, defaulting to the current one."
  ;; FIXME: Should limit to '("pdf" "jpeg" "jpg" "png" "ps" "eps")
  ;; which is org-export-latex-inline-image-extensions.
  (interactive "GImage name? ")
  (when (file-directory-p name)
    (setq name (concat
                 (concat (file-name-as-directory name)
                          "." "-"
  (unless (file-exists-p name)
    (unless (file-writable-p name)
      (error "Cannot create image file"))
    (message "Taking screenshot...")
    (call-process "import" nil nil nil name)
    (message "Taking screenshot...done"))
  (insert (concat "[[" name "]]"))

reply via email to

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