From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Magnar Sveen Newsgroups: gmane.emacs.devel Subject: Re: save-excursion and the mark Date: Wed, 15 Apr 2015 04:14:04 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11347920efa73d0513bb9367 X-Trace: ger.gmane.org 1429071263 20437 80.91.229.3 (15 Apr 2015 04:14:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 15 Apr 2015 04:14:23 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 15 06:14:22 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 1YiEiT-0001gq-PD for ged-emacs-devel@m.gmane.org; Wed, 15 Apr 2015 06:14:22 +0200 Original-Received: from localhost ([::1]:58678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiEiS-0008Gp-Nm for ged-emacs-devel@m.gmane.org; Wed, 15 Apr 2015 00:14:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiEiF-0008Gk-Mk for emacs-devel@gnu.org; Wed, 15 Apr 2015 00:14:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YiEiE-0004WV-Gs for emacs-devel@gnu.org; Wed, 15 Apr 2015 00:14:07 -0400 Original-Received: from mail-lb0-x233.google.com ([2a00:1450:4010:c04::233]:34423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiEiE-0004WN-47 for emacs-devel@gnu.org; Wed, 15 Apr 2015 00:14:06 -0400 Original-Received: by lbcga7 with SMTP id ga7so24555459lbc.1 for ; Tue, 14 Apr 2015 21:14:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=EYwE5MldokD3ii2tA8EMlsR9BqvqJsy+nE0sLH6hZuQ=; b=ef/5oqOxgUYQHo9OimGf9TuHaUV2171Zn289wz5epTN4UQ0i8UANZ6RUr7MZ9RcPSZ 0r2XPp28pQpfFUv6/Rt1++TZv4JDQG8cMkH3j4H6nwybpB8ukgHVQdWMJpJ98SEXPIDf 6+nRoWmnZjzuXLRLNbJ9MosrffkquN1vFPdC9kQuxUyfVlSdVLMdzRwvrgpiQL2b9k87 YTTTDj/tC4cEXZZ64uq/gIXmoq2k+wHv7ddw0Th0d+//dDoMpse4dfLtjBPa/WovVgF+ 4rANXJ2bCz6Q773ZkoPlDLe4c7/Ti6iO9R6RdACFeK18tHQhOuFxP5i4yIOxgxXTSBvt JaXw== X-Received: by 10.152.207.105 with SMTP id lv9mr22065550lac.10.1429071245320; Tue, 14 Apr 2015 21:14:05 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::233 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:185438 Archived-At: --001a11347920efa73d0513bb9367 Content-Type: text/plain; charset=UTF-8 There are millions of lines of elisp that you've never seen. Emacs is after all the eminently hackable editor. And you're making breaking changes to a core API out of a sense of cleanliness? You've now been made aware of one case where the change is harmful, and your conclusion is "this is the one case where it is harmful". No, it's the first case where it's been detected - and that's because expand-region is widely used by thousands of people - and thankfully it even has tests. People's code is going to break. You are maintaining an API with many thousands of users. Don't break it. If you must, deprecate it. Introduce save-point, and add "You probably want to use save-point" to the docstring of save-excursion. On Tue, Apr 14, 2015 at 10:17 PM Stefan Monnier wrote: > > If you are indeed going forward with this change (why is that?), > > There are various problems with the previous save-excursion semantics, > all linked to the mark-saving part of it, and this part is useless in > 98% of the cases, useful in 1%, and harmful in 1%, so it's better to get > rid of it in my view. > > Among the various problems, I actually fixed some recently (before > throwing out the code), but the remaining ones are ugly: > saving/restoring the mark includes saving/restoring the mark-active > state as well, and in the general case you'd also want to run the > (de)activate-mark-hook, which could break even more uses of > save-excursion which never expected it to run such hook code. > > > then maybe we could get a save-mark function? > > Since you're the only user so far, better write explicitly the exact > saving/restoring you need (especially since it's not obvious to me what > it is you really need, I guess you could start with something along the > lines of (cl-letf (((mark)) (mark-active mark-active)) ...)). > > > Stefan > --001a11347920efa73d0513bb9367 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
There are millions of lines of elisp that you've= never seen. Emacs is after all the=C2=A0eminently hackable editor. = And you're making breaking changes to a core API out of a sense of clea= nliness? You've now been made aware of one case where the change is har= mful, and your conclusion is "this is the one case where it is harmful= ". No, it's the first case where it's been detected - and that= 's because expand-region is widely used by thousands of people - and th= ankfully it even has tests. People's code is going to break.
=
You are maintaining an API with many thousands of users. Don= 't break it. If you must, deprecate it. Introduce save-point, and add &= quot;You probably want to use save-point" to the docstring of save-exc= ursion.


On= Tue, Apr 14, 2015 at 10:17 PM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> If you are indeed going forward with this change (wh= y is that?),

There are various problems with the previous save-excursion semantics,
all linked to the mark-saving part of it, and this part is useless in
98% of the cases, useful in 1%, and harmful in 1%, so it's better to ge= t
rid of it in my view.

Among the various problems, I actually fixed some recently (before
throwing out the code), but the remaining ones are ugly:
saving/restoring the mark includes saving/restoring the mark-active
state as well, and in the general case you'd also want to run the
(de)activate-mark-hook, which could break even more uses of
save-excursion which never expected it to run such hook code.

> then maybe we could get a save-mark function?

Since you're the only user so far, better write explicitly the exact saving/restoring you need (especially since it's not obvious to me what=
it is you really need, I guess you could start with something along the
lines of (cl-letf (((mark)) (mark-active mark-active)) ...)).


=C2=A0 =C2=A0 =C2=A0 =C2=A0 Stefan
--001a11347920efa73d0513bb9367--