diff --git a/src/dispnew.c b/src/dispnew.c index 65d9cf9b4e1..bd288286924 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -22,6 +22,7 @@ Copyright (C) 1985-1988, 1993-1995, 1997-2023 Free Software Foundation, #include "sysstdio.h" #include +#include #include #include "lisp.h" @@ -5611,6 +5612,9 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p argument is ZV to prevent move_it_in_display_line from matching based on buffer positions. */ move_it_in_display_line (&it, ZV, to_x, MOVE_TO_X); + if (mouse_point_alternate && to_x > it.current_x + ceil (it.pixel_width / 2.0)) + move_it_in_display_line (&it, ZV, it.current_x + it.pixel_width, MOVE_TO_X); + bidi_unshelve_cache (itdata, 0); Fset_buffer (old_current_buffer); @@ -6468,6 +6472,7 @@ init_display_interactive (void) inverse_video = 0; cursor_in_echo_area = false; + mouse_point_alternate = false; /* Now is the time to initialize this; it's used by init_sys_modes during startup. */ @@ -6788,6 +6793,11 @@ syms_of_display (void) DEFVAR_BOOL ("cursor-in-echo-area", cursor_in_echo_area, doc: /* Non-nil means put cursor in minibuffer, at end of any message there. */); + DEFVAR_BOOL ("mouse-point-alternate", mouse_point_alternate, + doc: /* Non-nil means use alternate mode for mouse click selection of point. +In alternate mode, if the clicked x coordinate exceeds half of the selected +display element's width, put point after it. */); + DEFVAR_LISP ("glyph-table", Vglyph_table, doc: /* Table defining how to output a glyph code to the frame. If not nil, this is a vector indexed by glyph code to define the glyph.