Skip to content

Instantly share code, notes, and snippets.

@foguinhoperuca
Forked from rpl/plantuml_helpers.el
Created August 27, 2014 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foguinhoperuca/7aa8b7df656b6ac173f6 to your computer and use it in GitHub Desktop.
Save foguinhoperuca/7aa8b7df656b6ac173f6 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 /usr/local/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)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment