From 68b65e8f480c17cfe1024001c236eb4065893f4d Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Fri, 24 Jul 2009 03:16:19 +0200 Subject: [PATCH] org-get-file-contents: Use a new argument: markup. When markup is passed to org-get-file-contents then this function does not protect org-like lines, since the exporter should handle them. --- lisp/ChangeLog | 4 ++++ lisp/org-exp.el | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a1be9561d..6c1e25b62 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2009-07-24 Bastien Guerry + * org-exp.el (org-get-file-contents): Use a new argument: markup. + When present, tell org-get-file-contents not to protect org-like + lines. + * org-id.el (org-id-uuid-program): New option to set the name of the uuidgen program. (org-id-method): Use `org-id-uuid-program'. diff --git a/lisp/org-exp.el b/lisp/org-exp.el index e0ab7a2bd..280b1f4e8 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -2093,14 +2093,16 @@ TYPE must be a string, any of: (setq start (format "#+begin_%s %s\n" markup switches) end (format "#+end_%s" markup)))) (insert (or start "")) - (insert (org-get-file-contents (expand-file-name file) prefix prefix1)) + (insert (org-get-file-contents (expand-file-name file) prefix prefix1 markup)) (or (bolp) (newline)) (insert (or end "")))))) -(defun org-get-file-contents (file &optional prefix prefix1) +(defun org-get-file-contents (file &optional prefix prefix1 markup) "Get the contents of FILE and return them as a string. If PREFIX is a string, prepend it to each line. If PREFIX1 -is a string, prepend it to the first line instead of PREFIX." +is a string, prepend it to the first line instead of PREFIX. +If MARKUP, don't protect org-like lines, the exporter will +take care of the block they are in." (with-temp-buffer (insert-file-contents file) (when (or prefix prefix1) @@ -2110,11 +2112,12 @@ is a string, prepend it to the first line instead of PREFIX." (setq prefix1 nil) (beginning-of-line 2))) (buffer-string) - (goto-char (point-min)) - (while (re-search-forward "^\\(\\*\\|[ \t]*#\\)" nil t) - (goto-char (match-beginning 0)) - (insert ",") - (end-of-line 1)) + (unless markup + (goto-char (point-min)) + (while (re-search-forward "^\\(\\*\\|[ \t]*#\\)" nil t) + (goto-char (match-beginning 0)) + (insert ",") + (end-of-line 1))) (buffer-string))) (defun org-get-and-remove-property (listvar prop) -- 2.11.4.GIT