1
0
Fork 0

Merge pull request #47 from 7mamu4/add-interactive-parameter-for-region

plantuml-preview-region: add interactive parameter for region
This commit is contained in:
Carlo Sciolla 2016-12-25 21:03:29 +01:00 committed by GitHub
commit 73442f1222

View file

@ -263,16 +263,17 @@ Uses prefix (as PREFIX) to choose where to display it:
(interactive "p") (interactive "p")
(plantuml-preview-string prefix (buffer-string))) (plantuml-preview-string prefix (buffer-string)))
(defun plantuml-preview-region (prefix) (defun plantuml-preview-region (prefix begin end)
"Preview diagram from the PlantUML sources in the current region. "Preview diagram from the PlantUML sources in from BEGIN to END.
Uses the current region when called interactively.
Uses prefix (as PREFIX) to choose where to display it: Uses prefix (as PREFIX) 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"
(interactive "p") (interactive "p\nr")
(plantuml-preview-string prefix (concat "@startuml\n" (plantuml-preview-string prefix (concat "@startuml\n"
(buffer-substring-no-properties (buffer-substring-no-properties
(region-beginning) (region-end)) begin end)
"\n@enduml"))) "\n@enduml")))
(defun plantuml-preview-current-block (prefix) (defun plantuml-preview-current-block (prefix)
@ -296,7 +297,7 @@ Uses prefix (as PREFIX) to choose where to display it:
- else -> new buffer" - else -> new buffer"
(interactive "p") (interactive "p")
(if mark-active (if mark-active
(plantuml-preview-region prefix) (plantuml-preview-region prefix (region-beginning) (region-end))
(plantuml-preview-buffer prefix))) (plantuml-preview-buffer prefix)))
(defun plantuml-init-once () (defun plantuml-init-once ()