summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <eric.schulte@gmx.com>2012-01-27 16:04:09 -0700
committerEric Schulte <eric.schulte@gmx.com>2012-01-27 16:04:09 -0700
commit3d255535886bb4bae8114f37ebbad11597dd58d6 (patch)
tree124b7a1c4d5695fec37b764a2964c4b794394cb6
parent0e7f2d6e263a15e383e5db97dc297bf7767999f7 (diff)
downloadorg-mode-3d255535886bb4bae8114f37ebbad11597dd58d6.tar.gz
allow customization of the noweb reference syntax
Thanks to Sean O'Halpin for suggesting this change. * lisp/ob-tangle.el (org-babel-tangle-clean): Use the customizable noweb wrappers. * lisp/ob.el (org-babel-noweb-wrap-start): Begin a noweb reference. (org-babel-noweb-wrap-end): End a noweb reference. (org-babel-noweb-wrap): Apply the customizable noweb wrappers. (org-babel-expand-noweb-references): Use the customizable noweb wrappers.
-rw-r--r--lisp/ob-tangle.el2
-rw-r--r--lisp/ob.el20
2 files changed, 19 insertions, 3 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index d7c4d7e..cf507c0 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -281,7 +281,7 @@ references."
(interactive)
(goto-char (point-min))
(while (or (re-search-forward "\\[\\[file:.*\\]\\[.*\\]\\]" nil t)
- (re-search-forward "<<[^[:space:]]*>>" nil t))
+ (re-search-forward (org-babel-noweb-wrap "[^[:space:]]*") nil t))
(delete-region (save-excursion (beginning-of-line 1) (point))
(save-excursion (end-of-line 1) (forward-char 1) (point)))))
diff --git a/lisp/ob.el b/lisp/ob.el
index 70c258f..62969ec 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -120,6 +120,21 @@ be used."
:group 'org-babel
:type 'string)
+(defcustom org-babel-noweb-wrap-start "<<"
+ "String used to begin a noweb reference in a code block.
+See also `org-babel-noweb-wrap-end'."
+ :group 'org-babel
+ :type 'string)
+
+(defcustom org-babel-noweb-wrap-end ">>"
+ "String used to end a noweb reference in a code block.
+See also `org-babel-noweb-wrap-start'."
+ :group 'org-babel
+ :type 'string)
+
+(defun org-babel-noweb-wrap (regexp)
+ (concat org-babel-noweb-wrap-start regexp org-babel-noweb-wrap-end))
+
(defvar org-babel-src-name-regexp
"^[ \t]*#\\+name:[ \t]*"
"Regular expression used to match a source name line.")
@@ -2163,7 +2178,8 @@ block but are passed literally to the \"example-block\"."
(with-temp-buffer
(insert body) (goto-char (point-min))
(setq index (point))
- (while (and (re-search-forward "<<\\([^ \t].+?[^ \t]\\|[^ \t]\\)>>"
+ (while (and (re-search-forward (org-babel-noweb-wrap
+ "\\([^ \t].+?[^ \t]\\|[^ \t]\\)")
nil t))
(save-match-data (setf source-name (match-string 1)))
(save-match-data (setq evaluate (string-match "\(.*\)" source-name)))
@@ -2234,7 +2250,7 @@ block but are passed literally to the \"example-block\"."
;; possibly raise an error if named block doesn't exist
(if (member lang org-babel-noweb-error-langs)
(error "%s" (concat
- "<<" source-name ">> "
+ (org-babel-noweb-wrap source-name)
"could not be resolved (see "
"`org-babel-noweb-error-langs')"))
"")))