PlanDuSite ModificationsRécentes Nouvelles SectionElisp CommentFaire

ScreentoImagebin

Emacs integration for taking screen-shots and uploading images to http://imagebin.org. Currently under construction. Sort of maintained by IzaakBeekman.

General Info

I am hoping to turn this into a package and make some substantial improvements, but right now I have very little time and knowledge of ELisp. I am also hoping that this code will be useful to the rest of the community. It seems to me that it could be particularly useful for collaborative debugging of Emacs, emacs packages, etc.

Dependancies

  1. Linux (*nix might suffice)
  2. xwd
  3. curl

What It Does

Right now this code is in my .emacs file. Two functions are defined, one for taking a screen shot with xwd and saving it as a .png, and the other for calling the first function and pasting the screen shot to http://imagebin.org with curl. This is then bound to some key.

What It Should Do

Below is a list of improvements I would like to make/ I would like to have help making/ if you’re impatient and want to make them yourself you should. This list is ranked in order of my perception of the improvement-of-functionality/time-investment ratio which could be incorrect.

  1. Figure out how to add a line break to the curl command.
  2. Have the screen-shot-taking function accept an optional argument for the name of the output .png file and have the posting-to-imagebin function accept an optional argument which chooses the file to post.
  3. Implement as much as possible of this in ELisp rather than letting Linux shell tools accomplish this. This will increase portability and robustness. Fixing the post to http://imagebin.org should not be too bad, I have seen plenty of ELisp code which sends http post requests, and all the form info is already available in the current code. My hopes for taking a screen shot via Emacs/lisp are considerably lower.
  4. Add general upload to imagebin functionality as outlined above and interface with dired and image-dired in a slick way. It sounds like the FlickrClient package does something like this.
  5. Roll this into a package once it is more than just a few lines of sloppy code.

Code

;;;;;;;;;;;;;;;;;;;;
;; Screen capture ;;
;;;;;;;;;;;;;;;;;;;;
(defun screen-cap ()
  (interactive)
  (shell-command "xwd -root | xwdtopnm | pnmtopng > ~/EmacsScreenshot.png")
  )

(defun screen-paste ()
  (interactive)
  (screen-cap)
  (shell-command "curl 'http://imagebin.org/index.php' -F 'nickname=ibeekman' -F \"image=@$HOME/EmacsScreenshot.png;type=image/png\" -F 'disclaimer_agree=Y' -F 'Submit=Submit' -F 'mode=add'")
)

(global-set-key [C-kp-enter] 'screen-paste)

Improvements and suggestions are encouraged!

I have some code that does screenshots, and surrounds them with web pages, while stepping through a sequence of emacs commands, at versor-demo.el on SourceForge. You could try extracting relevant bits of that — try the function versor-take-screenshot.