emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric S Fraga <e.fraga@ucl.ac.uk>
To: "François Pinard" <pinard@iro.umontreal.ca>
Cc: emacs-orgmode@gnu.org
Subject: Re: [Orgmode] Automatic screenshot insertion
Date: Tue, 10 Jan 2012 08:57:43 +0000	[thread overview]
Message-ID: <87wr90c4u0.fsf@ucl.ac.uk> (raw)
In-Reply-To: <87obucaanw.fsf@iro.umontreal.ca> ("François Pinard"'s message of "Mon, 09 Jan 2012 15:22:27 -0500")

pinard@iro.umontreal.ca (François 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
-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.90.1
: using Org-mode version 7.8.03 (release_7.8.03.67.g56c73)

  reply	other threads:[~2012-01-10  9:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-18 17:16 Automatic screenshot insertion Jonathan BISSON
2010-11-18 17:50 ` Sébastien Vauban
2010-11-28 19:35 ` David Maus
2011-03-29 14:43   ` [Orgmode] " Russell Adams
2011-06-06 18:59     ` David Maus
2012-01-05  4:54     ` François Pinard
2012-01-09 18:27       ` Eric S Fraga
2012-01-09 20:22         ` François Pinard
2012-01-10  8:57           ` Eric S Fraga [this message]
2012-01-10 14:53             ` François Pinard
2012-01-10 16:08               ` Eric S Fraga
2012-01-10 19:27                 ` François Pinard
2012-01-10 19:46                   ` Skip Collins
2012-01-11  5:50                     ` Jambunathan K
2012-01-12  5:26                       ` Skip Collins
2012-01-12  6:26                         ` Thomas S. Dye
2012-01-14 21:35                     ` François Pinard
2012-01-15  6:37                       ` Marcelo de Moraes Serpa
2012-01-15 12:10                         ` Russell Adams
2012-01-15 19:31                           ` Marcelo de Moraes Serpa
2012-01-15 21:45                             ` Russell Adams
2012-01-10 20:26                   ` Eric S Fraga
2011-02-03 13:33 ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wr90c4u0.fsf@ucl.ac.uk \
    --to=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=pinard@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).