unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Subject: move-beginning-of-line
Date: Wed, 02 Mar 2005 00:01:16 +0100	[thread overview]
Message-ID: <m3fyzfm0n7.fsf@kfs-l.imdomain.dk> (raw)


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 <storm@cua.dk> http://www.cua.dk

             reply	other threads:[~2005-03-01 23:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-01 23:01 Kim F. Storm [this message]
2005-03-14  2:58 ` move-beginning-of-line Luc Teirlinck
2005-03-14  8:20   ` move-beginning-of-line Kim F. Storm
2005-03-14 16:48     ` move-beginning-of-line Ralf Angeli
2005-03-14 17:31       ` move-beginning-of-line David Kastrup
2005-03-14 17:52         ` move-beginning-of-line Ralf Angeli
2005-03-14 18:48       ` move-beginning-of-line Stefan Monnier
2005-03-15 18:38         ` move-beginning-of-line Richard Stallman
2005-03-15 18:39     ` move-beginning-of-line Richard Stallman
2005-03-15 22:23     ` move-beginning-of-line David Kastrup
     [not found] ` <m364zqibx2.fsf@zsu.sush.org>
2005-03-17 15:34   ` move-beginning-of-line Kim F. Storm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3fyzfm0n7.fsf@kfs-l.imdomain.dk \
    --to=storm@cua.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).