From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: `vertical-motion', `goto-line' set point to invisible text Date: Mon, 04 Jul 2011 14:10:11 -0400 Message-ID: References: <87ei28f4re.fsf@gmail.com> <8362njqtv8.fsf@gnu.org> <83y60eoz6w.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1309803807 31690 80.91.229.12 (4 Jul 2011 18:23:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 4 Jul 2011 18:23:27 +0000 (UTC) Cc: dmitry.kurochkin@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 04 20:23:19 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Qdnni-0003vS-SD for ged-emacs-devel@m.gmane.org; Mon, 04 Jul 2011 20:23:19 +0200 Original-Received: from localhost ([::1]:33674 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qdnnh-0004ca-Fg for ged-emacs-devel@m.gmane.org; Mon, 04 Jul 2011 14:23:17 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:38127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qdnb7-0001Kn-Qj for emacs-devel@gnu.org; Mon, 04 Jul 2011 14:10:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qdnb5-00022B-Sh for emacs-devel@gnu.org; Mon, 04 Jul 2011 14:10:17 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183]:49888 helo=ironport2-out.pppoe.ca) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qdnb3-00021S-99; Mon, 04 Jul 2011 14:10:13 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EABwBEk5FxIxr/2dsb2JhbABTp3t4iHrBGIY2BJ5chCw X-IronPort-AV: E=Sophos;i="4.65,474,1304308800"; d="scan'208";a="120401699" Original-Received: from 69-196-140-107.dsl.teksavvy.com (HELO pastel.home) ([69.196.140.107]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 04 Jul 2011 14:10:12 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id E86D258DBA; Mon, 4 Jul 2011 14:10:11 -0400 (EDT) In-Reply-To: <83y60eoz6w.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 04 Jul 2011 18:14:31 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.183 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:141547 Archived-At: >> >> AFAIK none of those positions are *inside* invisible text >> > Try "M-x describe-text-properties RET", and you will see this isn't >> > true. >> AFAIK, describe-text-properties describes the properties of the char >> *after* point, so if you're at the beginning of invisible text (yet not >> inside it), describe-text-properties will show the `invisible' property. > So how many character positions are invisible after this: > (insert "line1\nline2\nline3\n") > (goto-line 2) > (put-text-property (line-beginning-position) > (line-beginning-position 2) > 'invisible 'invis1) > ? Without running the code, I'd say 6 ("line2\n"). Why? > Also, since we show cursor on the character after point, By default, yes. > which is invisible, what exactly do we mean to achieve in this case by > adjust_point_for_property? The intention is just to avoid having point in the middle of invisible text and have things like C-f and C-b appear to do nothing (because they only move within some invisible text chunk). Also it's so that inserting text will usually result in this text being visible (and hopefully inserted right where the cursor was displayed). None of those properties are guaranteed by adjust_point_for_property, sadly, but it's the motivation behind it. > Finally, what do you think of this: > (progn (switch-to-buffer "test") > (insert "aline1\nbline2\ncline3\n") > (goto-line 2) > (put-text-property (line-beginning-position) > (line-beginning-position 2) > 'invisible 'invis1) > (add-to-invisibility-spec 'invis1) > (goto-char (point-max))) > Eval this in *scratch*, then type "C-p C-x =". You will see that > Emacs reports that point is position 8 and the character at point is > `b', whereas what is shown (correctly) under the cursor is `c' whose > buffer position is 15. Do you think this is correct behavior? In this area, I don't think there's a clear cut definition of what is correct and what is not. Depending on what is being done some behavior is preferable, and in other cases another behavior is preferable. If point is anywhere between "bline2\n" the display will be identical, so the fact that the cursor is drawn over the "c" that follows it does not necessarily imply that point should be "at the end of "bline2\n", since the cursor is also drawn right after the "aline1\n" and by that logic point should be at the beginning of "bline2\n". What tilts the decision one way rather than the other here is the stickiness: for all positions other than right before "bline2\n", self-insert-command at point will result in an invisible char being inserted, which is very rarely the intention of the user. Of course, in a read-only buffer this consideration may not matter, but note that this stickiness issue also happens to be a way by which Elisp packages can control in which part of the invisible text point will end up. Stefan