From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleh Krehel Newsgroups: gmane.emacs.devel Subject: Re: save-excursion and the mark Date: Tue, 24 Feb 2015 00:14:31 +0100 Message-ID: <86r3tgjk4o.fsf@gmail.com> References: <87bnkklv44.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1424733289 16406 80.91.229.3 (23 Feb 2015 23:14:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 23 Feb 2015 23:14:49 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 24 00:14:46 2015 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 1YQ2D8-00063b-11 for ged-emacs-devel@m.gmane.org; Tue, 24 Feb 2015 00:14:46 +0100 Original-Received: from localhost ([::1]:45965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQ2D7-0002UP-B7 for ged-emacs-devel@m.gmane.org; Mon, 23 Feb 2015 18:14:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQ2D2-0002OK-3f for emacs-devel@gnu.org; Mon, 23 Feb 2015 18:14:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQ2Cy-0004sb-Q2 for emacs-devel@gnu.org; Mon, 23 Feb 2015 18:14:40 -0500 Original-Received: from mail-wg0-x230.google.com ([2a00:1450:400c:c00::230]:38240) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQ2Cy-0004sF-Cv for emacs-devel@gnu.org; Mon, 23 Feb 2015 18:14:36 -0500 Original-Received: by wgha1 with SMTP id a1so1873041wgh.5 for ; Mon, 23 Feb 2015 15:14:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=nl4OVgN2sMEan9OpTBD1Eli0FIUoM7qClQYc3ATVl0k=; b=y18bDOx9hYcjkirYKBEmIJ7swyi/7sa+7LUsQhQiZipEwHVwglv1/ZxzcZC2c5dRBa mM/L0mtPLr5fd4TBHw/holdObvWdr5ZgqO4Y0jdz9V3jw1B9A2hB2ZYg4vc/uAAUpTLq +9RDR6tg+lYl41UPkAjXczYNOMSYdJsVduo/oGKJnEYqzArqUieT25jTLE8xdNYIFLAj p+3S6qcXiV6VFbXpnwizQp7OE9iWpv9VJnBhQDhSv/rKx1wRVQYvREQQMs+y0jvHE+it mkzOCyrwnbFnwuWrbh+XuCnWH7m5E4qOxeka2iLy9SHYHSmE4wGeUSjRZzsgA+6VQGQA dr7g== X-Received: by 10.194.122.233 with SMTP id lv9mr26384700wjb.95.1424733275780; Mon, 23 Feb 2015 15:14:35 -0800 (PST) Original-Received: from olya-ThinkPad-Edge-E330 (ip20-32-209-87.adsl2.static.versatel.nl. [87.209.32.20]) by mx.google.com with ESMTPSA id qo10sm57589809wjc.38.2015.02.23.15.14.34 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 23 Feb 2015 15:14:35 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Mon, 23 Feb 2015 17:33:43 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::230 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:183434 Archived-At: Stefan Monnier writes: >> I have a package that might be using the feature. > > Where and how? It's at https://github.com/abo-abo/lispy. There's a bunch of functions that manipulate the active region sexp-wise. Some of them might use the fact that the mark is restored. I can't be sure until I get a `save-excursion' version that doesn't touch the mark. > >> None of the tests were failing when I wrapped `save-excursion' like >> this: > >> (defmacro lispy-save-excursion (&rest body) >> "More intuitive (`save-excursion' BODY)." >> (declare (indent 0)) >> `(let ((activep (region-active-p)) >> (mark (mark)) >> (out (save-excursion >> ,@body))) >> (when activep >> (set-mark mark)) >> (when (bolp) >> (back-to-indentation)) >> out)) > > Hmm... this seems to redundantly save&restore the mark. What is this > supposed to illustrate/test? Supposing that you would disable the mark storing/restoring in `save-excursion', I rewrote my code to save/restore the mark on top of that. It didn't hurt the tests. It was hard for me to write my own `save-excursion' in Elisp to completely test it, since it's not obvious how it works when chunks of text are deleted. Oleh