annotate lisp/org/org-freemind.el @ 111727:997260859cca

* lisp/calendar/diary-lib.el (diary-outlook-format-1): Fix match-strings.
author Glenn Morris <rgm@gnu.org>
date Thu, 25 Nov 2010 19:14:03 -0800
parents 5cb272c831e8
children a7740098b594
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1 ;;; org-freemind.el --- Export Org files to freemind
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106168
diff changeset
3 ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6 ;; Keywords: outlines, hypermedia, calendar, wp
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7 ;; Homepage: http://orgmode.org
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
8 ;; Version: 7.3
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
15 ;; (at your option) any later version.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
16
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
20 ;; GNU General Public License for more details.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
21
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
24
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
25 ;; --------------------------------------------------------------------
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
26 ;; Features that might be required by this library:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
27 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
28 ;; `backquote', `bytecomp', `cl', `easymenu', `font-lock',
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
29 ;; `noutline', `org', `org-compat', `org-faces', `org-footnote',
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
30 ;; `org-list', `org-macs', `org-src', `outline', `syntax',
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
31 ;; `time-date', `xml'.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
32 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
33 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
34 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
35 ;;; Commentary:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
36 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
37 ;; This file tries to implement some functions useful for
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
38 ;; transformation between org-mode and FreeMind files.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
39 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
40 ;; Here are the commands you can use:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
41 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
42 ;; M-x `org-freemind-from-org-mode'
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
43 ;; M-x `org-freemind-from-org-mode-node'
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
44 ;; M-x `org-freemind-from-org-sparse-tree'
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
45 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
46 ;; M-x `org-freemind-to-org-mode'
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
47 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
48 ;; M-x `org-freemind-show'
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
49 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
50 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
51 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
52 ;;; Change log:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
53 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
54 ;; 2009-02-15: Added check for next level=current+1
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
55 ;; 2009-02-21: Fixed bug in `org-freemind-to-org-mode'.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
56 ;; 2009-10-25: Added support for `org-odd-levels-only'.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
57 ;; Added y/n question before showing in FreeMind.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
58 ;; 2009-11-04: Added support for #+BEGIN_HTML.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
59 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
60 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
61 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
62 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
63 ;; This program is free software; you can redistribute it and/or
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
64 ;; modify it under the terms of the GNU General Public License as
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
65 ;; published by the Free Software Foundation; either version 2, or
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
66 ;; (at your option) any later version.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
67 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
68 ;; This program is distributed in the hope that it will be useful,
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
69 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
70 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
71 ;; General Public License for more details.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
72 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
73 ;; You should have received a copy of the GNU General Public License
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
74 ;; along with this program; see the file COPYING. If not, write to
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
75 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
76 ;; Floor, Boston, MA 02110-1301, USA.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
77 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
78 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
79 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
80 ;;; Code:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
81
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
82 (require 'xml)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
83 (require 'org)
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
84 ;(require 'rx)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
85 (require 'org-exp)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
86 (eval-when-compile (require 'cl))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
87
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
88 (defgroup org-freemind nil
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
89 "Customization group for org-freemind export/import."
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
90 :group 'org)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
91
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
92 ;; Fix-me: I am not sure these are useful:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
93 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
94 ;; (defcustom org-freemind-main-fgcolor "black"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
95 ;; "Color of main node's text."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
96 ;; :type 'color
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
97 ;; :group 'org-freemind)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
98
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
99 ;; (defcustom org-freemind-main-color "black"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
100 ;; "Background color of main node."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
101 ;; :type 'color
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
102 ;; :group 'org-freemind)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
103
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
104 ;; (defcustom org-freemind-child-fgcolor "black"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
105 ;; "Color of child nodes' text."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
106 ;; :type 'color
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
107 ;; :group 'org-freemind)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
108
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
109 ;; (defcustom org-freemind-child-color "black"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
110 ;; "Background color of child nodes."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
111 ;; :type 'color
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
112 ;; :group 'org-freemind)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
113
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
114 (defvar org-freemind-node-style nil "Internal use.")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
115
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
116 (defcustom org-freemind-node-styles nil
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
117 "Styles to apply to node.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
118 NOT READY YET."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
119 :type '(repeat
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
120 (list :tag "Node styles for file"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
121 (regexp :tag "File name")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
122 (repeat
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
123 (list :tag "Node"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
124 (regexp :tag "Node name regexp")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
125 (set :tag "Node properties"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
126 (list :format "%v" (const :format "" node-style)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
127 (choice :tag "Style"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
128 :value bubble
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
129 (const bubble)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
130 (const fork)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
131 (list :format "%v" (const :format "" color)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
132 (color :tag "Color" :value "red"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
133 (list :format "%v" (const :format "" background-color)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
134 (color :tag "Background color" :value "yellow"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
135 (list :format "%v" (const :format "" edge-color)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
136 (color :tag "Edge color" :value "green"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
137 (list :format "%v" (const :format "" edge-style)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
138 (choice :tag "Edge style" :value bezier
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
139 (const :tag "Linear" linear)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
140 (const :tag "Bezier" bezier)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
141 (const :tag "Sharp Linear" sharp-linear)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
142 (const :tag "Sharp Bezier" sharp-bezier)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
143 (list :format "%v" (const :format "" edge-width)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
144 (choice :tag "Edge width" :value thin
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
145 (const :tag "Parent" parent)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
146 (const :tag "Thin" thin)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
147 (const 1)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
148 (const 2)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
149 (const 4)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
150 (const 8)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
151 (list :format "%v" (const :format "" italic)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
152 (const :tag "Italic font" t))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
153 (list :format "%v" (const :format "" bold)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
154 (const :tag "Bold font" t))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
155 (list :format "%v" (const :format "" font-name)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
156 (string :tag "Font name" :value "SansSerif"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157 (list :format "%v" (const :format "" font-size)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
158 (integer :tag "Font size" :value 12)))))))
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
159 :group 'org-freemind)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
160
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
161 ;;;###autoload
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
162 (defun org-export-as-freemind (&optional hidden ext-plist
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
163 to-buffer body-only pub-dir)
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
164 "Export the current buffer as a Freemind file.
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
165 If there is an active region, export only the region. HIDDEN is
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
166 obsolete and does nothing. EXT-PLIST is a property list with
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
167 external parameters overriding org-mode's default settings, but
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
168 still inferior to file-local settings. When TO-BUFFER is
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
169 non-nil, create a buffer with that name and export to that
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
170 buffer. If TO-BUFFER is the symbol `string', don't leave any
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
171 buffer behind but just return the resulting HTML as a string.
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
172 When BODY-ONLY is set, don't produce the file header and footer,
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
173 simply return the content of the document (all top level
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
174 sections). When PUB-DIR is set, use this as the publishing
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
175 directory.
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
176
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
177 See `org-freemind-from-org-mode' for more information."
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
178 (interactive "P")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
179 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
180 ext-plist
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
181 (org-infile-export-plist)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
182 (region-p (org-region-active-p))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
183 (rbeg (and region-p (region-beginning)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
184 (rend (and region-p (region-end)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
185 (subtree-p
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
186 (if (plist-get opt-plist :ignore-subtree-p)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
187 nil
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
188 (when region-p
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
189 (save-excursion
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190 (goto-char rbeg)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191 (and (org-at-heading-p)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192 (>= (org-end-of-subtree t t) rend))))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
193 (opt-plist (setq org-export-opt-plist
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
194 (if subtree-p
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
195 (org-export-add-subtree-options opt-plist rbeg)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
196 opt-plist)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
197 (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
198 (filename (concat (file-name-as-directory
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
199 (or pub-dir
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200 (org-export-directory :ascii opt-plist)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201 (file-name-sans-extension
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202 (or (and subtree-p
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
203 (org-entry-get (region-beginning)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
204 "EXPORT_FILE_NAME" t))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
205 (file-name-nondirectory bfname)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
206 ".mm")))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
207 (when (file-exists-p filename)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
208 (delete-file filename))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
209 (cond
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
210 (subtree-p
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
211 (org-freemind-from-org-mode-node (line-number-at-pos rbeg)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
212 filename))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
213 (t (org-freemind-from-org-mode bfname filename)))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
214
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
215 ;;;###autoload
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
216 (defun org-freemind-show (mm-file)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
217 "Show file MM-FILE in Freemind."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
218 (interactive
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
219 (list
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
220 (save-match-data
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
221 (let ((name (read-file-name "FreeMind file: "
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
222 nil nil nil
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
223 (if (buffer-file-name)
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
224 (let* ((name-ext (file-name-nondirectory (buffer-file-name)))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
225 (name (file-name-sans-extension name-ext))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
226 (ext (file-name-extension name-ext)))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
227 (cond
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
228 ((string= "mm" ext)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
229 name-ext)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
230 ((string= "org" ext)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
231 (let ((name-mm (concat name ".mm")))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
232 (if (file-exists-p name-mm)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
233 name-mm
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
234 (message "Not exported to Freemind format yet")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
235 "")))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
236 (t
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
237 "")))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
238 "")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
239 ;; Fix-me: Is this an Emacs bug?
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
240 ;; This predicate function is never
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
241 ;; called.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
242 (lambda (fn)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
243 (string-match "^mm$" (file-name-extension fn))))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
244 (setq name (expand-file-name name))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
245 name))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
246 (org-open-file mm-file))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
247
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
248 (defconst org-freemind-org-nfix "--org-mode: ")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
249
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
250 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
251 ;;; Format converters
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
252
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
253 (defun org-freemind-escape-str-from-org (org-str)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
254 "Do some html-escaping of ORG-STR and return the result.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
255 The characters \"&<> will be escaped."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
256 (let ((chars (append org-str nil))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
257 (fm-str ""))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
258 (dolist (cc chars)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
259 (setq fm-str
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
260 (concat fm-str
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
261 (if (< cc 160)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
262 (cond
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
263 ((= cc ?\") "&quot;")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
264 ((= cc ?\&) "&amp;")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
265 ((= cc ?\<) "&lt;")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
266 ((= cc ?\>) "&gt;")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
267 (t (char-to-string cc)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
268 ;; Formatting as &#number; is maybe needed
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
269 ;; according to a bug report from kazuo
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
270 ;; fujimoto, but I have now instead added a xml
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
271 ;; processing instruction saying that the mm
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
272 ;; file is utf-8:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
273 ;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
274 ;; (format "&#x%x;" (- cc ;; ?\x800))
107863
594e81986a75 2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107169
diff changeset
275 (format "&#x%x;" (encode-char cc 'ucs))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
276 ))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
277 fm-str))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
278
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
279 ;;(org-freemind-unescape-str-to-org "&#x6d;A&#x224C;B&lt;C&#x3C;&#x3D;")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
280 ;;(org-freemind-unescape-str-to-org "&#x3C;&lt;")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
281 (defun org-freemind-unescape-str-to-org (fm-str)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
282 "Do some html-unescaping of FM-STR and return the result.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
283 This is the opposite of `org-freemind-escape-str-from-org' but it
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
284 will also unescape &#nn;."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
285 (let ((org-str fm-str))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
286 (setq org-str (replace-regexp-in-string "&quot;" "\"" org-str))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
287 (setq org-str (replace-regexp-in-string "&amp;" "&" org-str))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
288 (setq org-str (replace-regexp-in-string "&lt;" "<" org-str))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
289 (setq org-str (replace-regexp-in-string "&gt;" ">" org-str))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
290 (setq org-str (replace-regexp-in-string
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
291 "&#x\\([a-f0-9]\\{2,4\\}\\);"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
292 (lambda (m)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
293 (char-to-string
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
294 (+ (string-to-number (match-string 1 m) 16)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
295 0 ;?\x800 ;; What is this for? Encoding?
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
296 )))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
297 org-str))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
298
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
299 ;; (let* ((str1 "a quote: \", an amp: &, lt: <; over 256: öåäÖÅÄ")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
300 ;; (str2 (org-freemind-escape-str-from-org str1))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
301 ;; (str3 (org-freemind-unescape-str-to-org str2)))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
302 ;; (unless (string= str1 str3)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
303 ;; (error "Error str3=%s" str3)))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
304
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
305 (defun org-freemind-convert-links-helper (matched)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
306 "Helper for `org-freemind-convert-links-from-org'.
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
307 MATCHED is the link just matched."
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
308 (let* ((link (match-string 1 matched))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
309 (text (match-string 2 matched))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
310 (ext (file-name-extension link))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
311 (col-pos (string-match-p ":" link))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
312 (is-img (and (image-type-from-file-name link)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
313 (let ((url-type (substring link 0 col-pos)))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
314 (member url-type '("file" "http" "https")))))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
315 )
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
316 (if is-img
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
317 ;; Fix-me: I can't find a way to get the border to "shrink
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
318 ;; wrap" around the image using <div>.
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
319 ;;
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
320 ;; (concat "<div style=\"border: solid 1px #ddd; width:auto;\">"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
321 ;; "<img src=\"" link "\" alt=\"" text "\" />"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
322 ;; "<br />"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
323 ;; "<i>" text "</i>"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
324 ;; "</div>")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
325 (concat "<table border=\"0\" style=\"border: solid 1px #ddd;\"><tr><td>"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
326 "<img src=\"" link "\" alt=\"" text "\" />"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
327 "<br />"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
328 "<i>" text "</i>"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
329 "</td></tr></table>")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
330 (concat "<a href=\"" link "\">" text "</a>"))))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
331
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
332 (defun org-freemind-convert-links-from-org (org-str)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
333 "Convert org links in ORG-STR to freemind links and return the result."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
334 (let ((fm-str (replace-regexp-in-string
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
335 ;;(rx (not (any "[\""))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
336 ;; (submatch
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
337 ;; "http"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
338 ;; (opt ?\s)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
339 ;; "://"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
340 ;; (1+
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
341 ;; (any "-%.?@a-zA-Z0-9()_/:~=&#"))))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
342 "[^\"[]\\(http ?://[--:#%&()=?-Z_a-z~]+\\)"
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
343 "[[\\1][\\1]]"
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
344 org-str
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
345 nil ;; fixedcase
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
346 nil ;; literal
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
347 1 ;; subexp
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
348 )))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
349 (replace-regexp-in-string
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
350 ;;(rx "[["
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
351 ;; (submatch (*? nonl))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
352 ;; "]["
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
353 ;; (submatch (*? nonl))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
354 ;; "]]")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
355 "\\[\\[\\(.*?\\)]\\[\\(.*?\\)]]"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
356 ;;"<a href=\"\\1\">\\2</a>"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
357 'org-freemind-convert-links-helper
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
358 fm-str)))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
359
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
360 ;;(org-freemind-convert-links-to-org "<a href=\"http://www.somewhere/\">link-text</a>")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
361 (defun org-freemind-convert-links-to-org (fm-str)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
362 "Convert freemind links in FM-STR to org links and return the result."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
363 (let ((org-str (replace-regexp-in-string
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
364 ;;(rx "<a"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
365 ;; space
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
366 ;; (0+
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
367 ;; (0+ (not (any ">")))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
368 ;; space)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
369 ;; "href=\""
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
370 ;; (submatch (0+ (not (any "\""))))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
371 ;; "\""
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
372 ;; (0+ (not (any ">")))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
373 ;; ">"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
374 ;; (submatch (0+ (not (any "<"))))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
375 ;; "</a>")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
376 "<a[[:space:]]\\(?:[^>]*[[:space:]]\\)*href=\"\\([^\"]*\\)\"[^>]*>\\([^<]*\\)</a>"
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
377 "[[\\1][\\2]]"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
378 fm-str)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
379 org-str))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
380
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
381 ;; Fix-me:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
382 ;;(defun org-freemind-convert-drawers-from-org (text)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
383 ;; )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
384
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
385 ;; (let* ((str1 "[[http://www.somewhere/][link-text]")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
386 ;; (str2 (org-freemind-convert-links-from-org str1))
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
387 ;; (str3 (org-freemind-convert-links-to-org str2)))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
388 ;; (unless (string= str1 str3)
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
389 ;; (error "Error str3=%s" str3)))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
390
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
391 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
392 ;;; Org => FreeMind
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
393
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
394 (defvar org-freemind-bol-helper-base-indent nil)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
395
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
396 (defun org-freemind-bol-helper (matched)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
397 "Helper for `org-freemind-convert-text-p'.
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
398 MATCHED is the link just matched."
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
399 (let ((res "")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
400 (bi org-freemind-bol-helper-base-indent))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
401 (dolist (cc (append matched nil))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
402 (if (= 32 cc)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
403 ;;(setq res (concat res "&nbsp;"))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
404 ;; We need to use the numerical version. Otherwise Freemind
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
405 ;; ver 0.9.0 RC9 can not export to html/javascript.
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
406 (progn
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
407 (if (< 0 bi)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
408 (setq bi (1- bi))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
409 (setq res (concat res "&#160;"))))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
410 (setq res (concat res (char-to-string cc)))))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
411 res))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
412 ;; (setq x (replace-regexp-in-string "\n +" 'org-freemind-bol-nbsp-helper "\n "))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
413
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
414 (defun org-freemind-convert-text-p (text)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
415 "Convert TEXT to html with <p> paragraphs."
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
416 ;; (string-match-p "[^ ]" " a")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
417 (setq org-freemind-bol-helper-base-indent (string-match-p "[^ ]" text))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
418 (setq text (org-freemind-escape-str-from-org text))
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
419
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
420 (setq text (replace-regexp-in-string "\\([[:space:]]\\)\\(/\\)\\([^/]+\\)\\(/\\)\\([[:space:]]\\)" "\\1<i>\\3</i>\\5" text))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
421 (setq text (replace-regexp-in-string "\\([[:space:]]\\)\\(\*\\)\\([^*]+\\)\\(\*\\)\\([[:space:]]\\)" "\\1<b>\\3</b>\\5" text))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
422
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
423 (setq text (concat "<p>" text))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
424 (setq text (replace-regexp-in-string "\n[[:blank:]]*\n" "</p><p>" text))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
425 (setq text (replace-regexp-in-string "\\(?:<p>\\|\n\\) +" 'org-freemind-bol-helper text))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
426 (setq text (replace-regexp-in-string "\n" "<br />" text))
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
427 (setq text (concat text "</p>"))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
428
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
429 (org-freemind-convert-links-from-org text))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
430
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
431 (defcustom org-freemind-node-css-style
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
432 "p { margin-top: 3px; margin-bottom: 3px; }"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
433 "CSS style for Freemind nodes."
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
434 ;; Fix-me: I do not understand this. It worked to export from Freemind
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
435 ;; with this setting now, but not before??? Was this perhaps a java
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
436 ;; bug or is it a windows xp bug (some resource gets exhausted if you
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
437 ;; use sticky keys which I do).
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
438 :group 'org-freemind)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
439
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
440 (defun org-freemind-org-text-to-freemind-subnode/note (node-name start end drawers-regexp)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
441 "Convert text part of org node to freemind subnode or note.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
442 Convert the text part of the org node named NODE-NAME. The text
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
443 is in the current buffer between START and END. Drawers matching
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
444 DRAWERS-REGEXP are converted to freemind notes."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
445 ;; fix-me: doc
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
446 (let ((text (buffer-substring-no-properties start end))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
447 (node-res "")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
448 (note-res ""))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
449 (save-match-data
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
450 ;;(setq text (org-freemind-escape-str-from-org text))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
451 ;; First see if there is something that should be moved to the
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
452 ;; note part:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
453 (let (drawers)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
454 (while (string-match drawers-regexp text)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
455 (setq drawers (cons (match-string 0 text) drawers))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
456 (setq text
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
457 (concat (substring text 0 (match-beginning 0))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
458 (substring text (match-end 0))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
459 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
460 (when drawers
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
461 (dolist (drawer drawers)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
462 (let ((lines (split-string drawer "\n")))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
463 (dolist (line lines)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
464 (setq note-res (concat
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
465 note-res
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
466 org-freemind-org-nfix line "<br />\n")))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
467 ))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
468
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
469 (when (> (length note-res) 0)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
470 (setq note-res (concat
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
471 "<richcontent TYPE=\"NOTE\"><html>\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
472 "<head>\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
473 "</head>\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
474 "<body>\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
475 note-res
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
476 "</body>\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
477 "</html>\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
478 "</richcontent>\n"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
479 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
480
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
481 ;; There is always an LF char:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
482 (when (> (length text) 1)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
483 (setq node-res (concat
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
484 "<node style=\"bubble\" background_color=\"#eeee00\">\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
485 "<richcontent TYPE=\"NODE\"><html>\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
486 "<head>\n"
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
487 (if (= 0 (length org-freemind-node-css-style))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
488 ""
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
489 (concat
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
490 "<style type=\"text/css\">\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
491 "<!--\n"
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
492 org-freemind-node-css-style
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
493 "-->\n"
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
494 "</style>\n"))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
495 "</head>\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
496 "<body>\n"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
497 (let ((begin-html-mark (regexp-quote "#+BEGIN_HTML"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
498 (end-html-mark (regexp-quote "#+END_HTML"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
499 head
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
500 end-pos
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
501 end-pos-match
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
502 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
503 ;; Take care of #+BEGIN_HTML - #+END_HTML
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
504 (while (string-match begin-html-mark text)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
505 (setq head (substring text 0 (match-beginning 0)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
506 (setq end-pos-match (match-end 0))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
507 (setq node-res (concat node-res
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
508 (org-freemind-convert-text-p head)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
509 (setq text (substring text end-pos-match))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
510 (setq end-pos (string-match end-html-mark text))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
511 (if end-pos
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
512 (setq end-pos-match (match-end 0))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
513 (message "org-freemind: Missing #+END_HTML")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
514 (setq end-pos (length text))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
515 (setq end-pos-match end-pos))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
516 (setq node-res (concat node-res
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
517 (substring text 0 end-pos)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
518 (setq text (substring text end-pos-match)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
519 (setq node-res (concat node-res
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
520 (org-freemind-convert-text-p text))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
521 (setq node-res (concat
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
522 node-res
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
523 "</body>\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
524 "</html>\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
525 "</richcontent>\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
526 ;; Put a note that this is for the parent node
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
527 ;; "<richcontent TYPE=\"NOTE\"><html>"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
528 ;; "<head>"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
529 ;; "</head>"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
530 ;; "<body>"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
531 ;; "<p>"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
532 ;; "-- This is more about \"" node-name "\" --"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
533 ;; "</p>"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
534 ;; "</body>"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
535 ;; "</html>"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
536 ;; "</richcontent>\n"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
537 note-res
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
538 "</node>\n" ;; ok
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
539 )))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
540 (list node-res note-res))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
541
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
542 (defun org-freemind-write-node (mm-buffer drawers-regexp
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
543 num-left-nodes base-level
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
544 current-level next-level this-m2
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
545 this-node-end
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
546 this-children-visible
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
547 next-node-start
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
548 next-has-some-visible-child)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
549 (let* (this-icons
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
550 this-bg-color
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
551 this-m2-escaped
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
552 this-rich-node
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
553 this-rich-note
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
554 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
555 (when (string-match "TODO" this-m2)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
556 (setq this-m2 (replace-match "" nil nil this-m2))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
557 (add-to-list 'this-icons "button_cancel")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
558 (setq this-bg-color "#ffff88")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
559 (when (string-match "\\[#\\(.\\)\\]" this-m2)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
560 (let ((prior (string-to-char (match-string 1 this-m2))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
561 (setq this-m2 (replace-match "" nil nil this-m2))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
562 (cond
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
563 ((= prior ?A)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
564 (add-to-list 'this-icons "full-1")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
565 (setq this-bg-color "#ff0000"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
566 ((= prior ?B)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
567 (add-to-list 'this-icons "full-2")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
568 (setq this-bg-color "#ffaa00"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
569 ((= prior ?C)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
570 (add-to-list 'this-icons "full-3")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
571 (setq this-bg-color "#ffdd00"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
572 ((= prior ?D)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
573 (add-to-list 'this-icons "full-4")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
574 (setq this-bg-color "#ffff00"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
575 ((= prior ?E)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
576 (add-to-list 'this-icons "full-5"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
577 ((= prior ?F)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
578 (add-to-list 'this-icons "full-6"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
579 ((= prior ?G)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
580 (add-to-list 'this-icons "full-7"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
581 ))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
582 (setq this-m2 (org-trim this-m2))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
583 (setq this-m2-escaped (org-freemind-escape-str-from-org this-m2))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
584 (let ((node-notes (org-freemind-org-text-to-freemind-subnode/note
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
585 this-m2-escaped
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
586 this-node-end
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
587 (1- next-node-start)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
588 drawers-regexp)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
589 (setq this-rich-node (nth 0 node-notes))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
590 (setq this-rich-note (nth 1 node-notes)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
591 (with-current-buffer mm-buffer
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
592 (insert "<node text=\"" this-m2-escaped "\"")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
593 (org-freemind-get-node-style this-m2)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
594 (when (> next-level current-level)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
595 (unless (or this-children-visible
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
596 next-has-some-visible-child)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
597 (insert " folded=\"true\"")))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
598 (when (and (= current-level (1+ base-level))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
599 (> num-left-nodes 0))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
600 (setq num-left-nodes (1- num-left-nodes))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
601 (insert " position=\"left\""))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
602 (when this-bg-color
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
603 (insert " background_color=\"" this-bg-color "\""))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
604 (insert ">\n")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
605 (when this-icons
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
606 (dolist (icon this-icons)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
607 (insert "<icon builtin=\"" icon "\"/>\n")))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
608 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
609 (with-current-buffer mm-buffer
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
610 ;;(when this-rich-note (insert this-rich-note))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
611 (when this-rich-node (insert this-rich-node))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
612 num-left-nodes)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
613
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
614 (defun org-freemind-check-overwrite (file interactively)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
615 "Check if file FILE already exists.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
616 If FILE does not exists return t.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
617
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
618 If INTERACTIVELY is non-nil ask if the file should be replaced
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
619 and return t/nil if it should/should not be replaced.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
620
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
621 Otherwise give an error say the file exists."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
622 (if (file-exists-p file)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
623 (if interactively
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
624 (y-or-n-p (format "File %s exists, replace it? " file))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
625 (error "File %s already exists" file))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
626 t))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
627
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
628 (defvar org-freemind-node-pattern
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
629 ;;(rx bol
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
630 ;; (submatch (1+ "*"))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
631 ;; (1+ space)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
632 ;; (submatch (*? nonl))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
633 ;; eol)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
634 "^\\(\\*+\\)[[:space:]]+\\(.*?\\)$")
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
635
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
636 (defun org-freemind-look-for-visible-child (node-level)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
637 (save-excursion
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
638 (save-match-data
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
639 (let ((found-visible-child nil))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
640 (while (and (not found-visible-child)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
641 (re-search-forward org-freemind-node-pattern nil t))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
642 (let* ((m1 (match-string-no-properties 1))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
643 (level (length m1)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
644 (if (>= node-level level)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
645 (setq found-visible-child 'none)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
646 (unless (get-char-property (line-beginning-position) 'invisible)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
647 (setq found-visible-child 'found)))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
648 (eq found-visible-child 'found)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
649 ))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
650
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
651 (defun org-freemind-goto-line (line)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
652 "Go to line number LINE."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
653 (save-restriction
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
654 (widen)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
655 (goto-char (point-min))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
656 (forward-line (1- line))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
657
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
658 (defun org-freemind-write-mm-buffer (org-buffer mm-buffer node-at-line)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
659 (with-current-buffer org-buffer
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
660 (dolist (node-style org-freemind-node-styles)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
661 (when (string-match-p (car node-style) buffer-file-name)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
662 (setq org-freemind-node-style (cadr node-style))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
663 ;;(message "org-freemind-node-style =%s" org-freemind-node-style)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
664 (save-match-data
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
665 (let* ((drawers (copy-sequence org-drawers))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
666 drawers-regexp
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
667 (num-top1-nodes 0)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
668 (num-top2-nodes 0)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
669 num-left-nodes
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
670 (unclosed-nodes 0)
107863
594e81986a75 2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107169
diff changeset
671 (odd-only org-odd-levels-only)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
672 (first-time t)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
673 (current-level 1)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
674 base-level
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
675 prev-node-end
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
676 rich-text
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
677 unfinished-tag
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
678 node-at-line-level
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
679 node-at-line-last)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
680 (with-current-buffer mm-buffer
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
681 (erase-buffer)
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
682 (setq buffer-file-coding-system 'utf-8)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
683 ;; Fix-me: Currentl Freemind (ver 0.9.0 RC9) does not support this:
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
684 ;;(insert "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
685 (insert "<map version=\"0.9.0\">\n")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
686 (insert "<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->\n"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
687 (save-excursion
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
688 ;; Get special buffer vars:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
689 (goto-char (point-min))
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
690 (message "Writing Freemind file...")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
691 (while (re-search-forward "^#\\+DRAWERS:" nil t)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
692 (let ((dr-txt (buffer-substring-no-properties (match-end 0) (line-end-position))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
693 (setq drawers (append drawers (split-string dr-txt) nil))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
694 (setq drawers-regexp
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
695 (concat "^[[:blank:]]*:"
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
696 (regexp-opt drawers)
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
697 ;;(rx ":" (0+ blank)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
698 ;; "\n"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
699 ;; (*? anything)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
700 ;; "\n"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
701 ;; (0+ blank)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
702 ;; ":END:"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
703 ;; (0+ blank)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
704 ;; eol)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
705 ":[[:blank:]]*\n\\(?:.\\|\n\\)*?\n[[:blank:]]*:END:[[:blank:]]*$"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
706 ))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
707
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
708 (if node-at-line
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
709 ;; Get number of top nodes and last line for this node
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
710 (progn
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
711 (org-freemind-goto-line node-at-line)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
712 (unless (looking-at org-freemind-node-pattern)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
713 (error "No node at line %s" node-at-line))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
714 (setq node-at-line-level (length (match-string-no-properties 1)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
715 (forward-line)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
716 (setq node-at-line-last
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
717 (catch 'last-line
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
718 (while (re-search-forward org-freemind-node-pattern nil t)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
719 (let* ((m1 (match-string-no-properties 1))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
720 (level (length m1)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
721 (if (<= level node-at-line-level)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
722 (progn
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
723 (beginning-of-line)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
724 (throw 'last-line (1- (point))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
725 (if (= level (1+ node-at-line-level))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
726 (setq num-top2-nodes (1+ num-top2-nodes))))))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
727 (setq current-level node-at-line-level)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
728 (setq num-top1-nodes 1)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
729 (org-freemind-goto-line node-at-line))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
730
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
731 ;; First get number of top nodes
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
732 (goto-char (point-min))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
733 (while (re-search-forward org-freemind-node-pattern nil t)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
734 (let* ((m1 (match-string-no-properties 1))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
735 (level (length m1)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
736 (if (= level 1)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
737 (setq num-top1-nodes (1+ num-top1-nodes))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
738 (if (= level 2)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
739 (setq num-top2-nodes (1+ num-top2-nodes))))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
740 ;; If there is more than one top node we need to insert a node
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
741 ;; to keep them together.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
742 (goto-char (point-min))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
743 (when (> num-top1-nodes 1)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
744 (setq num-top2-nodes num-top1-nodes)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
745 (setq current-level 0)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
746 (let ((orig-name (if buffer-file-name
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
747 (file-name-nondirectory (buffer-file-name))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
748 (buffer-name))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
749 (with-current-buffer mm-buffer
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
750 (insert "<node text=\"" orig-name "\" background_color=\"#00bfff\">\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
751 ;; Put a note that this is for the parent node
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
752 "<richcontent TYPE=\"NOTE\"><html>"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
753 "<head>"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
754 "</head>"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
755 "<body>"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
756 "<p>"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
757 org-freemind-org-nfix "WHOLE FILE"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
758 "</p>"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
759 "</body>"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
760 "</html>"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
761 "</richcontent>\n")))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
762
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
763 (setq num-left-nodes (floor num-top2-nodes 2))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
764 (setq base-level current-level)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
765 (let (this-m2
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
766 this-node-end
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
767 this-children-visible
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
768 next-m2
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
769 next-node-start
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
770 next-level
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
771 next-has-some-visible-child
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
772 next-children-visible
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
773 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
774 (while (and
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
775 (re-search-forward org-freemind-node-pattern nil t)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
776 (if node-at-line-last (<= (point) node-at-line-last) t)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
777 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
778 (let* ((next-m1 (match-string-no-properties 1))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
779 (next-node-end (match-end 0))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
780 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
781 (setq next-node-start (match-beginning 0))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
782 (setq next-m2 (match-string-no-properties 2))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
783 (setq next-level (length next-m1))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
784 (setq next-children-visible
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
785 (not (eq 'outline
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
786 (get-char-property (line-end-position) 'invisible))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
787 (setq next-has-some-visible-child
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
788 (if next-children-visible t
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
789 (org-freemind-look-for-visible-child next-level)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
790 (when this-m2
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
791 (setq num-left-nodes (org-freemind-write-node mm-buffer drawers-regexp num-left-nodes base-level current-level next-level this-m2 this-node-end this-children-visible next-node-start next-has-some-visible-child)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
792 (when (if (= num-top1-nodes 1) (> current-level base-level) t)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
793 (while (>= current-level next-level)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
794 (with-current-buffer mm-buffer
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
795 (insert "</node>\n")
107863
594e81986a75 2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107169
diff changeset
796 (setq current-level
594e81986a75 2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107169
diff changeset
797 (- current-level (if odd-only 2 1))))))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
798 (setq this-node-end (1+ next-node-end))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
799 (setq this-m2 next-m2)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
800 (setq current-level next-level)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
801 (setq this-children-visible next-children-visible)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
802 (forward-char)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
803 ))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
804 ;;; (unless (if node-at-line-last
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
805 ;;; (>= (point) node-at-line-last)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
806 ;;; nil)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
807 ;; Write last node:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
808 (setq this-m2 next-m2)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
809 (setq current-level next-level)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
810 (setq next-node-start (if node-at-line-last
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
811 (1+ node-at-line-last)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
812 (point-max)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
813 (setq num-left-nodes (org-freemind-write-node mm-buffer drawers-regexp num-left-nodes base-level current-level next-level this-m2 this-node-end this-children-visible next-node-start next-has-some-visible-child))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
814 (with-current-buffer mm-buffer (insert "</node>\n"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
815 ;)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
816 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
817 (with-current-buffer mm-buffer
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
818 (while (> current-level base-level)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
819 (insert "</node>\n")
107863
594e81986a75 2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107169
diff changeset
820 (setq current-level
594e81986a75 2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107169
diff changeset
821 (- current-level (if odd-only 2 1)))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
822 ))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
823 (with-current-buffer mm-buffer
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
824 (insert "</map>")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
825 (delete-trailing-whitespace)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
826 (goto-char (point-min))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
827 ))))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
828
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
829 (defun org-freemind-get-node-style (node-name)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
830 "NOT READY YET."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
831 ;;<node BACKGROUND_COLOR="#eeee00" CREATED="1234668815593" MODIFIED="1234668815593" STYLE="bubble">
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
832 ;;<font BOLD="true" NAME="SansSerif" SIZE="12"/>
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
833 (let (node-styles
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
834 node-style)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
835 (dolist (style-list org-freemind-node-style)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
836 (let ((node-regexp (car style-list)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
837 (message "node-regexp=%s node-name=%s" node-regexp node-name)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
838 (when (string-match-p node-regexp node-name)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
839 ;;(setq node-style (org-freemind-do-apply-node-style style-list))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
840 (setq node-style (cadr style-list))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
841 (when node-style
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
842 (message "node-style=%s" node-style)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
843 (setq node-styles (append node-styles node-style)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
844 )))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
845
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
846 (defun org-freemind-do-apply-node-style (style-list)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
847 (message "style-list=%S" style-list)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
848 (let ((node-style 'fork)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
849 (color "red")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
850 (background-color "yellow")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
851 (edge-color "green")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
852 (edge-style 'bezier)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
853 (edge-width 'thin)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
854 (italic t)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
855 (bold t)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
856 (font-name "SansSerif")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
857 (font-size 12))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
858 (dolist (style (cadr style-list))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
859 (message " style=%s" style)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
860 (let ((what (car style)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
861 (cond
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
862 ((eq what 'node-style)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
863 (setq node-style (cadr style)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
864 ((eq what 'color)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
865 (setq color (cadr style)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
866 ((eq what 'background-color)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
867 (setq background-color (cadr style)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
868
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
869 ((eq what 'edge-color)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
870 (setq edge-color (cadr style)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
871
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
872 ((eq what 'edge-style)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
873 (setq edge-style (cadr style)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
874
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
875 ((eq what 'edge-width)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
876 (setq edge-width (cadr style)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
877
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
878 ((eq what 'italic)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
879 (setq italic (cadr style)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
880
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
881 ((eq what 'bold)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
882 (setq bold (cadr style)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
883
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
884 ((eq what 'font-name)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
885 (setq font-name (cadr style)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
886
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
887 ((eq what 'font-size)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
888 (setq font-size (cadr style)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
889 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
890 (insert (format " style=\"%s\"" node-style))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
891 (insert (format " color=\"%s\"" color))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
892 (insert (format " background_color=\"%s\"" background-color))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
893 (insert ">\n")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
894 (insert "<edge")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
895 (insert (format " color=\"%s\"" edge-color))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
896 (insert (format " style=\"%s\"" edge-style))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
897 (insert (format " width=\"%s\"" edge-width))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
898 (insert "/>\n")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
899 (insert "<font")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
900 (insert (format " italic=\"%s\"" italic))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
901 (insert (format " bold=\"%s\"" bold))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
902 (insert (format " name=\"%s\"" font-name))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
903 (insert (format " size=\"%s\"" font-size))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
904 ))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
905
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
906 ;;;###autoload
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
907 (defun org-freemind-from-org-mode-node (node-line mm-file)
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
908 "Convert node at line NODE-LINE to the FreeMind file MM-FILE.
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
909 See `org-freemind-from-org-mode' for more information."
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
910 (interactive
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
911 (progn
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
912 (unless (org-back-to-heading nil)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
913 (error "Can't find org-mode node start"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
914 (let* ((line (line-number-at-pos))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
915 (default-mm-file (concat (if buffer-file-name
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
916 (file-name-nondirectory buffer-file-name)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
917 "nofile")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
918 "-line-" (number-to-string line)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
919 ".mm"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
920 (mm-file (read-file-name "Output FreeMind file: " nil nil nil default-mm-file)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
921 (list line mm-file))))
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
922 (when (org-freemind-check-overwrite mm-file (org-called-interactively-p 'any))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
923 (let ((org-buffer (current-buffer))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
924 (mm-buffer (find-file-noselect mm-file)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
925 (org-freemind-write-mm-buffer org-buffer mm-buffer node-line)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
926 (with-current-buffer mm-buffer
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
927 (basic-save-buffer)
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
928 (when (org-called-interactively-p 'any)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
929 (switch-to-buffer-other-window mm-buffer)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
930 (when (y-or-n-p "Show in FreeMind? ")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
931 (org-freemind-show buffer-file-name)))))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
932
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
933 ;;;###autoload
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
934 (defun org-freemind-from-org-mode (org-file mm-file)
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
935 "Convert the `org-mode' file ORG-FILE to the FreeMind file MM-FILE.
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
936 All the nodes will be opened or closed in Freemind just as you
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
937 have them in `org-mode'.
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
938
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
939 Note that exporting to Freemind also gives you an alternative way
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
940 to export from `org-mode' to html. You can create a dynamic html
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
941 version of the your org file, by first exporting to Freemind and
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
942 then exporting from Freemind to html. The 'As
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
943 XHTML (JavaScript)' version in Freemind works very well \(and you
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
944 can use a CSS stylesheet to style it)."
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
945 ;; Fix-me: better doc, include recommendations etc.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
946 (interactive
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
947 (let* ((org-file buffer-file-name)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
948 (default-mm-file (concat
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
949 (if org-file
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
950 (file-name-nondirectory org-file)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
951 "nofile")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
952 ".mm"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
953 (mm-file (read-file-name "Output FreeMind file: " nil nil nil default-mm-file)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
954 (list org-file mm-file)))
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
955 (when (org-freemind-check-overwrite mm-file (org-called-interactively-p 'any))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
956 (let ((org-buffer (if org-file (find-file-noselect org-file) (current-buffer)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
957 (mm-buffer (find-file-noselect mm-file)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
958 (org-freemind-write-mm-buffer org-buffer mm-buffer nil)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
959 (with-current-buffer mm-buffer
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
960 (basic-save-buffer)
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
961 (when (org-called-interactively-p 'any)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
962 (switch-to-buffer-other-window mm-buffer)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
963 (when (y-or-n-p "Show in FreeMind? ")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
964 (org-freemind-show buffer-file-name)))))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
965
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
966 ;;;###autoload
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
967 (defun org-freemind-from-org-sparse-tree (org-buffer mm-file)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
968 "Convert visible part of buffer ORG-BUFFER to FreeMind file MM-FILE."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
969 (interactive
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
970 (let* ((org-file buffer-file-name)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
971 (default-mm-file (concat
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
972 (if org-file
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
973 (file-name-nondirectory org-file)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
974 "nofile")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
975 "-sparse.mm"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
976 (mm-file (read-file-name "Output FreeMind file: " nil nil nil default-mm-file)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
977 (list (current-buffer) mm-file)))
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
978 (when (org-freemind-check-overwrite mm-file (org-called-interactively-p 'any))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
979 (let (org-buffer
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
980 (mm-buffer (find-file-noselect mm-file)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
981 (save-window-excursion
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
982 (org-export-visible ?\ nil)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
983 (setq org-buffer (current-buffer)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
984 (org-freemind-write-mm-buffer org-buffer mm-buffer nil)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
985 (with-current-buffer mm-buffer
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
986 (basic-save-buffer)
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
987 (when (org-called-interactively-p 'any)
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
988 (switch-to-buffer-other-window mm-buffer)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
989 (when (y-or-n-p "Show in FreeMind? ")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
990 (org-freemind-show buffer-file-name)))))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
991
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
992
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
993 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
994 ;;; FreeMind => Org
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
995
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
996 ;; (sort '(b a c) 'org-freemind-lt-symbols)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
997 (defun org-freemind-lt-symbols (sym-a sym-b)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
998 (string< (symbol-name sym-a) (symbol-name sym-b)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
999 ;; (sort '((b . 1) (a . 2) (c . 3)) 'org-freemind-lt-xml-attrs)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1000 (defun org-freemind-lt-xml-attrs (attr-a attr-b)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1001 (string< (symbol-name (car attr-a)) (symbol-name (car attr-b))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1002
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1003 ;; xml-parse-region gives things like
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1004 ;; ((p nil "\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1005 ;; (a
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1006 ;; ((href . "link"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1007 ;; "text")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1008 ;; "\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1009 ;; (b nil "hej")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1010 ;; "\n"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1011
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1012 ;; '(a . nil)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1013
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1014 ;; (org-freemind-symbols= 'a (car '(A B)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1015 (defsubst org-freemind-symbols= (sym-a sym-b)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1016 "Return t if downcased names of SYM-A and SYM-B are equal.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1017 SYM-A and SYM-B should be symbols."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1018 (or (eq sym-a sym-b)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1019 (string= (downcase (symbol-name sym-a))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1020 (downcase (symbol-name sym-b)))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1021
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1022 (defun org-freemind-get-children (parent path)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1023 "Find children node to PARENT from PATH.
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1024 PATH should be a list of steps, where each step has the form
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1025
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1026 '(NODE-NAME (ATTR-NAME . ATTR-VALUE))"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1027 ;; Fix-me: maybe implement op? step: Name, number, attr, attr op val
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1028 ;; Fix-me: case insensitive version for children?
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1029 (let* ((children (if (not (listp (car parent)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1030 (cddr parent)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1031 (let (cs)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1032 (dolist (p parent)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1033 (dolist (c (cddr p))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1034 (add-to-list 'cs c)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1035 cs)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1036 ))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1037 (step (car path))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1038 (step-node (if (listp step) (car step) step))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1039 (step-attr-list (when (listp step) (sort (cdr step) 'org-freemind-lt-xml-attrs)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1040 (path-tail (cdr path))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1041 path-children)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1042 (dolist (child children)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1043 ;; skip xml.el formatting nodes
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1044 (unless (stringp child)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1045 ;; compare node name
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1046 (when (if (not step-node)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1047 t ;; any node name
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1048 (org-freemind-symbols= step-node (car child)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1049 (if (not step-attr-list)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1050 ;;(throw 'path-child child) ;; no attr to care about
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1051 (add-to-list 'path-children child)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1052 (let* ((child-attr-list (cadr child))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1053 (step-attr-copy (copy-sequence step-attr-list)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1054 (dolist (child-attr child-attr-list)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1055 ;; Compare attr names:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1056 (when (org-freemind-symbols= (caar step-attr-copy) (car child-attr))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1057 ;; Compare values:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1058 (let ((step-val (cdar step-attr-copy))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1059 (child-val (cdr child-attr)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1060 (when (if (not step-val)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1061 t ;; any value
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1062 (string= step-val child-val))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1063 (setq step-attr-copy (cdr step-attr-copy))))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1064 ;; Did we find all?
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1065 (unless step-attr-copy
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1066 ;;(throw 'path-child child)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1067 (add-to-list 'path-children child)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1068 ))))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1069 (if path-tail
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1070 (org-freemind-get-children path-children path-tail)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1071 path-children)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1072
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1073 (defun org-freemind-get-richcontent-node (node)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1074 (let ((rc-nodes
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1075 (org-freemind-get-children node '((richcontent (type . "NODE")) html body))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1076 (when (> (length rc-nodes) 1)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1077 (lwarn t :warning "Unexpected structure: several <richcontent type=\"NODE\" ...>"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1078 (car rc-nodes)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1079
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1080 (defun org-freemind-get-richcontent-note (node)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1081 (let ((rc-notes
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1082 (org-freemind-get-children node '((richcontent (type . "NOTE")) html body))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1083 (when (> (length rc-notes) 1)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1084 (lwarn t :warning "Unexpected structure: several <richcontent type=\"NOTE\" ...>"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1085 (car rc-notes)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1086
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1087 (defun org-freemind-test-get-tree-text ()
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1088 (let ((node '(p nil "\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1089 (a
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1090 ((href . "link"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1091 "text")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1092 "\n"
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1093 (b nil "hej")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1094 "\n")))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1095 (org-freemind-get-tree-text node)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1096 ;; (org-freemind-test-get-tree-text)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1097
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1098 (defun org-freemind-get-tree-text (node)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1099 (when node
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1100 (let ((ntxt "")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1101 (link nil)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1102 (lf-after nil))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1103 (dolist (n node)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1104 (case n
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1105 ;;(a (setq is-link t) )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1106 ((h1 h2 h3 h4 h5 h6 p)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1107 ;;(setq ntxt (concat "\n" ntxt))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1108 (setq lf-after 2)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1109 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1110 (br
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1111 (setq lf-after 1)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1112 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1113 (t
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1114 (cond
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1115 ((stringp n)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1116 (when (string= n "\n") (setq n ""))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1117 (if link
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1118 (setq ntxt (concat ntxt
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1119 "[[" link "][" n "]]"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1120 (setq ntxt (concat ntxt n))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1121 ((and n (listp n))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1122 (if (symbolp (car n))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1123 (setq ntxt (concat ntxt (org-freemind-get-tree-text n)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1124 ;; This should be the attributes:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1125 (dolist (att-val n)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1126 (let ((att (car att-val))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1127 (val (cdr att-val)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1128 (when (eq att 'href)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1129 (setq link val)))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1130 )))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1131 (if lf-after
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1132 (setq ntxt (concat ntxt (make-string lf-after ?\n)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1133 (setq ntxt (concat ntxt " ")))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1134 ;;(setq ntxt (concat ntxt (format "{%s}" n)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1135 ntxt)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1136
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1137 (defun org-freemind-get-richcontent-node-text (node)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1138 "Get the node text as from the richcontent node NODE."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1139 (save-match-data
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1140 (let* ((rc (org-freemind-get-richcontent-node node))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1141 (txt (org-freemind-get-tree-text rc)))
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
1142 ;;(when txt (setq txt (replace-regexp-in-string "[[:space:]]+" " " txt)))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1143 txt
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1144 )))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1145
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1146 (defun org-freemind-get-richcontent-note-text (node)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1147 "Get the node text as from the richcontent note NODE."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1148 (save-match-data
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1149 (let* ((rc (org-freemind-get-richcontent-note node))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1150 (txt (when rc (org-freemind-get-tree-text rc))))
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
1151 ;;(when txt (setq txt (replace-regexp-in-string "[[:space:]]+" " " txt)))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1152 txt
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1153 )))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1154
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1155 (defun org-freemind-get-icon-names (node)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1156 (let* ((icon-nodes (org-freemind-get-children node '((icon ))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1157 names)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1158 (dolist (icn icon-nodes)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1159 (setq names (cons (cdr (assq 'builtin (cadr icn))) names)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1160 ;; (icon (builtin . "full-1"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1161 names))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1162
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1163 (defun org-freemind-node-to-org (node level skip-levels)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1164 (let ((qname (car node))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1165 (attributes (cadr node))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1166 text
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
1167 ;; Fix-me: note is never inserted
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1168 (note (org-freemind-get-richcontent-note-text node))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1169 (mark "-- This is more about ")
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1170 (icons (org-freemind-get-icon-names node))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1171 (children (cddr node)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1172 (when (< 0 (- level skip-levels))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1173 (dolist (attrib attributes)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1174 (case (car attrib)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1175 ('TEXT (setq text (cdr attrib)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1176 ('text (setq text (cdr attrib)))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1177 (unless text
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1178 ;; There should be a richcontent node holding the text:
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1179 (setq text (org-freemind-get-richcontent-node-text node)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1180 (when icons
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1181 (when (member "full-1" icons) (setq text (concat "[#A] " text)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1182 (when (member "full-2" icons) (setq text (concat "[#B] " text)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1183 (when (member "full-3" icons) (setq text (concat "[#C] " text)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1184 (when (member "full-4" icons) (setq text (concat "[#D] " text)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1185 (when (member "full-5" icons) (setq text (concat "[#E] " text)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1186 (when (member "full-6" icons) (setq text (concat "[#F] " text)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1187 (when (member "full-7" icons) (setq text (concat "[#G] " text)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1188 (when (member "button_cancel" icons) (setq text (concat "TODO " text)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1189 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1190 (if (and note
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1191 (string= mark (substring note 0 (length mark))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1192 (progn
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1193 (setq text (replace-regexp-in-string "\n $" "" text))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1194 (insert text))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1195 (case qname
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1196 ('node
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1197 (insert (make-string (- level skip-levels) ?*) " " text "\n")
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
1198 (when note
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
1199 (insert ":COMMENT:\n" note "\n:END:\n"))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1200 ))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1201 (dolist (child children)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1202 (unless (or (null child)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1203 (stringp child))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1204 (org-freemind-node-to-org child (1+ level) skip-levels)))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1205
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1206 ;; Fix-me: put back special things, like drawers that are stored in
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1207 ;; the notes. Should maybe all notes contents be put in drawers?
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1208 ;;;###autoload
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1209 (defun org-freemind-to-org-mode (mm-file org-file)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1210 "Convert FreeMind file MM-FILE to `org-mode' file ORG-FILE."
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1211 (interactive
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1212 (save-match-data
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1213 (let* ((mm-file (buffer-file-name))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1214 (default-org-file (concat (file-name-nondirectory mm-file) ".org"))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1215 (org-file (read-file-name "Output org-mode file: " nil nil nil default-org-file)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1216 (list mm-file org-file))))
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
1217 (when (org-freemind-check-overwrite org-file (org-called-interactively-p 'any))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1218 (let ((mm-buffer (find-file-noselect mm-file))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1219 (org-buffer (find-file-noselect org-file)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1220 (with-current-buffer mm-buffer
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1221 (let* ((xml-list (xml-parse-file mm-file))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1222 (top-node (cadr (cddar xml-list)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1223 (note (org-freemind-get-richcontent-note-text top-node))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1224 (skip-levels
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1225 (if (and note
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents: 107863
diff changeset
1226 (string-match "^--org-mode: WHOLE FILE$" note))
105973
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1227 1
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1228 0)))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1229 (with-current-buffer org-buffer
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1230 (erase-buffer)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1231 (org-freemind-node-to-org top-node 1 skip-levels)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1232 (goto-char (point-min))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1233 (org-set-tags t t) ;; Align all tags
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1234 )
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1235 (switch-to-buffer-other-window org-buffer)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1236 )))))
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1237
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1238 (provide 'org-freemind)
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1239
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1240 ;; arch-tag: e7b0d776-94fd-404a-b35e-0f855fae3627
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1241
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1242 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b7d8222914b4 2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1243 ;;; org-freemind.el ends here