allow puml-preview to open in other window, frame

This commit is contained in:
Jonathan Meeks 2016-03-21 10:32:17 -05:00
parent 966064f371
commit 4bb8b2a04e
2 changed files with 13 additions and 4 deletions

View File

@ -61,7 +61,11 @@ Default key bindings
The following shortcuts are enabled by default:
C-c C-c renders a PlantUML diagram from the current buffer in the best supported format
C-c C-c puml-preview: renders a PlantUML diagram from the current buffer in the best supported format
C-u C-c C-c puml-preview in other window
C-u C-u C-c C-c puml-preview in other frame
Troubleshooting
===============

View File

@ -189,9 +189,9 @@ default output type for new buffers."
"Create the flag to pass to PlantUML to produce the selected output format."
(concat "-t" puml-output-type))
(defun puml-preview ()
(defun puml-preview (prefix)
"Preview diagram."
(interactive)
(interactive "p")
(let ((b (get-buffer puml-preview-buffer)))
(when b
(kill-buffer b)))
@ -212,7 +212,12 @@ default output type for new buffers."
(lambda (ps event)
(unless (equal event "finished\n")
(error "PUML Preview failed: %s" event))
(switch-to-buffer puml-preview-buffer)
(cond
((= prefix 16)
(switch-to-buffer-other-frame puml-preview-buffer))
((= prefix 4)
(switch-to-buffer-other-window puml-preview-buffer))
(t (switch-to-buffer puml-preview-buffer)))
(when imagep
(image-mode)
(set-buffer-multibyte t)))))))