From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Artur Malabarba Newsgroups: gmane.emacs.devel Subject: Re: save-excursion and the mark Date: Tue, 24 Feb 2015 00:12:14 +0000 Message-ID: References: <87bnkklv44.fsf@gmail.com> <86r3tgjk4o.fsf@gmail.com> Reply-To: bruce.connor.am@gmail.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1424736747 4751 80.91.229.3 (24 Feb 2015 00:12:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 24 Feb 2015 00:12:27 +0000 (UTC) Cc: Stefan Monnier , emacs-devel To: Oleh Krehel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 24 01:12:27 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 1YQ36q-0005jd-N0 for ged-emacs-devel@m.gmane.org; Tue, 24 Feb 2015 01:12:20 +0100 Original-Received: from localhost ([::1]:46100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQ36p-0005ei-NF for ged-emacs-devel@m.gmane.org; Mon, 23 Feb 2015 19:12:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQ36m-0005eS-Ap for emacs-devel@gnu.org; Mon, 23 Feb 2015 19:12:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQ36l-00042T-9D for emacs-devel@gnu.org; Mon, 23 Feb 2015 19:12:16 -0500 Original-Received: from mail-lb0-x22b.google.com ([2a00:1450:4010:c04::22b]:37941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQ36k-00042A-W6 for emacs-devel@gnu.org; Mon, 23 Feb 2015 19:12:15 -0500 Original-Received: by lbiz11 with SMTP id z11so21728759lbi.5 for ; Mon, 23 Feb 2015 16:12:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=ncCaUlr5i0p10sSDFpMjkmI8JdG5skaWfKtvHicMtow=; b=TNo75oxc3lAtUAdjiFAJc5GEHnpmuzMRh8bVnO7IWJM8Vhc+IvNX3Ae+/ZOmIkx+YJ C44y3oAR462uYyfu8BB4ciuDaHJWEqocEAiZJTm/Lhyy0QJvKhRnvJYDCbT9szK0f4kr qQaTePFcoxMp5ios2B+KRyaai88RlTFGMLbQK6SCa/rBqQNTdgZnbPQsdlB6Qvujnut9 DRL8sux7DiIyHk87kFgTX5BuCJREp+EJKINXx6JgTnvkeNNW44n6gsKbmr6/NeMNg6ED W756Sxm/y4v1MunNOWm4cdA+MrLo07WWctln7V1CSZOUxPQM1L4GZMDafSwJ28+eGY92 Kgow== X-Received: by 10.152.21.167 with SMTP id w7mr12268416lae.14.1424736734150; Mon, 23 Feb 2015 16:12:14 -0800 (PST) Original-Received: by 10.112.49.9 with HTTP; Mon, 23 Feb 2015 16:12:14 -0800 (PST) In-Reply-To: <86r3tgjk4o.fsf@gmail.com> X-Google-Sender-Auth: RLG0uPMFkS1C4JFwycZ0FeLK4bA X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22b 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:183436 Archived-At: 2015-02-23 23:14 GMT+00:00 Oleh Krehel : > 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. I think the following should do it. (cl-letf* (((point-marker)) ((current-buffer))) ;; Your code here. ) > 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 couldn't have hut the tests, given that it's redundant :-) (for now at least). > 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. I think it just follows the point marker. Test the snippet above and see if it works for you.