pin...@iro.umontreal.ca (François Pinard) writes: > Russell Adams <rlad...@adamsinfoserv.com> 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 "Cannot create image file")) (message "Taking screenshot...") (call-process "import" nil nil nil name) (message "Taking screenshot...done")) | (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")) | 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 -- : 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)