emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [Orgmode] Automatic screenshot insertion


From: Eric S Fraga
Subject: Re: [O] [Orgmode] Automatic screenshot insertion
Date: Tue, 10 Jan 2012 08:57:43 +0000
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux)

address@hidden (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 via email to

[Prev in Thread] Current Thread [Next in Thread]