Hi Nicolas, I've included the simplest patch I could come up with for the divergence in behavior between org-babel-tangle-single-file and org-link-search. I think there are two new threads that I need to create. One is related to how to make it possible to specify what should be removed along with the coderef (i.e. coderef prefix), the other is the addition of header arguments that provide the same functionality as switches. Best, Tom > This is already conflating the two. I'd like to solve the issue at hand > without having header args interfere at all. > > This can happen later, after a discussion on the ML. Ok. I've included the simplest version of the fix, which is to use org-src-coderef-regexp in org-babel-tangle-single-file. > Would you mind answering my questions first? I still don't follow you > about the coderef prefix/regexp. https://code.orgmode.org/bzg/org-mode/src/2d78ea57cfad1ddc3e993c949daf117b76315170/lisp/org-src.el#L882 That line defines a hardcoded regular expression for matching coderefs. The codref prefix is the first =[ \t]*= and the coderef regexp is the equivalent to the fully formatted version of that format string. Neither of those can currently be specified by the user. The user should not be able to specify the coderef regexp due to the fact that it is too easy to specify a regexp that will not work correctly and because the format string is needed to make org-link-search work for named coderefs (otherwise you wind up trying to replace .+ in the coderef regexp which is a nightmare). The coderef prefix is something that should probably be configurable by the user so that empty comments are not left in the file. I also looked into detecting the comment character for the language in question, but that is significantly more difficult even using (with-temp-buffer (funcall lang-mode) comment-start) because not all languages have sane comment start values and comment-start is not complete, so we would need a way to manually specify what to exclude anyway.