From unknown Tue Jun 24 17:29:34 2025 X-Loop: help-debbugs@gnu.org Subject: bug#19188: point adjustemnt moves *into* invisible text Resent-From: Jonas Bernoulli Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Nov 2014 03:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 19188 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 19188@debbugs.gnu.org X-Debbugs-Original-To: Bug-Gnu-Emacs Received: via spool by submit@debbugs.gnu.org id=B.141697139712232 (code B ref -1); Wed, 26 Nov 2014 03:10:02 +0000 Received: (at submit) by debbugs.gnu.org; 26 Nov 2014 03:09:57 +0000 Received: from localhost ([127.0.0.1]:45470 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XtSzM-0003BE-QM for submit@debbugs.gnu.org; Tue, 25 Nov 2014 22:09:57 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56999) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XtSzL-0003B4-0I for submit@debbugs.gnu.org; Tue, 25 Nov 2014 22:09:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XtSzA-0003Gr-Hk for submit@debbugs.gnu.org; Tue, 25 Nov 2014 22:09:54 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:59882) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtSzA-0003Gm-F7 for submit@debbugs.gnu.org; Tue, 25 Nov 2014 22:09:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtSz2-0000Gl-TT for bug-gnu-emacs@gnu.org; Tue, 25 Nov 2014 22:09:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XtSyv-0003FV-CB for bug-gnu-emacs@gnu.org; Tue, 25 Nov 2014 22:09:36 -0500 Received: from mail.hostpark.net ([212.243.197.30]:42978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtSyv-0003FO-5f for bug-gnu-emacs@gnu.org; Tue, 25 Nov 2014 22:09:29 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 17F3F16FD1 for ; Wed, 26 Nov 2014 04:09:26 +0100 (CET) X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail1.hostpark.net [127.0.0.1]) (amavisd-new, port 10124) with ESMTP id LYRNDJd-Tv9Z for ; Wed, 26 Nov 2014 04:09:26 +0100 (CET) Received: from lem (80-218-85-1.dclient.hispeed.ch [80.218.85.1]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPS id E5134176DF for ; Wed, 26 Nov 2014 04:09:25 +0100 (CET) From: Jonas Bernoulli Date: Wed, 26 Nov 2014 04:07:04 +0100 Message-ID: <87tx1mwtgn.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) When moving backward "point adjustment" which is supposed to move point out of an invisible region may end up doing the opposite. This problem exists at least in 24.3 and 24.4. 1. Yank this in an empty buffer in fundamental-mode and evaluate it. (progn (goto-char (point-min)) (insert "1\n" (propertize "3\n" 'invisible t) "5\n" "7\n") (backward-char 2)) 2. The cursor is now on the "7", which also is the 7th character. The buffer looks like .----- |1 |5 |7 |(progn |... `----- The cursor sits on the "7" and M-: (point) => 7 3. Move to "5" using e.g. C-p or C-b C-b. The cursor is now on "5", which also is the 5th character. However point is not were the cursor is M-: (point) => 3 The problem is in the code that is supposed to move point *out* of an invisible region, does the opposite when moving backward places point on the first character after an invisible region. It moves to the beginning of the preceding invisible region. When point adjustment is disabled (non-nil disable-point-adjustment or global-disable-point-adjustment) then this does not happen. It also does not happen when moving forward, e.g. starting at "1" C-p C-f places the cursor on "5" *and* point is also 5. From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 26 09:51:20 2014 Received: (at control) by debbugs.gnu.org; 26 Nov 2014 14:51:20 +0000 Received: from localhost ([127.0.0.1]:45727 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xtdw7-0006iH-HB for submit@debbugs.gnu.org; Wed, 26 Nov 2014 09:51:19 -0500 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:56016) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xtdw4-0006i6-Mn; Wed, 26 Nov 2014 09:51:17 -0500 Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id sAQEpCrR025582; Wed, 26 Nov 2014 09:51:12 -0500 Received: by pastel.home (Postfix, from userid 20848) id 385224820; Wed, 26 Nov 2014 09:51:12 -0500 (EST) From: Stefan Monnier To: Jonas Bernoulli Subject: Re: bug#19188: point adjustemnt moves *into* invisible text Message-ID: References: <87tx1mwtgn.fsf@bernoul.li> Date: Wed, 26 Nov 2014 09:51:12 -0500 In-Reply-To: <87tx1mwtgn.fsf@bernoul.li> (Jonas Bernoulli's message of "Wed, 26 Nov 2014 04:07:04 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5137=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5137> : inlines <1561> : streams <1348990> : uri <1836222> X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: control Cc: 19188-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) tags 19188 notabug thanks > However point is not were the cursor is > M-: (point) => 3 > The problem is in the code that is supposed to move point *out* of an > invisible region, does the opposite when moving backward places point > on the first character after an invisible region. It moves to the > beginning of the preceding invisible region. That is a common misunderstanding. The fact that point is equal to 3 means that point is *between* character 2 and character 3. So it's not *inside* an invisible text, but is right at the boundary. The position 5 (i.e. between character 4 and character 5) is at the other end of the boundary. The reason why Emacs decided to put point at position 3 rather than leave it at position 5 is because the boundary at position 3 is "less invisible" than the boundary at position 5. You can check it with M-: (list (get-pos-property 3 'invisible) (get-pos-property 5 'invisible)) RET This is because text-properties by default are front-non-sticky and rear-sticky, so if point is at position 5 and you type a character, that character will inherit the invisible property, whereas if you're at position 3 and you type a character this character will not inherit the invisible property. If you want point to be at position 5 rather than position 3, then you need to change the front/rear-stickiness of this invisible property accordingly. > When point adjustment is disabled (non-nil disable-point-adjustment or > global-disable-point-adjustment) then this does not happen. I assume you know why ;-) > It also does not happen when moving forward, e.g. starting at "1" > C-p C-f places the cursor on "5" *and* point is also 5. C-p C-f doesn't do it for me (it doesn't even reach the invisible part of the text), and if I change the recipe to C-f C-f it doesn't work either (point stays at position 3). But indeed C-n gets me to position 5, which is wrong (and doing M-: (point) returns 5 but moves me to position 3, so doing it again returns 3 :-( ). So we do have a bug here. Stefan From unknown Tue Jun 24 17:29:34 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Jonas Bernoulli Subject: bug#19188: closed (Re: bug#19188: point adjustemnt moves *into* invisible text) Message-ID: References: <87tx1mwtgn.fsf@bernoul.li> X-Gnu-PR-Message: they-closed 19188 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: notabug Reply-To: 19188@debbugs.gnu.org Date: Wed, 26 Nov 2014 14:52:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1417013523-25892-1" This is a multi-part message in MIME format... ------------=_1417013523-25892-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #19188: point adjustemnt moves *into* invisible text which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 19188@debbugs.gnu.org. --=20 19188: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D19188 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1417013523-25892-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 19188-done) by debbugs.gnu.org; 26 Nov 2014 14:51:20 +0000 Received: from localhost ([127.0.0.1]:45729 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xtdw8-0006iK-0S for submit@debbugs.gnu.org; Wed, 26 Nov 2014 09:51:20 -0500 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:56016) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xtdw4-0006i6-Mn; Wed, 26 Nov 2014 09:51:17 -0500 Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id sAQEpCrR025582; Wed, 26 Nov 2014 09:51:12 -0500 Received: by pastel.home (Postfix, from userid 20848) id 385224820; Wed, 26 Nov 2014 09:51:12 -0500 (EST) From: Stefan Monnier To: Jonas Bernoulli Subject: Re: bug#19188: point adjustemnt moves *into* invisible text Message-ID: References: <87tx1mwtgn.fsf@bernoul.li> Date: Wed, 26 Nov 2014 09:51:12 -0500 In-Reply-To: <87tx1mwtgn.fsf@bernoul.li> (Jonas Bernoulli's message of "Wed, 26 Nov 2014 04:07:04 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5137=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5137> : inlines <1561> : streams <1348990> : uri <1836222> X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 19188-done Cc: 19188-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) tags 19188 notabug thanks > However point is not were the cursor is > M-: (point) => 3 > The problem is in the code that is supposed to move point *out* of an > invisible region, does the opposite when moving backward places point > on the first character after an invisible region. It moves to the > beginning of the preceding invisible region. That is a common misunderstanding. The fact that point is equal to 3 means that point is *between* character 2 and character 3. So it's not *inside* an invisible text, but is right at the boundary. The position 5 (i.e. between character 4 and character 5) is at the other end of the boundary. The reason why Emacs decided to put point at position 3 rather than leave it at position 5 is because the boundary at position 3 is "less invisible" than the boundary at position 5. You can check it with M-: (list (get-pos-property 3 'invisible) (get-pos-property 5 'invisible)) RET This is because text-properties by default are front-non-sticky and rear-sticky, so if point is at position 5 and you type a character, that character will inherit the invisible property, whereas if you're at position 3 and you type a character this character will not inherit the invisible property. If you want point to be at position 5 rather than position 3, then you need to change the front/rear-stickiness of this invisible property accordingly. > When point adjustment is disabled (non-nil disable-point-adjustment or > global-disable-point-adjustment) then this does not happen. I assume you know why ;-) > It also does not happen when moving forward, e.g. starting at "1" > C-p C-f places the cursor on "5" *and* point is also 5. C-p C-f doesn't do it for me (it doesn't even reach the invisible part of the text), and if I change the recipe to C-f C-f it doesn't work either (point stays at position 3). But indeed C-n gets me to position 5, which is wrong (and doing M-: (point) returns 5 but moves me to position 3, so doing it again returns 3 :-( ). So we do have a bug here. Stefan ------------=_1417013523-25892-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 26 Nov 2014 03:09:57 +0000 Received: from localhost ([127.0.0.1]:45470 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XtSzM-0003BE-QM for submit@debbugs.gnu.org; Tue, 25 Nov 2014 22:09:57 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56999) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XtSzL-0003B4-0I for submit@debbugs.gnu.org; Tue, 25 Nov 2014 22:09:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XtSzA-0003Gr-Hk for submit@debbugs.gnu.org; Tue, 25 Nov 2014 22:09:54 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:59882) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtSzA-0003Gm-F7 for submit@debbugs.gnu.org; Tue, 25 Nov 2014 22:09:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtSz2-0000Gl-TT for bug-gnu-emacs@gnu.org; Tue, 25 Nov 2014 22:09:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XtSyv-0003FV-CB for bug-gnu-emacs@gnu.org; Tue, 25 Nov 2014 22:09:36 -0500 Received: from mail.hostpark.net ([212.243.197.30]:42978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtSyv-0003FO-5f for bug-gnu-emacs@gnu.org; Tue, 25 Nov 2014 22:09:29 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 17F3F16FD1 for ; Wed, 26 Nov 2014 04:09:26 +0100 (CET) X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail1.hostpark.net [127.0.0.1]) (amavisd-new, port 10124) with ESMTP id LYRNDJd-Tv9Z for ; Wed, 26 Nov 2014 04:09:26 +0100 (CET) Received: from lem (80-218-85-1.dclient.hispeed.ch [80.218.85.1]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPS id E5134176DF for ; Wed, 26 Nov 2014 04:09:25 +0100 (CET) From: Jonas Bernoulli To: Bug-Gnu-Emacs Subject: point adjustemnt moves *into* invisible text Date: Wed, 26 Nov 2014 04:07:04 +0100 Message-ID: <87tx1mwtgn.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) When moving backward "point adjustment" which is supposed to move point out of an invisible region may end up doing the opposite. This problem exists at least in 24.3 and 24.4. 1. Yank this in an empty buffer in fundamental-mode and evaluate it. (progn (goto-char (point-min)) (insert "1\n" (propertize "3\n" 'invisible t) "5\n" "7\n") (backward-char 2)) 2. The cursor is now on the "7", which also is the 7th character. The buffer looks like .----- |1 |5 |7 |(progn |... `----- The cursor sits on the "7" and M-: (point) => 7 3. Move to "5" using e.g. C-p or C-b C-b. The cursor is now on "5", which also is the 5th character. However point is not were the cursor is M-: (point) => 3 The problem is in the code that is supposed to move point *out* of an invisible region, does the opposite when moving backward places point on the first character after an invisible region. It moves to the beginning of the preceding invisible region. When point adjustment is disabled (non-nil disable-point-adjustment or global-disable-point-adjustment) then this does not happen. It also does not happen when moving forward, e.g. starting at "1" C-p C-f places the cursor on "5" *and* point is also 5. ------------=_1417013523-25892-1-- From unknown Tue Jun 24 17:29:34 2025 X-Loop: help-debbugs@gnu.org Subject: bug#19188: point adjustemnt moves *into* invisible text Resent-From: Jonas Bernoulli Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Dec 2014 19:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19188 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug To: Stefan Monnier Cc: 19188-done@debbugs.gnu.org Received: via spool by 19188-done@debbugs.gnu.org id=D19188.141927693112754 (code D ref 19188); Mon, 22 Dec 2014 19:36:01 +0000 Received: (at 19188-done) by debbugs.gnu.org; 22 Dec 2014 19:35:31 +0000 Received: from localhost ([127.0.0.1]:55168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y38lO-0003Je-QJ for submit@debbugs.gnu.org; Mon, 22 Dec 2014 14:35:31 -0500 Received: from mail.hostpark.net ([212.243.197.30]:54099) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y38lM-0003JS-DB for 19188-done@debbugs.gnu.org; Mon, 22 Dec 2014 14:35:29 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id D448616F3C; Mon, 22 Dec 2014 20:35:26 +0100 (CET) X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail0.hostpark.net [127.0.0.1]) (amavisd-new, port 10124) with ESMTP id RMVcra_EPrj3; Mon, 22 Dec 2014 20:35:26 +0100 (CET) Received: from lem (80-218-85-1.dclient.hispeed.ch [80.218.85.1]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id 986E816F24; Mon, 22 Dec 2014 20:35:26 +0100 (CET) References: <87tx1mwtgn.fsf@bernoul.li> From: Jonas Bernoulli In-reply-to: Date: Mon, 22 Dec 2014 20:32:38 +0100 Message-ID: <87ioh3cwfd.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Sorry for the delay. Stefan Monnier writes: > The fact that point is equal to 3 means that point is *between* > character 2 and character 3. So it's not *inside* an invisible text, > but is right at the boundary. I understand that and should have chosen my words more carefully. I noticed that the behavior was not consistent and jumped to the conclusion that the invisibility property did receive some special handling but that there was a bug in how that was done. Turns out it is supposed to behave according to its stickyness, like other properties. It is however possible to get the behavior that I want. This requires that `invisible's stickyness is set accordingly. (push (cons 'invisible t) text-property-default-nonsticky) For modes with collapsible section (magit, org-mode ...) this behavior makes a lot of sense. Basically this teaches Emacs to define `invisible' as "cannot be seen by the eye", which happens to be a reasonable definition I would think :-) Also required is this hack which relies on `get-text-property' and `get-pos-property' disagreeing about the value of `invisible'. (add-hook 'post-command-hook #'magit-post-command-adjust-point t t) (defun magit-post-command-adjust-point () (when (and (get-text-property (point) 'invisible) (not (if (fboundp 'get-pos-property) ; since 24.4, see #1671 (get-pos-property (point) 'invisible) (get-text-property (1+ (point)) 'invisible)))) (goto-char (next-single-char-property-change (point) 'invisible)))) Is there a better way? I am not (no longer) convinced that Emacs should necessarily behave the way I thought it was supposed to; not by default at least. But I do think that in some cases it feels strange to adjust point, just because point is "property-invisible" and even though the following character were the cursor would be displayed is "visible-to-the-eye". It is especially confusing when only point is adjusted and the cursor stays were it would have been without the adjustment of point. So maybe, just maybe, it might make sense if "property-visible-point" and "eye-visible-cursor" would agree by default. > > The position 5 (i.e. between character 4 and character 5) is at the > other end of the boundary. > > The reason why Emacs decided to put point at position 3 rather than > leave it at position 5 is because the boundary at position 3 is "less > invisible" than the boundary at position 5. > You can check it with > > M-: (list (get-pos-property 3 'invisible) (get-pos-property 5 'invisible)) RET > > This is because text-properties by default are front-non-sticky and > rear-sticky, so if point is at position 5 and you type a character, that > character will inherit the invisible property, whereas if you're at > position 3 and you type a character this character will not inherit the > invisible property. > > If you want point to be at position 5 rather than position 3, then you > need to change the front/rear-stickiness of this invisible > property accordingly. > >> When point adjustment is disabled (non-nil disable-point-adjustment or >> global-disable-point-adjustment) then this does not happen. > > I assume you know why ;-) > >> It also does not happen when moving forward, e.g. starting at "1" >> C-p C-f places the cursor on "5" *and* point is also 5. > > C-p C-f doesn't do it for me (it doesn't even reach the invisible part of the > text), and if I change the recipe to C-f C-f it doesn't work either > (point stays at position 3). > > But indeed C-n gets me to position 5, which is wrong (and doing M-: (point) > returns 5 but moves me to position 3, so doing it again returns 3 :-( ). > So we do have a bug here. > > > Stefan From unknown Tue Jun 24 17:29:34 2025 X-Loop: help-debbugs@gnu.org Subject: bug#19188: point adjustemnt moves *into* invisible text Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Dec 2014 04:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19188 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug To: Jonas Bernoulli Cc: 19188-done@debbugs.gnu.org Received: via spool by 19188-done@debbugs.gnu.org id=D19188.14193078924702 (code D ref 19188); Tue, 23 Dec 2014 04:12:01 +0000 Received: (at 19188-done) by debbugs.gnu.org; 23 Dec 2014 04:11:32 +0000 Received: from localhost ([127.0.0.1]:55409 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y3Gom-0001Dl-C2 for submit@debbugs.gnu.org; Mon, 22 Dec 2014 23:11:32 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:54792) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y3Goi-0001Dc-TB for 19188-done@debbugs.gnu.org; Mon, 22 Dec 2014 23:11:29 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjsPAOwQflTO+ILA/2dsb2JhbABbgweDYIVaxR0EAgKBJBcBAQEBAQF8hAMBAQMBViMFCws0EhQYDSSISgnWWQEBAQEGAQEBAR6QbweESAWLAaQugXiEGSGCdwEBAQ X-IPAS-Result: AjsPAOwQflTO+ILA/2dsb2JhbABbgweDYIVaxR0EAgKBJBcBAQEBAQF8hAMBAQMBViMFCws0EhQYDSSISgnWWQEBAQEGAQEBAR6QbweESAWLAaQugXiEGSGCdwEBAQ X-IronPort-AV: E=Sophos;i="5.07,502,1413259200"; d="scan'208";a="103234863" Received: from 206-248-130-192.dsl.teksavvy.com (HELO pastel.home) ([206.248.130.192]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 22 Dec 2014 23:11:28 -0500 Received: by pastel.home (Postfix, from userid 20848) id F19A21E17; Mon, 22 Dec 2014 23:11:27 -0500 (EST) From: Stefan Monnier Message-ID: References: <87tx1mwtgn.fsf@bernoul.li> <87ioh3cwfd.fsf@bernoul.li> Date: Mon, 22 Dec 2014 23:11:27 -0500 In-Reply-To: <87ioh3cwfd.fsf@bernoul.li> (Jonas Bernoulli's message of "Mon, 22 Dec 2014 20:32:38 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > Also required is this hack which relies on `get-text-property' and > `get-pos-property' disagreeing about the value of `invisible'. > (add-hook 'post-command-hook #'magit-post-command-adjust-point t t) > (defun magit-post-command-adjust-point () > (when (and (get-text-property (point) 'invisible) > (not (if (fboundp 'get-pos-property) ; since 24.4, see #1671 > (get-pos-property (point) 'invisible) > (get-text-property (1+ (point)) 'invisible)))) > (goto-char (next-single-char-property-change (point) 'invisible)))) > Is there a better way? I don't know, because I don't know what it's trying to do. > It is especially confusing when only point is adjusted and the cursor > stays were it would have been without the adjustment of point. IIUC you're describing a situation where the display is incorrect, so I think this would be a bug. >> But indeed C-n gets me to position 5, which is wrong (and doing M-: (point) >> returns 5 but moves me to position 3, so doing it again returns 3 :-( ). >> So we do have a bug here. I filed a separate bug report about this problem. Stefan