From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Kurochkin Newsgroups: gmane.emacs.devel Subject: Re: `vertical-motion', `goto-line' set point to invisible text Date: Sun, 03 Jul 2011 11:31:23 +0400 Message-ID: <87liwf4y7o.fsf@gmail.com> References: <87ei28f4re.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1309678383 17499 80.91.229.12 (3 Jul 2011 07:33:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 3 Jul 2011 07:33:03 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 03 09:32:53 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 1QdHAi-0001TX-Kz for ged-emacs-devel@m.gmane.org; Sun, 03 Jul 2011 09:32:53 +0200 Original-Received: from localhost ([::1]:56330 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdHAh-0007us-DA for ged-emacs-devel@m.gmane.org; Sun, 03 Jul 2011 03:32:51 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:46953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdH9r-0007mp-0J for emacs-devel@gnu.org; Sun, 03 Jul 2011 03:32:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QdH9p-0003e7-Cf for emacs-devel@gnu.org; Sun, 03 Jul 2011 03:31:58 -0400 Original-Received: from mail-fx0-f52.google.com ([209.85.161.52]:48807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdH9l-0003dN-Q3; Sun, 03 Jul 2011 03:31:54 -0400 Original-Received: by fxd18 with SMTP id 18so3904209fxd.39 for ; Sun, 03 Jul 2011 00:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; bh=dO5TakxckA5DUWQHgBVFuN+F47nAlLoOdxv7Pt7pjyU=; b=KrXKNRZ4XRbedGFHUebAqXSA94ok4PVTdXWG+WUNJquDM5yNKQumFHfdSmw4YHqlTw RurSb6UOH71x2gAB2bFH+DB94UyJo65bn4pysTisJuRvzf8xV9hCXm5zT6Wj7r584go9 tYX4XGkzm3iAbMqIiPqvrE8VEip0dvdZmCyZA= Original-Received: by 10.223.98.204 with SMTP id r12mr7496601fan.74.1309678311647; Sun, 03 Jul 2011 00:31:51 -0700 (PDT) Original-Received: from localhost ([83.149.47.102]) by mx.google.com with ESMTPS id h28sm3598529faj.29.2011.07.03.00.31.45 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 03 Jul 2011 00:31:50 -0700 (PDT) In-Reply-To: User-Agent: Notmuch/0.5-321-g41686e2 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.161.52 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:141487 Archived-At: Hi Eli. On Sun, 03 Jul 2011 02:55:31 -0400, Eli Zaretskii wrote: > > From: Dmitry Kurochkin > > Date: Sun, 03 Jul 2011 06:59:49 +0400 > > > > While working on notmuch [1] emacs client, I stumbled upon an unexpected > > behavior: `beginning-of-visual-line' places point to invisible text in > > the beginning to the line. I.e. you have: > > > > line1 > > line2 <--- this line is not visible > > line3 <--- point is on this line > > > > in this case, `beginning-of-visual-line' will set the position to start > > of line2 (which is invisible), not line3. It differs from what > > `move-beginning-of-line' and even does not match > > `line-beginning-position'. `beginning-of-visual-line' uses > > `vertical-motion' to do the job. `goto-line' has a similar behavior. I > > believe there are more functions like this. > > See the node "Invisible Text" in the ELisp manual. Some functions are > explicitly programmed to special behavior in the vicinity of invisible > text, others aren't. > Thanks for the hint. > > This does not look right to me. I expect these functions never set > > point inside invisible text and there should be some general way to > > protect from this. > > Are you sure you don't mix invisible with intangible? Yes, I know invisible is not the same as intangible. > Invisible means > just that: not shown on the screen. It doesn't mean point cannot > enter the invisible portion. Emacs does try to move point out of > invisible range of text, but it does so in its command loop, _after_ > the cursor motion functions and the display engine did their job. I guess that explains why in notmuch (which has multiple lines hidden, i.e. email body) I hit C-a, then M-: "(point)" I get X, then if I do M-: "(point)" again, I get Y. Is there a way to ask Emacs to sync point to visible position, so that I do not have to do it by hand? > So > your test program just shows that cursor motion has no problem getting > into the invisible region, which I think is not a bug. > > > But perhaps I am wrong and we have to manually skip > > all invisible text forward after any point move? > > Yes. > Thanks for your answers. > There is something strange in how we behave in this example, though. > To see it, modify your test program to make each line's 1st character > different from other lines. Then, after the program ends, C-a on the > 3rd line and type "C-x =": Emacs says the character at point is the > first character of the invisible line 2, which seems wrong, as the > display shows line 3. In fact, you cannot place point on the 1st > character of line 3: C-b from the 2nd character of line 3 gets you to > the 1st character of line 2! I think this happens because the range > of invisible characters includes the newline of line 2. Indeed, I did not notice that when testing in notmuch (I guess because there are many lines hidden). `backward-char' steps 1 position as expected. I.e. M-: (progn (backward-char) (point)) works fine. But after that M-: (point) returns another position which corresponds to the beginning of the hidden line. I guess this has to do command loop I know nothing about. IMO Emacs should not touch the point in this case, because it is already visible. Sounds like a bug to me. Regards, Dmitry