emacs-devel
[Top][All Lists]
Advanced

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

Re: invisible


From: martin rudalics
Subject: Re: invisible
Date: Wed, 28 Nov 2007 23:41:23 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

> But how are lines and columns counted?  Does an invisible newline cause
> the intended column numbersto fall back to 0?  Does an invisible "a"
> cause the intended column numnber to stay put or to be incremented by 1?

We are talking about the default `line-move-ignore-invisible' t case, I
presume.  `col' is the column to move to (presumably the `goal-column'
but I didn't check this).  This code starts with

    (move-to-column col)

and the first question is whether we can find a case where this fails to
DTRT.  Apparently it might fail in the case

    (when (and (not (bolp)) (invisible-p (1- (point))))

which raises the question whether `move-to-column' would move to a
position following invisible text.  As I know now it does so iff that
text has a rear-nonsticky property (but I don't know about overlays).

Next our code goes into a loop

        (while (and (not (eobp)) (invisible-p (point)))
          (goto-char (next-char-property-change (point))))

which just skips invisible text and we can conclude that lines are _not_
counted.  Moreover, it's strange that `move-to-column' didn't skip that
invisible text as well, but maybe it's a newline.  The following piece
of code is contrived and I leave it as an exercise to anyone interested
to find out what it's intended to do:

        (if (> (current-column) normal-column)
            ;; We have made some progress towards the desired column.
            ;; See if we can make any further progress.
            (line-move-to-column (+ (current-column) (- col normal-column)))

This must have been the motivation to splice out `line-move-to-column'
back in 2001 - make it callable recursively.  I don't understand the ">"
here (`normal-column' is the column `move-to-column' moved to before).
And I completely fail to understand the argument calculation: Suppose
the desired `col' is 17 and `move-to-column' moved to column 14 on that
line because everything after 14 was invisible.  Also suppose the
invisible text ends at the end of some line hence `current-column' would
report 0 - or can you imagine `current-column' to report anything but
zero in this case?  Now should we move to column 3 here - or what am I
missing?

The else part goes as

          (goto-char normal-location)
          (let ((line-beg (line-beginning-position)))
            (while (and (not (bolp)) (invisible-p (1- (point))))
              (goto-char
               (previous-char-property-change (point) line-beg))))))))

which simply moves to the first visible position on the line where
`move-to-column' stopped.  IIUC `move-to-column' never stops at a
position following invisible text unless it's rear-nonsticky, hence this
loop would be needed only to handle that special case.

All this got you is more questions asked than answered :-(





reply via email to

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