Amy Grinn <grinn....@gmail.com> writes: > First of all, I would like to change (defalias) the function name > org-babel-noweb-wrap to org-babel-noweb-make-regexp. I think this in > more in line with other functions which create regular expressions.
+1 You may even use obsolete alias (add it to lisp/org-compat.el) > Second, the command org-babel-tangle-clean is not able to determine > which noweb syntax is being used in any tangled source file because the > header arguments are not tangled along with the source code. > > My proposal is to add an additional warning to this command, stating: > > """ > Warning, this command removes any lines containing constructs which > resemble Org file links or noweb references. It also cannot determine > which noweb syntax is being used for any given source file, if > :noweb-wrap was specified in the original Org file. > """ Makes sense. Ideally, this function should try to follow the link and lookup code block headers, but it is already short of doing this. Improving `org-babel-tangle-clean' is out of scope of your patch. > +(defun org-babel-get-noweb-wrap (&optional info) > + "Retrieve a description the :noweb-wrap header arg from INFO. > + > +The description will be in the form of a list of two of strings > +for the start and end of a reference. INFO can be the result of > +`org-babel-get-src-block-info' otherwise this function will parse > +info at point." > + (unless info > + (setq info (org-babel-get-src-block-info 'no-eval))) > + (when-let ((raw (cdr (assq :noweb-wrap (nth 2 info))))) > + (let (result) > + (with-temp-buffer Please, avoid creating throwaway buffers and work with strings instead. Creating buffers (even temporary buffers) may be costly for some users who heavily customized buffer hooks. > + (insert raw) > + (goto-char (point-min)) > + (while (< (point) (point-max)) > + (unless (looking-at " *\"\\([^\"]+\\)\" *") > + (looking-at " *\\([^ ]+\\)")) May you please explain the rationale behind this regexp? AFAIU, it implies that you want to allow whitespace characters inside :noweb-wrap boundaries. But I do not think that we need to complicate things so much. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>