From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: Re: [Orgmode] Automatic screenshot insertion Date: Mon, 09 Jan 2012 18:27:57 +0000 Message-ID: <87fwfoohn6.fsf@ucl.ac.uk> References: <4CE55F66.80802@gmail.com> <87vd3hmebo.wl%dmaus@ictsoc.de> <20110329144327.GE2902@x201> <87ehveyck1.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]:36246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkL0N-0005i0-IG for emacs-orgmode@gnu.org; Mon, 09 Jan 2012 14:35:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkL0L-0003aE-PS for emacs-orgmode@gnu.org; Mon, 09 Jan 2012 14:35:39 -0500 Received: from vscane-c.ucl.ac.uk ([144.82.108.43]:46188) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkL0L-0003aA-Ie for emacs-orgmode@gnu.org; Mon, 09 Jan 2012 14:35:37 -0500 In-Reply-To: <87ehveyck1.fsf@iro.umontreal.ca> (=?utf-8?Q?=22Fran=C3=A7ois?= Pinard"'s message of "Wed, 04 Jan 2012 23:54:06 -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: > Russell Adams writes: >> On Sun, Nov 28, 2010 at 08:35:23PM +0100, David Maus wrote: >>> At Thu, 18 Nov 2010 18:16:22 +0100, Jonathan BISSON wrote: > >>> > Here is a little function that allows a user to insert a screenshot >>> > easily. Only works on unix-like systems where ImageMagick is installed >>> > (adapt "import" to your screenshot program if needed). > >>> Nice. Do you mind of I put the function on Org mode'S wiki (Worg) in >>> the "Org hacks" page?[1] > >> I made a minor change. File names are now generated by using the >> current org buffer filename, plus the date and time, and a unique >> number. This allows me to sort out the images better. > > For my own usage, I modified it further, like below: > > > (defun fp-org-image (name) [...] Thanks! Very nice update. I'd been using the original code for a while but prompting for the file name is quite helpful. However, if I give it a directory name, the function fails with "Cannot create image file" in the mini-buffer. With debug (note: only function name is different): ,---- | Debugger entered--Lisp error: (error "Cannot create image file") | signal(error ("Cannot create image file")) | error("Cannot create image file") | (if (file-writable-p name) nil (error "Cannot create image file")) | (unless (file-writable-p name) (error "Cannot create image file")) | (if (file-exists-p name) nil (unless (file-writable-p name) (error "Can= not create image file")) (message "Taking screenshot...") (call-process "im= port" nil nil nil name) (message "Taking screenshot...done")) | (unless (file-exists-p name) (unless (file-writable-p name) (error "Can= not create image file")) (message "Taking screenshot...") (call-process "im= port" nil nil nil name) (message "Taking screenshot...done")) | esf/org-screenshot("~/s/test") | call-interactively(esf/org-screenshot nil nil) `---- 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. thanks, eric --=20 : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.90.1 : using Org-mode version 7.8.03 (release_7.8.03.66.g1283.dirty)