diff --git a/lisp/org-freemind.el b/lisp/org-freemind.el index 07b57746e..2d0bed83d 100644 --- a/lisp/org-freemind.el +++ b/lisp/org-freemind.el @@ -5,7 +5,7 @@ ;; Author: Lennart Borgman (lennart O borgman A gmail O com) ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.33 +;; Version: 6.32trans ;; ;; This file is part of GNU Emacs. ;; @@ -55,7 +55,6 @@ ;; 2009-02-21: Fixed bug in `org-freemind-to-org-mode'. ;; 2009-10-25: Added support for `org-odd-levels-only'. ;; Added y/n question before showing in FreeMind. -;; 2009-11-04: Added support for #+BEGIN_HTML. ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -192,7 +191,6 @@ NOT READY YET." filename)) (t (org-freemind-from-org-mode bfname filename))))) - ;;;###autoload (defun org-freemind-show (mm-file) "Show file MM-FILE in Freemind." @@ -219,8 +217,6 @@ NOT READY YET." ;;; Format converters (defun org-freemind-escape-str-from-org (org-str) - "Do some html-escaping of ORG-STR and return the result. -The characters \"&<> will be escaped." (let ((chars (append org-str nil)) (fm-str "")) (dolist (cc chars) @@ -245,20 +241,17 @@ The characters \"&<> will be escaped." fm-str)) (defun org-freemind-unescape-str-to-org (fm-str) - "Do some html-unescaping of FM-STR and return the result. -This is the opposite of `org-freemind-escape-str-from-org' but it -will also unescape &#nn;." (let ((org-str fm-str)) (setq org-str (replace-regexp-in-string """ "\"" org-str)) (setq org-str (replace-regexp-in-string "&" "&" org-str)) (setq org-str (replace-regexp-in-string "<" "<" org-str)) (setq org-str (replace-regexp-in-string ">" ">" org-str)) (setq org-str (replace-regexp-in-string - "&#x\\([a-f0-9]\\{2\\}\\);" - (lambda (m) - (char-to-string (+ (string-to-number (match-string 1 org-str) 16) - ?\x800))) - org-str)))) + "&#x\\([a-f0-9]\\{2\\}\\);" + (lambda (m) + (char-to-string (+ (string-to-number (match-string 1 str) 16) + ?\x800))) + org-str)))) ;; (org-freemind-test-escape) ;; (defun org-freemind-test-escape () @@ -271,7 +264,6 @@ will also unescape &#nn;." ;; )) (defun org-freemind-convert-links-from-org (org-str) - "Convert org links in ORG-STR to freemind links and return the result." (let ((fm-str (replace-regexp-in-string (rx (not (any "[\"")) (submatch @@ -292,7 +284,6 @@ will also unescape &#nn;." ;;(org-freemind-convert-links-to-org "link-text") (defun org-freemind-convert-links-to-org (fm-str) - "Convert freemind links in FM-STR to org links and return the result." (let ((org-str (replace-regexp-in-string (rx " FreeMind -(defun org-freemind-convert-text-p (text) - (setq text (org-freemind-escape-str-from-org text)) - (setq text (replace-regexp-in-string (rx "\n" (0+ blank) "\n") "

\n" text)) - ;;(setq text (replace-regexp-in-string (rx bol (1+ blank) eol) "" text)) - ;;(setq text (replace-regexp-in-string (rx bol (1+ blank)) "
" text)) - (setq text (replace-regexp-in-string "\n" "
" text)) - (concat "

" - (org-freemind-convert-links-from-org text) - "

