emacs-devel
[Top][All Lists]
Advanced

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

Re: line/wrap-prefix patch


From: Stephen Berman
Subject: Re: line/wrap-prefix patch
Date: Wed, 02 Jul 2008 00:19:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

On Sun, 29 Jun 2008 23:38:02 -0400 Miles Bader <address@hidden> wrote:

> Here's a patch that implements the "wrap-prefix" feature discussed
> earlier.  It allows a prefix to be added to the beginning of each line
> wrapped by redisplay.
[...]
> Any comments?

I really like it.  I haven't tested it extensively yet, but it appears
to work for the most part as well as -- and in all likelihood in some
cases better than -- the modified version of longlines.el I wrote to get
this feature (posted at
<http://permalink.gmane.org/gmane.emacs.devel/100074>).  One nice
advantage of your implementation is that it does not, in conjunction
with auto-composition-mode, break isearch (see
<http://permalink.gmane.org/gmane.emacs.devel/90167>).  However, your
implementation does suffer from the same display problem at
(window-start) that mine does (see
<http://permalink.gmane.org/gmane.emacs.devel/86019>).  Here is a recipe
in terms of your implementation to show the problem:

1. emacs -Q

2. In an empty buffer type "test " enough time to make the line of text
longer than fill-column.

3. Type (setq word-wrap t wrap-prefix '(space :width 5)) and put the
cursor on the first `t' after the indentation.  Now the buffer displays
the following, where `|' marks the left fringe, and `^' the cursor:

|test test test test test test test test test test test test test test
|     test test 
      ^

4. Type M-: (scroll-up 1); now the buffer displays the following,
where again `|' marks the left fringe, and `^' the cursor:

|test test
 ^

That is, the displayed indentation is lost at window-start.  When I
reported this as a bug involving a display property with a newline
(which is what I use in my modification of longlines.el), RMS responded
thus:

> It seems to me that it is impossible to avoid this behavior,
> because the window-start value says to start the redisplay
> with the t that starts `test'.
> So it's more of a misfeature than a bug.

It still seems like a bug to me and I hope that you or someone else can
fix it.  

In fact, the problem is slightly worse (or at least different) in your
implementation than in mine.  Make the "test" line longer, so that after
wrapping it displays two indented lines, thus:

|test test test test test test test test test test test test test test test
|     test test test test test test test test test test test test test test
|     test test 

and append enough copies of that line to be able to scroll through
several screens, then scroll until you see this at the top of the
window:

|test test test test test test test test test test test test test test test
|     test test test test test test test test test test test test test test

The first line is in fact indented but this is not displayed due to the
"misfeature".  Now move the cursor up one line at a time until it gets
to the top and point is recentered.  Now you'll see this:

...
|test test test test test test test test test test test test test test test
|     test test test test test test test test test test test test test test
|     test test 
|test test test test test test test test test test test test test test test
|test test test test test test test test test test test test test test test
|     test test 
|test test test test test test test test test test test test test test test
|     test test test test test test test test test test test test test test
|     test test 
...

That is, the display bug is still visible, but now in the middle of the
window instead of at window-start.  Scrolling (but not line movement)
restores the proper display.  (In my implementation the display problem
seem confined to window-start, though it also has additional problems
that yours does not.)

I have two more comments.  One involves the continuation glyphs in the
fringes.  Probably it will usually be desirable to suppress them, but I
know of one case where it would be nice to suppress them only partially:
namely, if you have a long line that contains a string that cannot be
wrapped because it is longer than (window-width), such as a URL.  In
this case it would be nice to suppress the continuation glyphs on
wrappable long lines but display them on such unwrappable ones.

My final comment concerns adaptive filling.  In my modification of
longlines.el long lines are appropriately wrapped at different levels of
indentation, resulting in displays like this:

* test test test test test test test test test test test test test test 
  test test test test test test test test test test 
  * test test test test test test test test test test test test test 
    test test test test test test test test test test test test test 
    * test test test test test test test test test test test test test 
      test test test test test test test test test test test test test 
    * test test test test test test test test test test test test test 
      test test test test test test test test test test test test test 
  * test test test test test test test test test test test test test 
    test test test test test test test test test test

I get this by setting my equivalent of wrap-prefix to
(fill-context-prefix (line-beginning-position) (line-end-position)) each
time a new line is wrapped.  With your patch, doing (setq wrap-prefix
(fill-context-prefix (line-beginning-position) (line-end-position)))
results in a display like this:

* test test test test test test test test test test test test test test 
  test test test test test test test test test test 
  * test test test test test test test test test test test test test 
  test test test test test test test test test test test test test 
    * test test test test test test test test test test test test test 
  test test test test test test test test test test test test test 
    * test test test test test test test test test test test test test 
  test test test test test test test test test test test test test 
  * test test test test test test test test test test test test test 
  test test test test test test test test test test

It would be nice to get the appropriate indentation.

Steve Berman





reply via email to

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