mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-26 07:33:39 +00:00
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.
This commit is contained in:
parent
0e7f2d6e26
commit
3d25553588
@ -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)))))
|
||||
|
||||
|
20
lisp/ob.el
20
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')"))
|
||||
"")))
|
||||
|
Loading…
Reference in New Issue
Block a user