Hi Ihor,

I'm currently working on porting changes from Emacs's master branch to
Org's main.  In the process, I was reviewing d2e1c6789 (Use
`replace-region-contents' instead of `replace-buffer-contents',
2025-05-01) because it conflicts with one of the Emacs commits.

> diff --git a/lisp/org-src.el b/lisp/org-src.el
> index 6570b1b2a..d3f40cf35 100644
> --- a/lisp/org-src.el
> +++ b/lisp/org-src.el
> @@ -1420,7 +1420,7 @@ (defun org-edit-src-save ()
>                  (insert (with-current-buffer write-back-buf 
> (buffer-string))))
>         (save-restriction
>           (narrow-to-region beg end)
> -         (org-replace-buffer-contents write-back-buf 0.1 nil)
> +         (replace-region-contents beg end write-back-buf 0.1 nil)

Is it valid to pass a buffer as the third argument of
replace-region-contents on Emacs 30 or earlier?  If I understand
correctly, that capability came with Emacs's 7c82cc8b975 (2025-03-29).

For reference, the changes to org-edit-src-save on Emacs's side came in
6bcf41c311b (Org: Use new `replace-region-contents`, 2025-03-29).  I was
not planning to pull in that commit's changes without adjustments [*],
but it may be a good idea to follow that commit's general approach.

[*] ... at the very least, the changes from Org's 2d9e70b80
    (org-edit-src-*: When writing back, do not displace point in undo
    list, 2024-07-09) should be considered.  Plus, for compatibility, I
    think we'd want to keep org-replace-buffer-contents around but mark
    it as obsolete.

Reply via email to