From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: move-beginning-of-line Date: Wed, 02 Mar 2005 00:01:16 +0100 Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1109718150 13037 80.91.229.2 (1 Mar 2005 23:02:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 1 Mar 2005 23:02:30 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 02 00:02:30 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1D6GLc-00053L-6K for ged-emacs-devel@m.gmane.org; Wed, 02 Mar 2005 00:00:12 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D6GeG-0004e1-1U for ged-emacs-devel@m.gmane.org; Tue, 01 Mar 2005 18:19:28 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1D6Gdi-0004VB-5c for emacs-devel@gnu.org; Tue, 01 Mar 2005 18:18:54 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1D6GdY-0004Or-QD for emacs-devel@gnu.org; Tue, 01 Mar 2005 18:18:47 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D6GdY-0004Oh-NJ for emacs-devel@gnu.org; Tue, 01 Mar 2005 18:18:44 -0500 Original-Received: from [195.41.46.235] (helo=pfepa.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.34) id 1D6GMa-0003Xb-5v for emacs-devel@gnu.org; Tue, 01 Mar 2005 18:01:12 -0500 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepa.post.tele.dk (Postfix) with SMTP id CCE0047FE8B for ; Wed, 2 Mar 2005 00:01:10 +0100 (CET) Original-To: emacs-devel@gnu.org User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: main.gmane.org gmane.emacs.devel:34012 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:34012 As I indicated in another mail today, I have been looking at a problem with moving to the beginning of a line in a window with the following appearence: abc [ ] x[IMAGE]yz [ ] def Now, if I place the cursor on x, and do C-e, cursor moves to z. If I then do C-a, cursor moves to y, not x. The IMAGE is layed on top (via a display property) of text that ends in a newline, so formally, C-a (beginning-of-line) DTRT. However, from a user point of view, this is !TRT. Contrary to what I previously thought, this is not caused by an error in the move_it_vertically_backward function -- it is simply the way bolp and beginning-of-line work, i.e. they don't care if the newline before point is invisible. To fix this, I propose adding the following command to simple.el and binding it to C-a: (defun move-beginning-of-line (arg) "Move point to beginning of current display line. With argument ARG not nil or 1, move forward ARG - 1 lines first. If point reaches the beginning or end of buffer, it stops there. To ignore intangibility, bind `inhibit-point-motion-hooks' to t. This command does not move point across a field boundary unless doing so would move beyond there to a different line; if ARG is nil or 1, and point starts at a field boundary, point does not move. To ignore field boundaries bind `inhibit-field-text-motion' to t." (interactive "p") (or arg (setq arg 1)) (if (/= arg 1) (line-move (1- arg) t)) (let (done pos) (while (not done) (beginning-of-line 1) ;; (not bolp) means that it stopped at a field boundary. (if (or (bobp) (not (bolp))) (setq done t) (sit-for 0) (if (and (consp (setq pos (pos-visible-in-window-p (point) nil t))) (= (car pos) 0)) (setq done t) (backward-char 1)))))) I don't quite understand all of the "line-move" stuff in simple.el, so since this function looks quite different from its move-end-of-line counter-part, I would appreciate if someone would take a look at this to see whether it breaks something. Please also check if the doc string describes what's going on. -- Kim F. Storm http://www.cua.dk