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: Sun, 18 Nov 2007 16:27:09 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

>>>(put-text-property 6 7 `invisible t)
>>>(put-text-property 12 13 `invisible t)
>>>(put-text-property 18 19 `invisible t)
>>>(put-text-property 24 25 `invisible t)
>>>(put-text-property 30 31 `invisible t)

These will cause problems with `forward-line'.

I'd propose to use

(add-text-properties 6 7 '(invisible t rear-nonsticky t))
(add-text-properties 12 13 '(invisible t rear-nonsticky t))
(add-text-properties 18 19 '(invisible t rear-nonsticky t))
(add-text-properties 24 25 '(invisible t rear-nonsticky t))
(add-text-properties 30 31 '(invisible t rear-nonsticky t))

instead.

>>>C-p beginning of line4.  Why did we skip line5?
>>>C-p beginning of line2.  Skipped line3.

See above.  Verify by running (forward-line -1) on these.  Your results
may differ according to the value of `track-eol'.

>>This behavior still exists in GNU Emacs 23.0.50.4 (i686-pc-linux-gnu,
>>GTK+ Version 2.12.0) of 2007-11-09 on escher.[1]  In addition, starting
>>with the cursor at (point-min), the line number indicator in the mode
>>line displays L1, and it continues to display L1 as you advance either
>>by C-n or by C-f until it reaches the `l' of `line7', then it changes to
>>L7.  From there if you type C-b moving point to just after `6', the mode
>>line displays L6.  Now continuing backwards either by C-p or C-b the
>>mode line usually continues to display L6, even at (point-min).  Typing
>>C-b again here then changes the display to L1.

We have been discussing this at the beginning of this year but I don't
recall the thread.  I seem to recall that Emacs tries to optimize line
number calculations as long as the buffer is not modified.

> In current development Emacs, the cursor stays put, i.e., C-p is a no-op
> here; the same goes for every position in line 3, except the beginning
> of the line: here C-p goes to the beginning of line 1 (the parenthetical
> comment doesn't make sense, unless it is a typo for line 1, or maybe he
> means the mode line should display L2 instead of L3, even though the
> cursor stays put).

This seems like a bug in `line-move-finish', please try the attached
patch (untested).

>>At the beginning of line 3, C-e goes to "i" in line 3.
>>        (should go to the end of line 3)
>
>
> In current development Emacs, the cursor goes to the end of line 1
> (anywhere else on line 3, C-e goes to the end of line 3).  On the other
> hand, C-a at the beginning of line 3 goes to "i" in line 3 (elsewhere it
> goes to the beginning of the line, so that repeatedly typing C-a
> starting from the beginning of line 3 makes the cursor oscillate between
> the first and second columns of the line).
>
>
>>(2) If line-move-ignore-invisible is t:
>>
>>At the end of line 1, C-n goes to the beginning of line 3.
>>        (should go to the end of line 3)
>>At the end of line 4, C-p goes to the beginning of line 3.
>>        (should go to the end of line 3)
>>At the beginning of the line 3, C-e goes to "i" in line 3.
>>        (should go to the end of line 3)

There's likely also a bug in `line-move-to-column': `move-to-column'
apparently skips invisible text (I didn't find any documentation for
that).  I tried to fix it in a really awkward way in the same patch.
*** simple.el.~1.888.~  Sat Nov 10 09:23:20 2007
--- simple.el   Sun Nov 18 16:02:42 2007
***************
*** 3862,3868 ****
             (save-excursion
               ;; Like end-of-line but ignores fields.
               (skip-chars-forward "^\n")
!              (while (and (not (eobp)) (invisible-p (point)))
                 (goto-char (next-char-property-change (point)))
                 (skip-chars-forward "^\n"))
               (point))))
--- 3862,3869 ----
             (save-excursion
               ;; Like end-of-line but ignores fields.
               (skip-chars-forward "^\n")
!              (while (and line-move-ignore-invisible
!                          (not (eobp)) (invisible-p (point)))
                 (goto-char (next-char-property-change (point)))
                 (skip-chars-forward "^\n"))
               (point))))
***************
*** 3940,3948 ****
  This function works only in certain cases,
  because what we really need is for `move-to-column'
  and `current-column' to be able to ignore invisible text."
!   (if (zerop col)
!       (beginning-of-line)
      (move-to-column col))

    (when (and line-move-ignore-invisible
             (not (bolp)) (invisible-p (1- (point))))
--- 3941,3956 ----
  This function works only in certain cases,
  because what we really need is for `move-to-column'
  and `current-column' to be able to ignore invisible text."
!   (cond
!    ((zerop col)
!     (beginning-of-line))
!    (line-move-ignore-invisible
      (move-to-column col))
+    (t
+     ;; Tedious.
+     (save-restriction
+       (narrow-to-region (line-beginning-position) (line-end-position))
+       (move-to-column col))))

    (when (and line-move-ignore-invisible
             (not (bolp)) (invisible-p (1- (point))))

reply via email to

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