GNU bug report logs - #20260
24.4.1; Triple-clicking selects and deselects the line in weird situations

Previous Next

Package: emacs;

Reported by: Jorgen Schaefer <contact <at> jorgenschaefer.de>

Date: Sat, 4 Apr 2015 22:30:04 UTC

Severity: normal

Found in version 24.4.1

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20260 in the body.
You can then email your comments to 20260 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#20260; Package emacs. (Sat, 04 Apr 2015 22:30:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jorgen Schaefer <contact <at> jorgenschaefer.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 04 Apr 2015 22:30:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jorgen Schaefer <contact <at> jorgenschaefer.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.4.1;
 Triple-clicking selects and deselects the line in weird situations
Date: Sun, 05 Apr 2015 00:29:21 +0200
Hello!
We came across a weird behavior in Emacs.

The graphical version (in X) will select a line if the mouse is
triple-clicked. Under certain situations, it will select but immediately
deselect the line again.

Reproduction:

Triple-click on any line in any buffer. Notice that Emacs selects the
whole line, and leaves it selected.

Evaluate the following code.

(defun repro-filter (fun beg end delete)
  (let ((string (funcall fun beg end delete)))
    (with-temp-buffer
      (insert "."))
    string))

(with-current-buffer (get-buffer-create "*Bug*")
  (set (make-local-variable 'filter-buffer-substring-functions)
       '(repro-filter))
  (insert "Hello, World!\n")
  (pop-to-buffer (current-buffer)))

Triple-click on the "World" in the *Bug* buffer. Notice that Emacs
selects the whole line only momentarily, and then deselects it again
immediately.

I expected the line to stay selected like without this piece of code.

This bug was not present in 24.3.

Regards,
Jorgen




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20260; Package emacs. (Tue, 07 Apr 2015 18:55:01 GMT) Full text and rfc822 format available.

Message #8 received at 20260 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Jorgen Schaefer <contact <at> jorgenschaefer.de>
Cc: 20260 <at> debbugs.gnu.org
Subject: Re: bug#20260: 24.4.1;
 Triple-clicking selects and deselects the line in weird situations
Date: Tue, 07 Apr 2015 14:53:42 -0400
> Triple-click on the "World" in the *Bug* buffer. Notice that Emacs
> selects the whole line only momentarily, and then deselects it again
> immediately.

Indeed.  I though I had fixed this in Emacs-25 by making deactivate-mark
buffer-local, but I actually failed to adjust the C code accordingly.

The patch below seems to fix your test case.  Can you confirm it also
fixes your real use case?


        Stefan


diff --git a/src/fileio.c b/src/fileio.c
index d4e12cb..a6e7fbb 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4165,7 +4165,7 @@ by calling `format-decode', which see.  */)
       Vdeactivate_mark = old_Vdeactivate_mark;
     }
   else
-    Vdeactivate_mark = Qt;
+    Fset (Qdeactivate_mark, Qt);
 
   emacs_close (fd);
   clear_unwind_protect (fd_index);
diff --git a/src/insdel.c b/src/insdel.c
index 80650be..22c2bcc 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1846,7 +1846,7 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
       = call1 (Fsymbol_value (Qregion_extract_function), Qnil);
 
   signal_before_change (start, end, preserve_ptr);
-  Vdeactivate_mark = Qt;
+  Fset (Qdeactivate_mark, Qt);
 }
 
 /* Like above, but called when we know that the buffer text




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20260; Package emacs. (Wed, 08 Apr 2015 10:42:01 GMT) Full text and rfc822 format available.

Message #11 received at 20260 <at> debbugs.gnu.org (full text, mbox):

From: Vasilij Schneidermann <v.schneidermann <at> gmail.com>
To: 20260 <at> debbugs.gnu.org
Cc: contact <at> jorgenschaefer.de, monnier <at> iro.umontreal.ca
Subject: Re: bug#20260: 24.4.1; Triple-clicking selects and deselects the
 line in weird situations
Date: Wed, 8 Apr 2015 12:41:06 +0200
The patch does indeed fix the test case for me, but the real use case
stays unchanged.

Meanwhile, I've found a way to make the test case pass on 24.4,
let-binding `deactivate-mark`:

(defun repro-filter (fun beg end delete)
  (let ((string (funcall fun beg end delete))
	deactivate-mark)
    (with-temp-buffer
      (insert "."))
    string))

(with-current-buffer (get-buffer-create "*Bug*")
  (set (make-local-variable 'filter-buffer-substring-functions)
       '(repro-filter))
  (insert "Hello, World!\n")
  (pop-to-buffer (current-buffer)))

This change makes triple-clicking "World" in the *Bug* buffer no longer
deselect it.  Why it is needed in 24.4, but not in 24.3 is beyond my
understanding of Emacs.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20260; Package emacs. (Wed, 08 Apr 2015 14:28:02 GMT) Full text and rfc822 format available.

Message #14 received at 20260 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Vasilij Schneidermann <v.schneidermann <at> gmail.com>
Cc: contact <at> jorgenschaefer.de, 20260 <at> debbugs.gnu.org
Subject: Re: bug#20260: 24.4.1;
 Triple-clicking selects and deselects the line in weird situations
Date: Wed, 08 Apr 2015 10:26:59 -0400
> The patch does indeed fix the test case for me, but the real use case
> stays unchanged.

Hmm... Can you provide another recipe that still isn't fixed with the patch?

> Meanwhile, I've found a way to make the test case pass on 24.4,
> let-binding `deactivate-mark`:

Yes, that works around the problem, but it shouldn't be necessary in Emacs-25.

The workaround you use was needed in many places: deactivate-mark was
global, so modifying one buffer could end up deactivating the mark in
some unrelated buffer.  In Emacs-25, we've changed it to be
buffer-local, so modifications in one buffer should not affect the
activation of the mark in another any more.

> Why it is needed in 24.4, but not in 24.3 is beyond my
> understanding of Emacs.

I don't know either, actually.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20260; Package emacs. (Fri, 10 Apr 2015 19:05:02 GMT) Full text and rfc822 format available.

Message #17 received at 20260 <at> debbugs.gnu.org (full text, mbox):

From: Jorgen Schäfer <contact <at> jorgenschaefer.de>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Vasilij Schneidermann <v.schneidermann <at> gmail.com>, 20260 <at> debbugs.gnu.org
Subject: Re: bug#20260: 24.4.1; Triple-clicking selects and deselects the line
 in weird situations
Date: Fri, 10 Apr 2015 21:04:42 +0200
Hello.
At least for me, the patch fixes the problem in the original context
(Circe IRC buffers).
Thank you. But that means I'm out of the game for providing test
cases, I am afraid ...

Regards,
Jorgen




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 13 Apr 2015 14:19:02 GMT) Full text and rfc822 format available.

Notification sent to Jorgen Schaefer <contact <at> jorgenschaefer.de>:
bug acknowledged by developer. (Mon, 13 Apr 2015 14:19:02 GMT) Full text and rfc822 format available.

Message #22 received at 20260-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Vasilij Schneidermann <v.schneidermann <at> gmail.com>
Cc: contact <at> jorgenschaefer.de, 20260-done <at> debbugs.gnu.org
Subject: Re: bug#20260: 24.4.1;
 Triple-clicking selects and deselects the line in weird situations
Date: Mon, 13 Apr 2015 10:18:02 -0400
>> The patch does indeed fix the test case for me, but the real use case
>> stays unchanged.

Since it fixes Jorgen's test case I installed the patch into master, and
I'm closing this bug.

> Hmm... Can you provide another recipe that still isn't fixed with the patch?

If/when you find another recipe to reproduce your problem, just make
a new bug report (or re-open this one).

Thank you,


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 12 May 2015 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 93 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.