From: Nicolas Richard <theonewiththeevillook@yahoo.fr>
To: Marcin Borkowski <mbork@wmi.amu.edu.pl>
Cc: Org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: How to represent this in Org-mode
Date: Thu, 14 Aug 2014 13:08:52 +0200 [thread overview]
Message-ID: <87zjf78h17.fsf@geodiff-mac3.ulb.ac.be> (raw)
In-Reply-To: <20140813134105.783be844@aga-netbook> (Marcin Borkowski's message of "Wed, 13 Aug 2014 13:41:05 +0200")
Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
> Hello,
>
> now that I learned how to use a hammer, everything looks like a nail.
> So I want to use Org-mode for this; my question is, did anyone do
> anything similar and has some suggestions how to structure this
> material?
I did not do it, but still have one suggestion.
Each module could come with a name (e.g. CUSTOM_ID) and you could add a
:PREREQ: property listing all the other modules that are
prerequisite of that one.
It might then take some lisp to convert the data into an actual
dependency graph. graphviz might also come in handy for this task : it
allows to draw directed graphs easily. see below, I ended up writing
some of that lisp.
Imagine an org file like this:
#+BEGIN_SRC org
,* Module A
:PROPERTIES:
:CUSTOM_ID: A
:END:
,* Module B
:PROPERTIES:
:CUSTOM_ID: B
:PREREQ: A
:END:
,* Module C
:PROPERTIES:
:CUSTOM_ID: C
:PREREQ: A
:END:
,* Module D
:PROPERTIES:
:CUSTOM_ID: D
:PREREQ: A B
:END:
#+END_SRC
It could be translated to an graphviz code like this one very easily :
#+BEGIN_SRC dot :file dot-example3.png
digraph test123 {
{A} -> B;
{A} -> C;
{A B} -> D;
}
#+END_SRC
which then compiles into a dependency graph. (note that "{A}-> B" could
also be written as "A -> B", but an automated translation mechanism
doesn't need to do that)
Here's some more graphviz code (taken from the manpage IIRC, the
comments in french are mine) to see what it can do if you want more:
#+begin_src dot :file dot-example.png
digraph test123 {
// on peut faire un digraphe sans tête de flèches!
edge [arrowhead=none];
// créer des flèches
a -> b -> c;
// créer des flèches d'un noeud vers plusieurs
a -> {x y} [weight=10];
// donner la forme d'un noeud
b [shape=box];
// donner un nom, une couleur, etc. à un noeud
c [label="hello\nworld",color=blue,fontsize=24,
fontname="Palatino-Italic",fontcolor=red,style=filled];
// créer une flèche avec un label et un poids.
// si on diminue le poids (4, 3, 2, 1, 0), la flèche se courbe.
a -> z [label="hi", weight=60];
// label multiligne.
x -> z [label="multi-line\nlabel"];
//
edge [style=dashed,color=red,arrowhead=normal];
{rank=same; b->x};
}
#+end_src
Because I was curious, I wrote a few lines of elisp to do the
conversion:
;; call this one via M-x ...
(defun yf/org-dependencies ()
(interactive)
(with-output-to-temp-buffer (get-buffer-create "*OrgFormatDeps*")
(princ "digraph OrgDeps {\n")
(org-map-entries 'yf/org-format-dependency)
(princ "}")
(terpri)
(pop-to-buffer (current-buffer))))
;; this is a helper function
(defun yf/org-format-dependency ()
(let ((id (org-entry-get (point) "CUSTOM_ID"))
(prereqs (org-entry-get-multivalued-property (point) "PREREQ")))
(when (and id prereqs)
(princ
(concat " {"
(mapconcat 'identity prereqs " ")
"} -> "
id
";"))
(terpri))))
--
Nico.
next prev parent reply other threads:[~2014-08-14 11:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-13 11:41 How to represent this in Org-mode Marcin Borkowski
2014-08-13 12:46 ` Pascal Fleury
2014-08-13 20:41 ` Marcin Borkowski
2014-08-13 23:30 ` John Kitchin
2014-08-13 14:53 ` Thorsten Jolitz
2014-08-13 20:42 ` Marcin Borkowski
2014-08-14 11:08 ` Nicolas Richard [this message]
2014-08-27 12:01 ` Nicolas Richard
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=87zjf78h17.fsf@geodiff-mac3.ulb.ac.be \
--to=theonewiththeevillook@yahoo.fr \
--cc=emacs-orgmode@gnu.org \
--cc=mbork@wmi.amu.edu.pl \
/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).