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