From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jonas Bernoulli Newsgroups: gmane.emacs.bugs Subject: bug#19188: point adjustemnt moves *into* invisible text Date: Mon, 22 Dec 2014 20:32:38 +0100 Message-ID: <87ioh3cwfd.fsf@bernoul.li> References: <87tx1mwtgn.fsf@bernoul.li> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1419276987 2182 80.91.229.3 (22 Dec 2014 19:36:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 22 Dec 2014 19:36:27 +0000 (UTC) Cc: 19188-done@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 22 20:36:20 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y38m9-00061X-T5 for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Dec 2014 20:36:18 +0100 Original-Received: from localhost ([::1]:41688 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y38m9-0006DD-1G for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Dec 2014 14:36:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y38m0-0006D1-Cs for bug-gnu-emacs@gnu.org; Mon, 22 Dec 2014 14:36:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y38lu-0002x7-DE for bug-gnu-emacs@gnu.org; Mon, 22 Dec 2014 14:36:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45802) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y38lu-0002x1-9R for bug-gnu-emacs@gnu.org; Mon, 22 Dec 2014 14:36:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Y38lu-0003KL-0V for bug-gnu-emacs@gnu.org; Mon, 22 Dec 2014 14:36:02 -0500 X-Loop: help-debbugs@gnu.org 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 Original-Received: via spool by 19188-done@debbugs.gnu.org id=D19188.141927693112754 (code D ref 19188); Mon, 22 Dec 2014 19:36:01 +0000 Original-Received: (at 19188-done) by debbugs.gnu.org; 22 Dec 2014 19:35:31 +0000 Original-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 Original-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 Original-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 Original-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) Original-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) In-reply-to: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:97681 Archived-At: 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