From 0bdd6fa6508443f150713cb742880fa244a201cb Mon Sep 17 00:00:00 2001 From: Carlo Sciolla Date: Tue, 21 May 2019 07:41:57 +0200 Subject: [PATCH] WIP --- plantuml-mode.el | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index 6a1d4cb..4f323c4 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -111,12 +111,17 @@ :type '(repeat string) :group 'plantuml) +(defcustom plantuml-server-url "http://www.plantuml.com/plantuml" + "The base URL of the PlantUML server." + :type 'string + :group 'plantuml) + (defcustom plantuml-default-exec-mode 'jar - "Default execution mode for PlantUML. Valid values are: - - `jar': run PlantUML as a JAR file (requires a local install of the PlantUML JAR file, see `plantuml-jar-path'" + "Default execution mode for PlantUML. Valid values are: +- `jar': run PlantUML as a JAR file (requires a local install of the PlantUML JAR file, see `plantuml-jar-path'" :type 'symbol :group 'plantuml - :options '(jar)) + :options '(jar server)) (defcustom plantuml-suppress-deprecation-warning t "To silence the deprecation warning when `puml-mode' is found upon loading." @@ -211,10 +216,18 @@ (apply 'call-process cmd-args) (goto-char (point-min))))) +(defun plantuml-server-get-language (buf) + "Retrieve the language specification from the PlantUML server and paste it into BUF." + ;; Currently waiting on https://github.com/plantuml/plantuml-server/pull/106 for a proper implementation + (let ((lang-url (concat plantuml-server-url "/language"))) + (with-current-buffer buf + (url-insert-file-contents lang-url)))) + (defun plantuml-get-language (mode buf) "Retrieve the language spec using the preferred PlantUML execution mode MODE. Paste the result into BUF." (let ((get-fn (pcase mode - ('jar #'plantuml-jar-get-language)))) + ('jar #'plantuml-jar-get-language) + ('server #'plantuml-server-get-language)))) (if get-fn (funcall get-fn buf) (error "Unsupported execution mode %s" mode)))) @@ -331,6 +344,10 @@ default output type for new buffers." (image-mode) (set-buffer-multibyte t))))))) +(defun plantuml-server-preview-string (prefix string buf) + "Preview the diagram from STRING as rendered by the PlantUML server. +Put the result into buffer BUF and place it according to PREFIX.") + (defun plantuml-exec-mode-preview-string (prefix mode string buf) "Preview the diagram from STRING using the execution mode MODE. Put the result into buffer BUF, selecting the window according to PREFIX: