From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Moving point after character when clicking latter half of it Date: Sun, 09 Jul 2023 09:35:42 +0300 Message-ID: <83fs5xbni9.fsf@gnu.org> References: <2255158.iZASKD2KPV@silef> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2401"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Moritz Maxeiner Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jul 09 08:36:32 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 1qIO23-0000RN-7w for ged-emacs-devel@m.gmane-mx.org; Sun, 09 Jul 2023 08:36:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIO1D-00061F-7M; Sun, 09 Jul 2023 02:35:39 -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 1qIO1A-00060s-P8 for emacs-devel@gnu.org; Sun, 09 Jul 2023 02:35:36 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIO1A-00015S-AO; Sun, 09 Jul 2023 02:35:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=pSMoPb8OyebRdhtgiKk9DmoEps6js7bPAQ7hL6WanGs=; b=eFtiPHmxJRrW iUeLQhSrS/wk258S24NzTm/TW/Sv7lFLox619PEiRkPhQ9KCTcBGD8pbq14AC5A+nosbeU00iBnVC Tj/EwEsX5GX2QR6tVlhucokGICiLgHqiRhl2+6IEJoHyg/U5Mejmek+dFvAzR7f7cUdDk5bOCVA8Z 58ixmJepHeetMRDJGd7WfFZLCk2Mqgx+KZOB+BOUM5JGsdv2YJawZCmcaj17uOC8dLtM/xgZTf0SD 6qEflW1jot3Zai+XlJFbssZnpwdQWX19ToctmHzl7IU+PH3cMl5uMYojVyLSvlSd/m1L+7vOK6O8v fPl5TXX4eUdY9tqj9rkmmw==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIO19-0006sW-PR; Sun, 09 Jul 2023 02:35:36 -0400 In-Reply-To: <2255158.iZASKD2KPV@silef> (message from Moritz Maxeiner on Sat, 08 Jul 2023 23:01:12 +0200) 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:307641 Archived-At: > From: Moritz Maxeiner > Date: Sat, 08 Jul 2023 23:01:12 +0200 > > 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. Thanks, but the place where you suggest to make the change is not the correct one. The function move_it_in_display_line_to is the workhorse of "display emulation", and is used by any code which needs to perform calculations related to display layout without producing anything on the glass. It is fundamentally wrong to modify how all of that code finds the position corresponding to a certain X coordinate just because the user wants a mouse click to move point to the next character. The right place is in buffer_posn_from_coords. The change will be more complex there, but there's no way around this, since we want this change to affect only mouse clicks. > 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. I think this will be acceptable as optional behavior, yes. But we need to consider all of its implications, such as what should happen when the use drags the mouse -- do we also want the drag to affect only the following character if the initial click is half-way across a character's glyph?