[Top][All Lists]

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

Re: save-excursion and the mark

From: Stefan Monnier
Subject: Re: save-excursion and the mark
Date: Tue, 07 Apr 2015 21:57:34 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> 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 

reply via email to

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