Capture stderr in *plantuml errors* when generating preview

Ensure logging output from the plantuml binaries does not get mixed in
with the image output. Error output will be collected in the *plantuml
errors* buffer instead.
This commit is contained in:
Joost Diepenmaat 2020-03-12 15:38:45 +01:00
parent ea45a13707
commit 0d2dff6961
No known key found for this signature in database
GPG Key ID: C945FE6EED8A098C
1 changed files with 21 additions and 12 deletions

View File

@ -368,26 +368,35 @@ Note that output type `txt' is promoted to `utxt' for better rendering."
("txt" "utxt") ("txt" "utxt")
(_ output-type)))) (_ output-type))))
(defun plantuml-start-process (command buf)
"Start rendering process running COMMAND with output to BUF"
(make-process :name
"PLANTUML"
:buffer buf
:command command
:noquery t
:stderr (get-buffer-create "*plantuml errors*")))
(defun plantuml-jar-start-process (buf) (defun plantuml-jar-start-process (buf)
"Run PlantUML as an Emacs process and puts the output into the given buffer (as BUF)." "Run PlantUML as an Emacs process and puts the output into the given buffer (as BUF)."
(let ((java-args (if (<= 8 (plantuml-jar-java-version)) (let ((java-args (if (<= 8 (plantuml-jar-java-version))
(remove "--illegal-access=deny" plantuml-java-args) (remove "--illegal-access=deny" plantuml-java-args)
plantuml-java-args))) plantuml-java-args)))
(apply #'start-process (plantuml-start-process `(,plantuml-java-command
"PLANTUML" buf plantuml-java-command ,@java-args
`(,@java-args ,(expand-file-name plantuml-jar-path)
,(expand-file-name plantuml-jar-path) ,(plantuml-jar-output-type-opt plantuml-output-type)
,(plantuml-jar-output-type-opt plantuml-output-type) "-p")
,@plantuml-jar-args buf)))
"-p"))))
(defun plantuml-executable-start-process (buf) (defun plantuml-executable-start-process (buf)
"Run PlantUML as an Emacs process and puts the output into the given buffer (as BUF)." "Run PlantUML as an Emacs process and puts the output into the given buffer (as BUF)."
(apply #'start-process (plantuml-start-process `(,plantuml-executable-path
"PLANTUML" buf plantuml-executable-path ,@plantuml-executable-args
`(,@plantuml-executable-args ,(expand-file-name plantuml-jar-path)
,(plantuml-jar-output-type-opt plantuml-output-type) ,(plantuml-jar-output-type-opt plantuml-output-type)
"-p"))) "-p")
buf))
(defun plantuml-update-preview-buffer (prefix buf) (defun plantuml-update-preview-buffer (prefix buf)
"Show the preview in the preview buffer BUF. "Show the preview in the preview buffer BUF.