Hello, I noticed that each time I reevaluate a Babel block, one blank line after its results disappears. This happens with both :results value and :results output when the result is long enough to become an example block (10 lines by default).
For example: #+begin_src emacs-lisp :results value (mapconcat #'number-to-string (number-sequence 1 10) "\n") #+end_src #+RESULTS: #+begin_example 1 2 3 4 5 6 7 8 9 10 #+end_example Following text. Reevaluating this block removes the blank lines before "Following text.", one at a time. When replacing the results, Babel deletes the old block, including the newline after "#+end_example". But org-babel-examplify-region only inserts a new newline if point is not at end of line. If a blank line follows, it uses that line's newline instead. The attached patch fixes this by inserting a new newline after the closing marker when the original region ends with a newline. Babel string results already end with a newline, so this preserves the blank lines after them. When the function is called manually on a region that excludes its following newline, the patch still reuses that newline, preserving the existing layout. It also ensures that the closing marker has a terminating newline at the end of the buffer. Thank you. -- Shigeaki Nishina
0001-lisp-ob-core.el-Preserve-blank-lines-after-example-r.patch
Description: Binary data