\n")) - -(defun org-freemind-org-text-to-freemind-subnode/note (node-name start end drawers-regexp) - "Convert text part of org node to freemind subnode or note. -Convert the text part of the org node named NODE-NAME. The text -is in the current buffer between START and END. Drawers matching -DRAWERS-REGEXP are converted to freemind notes." +(defun org-freemind-org-text-to-freemind-subnode/note (node-name start end) ;; fix-me: doc (let ((text (buffer-substring-no-properties start end)) (node-res "") (note-res "")) (save-match-data - ;;(setq text (org-freemind-escape-str-from-org text)) + (setq text (org-freemind-escape-str-from-org text)) ;; First see if there is something that should be moved to the ;; note part: (let (drawers) @@ -391,30 +367,14 @@ DRAWERS-REGEXP are converted to freemind notes." "\n" "\n" "\n")) - (let ((begin-html-mark (regexp-quote "#+BEGIN_HTML")) - (end-html-mark (regexp-quote "#+END_HTML")) - head - end-pos - end-pos-match - ) - ;; Take care of #+BEGIN_HTML - #+END_HTML - (while (string-match begin-html-mark text) - (setq head (substring text 0 (match-beginning 0))) - (setq end-pos-match (match-end 0)) - (setq node-res (concat node-res - (org-freemind-convert-text-p head))) - (setq text (substring text end-pos-match)) - (setq end-pos (string-match end-html-mark text)) - (if end-pos - (setq end-pos-match (match-end 0)) - (message "org-freemind: Missing #+END_HTML") - (setq end-pos (length text)) - (setq end-pos-match end-pos)) - (setq node-res (concat node-res - (substring text 0 end-pos))) - (setq text (substring text end-pos-match))) - (setq node-res (concat node-res - (org-freemind-convert-text-p text)))) + (setq node-res (concat node-res "

")) + (setq text (replace-regexp-in-string (rx "\n" (0+ blank) "\n") "

\n" text)) + ;;(setq text (replace-regexp-in-string (rx bol (1+ blank) eol) "" text)) + ;;(setq text (replace-regexp-in-string (rx bol (1+ blank)) "
" text)) + (setq text (replace-regexp-in-string "\n" "
" text)) + (org-freemind-convert-links-from-org text) + (setq node-res (concat node-res text)) + (setq node-res (concat node-res "

\n")) (setq node-res (concat node-res "\n" @@ -435,16 +395,7 @@ DRAWERS-REGEXP are converted to freemind notes." ))) (list node-res note-res)))) -(defun org-freemind-write-node (this-m2 - this-node-end - drawers-regexp - next-has-some-visible-child - this-children-visible - mm-buffer - num-nodes-left - next-level - current-level - base-level) +(defun org-freemind-write-node (this-m2 this-node-end) (let* (this-icons this-bg-color this-m2-escaped @@ -482,9 +433,7 @@ DRAWERS-REGEXP are converted to freemind notes." (setq this-m2-escaped (org-freemind-escape-str-from-org this-m2)) (let ((node-notes (org-freemind-org-text-to-freemind-subnode/note this-m2-escaped - this-node-end (1- next-node-start) - drawers-regexp - ))) + this-node-end (1- next-node-start)))) (setq this-rich-node (nth 0 node-notes)) (setq this-rich-note (nth 1 node-notes))) (with-current-buffer mm-buffer @@ -496,8 +445,8 @@ DRAWERS-REGEXP are converted to freemind notes." next-has-some-visible-child) (insert " folded=\"true\""))) (when (and (= current-level (1+ base-level)) - (> num-nodes-left 0)) - (setq num-nodes-left (1- num-nodes-left)) + (> num-left-nodes 0)) + (setq num-left-nodes (1- num-left-nodes)) (insert " position=\"left\"")) (when this-bg-color (insert " background_color=\"" this-bg-color "\"")) @@ -513,13 +462,6 @@ DRAWERS-REGEXP are converted to freemind notes." )) (defun org-freemind-check-overwrite (file interactively) - "Check if file FILE already exists. -If FILE does not exists return t. - -If INTERACTIVELY is non-nil ask if the file should be replaced -and return t/nil if it should/should not be replaced. - -Otherwise give an error say the file exists." (if (file-exists-p file) (if interactively (y-or-n-p (format "File %s exists, replace it? " file)) @@ -548,7 +490,6 @@ Otherwise give an error say the file exists." )))) (defun org-freemind-goto-line (line) - "Go to line number LINE." (save-restriction (widen) (goto-char (point-min)) @@ -565,7 +506,7 @@ Otherwise give an error say the file exists." drawers-regexp (num-top1-nodes 0) (num-top2-nodes 0) - num-nodes-left + num-left-nodes (unclosed-nodes 0) (first-time t) (current-level 1) @@ -656,7 +597,7 @@ Otherwise give an error say the file exists." "" "\n"))))) - (setq num-nodes-left (floor num-top2-nodes 2)) + (setq num-left-nodes (floor num-top2-nodes 2)) (setq base-level current-level) (let (this-m2 this-node-end @@ -685,11 +626,7 @@ Otherwise give an error say the file exists." (setq skipped-odd (1+ skipped-odd))) (unless (or (= next-level (1+ current-level)) skipping-odd) - (if (or org-odd-levels-only - (/= next-level (+ 2 current-level))) - (error "Next level step > +1 for node ending at line %s" (line-number-at-pos)) - (error "Next level step = +2 for node ending at line %s, forgot org-odd-levels-only?" - (line-number-at-pos))) + (error "Next level step > +1 for node ending at line %s" (line-number-at-pos)) )) (setq next-children-visible (not (eq 'outline @@ -698,7 +635,7 @@ Otherwise give an error say the file exists." (if next-children-visible t (org-freemind-look-for-visible-child next-level))) (when this-m2 - (org-freemind-write-node this-m2 this-node-end drawers-regexp next-has-some-visible-child this-children-visible mm-buffer num-nodes-left next-level current-level base-level)) + (org-freemind-write-node this-m2 this-node-end)) (when (if (= num-top1-nodes 1) (> current-level base-level) t) (while (>= current-level next-level) (with-current-buffer mm-buffer @@ -724,7 +661,7 @@ Otherwise give an error say the file exists." (setq next-node-start (if node-at-line-last (1+ node-at-line-last) (point-max))) - (org-freemind-write-node this-m2 this-node-end drawers-regexp next-has-some-visible-child this-children-visible mm-buffer num-nodes-left next-level current-level base-level) + (org-freemind-write-node this-m2 this-node-end) (with-current-buffer mm-buffer (insert "\n")) ;) ) @@ -916,8 +853,6 @@ Otherwise give an error say the file exists." ;; (org-freemind-symbols= 'a (car '(A B))) (defsubst org-freemind-symbols= (sym-a sym-b) - "Return t if downcased names of SYM-A and SYM-B are equal. -SYM-A and SYM-B should be symbols." (or (eq sym-a sym-b) (string= (downcase (symbol-name sym-a)) (downcase (symbol-name sym-b))))) @@ -926,7 +861,8 @@ SYM-A and SYM-B should be symbols." "Find children node to PARENT from PATH. PATH should be a list of steps, where each step has the form - '(NODE-NAME (ATTR-NAME . ATTR-VALUE))" + '(NODE-NAME (ATTR-NAME . ATTR-VALUE)) +" ;; Fix-me: maybe implement op? step: Name, number, attr, attr op val ;; Fix-me: case insensitive version for children? (let* ((children (if (not (listp (car parent))) @@ -1038,7 +974,7 @@ PATH should be a list of steps, where each step has the form ntxt))) (defun org-freemind-get-richcontent-node-text (node) - "Get the node text as from the richcontent node NODE." + "Get the node text as from the richcontent note NODE." (save-match-data (let* ((rc (org-freemind-get-richcontent-node node)) (txt (org-freemind-get-tree-text rc))) @@ -1136,8 +1072,8 @@ PATH should be a list of steps, where each step has the form ))))) (provide 'org-freemind) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; arch-tag: e7b0d776-94fd-404a-b35e-0f855fae3627 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; org-freemind.el ends here