emacs-devel
[Top][All Lists]
Advanced

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

Re: PATCH: ewoc.el to permit node representation abutment


From: Stefan Monnier
Subject: Re: PATCH: ewoc.el to permit node representation abutment
Date: Fri, 05 May 2006 09:20:08 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> ewoc.el is pretty cool but as it stands it inserts a gratuitous newline
> between each node's "pretty-printed" representation.  this makes it
> unsuitable for single-line usage, a design bug in my book.  i've locally
> modified ewoc.el to allow abutment of a node's representation, and
> correspondingly its only in-emacs client, as shown by the appended
> patch.  here is a suitable ChangeLog entry:

Cool.  I assume you tested it with the most important case: when the
pretty-printer returns the empty string (so you can temporarily hide
elements, which is the main reason why I wanted this feature implemented).

>       * emacs-lisp/ewoc.el (ewoc--create-node): Don't insert
>       trailing newline.  Also, create marker with insertion type t.
>       (ewoc--refresh-node): Delete all text from current node's
>       start marker to the next one's.  Also, temporarily set the
>       marker's insertion type to nil around the pretty-printer call.

Ah, setting the marker's insertion type is a great idea.

The problem case is when we have at the same spot many empty elements, and
the one we refresh is one of the middle ones, so the preceding ones
shouldn't move but the subsequent ones should.  It seems your code doesn't
pay attention to this detail and will either move the preceding ones as well
or fail to move the subsequent ones.

>       (ewoc-create): Use marker insertion type t.  Elide two lambdas.

Your "elide a lambda" is pretty much an "eta reduction".  Thanks for
spotting it.

> !       (let* ((pp (ewoc--pretty-printer ewoc))
> !              (node (ewoc--node-nth dll 1))
> !              (m (ewoc--node-start-marker node)))
>       (while (not (eq node footer))
> !       (set-marker m (point))
> !           (set-marker-insertion-type m nil)
> !       (funcall pp (ewoc--node-data node))
> !           (set-marker-insertion-type m t)
> !       (setq node (ewoc--node-next dll node)
> !                 m (ewoc--node-start-marker node)))))
>       (set-marker (ewoc--node-start-marker footer) (point))))
  
Please move the let-declaration of `m' assignment to right after the `while'
rather than duplicating it (one before the while, the other at its end).


        Stefan




reply via email to

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