unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#20357: 25.0.50; deactivate-mark behavior broken
@ 2015-04-17 10:21 Oleh Krehel
  2015-04-17 14:31 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Oleh Krehel @ 2015-04-17 10:21 UTC (permalink / raw)
  To: 20357


This is a recent change, 24.5.2 doesn't have this bug.

How to reproduce:

1. Mark some text.
2. Call this:

(let (deactivate-mark)
  (indent-region (region-beginning)
                 (region-end)))

Expected behavior: the mark isn't deactivated.

Actual behavior: the mark is deactivated.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#20357: 25.0.50; deactivate-mark behavior broken
  2015-04-17 10:21 bug#20357: 25.0.50; deactivate-mark behavior broken Oleh Krehel
@ 2015-04-17 14:31 ` Stefan Monnier
  2015-04-17 16:02   ` Oleh Krehel
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2015-04-17 14:31 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: 20357-done

> (let (deactivate-mark)
>   (indent-region (region-beginning)
>                  (region-end)))
> Expected behavior: the mark isn't deactivated.
> Actual behavior: the mark is deactivated.

Oops, indeed.  Fixed with the patch below,


        Stefan


diff --git a/lisp/indent.el b/lisp/indent.el
index 74e73a6..18c1fd4 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -537,7 +537,7 @@ column to indent to; if it is nil, use one of the three methods above."
   ;; In most cases, reindenting modifies the buffer, but it may also
   ;; leave it unmodified, in which case we have to deactivate the mark
   ;; by hand.
-  (deactivate-mark))
+  (setq deactivate-mark t))
 
 (defun indent-relative-maybe ()
   "Indent a new line like previous nonblank line.





^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#20357: 25.0.50; deactivate-mark behavior broken
  2015-04-17 14:31 ` Stefan Monnier
@ 2015-04-17 16:02   ` Oleh Krehel
  2015-04-17 18:22     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Oleh Krehel @ 2015-04-17 16:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 20357-done

Hi Stefan,

On Fri, Apr 17, 2015 at 4:31 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> (let (deactivate-mark)
>>   (indent-region (region-beginning)
>>                  (region-end)))
>> Expected behavior: the mark isn't deactivated.
>> Actual behavior: the mark is deactivated.
>
> Oops, indeed.  Fixed with the patch below,
>
> diff --git a/lisp/indent.el b/lisp/indent.el
> index 74e73a6..18c1fd4 100644
> --- a/lisp/indent.el
> +++ b/lisp/indent.el
> @@ -537,7 +537,7 @@ column to indent to; if it is nil, use one of the three methods above."
>    ;; In most cases, reindenting modifies the buffer, but it may also
>    ;; leave it unmodified, in which case we have to deactivate the mark
>    ;; by hand.
> -  (deactivate-mark))
> +  (setq deactivate-mark t))
>
>  (defun indent-relative-maybe ()
>    "Indent a new line like previous nonblank line.

This is still not the correct behavior. Example code:

(with-temp-buffer
  (insert "foobar")
  (set-mark (point))
  (goto-char (point-min))
  (indent-region (point-min)
                 (point-max))
  mark-active)

In 24.5 it returns nil, which is correct. While in 25 it returns t.

Oleh





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#20357: 25.0.50; deactivate-mark behavior broken
  2015-04-17 16:02   ` Oleh Krehel
@ 2015-04-17 18:22     ` Stefan Monnier
  2015-04-17 18:30       ` Oleh Krehel
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2015-04-17 18:22 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: 20357-done

> (with-temp-buffer
>   (insert "foobar")
>   (set-mark (point))
>   (goto-char (point-min))
>   (indent-region (point-min)
>                  (point-max))
>   mark-active)
> In 24.5 it returns nil, which is correct. While in 25 it returns t.

Why is it more correct to return nil than to return t?

> This is a recent change, 24.5.2 doesn't have this bug.
>
> (let (deactivate-mark)
>   (indent-region (region-beginning)
>                  (region-end)))
>
> Expected behavior: the mark isn't deactivated.

At least in 24.4, the mark does get deactivated in my test.


        Stefan





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#20357: 25.0.50; deactivate-mark behavior broken
  2015-04-17 18:22     ` Stefan Monnier
@ 2015-04-17 18:30       ` Oleh Krehel
  2015-04-17 19:15         ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Oleh Krehel @ 2015-04-17 18:30 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 20357-done

On Fri, Apr 17, 2015 at 8:22 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> (with-temp-buffer
>>   (insert "foobar")
>>   (set-mark (point))
>>   (goto-char (point-min))
>>   (indent-region (point-min)
>>                  (point-max))
>>   mark-active)
>> In 24.5 it returns nil, which is correct. While in 25 it returns t.
>
> Why is it more correct to return nil than to return t?

Because it's a long standing behavior that if you mark some stuff and
press TAB, the mark will be deactivated.  And in 25, the mark actually
is deactivated outside of temp buffers, which is where I run my ERT
tests. So the tests are passing for 24.5 and failing for 25, while the
functions actually do work in both.

>
>> This is a recent change, 24.5.2 doesn't have this bug.
>>
>> (let (deactivate-mark)
>>   (indent-region (region-beginning)
>>                  (region-end)))
>>
>> Expected behavior: the mark isn't deactivated.
>
> At least in 24.4, the mark does get deactivated in my test.

This may be possible. Previously, I was testing using the emacs24 ppa
install, that uses emacs-24.3.
I've started testing with emacs-snapshot only this week, and the tests
started failing.
But when I've tested with 24.5 or 25 on my own machine, the tests were
running fine.

Oleh





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#20357: 25.0.50; deactivate-mark behavior broken
  2015-04-17 18:30       ` Oleh Krehel
@ 2015-04-17 19:15         ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2015-04-17 19:15 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: 20357-done

>>> (with-temp-buffer
>>> (insert "foobar")
>>> (set-mark (point))
>>> (goto-char (point-min))
>>> (indent-region (point-min)
>>> (point-max))
>>> mark-active)
>>> In 24.5 it returns nil, which is correct. While in 25 it returns t.
>> Why is it more correct to return nil than to return t?
> Because it's a long standing behavior that if you mark some stuff and
> press TAB, the mark will be deactivated.

That's still the case.  The difference is that now it's deactivated by
the command loop rather than by the command itself.  Doing it in the
command loop is the normal behavior (the one used for most other
commands which cause the mark to be deactivated).

>>> This is a recent change, 24.5.2 doesn't have this bug.
>>> (let (deactivate-mark)
>>>   (indent-region (region-beginning)
>>>                  (region-end)))
>>> Expected behavior: the mark isn't deactivated.
>> At least in 24.4, the mark does get deactivated in my test.

It's also deactivated in Emacs-23.4 in my tests.

> But when I've tested with 24.5 or 25 on my own machine, the tests were
> running fine.

I think we need to know more about what your tests really do.
Maybe they should just be fixed to test (or (not mark-active)
deactivate-mark) instead of only testing mark-active.


        Stefan





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-04-17 19:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-17 10:21 bug#20357: 25.0.50; deactivate-mark behavior broken Oleh Krehel
2015-04-17 14:31 ` Stefan Monnier
2015-04-17 16:02   ` Oleh Krehel
2015-04-17 18:22     ` Stefan Monnier
2015-04-17 18:30       ` Oleh Krehel
2015-04-17 19:15         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).