org-babel-exp-process-buffer: Fix edge case when src block ends at eob

* lisp/ob-exp.el (org-babel-exp-process-buffer): When src block ends
at eob, do not leave the #+end_src behind after replacement.
This commit is contained in:
Ihor Radchenko 2024-06-13 17:26:02 +02:00
parent e4902995a0
commit a13d8fe83b
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 6 additions and 4 deletions

View File

@ -265,8 +265,9 @@ this template."
(if (not (eq type 'babel-call))
(progn (skip-chars-forward " \t")
(point))
(skip-chars-forward " \r\t\n")
(line-beginning-position)))))
(unless (eobp)
(skip-chars-forward " \r\t\n")
(line-beginning-position))))))
((not rep)
;; Replacement code cannot be determined.
;; Leave the code block as is.
@ -291,8 +292,9 @@ this template."
(cond ((not replacement) (goto-char end))
((equal replacement "")
(goto-char end)
(skip-chars-forward " \r\t\n")
(forward-line 0)
(unless (eobp)
(skip-chars-forward " \r\t\n")
(forward-line 0))
(delete-region begin (point)))
(t
(if (org-src-preserve-indentation-p element)