From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Richard Subject: Re: How to represent this in Org-mode Date: Thu, 14 Aug 2014 13:08:52 +0200 Message-ID: <87zjf78h17.fsf@geodiff-mac3.ulb.ac.be> References: <20140813134105.783be844@aga-netbook> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHssH-0004Uf-Q8 for emacs-orgmode@gnu.org; Thu, 14 Aug 2014 07:07:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHssB-0003SL-Oe for emacs-orgmode@gnu.org; Thu, 14 Aug 2014 07:07:17 -0400 Received: from mxin.ulb.ac.be ([164.15.128.112]:33647) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHssB-0003S6-Iw for emacs-orgmode@gnu.org; Thu, 14 Aug 2014 07:07:11 -0400 In-Reply-To: <20140813134105.783be844@aga-netbook> (Marcin Borkowski's message of "Wed, 13 Aug 2014 13:41:05 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Marcin Borkowski Cc: Org-mode mailing list Marcin Borkowski 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=C3=AAte de fl=C3=A8ches! edge [arrowhead=3Dnone]; // cr=C3=A9er des fl=C3=A8ches a -> b -> c; // cr=C3=A9er des fl=C3=A8ches d'un noeud vers plusieurs a -> {x y} [weight=3D10]; // donner la forme d'un noeud b [shape=3Dbox]; // donner un nom, une couleur, etc. =C3=A0 un noeud c [label=3D"hello\nworld",color=3Dblue,fontsize=3D24, fontname=3D"Palatino-Italic",fontcolor=3Dred,style=3Dfilled]; // cr=C3=A9er une fl=C3=A8che avec un label et un poids. // si on diminue le poids (4, 3, 2, 1, 0), la fl=C3=A8che se cour= be. a -> z [label=3D"hi", weight=3D60]; // label multiligne. x -> z [label=3D"multi-line\nlabel"]; //=20 edge [style=3Ddashed,color=3Dred,arrowhead=3Dnormal]; {rank=3Dsame; 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)))) --=20 Nico.