Skip to content

Instantly share code, notes, and snippets.

@rpl
Created August 24, 2010 13:05
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save rpl/547521 to your computer and use it in GitHub Desktop.
Save rpl/547521 to your computer and use it in GitHub Desktop.
(require 'iimage)
(autoload 'iimage-mode "iimage" "Support Inline image minor mode." t)
(autoload 'turn-on-iimage-mode "iimage" "Turn on Inline image minor mode." t)
(add-to-list 'iimage-mode-image-regex-alist '("@startuml\s+\\(.+\\)" . 1))
;; Rendering plantuml
(defun plantuml-render-buffer ()
(interactive)
(message "PLANTUML Start rendering")
(shell-command (concat "java -jar ~/Downloads/plantuml.jar "
buffer-file-name))
(message (concat "PLANTUML Rendered: " (buffer-name))))
;; Image reloading
(defun reload-image-at-point ()
(interactive)
(message "reloading image at point in the current buffer...")
(image-refresh (get-text-property (point) 'display)))
;; Image resizing and reloading
(defun resize-image-at-point ()
(interactive)
(message "resizing image at point in the current buffer123...")
(let* ((image-spec (get-text-property (point) 'display))
(file (cadr (member :file image-spec))))
(message (concat "resizing image..." file))
(shell-command (format "convert -resize %d %s %s "
(* (window-width (selected-window)) (frame-char-width))
file file))
(reload-image-at-point)))
@papoanaya
Copy link

One thing I would like to modify this code is to work for an emacs region in addition to the whole buffer. This probably would entail either creating a temporary file or sending it to sysinput. We'll see, I'll dabble with it whenever I get a chance. But it works well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment