From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Aaron Ecay Newsgroups: gmane.emacs.devel Subject: Re: Using `save-window-excursion' instead of `save-excursion' for `comment-region'? Date: Thu, 05 Dec 2013 14:05:37 -0500 Message-ID: <87fvq7dsou.fsf@gmail.com> References: <87y53zk3dx.fsf@bzg.ath.cx> <87ob4vuoi8.fsf@bzg.ath.cx> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1386270369 24210 80.91.229.3 (5 Dec 2013 19:06:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Dec 2013 19:06:09 +0000 (UTC) Cc: emacs-devel@gnu.org To: Bastien , Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 05 20:06:14 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VoeFY-0007f7-M3 for ged-emacs-devel@m.gmane.org; Thu, 05 Dec 2013 20:06:12 +0100 Original-Received: from localhost ([::1]:55277 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoeFY-0000WF-6m for ged-emacs-devel@m.gmane.org; Thu, 05 Dec 2013 14:06:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoeFN-0000W3-Gg for emacs-devel@gnu.org; Thu, 05 Dec 2013 14:06:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VoeFF-0000vt-3s for emacs-devel@gnu.org; Thu, 05 Dec 2013 14:06:01 -0500 Original-Received: from mail-qa0-x229.google.com ([2607:f8b0:400d:c00::229]:45980) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoeF2-0000tz-Jh; Thu, 05 Dec 2013 14:05:40 -0500 Original-Received: by mail-qa0-f41.google.com with SMTP id j5so96794qaq.0 for ; Thu, 05 Dec 2013 11:05:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type:content-transfer-encoding; bh=u4gCRrahZOuZX/2m45QmMMw53VqkiwLkZYZ3Hn/ssms=; b=vawIbrmu4P0lr+rdVyIMCuCF1Ygw/UQ6eo9IZQZGuAxtGb6xG7nZ1L3NTboxAV4Xp8 ZXBHr0oq2Oq8dfyKCgVF8nuE35UBWwSKnXzPEcwELBhdstXiIT4/tfBjg9SfpHAaXMq2 IZy1O1O4W4QpXo8FmISzodRUAXqVWj5lYmSYaRWeB1gqOEBr82327QLl4MAYd4Ifck6B TN9R5m8VxOjveUA302DY4N5rCnOMMOiIXnCIvTC2+llHPPnd9f0rkHz4/VyOphQesYzQ QDDHtG0twrtN15ojkp6bmxB+yj+m/1TAC1jkQUjA86wfgN/pIOos0DWgbhtvaM2LmLDT Fj/A== X-Received: by 10.224.24.131 with SMTP id v3mr147870655qab.48.1386270339373; Thu, 05 Dec 2013 11:05:39 -0800 (PST) Original-Received: from localhost (c-68-81-204-26.hsd1.pa.comcast.net. [68.81.204.26]) by mx.google.com with ESMTPSA id u17sm29210339qeb.4.2013.12.05.11.05.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Dec 2013 11:05:38 -0800 (PST) In-Reply-To: <87ob4vuoi8.fsf@bzg.ath.cx> User-Agent: Notmuch/0.16+154~g96c0ce2 (http://notmuchmail.org) Emacs/24.3.50.1 (x86_64-unknown-linux-gnu) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c00::229 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:166134 Archived-At: 2013ko abenudak 5an, Bastien-ek idatzi zuen: >=20 > This is how it works: >=20 > comment-region calls comment-region-function within save-excursion > (assuming there is no window change.) >=20 > comment-region-function calls org-babel-do-in-edit-buffer which > inserts the source code in another buffer, then calls back again > comment-region with comment-region-function bound to the correct > mode-dependent function. >=20 > The "outward" comment-region does not restore the point position > correctly. >=20 > So I'm not sure why save-window-excursion would only works "by > accident" here. I cannot think of a better fix right now, I'll > continue to travel through the Babel maze. I think the problem is that org-babel-do-in-edit-buffer deletes the whole contents of the source code block, and re-inserts it. This means that the marker that save-excursion uses (pointing to somewhere in the deleted and re-inserted span) no longer points to the desired position, but rather to just before the span. Org babel has its own point-restoration functionality (which works by counting lines and columns), but this is executed inside of the scope of comment-region=E2=80=99s save-excursion, so exiting the latter restores the point to a bogus position (from the POV of the user). --=20 Aaron Ecay