From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Moritz Maxeiner Newsgroups: gmane.emacs.devel Subject: Moving point after character when clicking latter half of it Date: Sat, 08 Jul 2023 23:01:12 +0200 Message-ID: <2255158.iZASKD2KPV@silef> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart1959446.PYKUYFuaPT" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28457"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jul 09 07:05:31 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qIMbz-0007GJ-8t for ged-emacs-devel@m.gmane-mx.org; Sun, 09 Jul 2023 07:05:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIMbB-0006Yt-CO; Sun, 09 Jul 2023 01:04:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIF47-0005Bt-Bo for emacs-devel@gnu.org; Sat, 08 Jul 2023 17:02:03 -0400 Original-Received: from nephos.ucw.sh ([138.201.61.214] helo=mail.ucw.sh) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIF45-0000Kt-HM for emacs-devel@gnu.org; Sat, 08 Jul 2023 17:02:03 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.ucw.sh (Postfix) with ESMTP id 847E396B3C for ; Sat, 8 Jul 2023 23:01:55 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.ucw.sh Original-Received: from mail.ucw.sh ([127.0.0.1]) by localhost (mail.ucw.sh [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id 5B53IMFy0N6P for ; Sat, 8 Jul 2023 23:01:55 +0200 (CEST) Original-Received: from silef.localnet (p200300d29734adf95de61d0d7ca45959.dip0.t-ipconnect.de [IPv6:2003:d2:9734:adf9:5de6:1d0d:7ca4:5959]) (Authenticated sender: mm@ucw.sh) by mail.ucw.sh (Postfix) with ESMTPSA for ; Sat, 8 Jul 2023 23:01:54 +0200 (CEST) Received-SPF: pass client-ip=138.201.61.214; envelope-from=mm@ucw.sh; helo=mail.ucw.sh X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 09 Jul 2023 01:04:35 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:307638 Archived-At: This is a multi-part message in MIME format. --nextPart1959446.PYKUYFuaPT Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" I am using emacs gtk gui alongside other graphical text editors (left to right text only). In all of the ones I'm using (other than emacs), clicking with the mouse on a character moves the point either in front of, or after that character, depending on whether you clicked the left or right half of it. In emacs, however, point seems to always be moved in front of the clicked character, regardless of where on it you click. It would be great if emacs could (optionally) also support the before/after behavior described above. After delving into the code, it seems that this would need changes in C. I have attached a proof of concept patch that changes emacs' behavior, but it lacks an option mechanism. I also am not familiar enough with what unintended consequences this change may have. I am looking for feedback of whether this feature in general is something that would be acceptable to have in emacs and if there are any pitfalls this change may cause that I need to be aware of. Best, Moritz Maxeiner --nextPart1959446.PYKUYFuaPT Content-Disposition: attachment; filename="emacs-29-move_it_in_display_line_to-nextglyphafterhalf.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="x-UTF_8J"; name="emacs-29-move_it_in_display_line_to-nextglyphafterhalf.patch" diff --git a/src/xdisp.c b/src/xdisp.c index 763af7d3bc8..46611628d06 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -9905,6 +9905,7 @@ #define IT_RESET_X_ASCENT_DESCENT(IT) \ /* More than one glyph or glyph doesn't fit on line. All glyphs have the same width. */ int single_glyph_width = it->pixel_width / it->nglyphs; + int single_glyph_halfwidth = single_glyph_width / 2; int new_x; int x_before_this_char = x; int hpos_before_this_char = it->hpos; @@ -9914,7 +9915,7 @@ #define IT_RESET_X_ASCENT_DESCENT(IT) \ new_x = x + single_glyph_width; /* We want to leave anything reaching TO_X to the caller. */ - if ((op & MOVE_TO_X) && new_x > to_x) + if ((op & MOVE_TO_X) && (x + single_glyph_halfwidth) > to_x) { if (BUFFER_POS_REACHED_P ()) { --nextPart1959446.PYKUYFuaPT--