From 2134815c6c722e1607d93af500522ed5abb78cc1 Mon Sep 17 00:00:00 2001 From: Bram Schoenmakers Date: Thu, 8 Sep 2022 07:05:43 +0200 Subject: [PATCH] Reuse the old preview buffer/window such that display-buffer behaves Before, the buffer is killed and then recreated. This causes wrong behavior for display-buffer when display-buffer-reuse-window and display-buffer-same-window is used: the first one fails so the same window is used where the diagram source is situated. Instead, reuse the buffer and its window, so don't kill the buffer, erase it instead. --- plantuml-mode.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index e40ba0d..8014a5e 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -404,7 +404,8 @@ Window is selected according to PREFIX: (when imagep (with-current-buffer buf (image-mode) - (set-buffer-multibyte t))))) + (set-buffer-multibyte t))) + (set-window-point (get-buffer-window buf 'visible) (point-min)))) (defun plantuml-jar-preview-string (prefix string buf) "Preview the diagram from STRING by running the PlantUML JAR. @@ -484,7 +485,8 @@ Put the result into buffer BUF, selecting the window according to PREFIX: to choose where to display it." (let ((b (get-buffer plantuml-preview-buffer))) (when b - (kill-buffer b))) + (with-current-buffer b + (erase-buffer)))) (let* ((imagep (and (display-images-p) (plantuml-is-image-output-p)))