* [PATCH] Using org babel for generating ASCII art using PlantUML
@ 2013-03-09 21:37 Mats Kindahl
2013-03-09 23:23 ` Eric Schulte
2013-04-05 17:05 ` Bastien
0 siblings, 2 replies; 6+ messages in thread
From: Mats Kindahl @ 2013-03-09 21:37 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 474 bytes --]
Hi all,
I find the PlantUML support very useful to generate diagrams when
presenting designs, but unfortunately, I quite frequently have to send
simple descriptions requiring ASCII only. Since PlantUML support
generation of ASCII-art diagrams, I updated the org babel PlantUML
support to generate ASCII art in place when no :file parameter is provided.
Patch is attached.
Just my few cents,
Mats Kindahl
--
Senior Principal Software Developer
Oracle, MySQL Department
[-- Attachment #2: plantuml-ascii-art.diff --]
[-- Type: text/x-diff, Size: 2655 bytes --]
diff --git a/lisp/ob-plantuml.el b/lisp/ob-plantuml.el
index c17d444..b4e2b01 100644
--- a/lisp/ob-plantuml.el
+++ b/lisp/ob-plantuml.el
@@ -37,7 +37,7 @@
(require 'ob)
(defvar org-babel-default-header-args:plantuml
- '((:results . "file") (:exports . "results"))
+ '((:exports . "results"))
"Default arguments for evaluating a plantuml source block.")
(defcustom org-plantuml-jar-path nil
@@ -46,33 +46,43 @@
:version "24.1"
:type 'string)
+(defvar org-babel-plantuml-ext-alist
+ '(("svg" . "-tsvg")
+ ("eps" . "-teps")
+ ("atxt" . "-txt")
+ ("png" . ""))
+ "Switch to use for different file name extensions.")
+
+(defun org-babel-plantuml-switch (filename)
+ (concat " "
+ (if filename
+ (let ((ext (file-name-extension filename)))
+ (or (cdr (assoc ext org-babel-plantuml-ext-alist))
+ (error "Unrecognized file name extension '%s'" ext)))
+ "-txt")))
+
(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* ((result-params (split-string (or (cdr (assoc :results params)) "")))
- (out-file (or (cdr (assoc :file params))
- (error "PlantUML requires a \":file\" header argument")))
+ (out-file (cdr (assoc :file params)))
(cmdline (cdr (assoc :cmdline params)))
- (in-file (org-babel-temp-file "plantuml-"))
(java (or (cdr (assoc :java params)) ""))
(cmd (if (not org-plantuml-jar-path)
(error "`org-plantuml-jar-path' is not set")
(concat "java " java " -jar "
(shell-quote-argument
(expand-file-name org-plantuml-jar-path))
- (if (string= (file-name-extension out-file) "svg")
- " -tsvg" "")
- (if (string= (file-name-extension out-file) "eps")
- " -teps" "")
- " -p " cmdline " < "
- (org-babel-process-file-name in-file)
- " > "
- (org-babel-process-file-name out-file)))))
+ (org-babel-plantuml-switch out-file)
+ " -p " cmdline
+ (if out-file
+ (concat " > " (org-babel-process-file-name out-file))
+ "")))))
(unless (file-exists-p org-plantuml-jar-path)
(error "Could not find plantuml.jar at %s" org-plantuml-jar-path))
- (with-temp-file in-file (insert (concat "@startuml\n" body "\n@enduml")))
- (message "%s" cmd) (org-babel-eval cmd "")
- nil)) ;; signal that output has already been written to file
+ (message "%s" cmd)
+ (let ((result (org-babel-eval cmd (concat "@startuml\n" body "\n@enduml"))))
+ (if (string= result "") nil result))))
(defun org-babel-prep-session:plantuml (session params)
"Return an error because plantuml does not support sessions."
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Using org babel for generating ASCII art using PlantUML
2013-03-09 21:37 [PATCH] Using org babel for generating ASCII art using PlantUML Mats Kindahl
@ 2013-03-09 23:23 ` Eric Schulte
2013-03-10 7:13 ` Mats Kindahl
2013-04-05 17:05 ` Bastien
1 sibling, 1 reply; 6+ messages in thread
From: Eric Schulte @ 2013-03-09 23:23 UTC (permalink / raw)
To: Mats Kindahl; +Cc: emacs-orgmode
Mats Kindahl <mats.kindahl@oracle.com> writes:
> Hi all,
>
> I find the PlantUML support very useful to generate diagrams when
> presenting designs, but unfortunately, I quite frequently have to send
> simple descriptions requiring ASCII only. Since PlantUML support
> generation of ASCII-art diagrams, I updated the org babel PlantUML
> support to generate ASCII art in place when no :file parameter is provided.
>
> Patch is attached.
>
> Just my few cents,
> Mats Kindahl
Hi Mats,
Thanks for sharing this patch, I think defaulting to text output when no
:file argument is given is a great idea, and your patch looks good.
Unfortunately, being part of Emacs, Org-mode's contribution rules are
pretty strict. Would you be willing to go through the Emacs Copyright
attribution process described here [1] so that we may apply this patch?
Thanks,
Footnotes:
[1] http://orgmode.org/worg/org-contribute.html
--
Eric Schulte
http://cs.unm.edu/~eschulte
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Using org babel for generating ASCII art using PlantUML
2013-03-09 23:23 ` Eric Schulte
@ 2013-03-10 7:13 ` Mats Kindahl
0 siblings, 0 replies; 6+ messages in thread
From: Mats Kindahl @ 2013-03-10 7:13 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode
On 03/10/2013 12:23 AM, Eric Schulte wrote:
> Mats Kindahl <mats.kindahl@oracle.com> writes:
>
>> Hi all,
>>
>> I find the PlantUML support very useful to generate diagrams when
>> presenting designs, but unfortunately, I quite frequently have to send
>> simple descriptions requiring ASCII only. Since PlantUML support
>> generation of ASCII-art diagrams, I updated the org babel PlantUML
>> support to generate ASCII art in place when no :file parameter is provided.
>>
>> Patch is attached.
>>
>> Just my few cents,
>> Mats Kindahl
> Hi Mats,
Hi Eric,
>
> Thanks for sharing this patch, I think defaulting to text output when no
> :file argument is given is a great idea, and your patch looks good.
OK. Good.
>
> Unfortunately, being part of Emacs, Org-mode's contribution rules are
> pretty strict. Would you be willing to go through the Emacs Copyright
> attribution process described here [1] so that we may apply this patch?
Sure, I'll be back.
Best wishes,
Mats Kindahl
>
> Thanks,
>
> Footnotes:
> [1] http://orgmode.org/worg/org-contribute.html
>
--
Senior Principal Software Developer
Oracle, MySQL Department
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Using org babel for generating ASCII art using PlantUML
2013-03-09 21:37 [PATCH] Using org babel for generating ASCII art using PlantUML Mats Kindahl
2013-03-09 23:23 ` Eric Schulte
@ 2013-04-05 17:05 ` Bastien
2013-04-05 18:57 ` Mats Kindahl
1 sibling, 1 reply; 6+ messages in thread
From: Bastien @ 2013-04-05 17:05 UTC (permalink / raw)
To: Mats Kindahl; +Cc: emacs-orgmode
Hi Mats,
sorry for the late reply.
Mats Kindahl <mats.kindahl@oracle.com> writes:
> I find the PlantUML support very useful to generate diagrams when
> presenting designs, but unfortunately, I quite frequently have to send
> simple descriptions requiring ASCII only. Since PlantUML support
> generation of ASCII-art diagrams, I updated the org babel PlantUML
> support to generate ASCII art in place when no :file parameter is
> provided.
This could be useful, yes, but we cannot apply this patch until you
sign the FSF copyright assignment, as ob-plantuml.el is part of Org's
core which is part of Emacs.
If you want to sign the assignment, please let me know and I'll send
you the details in private.
Thanks!
--
Bastien
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Using org babel for generating ASCII art using PlantUML
2013-04-05 17:05 ` Bastien
@ 2013-04-05 18:57 ` Mats Kindahl
2013-04-06 20:37 ` Bastien
0 siblings, 1 reply; 6+ messages in thread
From: Mats Kindahl @ 2013-04-05 18:57 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode
On 04/05/2013 07:05 PM, Bastien wrote:
> Hi Mats,
>
> sorry for the late reply.
>
> Mats Kindahl <mats.kindahl@oracle.com> writes:
>
>> I find the PlantUML support very useful to generate diagrams when
>> presenting designs, but unfortunately, I quite frequently have to send
>> simple descriptions requiring ASCII only. Since PlantUML support
>> generation of ASCII-art diagrams, I updated the org babel PlantUML
>> support to generate ASCII art in place when no :file parameter is
>> provided.
> This could be useful, yes, but we cannot apply this patch until you
> sign the FSF copyright assignment, as ob-plantuml.el is part of Org's
> core which is part of Emacs.
>
> If you want to sign the assignment, please let me know and I'll send
> you the details in private.
Thank you Bastien,
I've got the necessary papers and am working on it. I don't expect any
problems, it's just red tape.
I'll be back once I have the signatures I need.
Best wishes,
Mats Kindahl
>
> Thanks!
>
--
Senior Principal Software Developer
Oracle, MySQL Department
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Using org babel for generating ASCII art using PlantUML
2013-04-05 18:57 ` Mats Kindahl
@ 2013-04-06 20:37 ` Bastien
0 siblings, 0 replies; 6+ messages in thread
From: Bastien @ 2013-04-06 20:37 UTC (permalink / raw)
To: Mats Kindahl; +Cc: emacs-orgmode
Hi Mats,
Mats Kindahl <mats.kindahl@oracle.com> writes:
> I've got the necessary papers and am working on it. I don't expect any
> problems, it's just red tape.
Great, I added you to this page:
http://orgmode.org/worg/org-contribute.html#sec-6-2
> I'll be back once I have the signatures I need.
Thanks!
--
Bastien
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-04-06 20:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-09 21:37 [PATCH] Using org babel for generating ASCII art using PlantUML Mats Kindahl
2013-03-09 23:23 ` Eric Schulte
2013-03-10 7:13 ` Mats Kindahl
2013-04-05 17:05 ` Bastien
2013-04-05 18:57 ` Mats Kindahl
2013-04-06 20:37 ` Bastien
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).