Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
(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)))

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