unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#23478: 25.0.93; Mouse region selection asymmetry
@ 2016-05-08 15:44 Stephen Berman
  2016-05-08 16:23 ` Eli Zaretskii
  0 siblings, 1 reply; 31+ messages in thread
From: Stephen Berman @ 2016-05-08 15:44 UTC (permalink / raw)
  To: 23478

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





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

end of thread, other threads:[~2016-07-08 15:38 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-08 15:44 bug#23478: 25.0.93; Mouse region selection asymmetry Stephen Berman
2016-05-08 16:23 ` Eli Zaretskii
2016-05-08 18:31   ` Stephen Berman
2016-05-08 18:54     ` Eli Zaretskii
2016-05-08 19:41       ` Stephen Berman
2016-05-08 19:45         ` Eli Zaretskii
2016-07-02 23:16           ` npostavs
2016-07-03 14:33             ` Stephen Berman
2016-07-03 15:38               ` Eli Zaretskii
2016-07-03 22:24                 ` Stephen Berman
2016-07-04  2:38                   ` Eli Zaretskii
2016-07-04  8:45                     ` Stephen Berman
2016-07-04 14:57                       ` Eli Zaretskii
2016-07-04 16:56                         ` Stephen Berman
2016-07-04 18:26                           ` Stephen Berman
2016-07-05 17:23                           ` Eli Zaretskii
2016-07-06 16:40                             ` Stephen Berman
2016-07-06 18:44                               ` Eli Zaretskii
2016-07-07 12:08                                 ` Stephen Berman
2016-07-07 15:29                                   ` Eli Zaretskii
2016-07-07 16:22                                     ` Stephen Berman
2016-07-07 16:48                                       ` Eli Zaretskii
2016-07-07 17:02                                         ` Noam Postavsky
2016-07-07 17:16                                           ` Eli Zaretskii
2016-07-07 18:26                                           ` Stephen Berman
2016-07-08  9:58                                             ` Stephen Berman
2016-07-08 10:14                                               ` Eli Zaretskii
2016-07-08 15:38                                             ` Stephen Berman
2016-07-07 17:04                                         ` Stephen Berman
2016-07-04 15:29                       ` Drew Adams
2016-07-05  1:32                         ` npostavs

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