bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#23478: 25.0.93; Mouse region selection asymmetry


From: Stephen Berman
Subject: bug#23478: 25.0.93; Mouse region selection asymmetry
Date: Sun, 08 May 2016 17:44:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (gnu/linux)

When you select a region by double-clicking with mouse-1 and the end of
the region is below the last visible line of the window, Emacs recenters
the display, making the entire selected region visible (unless it's
larger than half the window's height).  But when you select a region by
double-clicking with mouse-1 and the beginning of the region is above
the first visible line of the window, Emacs does not recenter the
display, so the entire selected region is not visible.  To reproduce:

0. emacs -Q
1. C-h t M-g M-g 42 RET (to open the English Emacs Tutorial and put
   point on line 42).
2. C-l C-l C-l (to make line 42 the last visible line in the window).
3. Double click with mouse-1 on the `(' before "hold" in line 42.
=> The display is recentered and the region between `(' on line 42 and
   `)' on line 43 is selected and highlighted.
4. C-a C-l C-l (to clear the selection highlighting and make line 43 the
   first visible line in the window).
5. Double click with mouse-1 on the `)' after "key" in line 43.
=> Line 43 is highlighted but remains the first visible line in the
   window and the part of the region on line 42 is not visible.

This is not a program bug, since Emacs is behaving as intended, but it
is a UX asymmetry that I think it would be preferable to eliminate.  The
patch below does that, but I'm not sure it's the best way to handle
this, since I don't know whether calling `recenter' from Lisp may have
undesirable side effects that the automatic recentering Emacs redisplay
does when point moves out of the visible portion of the window does not
have.

diff --git a/lisp/mouse.el b/lisp/mouse.el
index fa355ff..c3efefe 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -531,7 +531,10 @@ mouse-set-point
   (interactive "e\np")
   (mouse-minibuffer-check event)
   (if (and promote-to-region (> (event-click-count event) 1))
-      (mouse-set-region event)
+      (progn
+        (mouse-set-region event)
+        (when (> (window-start) (region-beginning))
+         (recenter)))
     ;; Use event-end in case called from mouse-drag-region.
     ;; If EVENT is a click, event-end and event-start give same value.
     (posn-set-point (event-end event))))


In GNU Emacs 25.0.93.5 (x86_64-suse-linux-gnu, GTK+ Version 3.14.15)
 of 2016-05-08 built on rosalinde
Repository revision: cd27f7396b77086b6c02eff5b2648bfba439d264
Windowing system distributor 'The X.Org Foundation', version 11.0.11601000
System Description:     openSUSE 13.2 (Harlequin) (x86_64)

Configured using:
 'configure --with-xwidgets 'CFLAGS=-Og -g3''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GCONF GSETTINGS NOTIFY
GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS
GTK3 X11 XWIDGETS

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix





reply via email to

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