merged with current develop branch

This commit is contained in:
Carlo Sciolla 2016-11-11 11:03:04 +01:00
commit 5cb8d2336a
No known key found for this signature in database
GPG Key ID: BA5D71E6F3C580C1
1 changed files with 21 additions and 12 deletions

View File

@ -79,16 +79,12 @@
(defcustom plantuml-suppress-deprecation-warning t (defcustom plantuml-suppress-deprecation-warning t
"To silence the deprecation warning when `puml-mode' is found upon loading.") "To silence the deprecation warning when `puml-mode' is found upon loading.")
(defun plantuml-command-line ()
"Compose the PlantUML command line as a string."
(mapconcat 'identity (cons plantuml-java-command plantuml-java-args) " "))
(defun plantuml-render-command (&rest arguments) (defun plantuml-render-command (&rest arguments)
"Create a command line to execute PlantUML with arguments (as ARGUMENTS)." "Create a command line to execute PlantUML with arguments (as ARGUMENTS)."
(let ((cmd (concat (plantuml-command-line) " " (shell-quote-argument plantuml-jar-path))) (let* ((cmd-list (append plantuml-java-args (list (expand-file-name plantuml-jar-path)) arguments))
(argstring (mapconcat 'identity arguments " "))) (cmd (mapconcat 'identity cmd-list "|")))
(plantuml-debug (format "Command is %s" cmd)) (plantuml-debug (format "Command is [%s]" cmd))
(concat cmd " " argstring))) cmd-list))
;;; syntax table ;;; syntax table
(defvar plantuml-mode-syntax-table (defvar plantuml-mode-syntax-table
@ -134,11 +130,12 @@
(defun plantuml-init () (defun plantuml-init ()
"Initialize the keywords or builtins from the cmdline language output." "Initialize the keywords or builtins from the cmdline language output."
(unless (file-exists-p plantuml-jar-path) (unless (or (eq system-type 'cygwin) (file-exists-p plantuml-jar-path))
(error "Could not find plantuml.jar at %s" plantuml-jar-path)) (error "Could not find plantuml.jar at %s" plantuml-jar-path))
(with-temp-buffer (with-temp-buffer
(let ((cmd (plantuml-render-command "-charset UTF-8 -language"))) (let ((cmd-args (append (list plantuml-java-command nil t nil)
(shell-command cmd (current-buffer)) (plantuml-render-command "-charset" "UTF-8" "-language"))))
(apply 'call-process cmd-args)
(goto-char (point-min))) (goto-char (point-min)))
(let ((found (search-forward ";" nil t)) (let ((found (search-forward ";" nil t))
(word "") (word "")
@ -220,7 +217,7 @@ default output type for new buffers."
`(start-process "PLANTUML" ,buf `(start-process "PLANTUML" ,buf
plantuml-java-command plantuml-java-command
,@plantuml-java-args ,@plantuml-java-args
plantuml-jar-path (expand-file-name plantuml-jar-path)
(plantuml-output-type-opt) "-p")) (plantuml-output-type-opt) "-p"))
(defun plantuml-preview-string (prefix string) (defun plantuml-preview-string (prefix string)
@ -278,6 +275,18 @@ Uses prefix (as PREFIX) to choose where to display it:
(region-beginning) (region-end)) (region-beginning) (region-end))
"\n@enduml"))) "\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) (defun plantuml-preview (prefix)
"Preview diagram from the PlantUML sources. "Preview diagram from the PlantUML sources.
Uses the current region if one is active, or the entire buffer otherwise. Uses the current region if one is active, or the entire buffer otherwise.