From 9c509f879dd16bce7d8b49853dc6fc5e375a60af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20M=C3=BCller?= Date: Wed, 26 Oct 2016 01:03:37 +0200 Subject: [PATCH] Add plantuml-preview-current-block Add a function that allows to preview the current block. The current block is defined to be the region beginning at previous "@startuml" and ending at "@enduml". The prefix argument is handled according to the existing prview functions. --- plantuml-mode.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plantuml-mode.el b/plantuml-mode.el index 6947bcd..c803e9c 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -278,6 +278,18 @@ Uses prefix (as PREFIX) to choose where to display it: (region-beginning) (region-end)) "\n@enduml"))) +(defun plantuml-preview-current-block (prefix) + "Preview diagram from the PlantUML sources from the previous @startuml to the next @enduml. +Uses prefix (as PREFIX) to choose where to display it: +- 4 (when prefixing the command with C-u) -> new window +- 16 (when prefixing the command with C-u C-u) -> new frame. +- else -> new buffer" + (interactive "p") + (save-restriction + (narrow-to-region + (search-backward "@startuml") (search-forward "@enduml")) + (plantuml-preview-buffer prefix))) + (defun plantuml-preview (prefix) "Preview diagram from the PlantUML sources. Uses the current region if one is active, or the entire buffer otherwise.