diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2025-03-28 00:49:33 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2025-03-29 17:49:49 -0400 |
commit | 6bcf41c311b220e84f4eb423700f36ac1ddfffa7 (patch) | |
tree | 02691864aa0b9137f1f9af569bf70bcf1ac98515 /lisp/org/org-src.el | |
parent | 1d07a6d7e34677be1653b1d4d464ff00cabfa102 (diff) | |
download | emacs-6bcf41c311b220e84f4eb423700f36ac1ddfffa7.tar.gz emacs-6bcf41c311b220e84f4eb423700f36ac1ddfffa7.tar.bz2 emacs-6bcf41c311b220e84f4eb423700f36ac1ddfffa7.zip |
Org: Use new `replace-region-contents`
* lisp/org/org-compat.el (org-replace-buffer-contents): Delete function.
(org-replace-region-contents): New function.
* lisp/org/org-src.el (org-edit-src-save, org-edit-src-exit): Use it.
Diffstat (limited to 'lisp/org/org-src.el')
-rw-r--r-- | lisp/org/org-src.el | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/lisp/org/org-src.el b/lisp/org/org-src.el index 302c27ac866..d8a928b1f9f 100644 --- a/lisp/org/org-src.el +++ b/lisp/org/org-src.el @@ -1414,13 +1414,9 @@ EVENT is passed to `mouse-set-point'." ;; insert new contents. (delete-overlay overlay) (let ((expecting-bol (bolp))) - (if (version< emacs-version "27.1") - (progn (delete-region beg end) - (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) - (goto-char (point-max)))) + (goto-char end) + (org-replace-region-contents beg end write-back-buf 0.1 nil) + (cl-assert (= (point) (+ beg (buffer-size write-back-buf)))) (when (and expecting-bol (not (bolp))) (insert "\n"))) (kill-buffer write-back-buf) (save-buffer) @@ -1461,14 +1457,9 @@ EVENT is passed to `mouse-set-point'." (undo-boundary) (goto-char beg) (let ((expecting-bol (bolp))) - (if (version< emacs-version "27.1") - (progn (delete-region beg end) - (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) - (goto-char (point-max)))) + (goto-char end) + (org-replace-region-contents beg end write-back-buf 0.1 nil) + (cl-assert (= (point) (+ beg (buffer-size write-back-buf)))) (when (and expecting-bol (not (bolp))) (insert "\n"))))) (when write-back-buf (kill-buffer write-back-buf)) ;; If we are to return to source buffer, put point at an |