unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: emacs-devel@gnu.org
Subject: Re: line/wrap-prefix patch
Date: Wed, 02 Jul 2008 00:19:17 +0200	[thread overview]
Message-ID: <87abh1i6xm.fsf@escher.local.home> (raw)
In-Reply-To: 61zlp3k2xx.fsf@fencepost.gnu.org

On Sun, 29 Jun 2008 23:38:02 -0400 Miles Bader <miles@gnu.org> 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





  parent reply	other threads:[~2008-07-01 22:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-30  3:38 line/wrap-prefix patch Miles Bader
2008-06-30  4:18 ` Miles Bader
2008-07-01  0:36   ` Miles Bader
2008-07-01  4:52     ` Chong Yidong
2008-07-01  5:38       ` Miles Bader
2008-07-01 14:10         ` Chong Yidong
2008-07-01 22:19 ` Stephen Berman [this message]
2008-07-03  4:19   ` Miles Bader
2008-07-04 20:50     ` Stephen Berman
2008-07-04 21:25       ` Stefan Monnier
2008-07-05  0:52       ` Miles Bader
2008-07-05 21:30         ` Stephen Berman
2008-07-06  1:05           ` Stefan Monnier

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=87abh1i6xm.fsf@escher.local.home \
    --to=stephen.berman@gmx.net \
    --cc=emacs-devel@gnu.org \
    /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).