[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: save-excursion and the mark

From: Magnar Sveen
Subject: Re: save-excursion and the mark
Date: Tue, 14 Apr 2015 16:08:10 +0000

Thanks for taking a look. Unfortunately it breaks several expansions, that use the current mark as input to its expansion. If you are indeed going forward with this change (why is that?), then maybe we could get a save-mark function?

On Wed, Apr 8, 2015 at 3:57 AM Stefan Monnier <address@hidden> wrote:
> The change breaks expand-region, for one.

Looks like the problem is basically in er--expand-region-1 where you do:

    (while try-list
          (setq mark-active nil)
          (funcall (car try-list))
          (when (and (region-active-p)

The test (region-active-p) is meant to check whether the (car try-list)
function activated the region, but you don't actually ensure that the
region is deactivated before the call.  So if that function "fails" and
the region happened to be enabled when we entered er--expand-region-1 you
end up taking that "input region" as one of the choices.

In practice this was harmless, but I don't think it was ever correct.
The patch below seems to fix the behavior.


diff --git a/expand-region-core.el b/expand-region-core.el
index ccab290..942318c 100644
--- a/expand-region-core.el
+++ b/expand-region-core.el
@@ -92,6 +92,7 @@ moving point or mark as little as possible."
     (while try-list
+         (setq mark-active nil)
           (funcall (car try-list))
           (when (and (region-active-p)
                      (er--this-expansion-is-better start end best-start best-end))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]