Ihor Radchenko writes: > I think that the existing code can be improved. Relying on the > undocumented behavior of (org-back-to-heading) is not ideal. Not to > mention code blocks before first headline. > > It would be great if you rewrite the existing code to suite both the > defaults and the proposed behavior.
Yes, I agree that this needs a more robust approach. Also, I've noticed that the patch I've proposed has a rather silly bug: replacing the second `match-end 0' with `match-beginning 0' naturally causes intermediate code blocks to be exported as comments (!). Returning it to `match-end 0' everything is OK, but the present approach is still tricky. I'm going to see if I can try something cleaner these days. Ideally, everything should be controlled from org-babel-process-comment-text... On the other hand, I have a curiosity. I understand that the behavior of the `:comments org' option should be left intact to ensure backwards compatibility. But I've always wondered if there is any use case where this value, as it behaves, might be practical. I don't quite understand how useful all the Org metadata in the comments of the tangled file can be. The expectation with `:comments org' is that only the content of the Org document will be rendered (as comments), but not its metadata, that all they do is unnecessarily fatten up the source file. I'm thinking, for example, of headers with lots of properties. or comment blocks, which would be visible in the tangled source file: ┌──── │ ;; Header │ ;; :PROPERTIES: │ ;; :A_LOT_OF: properties │ ;; :END: │ │ ;; #+begin_comment │ ;; Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit tempor tellus. │ ;; Donec pretium posuere tellus. Proin quam nisl, tincidunt et, mattis eget, convallis nec, │ ;; purus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus │ ;; mus. Nulla posuere. Donec vitae dolor. Nullam tristique diam non turpis. Cras placerat │ ;; accumsan nulla. Nullam rutrum. Nam vestibulum accumsan nisl. │ ;; #+end_comment └──── Best regards, Juan Manuel