From mboxrd@z Thu Jan 1 00:00:00 1970 From: pinard@iro.umontreal.ca (=?utf-8?Q?Fran=C3=A7ois?= Pinard) Subject: Re: [Orgmode] Automatic screenshot insertion Date: Mon, 09 Jan 2012 15:22:27 -0500 Message-ID: <87obucaanw.fsf@iro.umontreal.ca> References: <4CE55F66.80802@gmail.com> <87vd3hmebo.wl%dmaus@ictsoc.de> <20110329144327.GE2902@x201> <87ehveyck1.fsf@iro.umontreal.ca> <87fwfoohn6.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:46640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkLji-0004L3-0f for emacs-orgmode@gnu.org; Mon, 09 Jan 2012 15:22:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkLjg-000300-N1 for emacs-orgmode@gnu.org; Mon, 09 Jan 2012 15:22:29 -0500 Received: from 206-248-137-202.dsl.teksavvy.com ([206.248.137.202]:60604 helo=mercure.epsilon-ti.ca) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkLjg-0002zv-Er for emacs-orgmode@gnu.org; Mon, 09 Jan 2012 15:22:28 -0500 In-Reply-To: <87fwfoohn6.fsf@ucl.ac.uk> (Eric S. Fraga's message of "Mon, 09 Jan 2012 18:27:57 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Eric S Fraga writes: > pinard@iro.umontreal.ca (Fran=C3=A7ois 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=C3=A7ois (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 (make-temp-name (concat (file-name-as-directory name) (subst-char-in-string "." "-" (file-name-sans-extension (file-name-nondirectory (buffer-file-name)))))) ".png"))) (unless (file-exists-p name) (unless (file-writable-p name) (debug) (error "Cannot create image file")) (message "Taking screenshot...") (call-process "import" nil nil nil name) (message "Taking screenshot...done")) (insert (concat "[[" name "]]")) (org-display-inline-images))