From: Dan Davison <davison@stats.ox.ac.uk>
To: Juan <Pechiar@computer.org>
Cc: Emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Code snippet for Message Sequence Diagram export
Date: Mon, 17 May 2010 19:04:14 -0400 [thread overview]
Message-ID: <87hbm6w2oh.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <20100517200431.GA27574@soloJazz.com> (Juan's message of "Mon, 17 May 2010 17:04:31 -0300")
Juan <Pechiar@computer.org> writes:
> Below goes code snippet using org-babel instead of org-export.
Hi Juan,
Thanks, we'd be pleased to include this in org-babel. First question is:
if you haven't already, can you sign FSF copyright transfer forms for
Emacs / Org-mode?
http://orgmode.org/worg/org-contribute.php
And a couple of little questions:
- I think I'd prefer to get rid of the org-mscgen-path variable, and
simply require that mscgen is on the user's $PATH. Is that OK or am I
missing a reason for doing it differently?
- Is it definitely correct to automatically wrap the user's code in msg
{ ... }? I initially fell into the trap of including that inside my
code block. I do not know the language; are there situations where the
desired mscgen code will not be generated by wrapping everything in a
msg { ... } block?
- If you are feeling energetic, it would be really nice to check the
exit code from the shell-command and use org-babel-error-notify if
necessary, similar to this fragment from org-babel-python
(setq exit-code (org-babel-shell-command-on-region
(point-min) (point-max) "python" nil 'replace (current-buffer)))
(buffer-string))))
(if (> exit-code 0) (org-babel-error-notify exit-code stderr))
(Looks like we should be doing this in org-babel-ditaa also)
Thanks again,
Dan
>
> On Mon, May 17, 2010 at 09:13:29AM +0100, Eric S Fraga wrote:
>> On Sun, 16 May 2010 17:18:39 -0300, Juan <pechiar@computer.org> wrote:
>> > The following code adds an export block of type 'mscgen'. The block
>> > body will be processed by the mscgen application. Sort of works, not
>> > very tested yet.
>>
>> [...]
>>
>> Juan,
>>
>> this could be very useful. Thanks! I do wonder, however, whether it
>> would make sense to have this as a org-babel language? It would be
>> nice to have the images generated appear in the org file directly...
>>
>> Thanks again,
>> eric
>
> ;;; org-babel-mscgen.el --- org-babel functions for mscgen evaluation
>
> ;;; TODO insert GPL header here
>
> ;;; Commentary:
> ;;
> ;; This software provides EMACS org-babel export support for message
> ;; sequence charts. The mscgen utility is used for processing the
> ;; sequence definition, and must therefore be installed in the system.
> ;;
> ;; The code is a direct modification of org-babel-ditaa
> ;; from the org-mode distribution.
> ;;
> ;; Mscgen is available and documented at http://www.mcternan.me.uk/mscgen/index.html
> ;;
> ;; Customize path to mscgen utility with org-mscgen-path variable
> ;;
> ;; Example:
> ;;
> ;; #+begin_src mscgen :file example.png
> ;; A,B;
> ;; A -> B [ label = "send message" ];
> ;; B <: A [ label = "get answer" ];
> ;; #+end_src
>
> ;;; Code:
> (require 'org-babel)
>
> (defvar org-mscgen-path
> "/opt/local/bin/mscgen"
> "Complete path to the mscgen executable")
>
> (org-babel-add-interpreter "mscgen")
>
> (add-to-list 'org-babel-tangle-langs '("mscgen" "mscgen"))
>
> (defvar org-babel-default-header-args:mscgen
> '((:results . "file") (:exports . "results"))
> "Default arguments to use when evaluating a mscgen source block.")
>
> (defun org-babel-expand-body:mscgen (body params &optional processed-params) body)
>
> (defun org-babel-execute:mscgen (body params)
> "Execute a block of Mscgen code with org-babel. This function is
> called by `org-babel-execute-src-block'."
> (message "executing Mscgen source code block")
> (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
> (out-file (cdr (assoc :file params)))
> (cmdline (cdr (assoc :cmdline params)))
> (in-file (make-temp-file "org-babel-mscgen")))
> (unless (file-exists-p org-mscgen-path)
> (error (format "Could not find mscgen at %s" org-mscgen-path)))
> (with-temp-file in-file (insert (concat "msc {\n" body "\n}\n")))
> (message (concat org-mscgen-path " -T png -o " out-file " -i " in-file))
> (shell-command (concat org-mscgen-path " -T png -o " out-file " -i " in-file))
> out-file))
>
> (defun org-babel-prep-session:mscgen (session params)
> (error "Mscgen does not support sessions"))
>
> (provide 'org-babel-mscgen)
> ;;; org-babel-mscgen.el ends here
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2010-05-17 23:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-16 20:18 Code snippet for Message Sequence Diagram export Juan
2010-05-17 8:13 ` Eric S Fraga
2010-05-17 20:04 ` Juan
2010-05-17 23:04 ` Dan Davison [this message]
2010-05-18 1:24 ` Juan
2010-05-23 22:43 ` Juan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87hbm6w2oh.fsf@stats.ox.ac.uk \
--to=davison@stats.ox.ac.uk \
--cc=Pechiar@computer.org \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).