diff --git a/doc/org.texi b/doc/org.texi index 9205abb..876f673 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -15042,30 +15042,6 @@ references will be removed when the code block is exported. expanded before the block is evaluated. @end itemize -@subsubheading Noweb prefix lines -Noweb insertions are now placed behind the line prefix of the -@code{<>}. -This behavior is illustrated in the following example. Because the -@code{<>} noweb reference appears behind the SQL comment syntax, -each line of the expanded noweb reference will be commented. - -This code block: - -@example --- <> -@end example - -expands to: - -@example --- this is the --- multi-line body of example -@end example - -Note that noweb replacement text that does not contain any newlines will not -be affected by this change, so it is still possible to use inline noweb -references. - @node noweb-ref @subsubsection @code{:noweb-ref} @cindex @code{:noweb-ref}, src header argument diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 0adfc33..1ae16d7 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -2536,34 +2536,23 @@ block but are passed literally to the \"example-block\"." (comment (string= "noweb" (cdr (assoc :comments (nth 2 info))))) (rx-prefix (concat "\\(" org-babel-src-name-regexp "\\|" ":noweb-ref[ \t]+" "\\)")) - (new-body "") - (nb-add (lambda (text) (setq new-body (concat new-body text)))) (c-wrap (lambda (text) (with-temp-buffer (funcall (intern (concat lang "-mode"))) (comment-region (point) (progn (insert text) (point))) (org-babel-trim (buffer-string))))) - index source-name evaluate prefix) + source-name evaluate prefix) (with-temp-buffer (org-set-local 'org-babel-noweb-wrap-start ob-nww-start) (org-set-local 'org-babel-noweb-wrap-end ob-nww-end) (insert body) (goto-char (point-min)) - (setq index (point)) - (while (and (re-search-forward (org-babel-noweb-wrap) nil t)) + (while (re-search-forward (org-babel-noweb-wrap) nil t) + (goto-char (match-beginning 0)) (save-match-data (setf source-name (match-string 1))) (save-match-data (setq evaluate (string-match "\(.*\)" source-name))) - (save-match-data - (setq prefix - (buffer-substring (match-beginning 0) - (save-excursion - (beginning-of-line 1) (point))))) - ;; add interval to new-body (removing noweb reference) - (goto-char (match-beginning 0)) - (funcall nb-add (buffer-substring index (point))) - (goto-char (match-end 0)) - (setq index (point)) - (funcall - nb-add + (save-match-data (setq prefix (make-string (current-column) ?\s))) + (delete-region (point) (match-end 0)) + (insert (with-current-buffer parent-buffer (save-restriction (widen) @@ -2625,8 +2614,7 @@ block but are passed literally to the \"example-block\"." "`org-babel-noweb-error-langs')")) ""))) "[\n\r]") (concat "\n" prefix)))))) - (funcall nb-add (buffer-substring index (point-max)))) - new-body)) + (buffer-string)))) (defun org-babel-script-escape (str &optional force) "Safely convert tables into elisp lists."