emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Something is rotten with end-of-line and move-end-of-line


From: Lőrentey Károly
Subject: Re: Something is rotten with end-of-line and move-end-of-line
Date: Mon, 28 Nov 2005 23:24:40 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.52 (gnu/linux)

Lőrentey Károly <address@hidden> writes:
> Indeed, there are some bugs.
[...]
> Obviously this needs to be elaborated.

Here is a patch that updates the doc strings and fixes
move-end-of-line behaviour with respect to field boundaries.

diff -u -3 -p -r1.774 simple.el
*** simple.el   28 Nov 2005 19:59:34 -0000      1.774
--- simple.el   28 Nov 2005 22:10:28 -0000
***************
*** 3641,3658 ****
            (goto-char (previous-char-property-change (point) line-beg))))))))
  
  (defun move-end-of-line (arg)
!   "Move point to end of current 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))
!   (let (done)
      (while (not done)
        (let ((newpos
             (save-excursion
--- 3641,3664 ----
            (goto-char (previous-char-property-change (point) line-beg))))))))
  
  (defun move-end-of-line (arg)
!   "Move point to end 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.
  
! Unlike `end-of-line' (which see), this command ignores invisible
! newline characters while it searches for the end of the current
! line.  It moves the point to the end of the displayed screen
! line, which is not necessarily the same as the end of the current
! line in the buffer.
! 
! This command does not move point across the boundary of the
! current field.  To ignore field boundaries bind
! `inhibit-field-text-motion' to t."
    (interactive "p")
    (or arg (setq arg 1))
!   (let ((orig (point))
!       done)
      (while (not done)
        (let ((newpos
             (save-excursion
***************
*** 3664,3670 ****
                          (goto-char (previous-char-property-change (point))))
                        (backward-char 1)))
                 (point)))))
!       (goto-char newpos)
        (if (and (> (point) newpos)
                 (eq (preceding-char) ?\n))
            (backward-char 1)
--- 3670,3676 ----
                          (goto-char (previous-char-property-change (point))))
                        (backward-char 1)))
                 (point)))))
!       (goto-char (constrain-to-field newpos orig (/= arg 1) t nil))
        (if (and (> (point) newpos)
                 (eq (preceding-char) ?\n))
            (backward-char 1)
***************
*** 3682,3691 ****
  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)
--- 3688,3703 ----
  If point reaches the beginning or end of buffer, it stops there.
  To ignore intangibility, bind `inhibit-point-motion-hooks' to t.
  
! Unlike `beginning-of-line' (which see), this command ignores
! invisible newline characters while it searches for the beginning
! of the current line.  It moves the point to the beginning of the
! displayed screen line, which is not necessarily the same as the
! end of the current line in the buffer.
! 
! This command does not move point across the boundary of the
! current field.  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)
I have a feeling that C-e should behave like C-a on a field boundary,
and leave the point unchanged when it is at the field end.  This would
make these operations idempotent.

For example, let's say the buffer contents are

        other stuff FIELD other stuff

Suppose that the characters "FIELD" have the same (front-sticky) field
property, while the rest are non-field.  Currently,
move-beginning-of-line (C-a) is a no-op when point is before F:

        other stuff <!>FIELD other stuff

I argue that either C-a should be changed to go the line beginning, or
move-end-of-line should behave symmetrically, i.e. it should have the
following fixed point:

        other stuff FIELD<!> other stuff

This could be achieved by changing `constrain-to-field'.

The various behaviours of C-a/C-e near field-field boundaries are also
somewhat surprising at the moment.

-- 
Károly

reply via email to

[Prev in Thread] Current Thread [Next in Thread]