emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sébastien Miquel" <sebastien.miquel@posteo.eu>
To: Michael Gauland <mikelygee@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: [PATCH] source blocks mangled when edited
Date: Tue,  1 Jun 2021 08:20:15 +0000	[thread overview]
Message-ID: <2699cddd-69b1-0f46-47bb-0b450873ea7c@posteo.eu> (raw)
In-Reply-To: <0dd1fbfe-8718-af8b-dbab-2818d504590d@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 736 bytes --]

Michael Gauland writes:
> This is all the*trace-output*  buffer shows:
>
> ======================================================================
> 1 -> (replace-buffer-contents #<buffer*org-src-write-back*>)
> 1 <- replace-buffer-contents: nil
Indeed, the `replace-buffer-contents` call is failing.

I've been able to reproduce with earlier versions of emacs 26.1. With
later versions of emacs 26, the problem goes away.

It seems earlier versions of `replace-buffer-contents` are not quite
reliable. It was patched prior to 27.1 and the new documentation
string makes some guarantees of correctness, so let's just change the
minimal version to 27.1.

Thank you for the report.

Regards,

-- 
Sébastien Miquel

X-Woof-Bug: confirmed


[-- Attachment #2: 0001-org-src.el-Use-replace-buffer-contents-only-for-emac.patch --]
[-- Type: text/x-patch, Size: 1976 bytes --]

From 8ebdbc5eca92de4429d3994a3663d8aa3b9877fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miquel@posteo.eu>
Date: Tue, 1 Jun 2021 08:56:48 +0200
Subject: [PATCH] org-src.el: Use `replace-buffer-contents' only for emacs >=
 27

* lisp/org-src.el: Use `replace-buffer-contents' only for emacs >= 27.

It was introduced in emacs 26.1, but earlier versions made no
guarantees of correctness.
---
 lisp/org-src.el | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 79f002e56..4698c6dd2 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -1199,12 +1199,12 @@ Throw an error if there is no such buffer."
       ;; insert new contents.
       (delete-overlay overlay)
       (let ((expecting-bol (bolp)))
-	(if (version< emacs-version "26.1")
+	(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)
-	      (replace-buffer-contents write-back-buf)
+	      (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)
@@ -1246,13 +1246,13 @@ Throw an error if there is no such buffer."
        (undo-boundary)
        (goto-char beg)
        (let ((expecting-bol (bolp)))
-	 (if (version< emacs-version "26.1")
+	 (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)
-	       (replace-buffer-contents write-back-buf)
+	       (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))
-- 
2.31.1


  reply	other threads:[~2021-06-01  8:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-31  3:39 source blocks mangled when edited Michael Gauland
2021-05-31  4:21 ` Samuel Wales
2021-05-31  8:01   ` Michael Gauland
2021-05-31  8:15 ` Sébastien Miquel
2021-05-31  8:54   ` Michael Gauland
2021-05-31  9:42     ` Sébastien Miquel
2021-05-31 10:02       ` Michael Gauland
2021-06-01  8:20         ` Sébastien Miquel [this message]
2021-06-27 13:54           ` [PATCH] " Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2699cddd-69b1-0f46-47bb-0b450873ea7c@posteo.eu \
    --to=sebastien.miquel@posteo.eu \
    --cc=emacs-orgmode@gnu.org \
    --cc=mikelygee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).