unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#20260: 24.4.1; Triple-clicking selects and deselects the line in weird situations
@ 2015-04-04 22:29 Jorgen Schaefer
  2015-04-07 18:53 ` Stefan Monnier
  2015-04-08 10:41 ` Vasilij Schneidermann
  0 siblings, 2 replies; 6+ messages in thread
From: Jorgen Schaefer @ 2015-04-04 22:29 UTC (permalink / raw)
  To: 20260

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





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

* bug#20260: 24.4.1; Triple-clicking selects and deselects the line in weird situations
  2015-04-04 22:29 bug#20260: 24.4.1; Triple-clicking selects and deselects the line in weird situations Jorgen Schaefer
@ 2015-04-07 18:53 ` Stefan Monnier
  2015-04-08 10:41 ` Vasilij Schneidermann
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2015-04-07 18:53 UTC (permalink / raw)
  To: Jorgen Schaefer; +Cc: 20260

> 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





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

* bug#20260: 24.4.1; Triple-clicking selects and deselects the line in weird situations
  2015-04-04 22:29 bug#20260: 24.4.1; Triple-clicking selects and deselects the line in weird situations Jorgen Schaefer
  2015-04-07 18:53 ` Stefan Monnier
@ 2015-04-08 10:41 ` Vasilij Schneidermann
  2015-04-08 14:26   ` Stefan Monnier
  1 sibling, 1 reply; 6+ messages in thread
From: Vasilij Schneidermann @ 2015-04-08 10:41 UTC (permalink / raw)
  To: 20260; +Cc: contact

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.





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

* bug#20260: 24.4.1; Triple-clicking selects and deselects the line in weird situations
  2015-04-08 10:41 ` Vasilij Schneidermann
@ 2015-04-08 14:26   ` Stefan Monnier
  2015-04-10 19:04     ` Jorgen Schäfer
  2015-04-13 14:18     ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Monnier @ 2015-04-08 14:26 UTC (permalink / raw)
  To: Vasilij Schneidermann; +Cc: contact, 20260

> 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





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

* bug#20260: 24.4.1; Triple-clicking selects and deselects the line in weird situations
  2015-04-08 14:26   ` Stefan Monnier
@ 2015-04-10 19:04     ` Jorgen Schäfer
  2015-04-13 14:18     ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Jorgen Schäfer @ 2015-04-10 19:04 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Vasilij Schneidermann, 20260

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





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

* bug#20260: 24.4.1; Triple-clicking selects and deselects the line in weird situations
  2015-04-08 14:26   ` Stefan Monnier
  2015-04-10 19:04     ` Jorgen Schäfer
@ 2015-04-13 14:18     ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2015-04-13 14:18 UTC (permalink / raw)
  To: Vasilij Schneidermann; +Cc: contact, 20260-done

>> 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





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

end of thread, other threads:[~2015-04-13 14:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-04 22:29 bug#20260: 24.4.1; Triple-clicking selects and deselects the line in weird situations Jorgen Schaefer
2015-04-07 18:53 ` Stefan Monnier
2015-04-08 10:41 ` Vasilij Schneidermann
2015-04-08 14:26   ` Stefan Monnier
2015-04-10 19:04     ` Jorgen Schäfer
2015-04-13 14:18     ` 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).