Skip to content

Commit

Permalink
lisp/ob-plantuml.el: Insert results in buffer
Browse files Browse the repository at this point in the history
When :results header arg is set to a value that doesn't include
"file", insert txt output in buffer below src block.

TINYCHANGE
  • Loading branch information
josephmturner authored and yantar92 committed Aug 6, 2022
1 parent a0b21e3 commit 9cc60de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions etc/ORG-NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,13 @@ files that are exported to Texinfo.

=org-at-heading-p= now returns t by default on headings inside folds.
Passing optional argument will produce the old behaviour.

*** =org-babel-execute:plantuml= can output ASCII graphs in the buffer

Previously, executing PlantUML src blocks always exported to a file. Now, if
:results is set to a value which does not include "file", no file will be
exported and an ASCII graph will be inserted below the src block.

** Removed or renamed functions and variables
*** =org-plantump-executable-args= is renamed and applies to jar as well

Expand Down
12 changes: 9 additions & 3 deletions lisp/ob-plantuml.el
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ If BODY does not contain @startXXX ... @endXXX clauses, @startuml
(defun org-babel-execute:plantuml (body params)
"Execute a block of plantuml code with org-babel.
This function is called by `org-babel-execute-src-block'."
(let* ((out-file (or (cdr (assq :file params))
(error "PlantUML requires a \":file\" header argument")))
(let* ((do-export (member "file" (cdr (assq :result-params params))))
(out-file (if do-export
(or (cdr (assq :file params))
(error "No :file provided but :results set to file. For plain text output, set :results to verbatim"))
(org-babel-temp-file "plantuml-" ".txt")))
(cmdline (cdr (assq :cmdline params)))
(in-file (org-babel-temp-file "plantuml-"))
(java (or (cdr (assq :java params)) ""))
Expand Down Expand Up @@ -155,7 +158,10 @@ This function is called by `org-babel-execute-src-block'."
(if (and (string= (file-name-extension out-file) "svg")
org-babel-plantuml-svg-text-to-path)
(org-babel-eval (format "inkscape %s -T -l %s" out-file out-file) ""))
nil)) ;; signal that output has already been written to file
(unless do-export (with-temp-buffer
(insert-file-contents out-file)
(buffer-substring-no-properties
(point-min) (point-max))))))

(defun org-babel-prep-session:plantuml (_session _params)
"Return an error because plantuml does not support sessions."
Expand Down

0 comments on commit 9cc60de

Please sign in to comment.