Improving preview functionality. No buffer switch.
- Using temp buffer instead of new buffer. - Windows layout is retained. No need to switch buffer after every preview
This commit is contained in:
parent
2b84a2df52
commit
a8e0b5cd56
|
@ -262,33 +262,28 @@ to choose where to display it:
|
||||||
- 4 (when prefixing the command with C-u) -> new window
|
- 4 (when prefixing the command with C-u) -> new window
|
||||||
- 16 (when prefixing the command with C-u C-u) -> new frame.
|
- 16 (when prefixing the command with C-u C-u) -> new frame.
|
||||||
- else -> new buffer"
|
- else -> new buffer"
|
||||||
(let ((b (get-buffer plantuml-preview-buffer)))
|
|
||||||
(when b
|
|
||||||
(kill-buffer b)))
|
|
||||||
|
|
||||||
(let* ((imagep (and (display-images-p)
|
(let* ((imagep (and (display-images-p)
|
||||||
(plantuml-is-image-output-p)))
|
(plantuml-is-image-output-p)))
|
||||||
(process-connection-type nil)
|
(process-connection-type nil)
|
||||||
(buf (get-buffer-create plantuml-preview-buffer))
|
|
||||||
(coding-system-for-read (and imagep 'binary))
|
(coding-system-for-read (and imagep 'binary))
|
||||||
(coding-system-for-write (and imagep 'binary)))
|
(coding-system-for-write (and imagep 'binary)))
|
||||||
|
|
||||||
(let ((ps (plantuml-start-process buf)))
|
(with-output-to-temp-buffer plantuml-preview-buffer
|
||||||
(process-send-string ps string)
|
(let* ((buf (get-buffer-create plantuml-preview-buffer)) (ps (plantuml-start-process buf)))
|
||||||
(process-send-eof ps)
|
(process-send-string ps string)
|
||||||
(set-process-sentinel ps
|
(process-send-eof ps)
|
||||||
(lambda (_ps event)
|
(set-process-sentinel ps
|
||||||
(unless (equal event "finished\n")
|
(lambda (_ps event)
|
||||||
(error "PLANTUML Preview failed: %s" event))
|
(unless (equal event "finished\n")
|
||||||
(cond
|
(error "PLANTUML Preview failed: %s" event))
|
||||||
((= prefix 16)
|
(cond
|
||||||
(switch-to-buffer-other-frame plantuml-preview-buffer))
|
((= prefix 16)
|
||||||
((= prefix 4)
|
(switch-to-buffer-other-frame plantuml-preview-buffer))
|
||||||
(switch-to-buffer-other-window plantuml-preview-buffer))
|
((= prefix 4)
|
||||||
(t (switch-to-buffer plantuml-preview-buffer)))
|
(switch-to-buffer-other-window plantuml-preview-buffer)))
|
||||||
(when imagep
|
(when imagep
|
||||||
(image-mode)
|
(image-mode)
|
||||||
(set-buffer-multibyte t)))))))
|
(set-buffer-multibyte t))))))))
|
||||||
|
|
||||||
(defun plantuml-preview-buffer (prefix)
|
(defun plantuml-preview-buffer (prefix)
|
||||||
"Preview diagram from the PlantUML sources in the current buffer.
|
"Preview diagram from the PlantUML sources in the current buffer.
|
||||||
|
|
Loading…
Reference in New Issue