From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: Re: [Orgmode] Automatic screenshot insertion Date: Tue, 10 Jan 2012 08:57:43 +0000 Message-ID: <87wr90c4u0.fsf@ucl.ac.uk> References: <4CE55F66.80802@gmail.com> <87vd3hmebo.wl%dmaus@ictsoc.de> <20110329144327.GE2902@x201> <87ehveyck1.fsf@iro.umontreal.ca> <87fwfoohn6.fsf@ucl.ac.uk> <87obucaanw.fsf@iro.umontreal.ca> 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]:47541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkY71-0005uP-V4 for emacs-orgmode@gnu.org; Tue, 10 Jan 2012 04:35:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkY70-0005lI-Re for emacs-orgmode@gnu.org; Tue, 10 Jan 2012 04:35:23 -0500 Received: from vscani-e.ucl.ac.uk ([144.82.108.33]:39241) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkY70-0005l6-NO for emacs-orgmode@gnu.org; Tue, 10 Jan 2012 04:35:22 -0500 In-Reply-To: <87obucaanw.fsf@iro.umontreal.ca> (=?utf-8?Q?=22Fran=C3=A7ois?= Pinard"'s message of "Mon, 09 Jan 2012 15:22:27 -0500") 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: =?utf-8?Q?Fran=C3=A7ois?= Pinard Cc: emacs-orgmode@gnu.org pinard@iro.umontreal.ca (Fran=C3=A7ois Pinard) writes: [...] > 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. This correction did not work for me out of the box. I had to add a call to expand-file-name for getting a file name which worked on my system for some reason. I also re-arranged your second (unless ...) to an (if ...): #+begin_src emacs-lisp (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 (expand-file-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) (if (file-writable-p name) (progn (message "Taking screenshot into %s" name) (call-process "import" nil nil nil name) (message "Taking screenshot...done")) (error "Cannot create image file"))) (insert (concat "[[" name "]]")) (org-display-inline-images)) #+end_src This now appears to work (for me). Thanks again, eric --=20 : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.90.1 : using Org-mode version 7.8.03 (release_7.8.03.67.g56c73)