Subject: bug#29538: 26.0.90; Gnus, group buffer: Mouse click on empty space selects group

From: Katsumi Yamaoka <[email-masked]>
Date: Tue, 05 Dec 2017 11:08:15 +0900

On Mon, 04 Dec 2017 20:47:53 +0100, Benjamin Riefenstahl wrote:
> Thank you for looking into this.

>> On Sat, 02 Dec 2017 21:15:37 +0100, Benjamin Riefenstahl wrote:
>>> The behaviour of mouse clicks has changed in the Gnus group buffer from
>>> Emacs 25 to Emacs 26.

> Katsumi Yamaoka writes:
>> I found no difference in the end of a group line between 25 and 26.
>> Don't you have a special treatment on `gnus-mouse-2'?  In Emacs 25
>> the default value of it is `[mouse-2]' that Emacs 26 directly uses
>> instead of `gnus-mouse-2'.

> What is `gnus-mouse-2'?  I do not seem to have a variable or function of
> that name.

There used to be many `gnus-ORIGINAL-FUNCTION-OR-VARIABLE-NAME'
in old Gnus in order to keep the compatibility with old Emacsen
and XEmacsen.  As for the variable `gnus-mouse-2', the value was
[mouse-2] in Emacs, and [button2] in XEmacs.

> I tried C-h k mouse-1 after the line end and also inside the group
> string.

> For Enacs 25 I get this for after the line end:
[...]
> While for Emacs 26 I get this for both:
[...]

The same as here.  And I got to be able to reproduce the problem
in Emacs 26, not 25.  Sorry, I tested only mouse-2 yesterday as
I set `mouse-1-click-follows-link' to nil.  But it's 450 now.

In `gnus-group-mode-map' the [follow-link] key is bound to
`mouse-face'.  This causes the [mouse-1] event to be converted
to the [mouse-2] event at the areas where the `mouse-face'
exists if `mouse-1-click-follows-link' is non-nil.
The difference between Emacs 25 and 26 is that only Emacs 26 is
sensitive to the `mouse-face' text property even if the observation
point is behind the area where the text property exists.

Here is a test code.  You may see "Hello World" in Emacs 26 when
clicking the mouse-1 button just after the "group.name", whereas
you will not see it in Emacs 25.  Adding the `(rear-nonsticky t)'
text property doesn't help.

(require 'gnus-group)
(let ((buffer (get-buffer-create "*testing*"))
      (keymap (copy-keymap gnus-group-mode-map)))
  (define-key keymap [mouse-2] (lambda ()
				 (interactive)
				 (message "Hello World")))
  (with-current-buffer buffer
    (erase-buffer)
    (use-local-map keymap)
    (insert "  123: "
	    (propertize "group.name" 'mouse-face 'highlight)
	    "\n"))
  (display-buffer buffer))

However the following test code 2 does not make the mouse-1
button sensitive at the line end even in Emacs 26.

(let ((buffer (get-buffer-create "*testing*"))
      (keymap (make-keymap)))
  (define-key keymap [follow-link] 'mouse-face)
  (define-key keymap [mouse-2] (lambda ()
				 (interactive)
				 (message "Hello World")))
  (with-current-buffer buffer
    (erase-buffer)
    (use-local-map keymap)
    (insert "  123: "
	    (propertize "group.name" 'mouse-face 'highlight)
	    "\n"))
  (display-buffer buffer))

Does anyone know what is different between them?