Backport from main: Fix compatibility with Emacs 26

* lisp/org-compat.el (org-replace-buffer-contents): Add compatibility
function for `replace-buffer-contents'.

* lisp/org-src.el (org-edit-src-save, org-edit-src-exit): Use
`org-replace-buffer-contents'.
This commit is contained in:
Ihor Radchenko 2021-10-17 14:34:10 +08:00
parent a0a078049b
commit 1c3a46268f
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 7 additions and 2 deletions

View File

@ -113,6 +113,11 @@ the symbol of the calling function, for example."
;;; Emacs < 27.1 compatibility
(if (version< emacs-version "27.1")
(defsubst org-replace-buffer-contents (source &optional _max-secs _max-costs)
(replace-buffer-contents source))
(defalias 'org-replace-buffer-contents #'replace-buffer-contents))
(unless (fboundp 'proper-list-p)
;; `proper-list-p' was added in Emacs 27.1. The function below is
;; taken from Emacs subr.el 200195e824b^.

View File

@ -1235,7 +1235,7 @@ Throw an error if there is no such buffer."
(insert (with-current-buffer write-back-buf (buffer-string))))
(save-restriction
(narrow-to-region beg end)
(replace-buffer-contents write-back-buf 0.1 nil)
(org-replace-buffer-contents write-back-buf 0.1 nil)
(goto-char (point-max))))
(when (and expecting-bol (not (bolp))) (insert "\n")))
(kill-buffer write-back-buf)
@ -1283,7 +1283,7 @@ Throw an error if there is no such buffer."
(buffer-string))))
(save-restriction
(narrow-to-region beg end)
(replace-buffer-contents write-back-buf 0.1 nil)
(org-replace-buffer-contents write-back-buf 0.1 nil)
(goto-char (point-max))))
(when (and expecting-bol (not (bolp))) (insert "\n")))))
(when write-back-buf (kill-buffer write-back-buf))