From 2e38ed36cb2f46df2d84e0566d0a5ddb9b90d7fe Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 30 Jun 2012 09:05:24 +0200 Subject: [PATCH] org-element: New syntax for export snippets * contrib/lisp/org-element.el (org-element-export-snippet-parser, org-element-export-snippet-interpreter, org-element-export-snippet-successor): Use "@@backend:contents@@" syntax. --- contrib/lisp/org-element.el | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/contrib/lisp/org-element.el b/contrib/lisp/org-element.el index 606ec4c97..9366dbca5 100644 --- a/contrib/lisp/org-element.el +++ b/contrib/lisp/org-element.el @@ -1899,17 +1899,12 @@ keywords. Assume point is at the beginning of the snippet." (save-excursion - (looking-at "<\\([-A-Za-z0-9]+\\)@") - (let* ((begin (point)) + (re-search-forward "@@\\([-A-Za-z0-9]+\\):" nil t) + (let* ((begin (match-beginning 0)) (back-end (org-match-string-no-properties 1)) - (inner-begin (match-end 0)) - (inner-end - (let ((count 1)) - (goto-char inner-begin) - (while (and (> count 0) (re-search-forward "[<>]" nil t)) - (if (equal (match-string 0) "<") (incf count) (decf count))) - (1- (point)))) - (value (buffer-substring-no-properties inner-begin inner-end)) + (value (buffer-substring-no-properties + (point) + (progn (re-search-forward "@@" nil t) (match-beginning 0)))) (post-blank (skip-chars-forward " \t")) (end (point))) `(export-snippet @@ -1922,7 +1917,7 @@ Assume point is at the beginning of the snippet." (defun org-element-export-snippet-interpreter (export-snippet contents) "Interpret EXPORT-SNIPPET object as Org syntax. CONTENTS is nil." - (format "<%s@%s>" + (format "@@%s:%s@@" (org-element-property :back-end export-snippet) (org-element-property :value export-snippet))) @@ -1931,18 +1926,14 @@ CONTENTS is nil." LIMIT bounds the search. -Return value is a cons cell whose CAR is `export-snippet' CDR is +Return value is a cons cell whose CAR is `export-snippet' and CDR its beginning position." (save-excursion - (catch 'exit - (while (re-search-forward "<[-A-Za-z0-9]+@" limit t) - (save-excursion - (let ((beg (match-beginning 0)) - (count 1)) - (while (re-search-forward "[<>]" limit t) - (if (equal (match-string 0) "<") (incf count) (decf count)) - (when (zerop count) - (throw 'exit (cons 'export-snippet beg)))))))))) + (let (beg) + (when (and (re-search-forward "@@[-A-Za-z0-9]+:" limit t) + (setq beg (match-beginning 0)) + (re-search-forward "@@" limit t)) + (cons 'export-snippet beg))))) ;;;; Footnote Reference