From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [BUG] in Release 8.2 - editing code in indirect buffer Date: Tue, 24 Sep 2013 18:02:36 +0200 Message-ID: <220E3767-24DA-494B-9512-9C4DA30CEA43@gmail.com> References: <8F09B93E-FC4D-48B8-A9AB-3EDC0D81EEEF@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Content-Type: multipart/signed; boundary="Apple-Mail=_2596802B-6CAC-4B5A-985A-C66EECD861E4"; protocol="application/pgp-signature"; micalg=pgp-sha1 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOV5Q-0004x4-17 for emacs-orgmode@gnu.org; Tue, 24 Sep 2013 12:03:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VOV5K-0001QL-5T for emacs-orgmode@gnu.org; Tue, 24 Sep 2013 12:03:39 -0400 Received: from mail-bk0-x230.google.com ([2a00:1450:4008:c01::230]:41169) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOV5J-0001QF-Tw for emacs-orgmode@gnu.org; Tue, 24 Sep 2013 12:03:34 -0400 Received: by mail-bk0-f48.google.com with SMTP id my13so1751541bkb.21 for ; Tue, 24 Sep 2013 09:03:32 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Rainer M Krug Cc: Carsten Neumann , emacs-orgmode@gnu.org --Apple-Mail=_2596802B-6CAC-4B5A-985A-C66EECD861E4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi Rainer, hi Carsten, it does not get lost - it is in my queue. As are, unfortunately, = another 35 threads with possible bugs. Help is definitely wanted. Please see below for my comments and a possible fix. On 23.9.2013, at 09:40, Rainer M Krug wrote: > I just resend this bug report which has been confirmed by Ista Zahn. >=20 > Updated via git ust now: >=20 > Org-mode version 8.2 (release_8.2-14-ge5f16b @ > /Users/rainerkrug/.emacs.d/org-mode/lisp/) >=20 >=20 > When starting to edit a code block via C-c ' everything works as = expected > and the code block is highlighted and an indirect buffer is opened. >=20 > When I click into the highlighted block, I an "send" to the indirect > buffer. This behavior changes, after saving with C-s, even when = nothing > has been edited: the area in the original org file looses its magic, = and > looks normal again and can also be edited!=20 >=20 > The indirect buffer stays functional and, upon close via C-c ' saves = the > changes into the original buffer and *overwrites* changes done in this > block in the org document. This is a bug which is difficult to fix in all generality. What should = really happen is that the text in the original buffer is made read-only. = But so far this does not happen in our implementation (due to Dan = Davison IIRC). The reason for this is that read-only text properties = left by accident in a buffer are difficult to get rid of.=20 There are many things the user could go back and screw up the original. = That's why Org choses to protect with highlighting with an overlay. = Note that this is not a protection against editing, but it is a visual = warning. However, what happens during saving is indeed a problem - the overlay = gets lost (not really, it gets squeezed to zero by first removing the = source code and then inserting the modified version). =20 Could you please try this patch and test it to see if it is stable and = does the right thing? Thank you. - Carsten diff --git a/lisp/org-src.el b/lisp/org-src.el index 0f88174..062d2d7 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -757,6 +757,8 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"." (delete-region beg (max beg end)) (unless (string-match "\\`[ \t]*\\'" code) (insert code)) + ;; Make sure the overlay stays in place + (when (eq context 'save) (move-overlay ovl beg (point))) (goto-char beg) (if single (just-one-space)))) (if (memq t (mapcar (lambda (overlay) --Apple-Mail=_2596802B-6CAC-4B5A-985A-C66EECD861E4 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJSQbecAAoJEO+gg/nAZuwMascH/jJQXTPuIh0e9+sBN6FuuQ/L 8F4gK3is3+PRw1VXpkz5p5xseU2wx3jjrXbLHWEhEkKMqxSJNQNyLOvFPmPV/EP4 8ktrs6IWn18DqkRrvWmBA0ti1sish7jWz6YbdGrSo2bPm31XEE79L44kVW3MiB9F LkGGku/q3cIuPfzvUDTEAryZDNhZIRl1GO83DYNLtda4AUL+/U3fN1dCc4e2wtDW 6VmobBAiWfpu3Uxa3LVCBOlDeC8FLo27JOsjUh0ngZ+JgPCr8GlmdfJbIXDPeyjo JLr5RBwOii6eCuPfr0I79c1L+KcGaedERWMOAz+Rz3C1wSuPI2dw+XZQx+BJI4k= =QzSu -----END PGP SIGNATURE----- --Apple-Mail=_2596802B-6CAC-4B5A-985A-C66EECD861E4--