unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: PATCH: ewoc.el to permit node representation abutment
Date: Fri, 05 May 2006 09:20:08 -0400	[thread overview]
Message-ID: <8764kkty67.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <E1Fbz1f-0002Xo-00@surf.glug.org> (Thien-Thi Nguyen's message of "Fri, 05 May 2006 14:03:15 +0200")

> 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	other threads:[~2006-05-05 13:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-05 12:03 PATCH: ewoc.el to permit node representation abutment Thien-Thi Nguyen
2006-05-05 13:20 ` Stefan Monnier [this message]
2006-05-05 21:43   ` ttn
2006-05-08  8:48     ` Thien-Thi Nguyen
2006-05-08 15:04       ` Stefan Monnier
2006-05-13  5:08         ` Thien-Thi Nguyen

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=8764kkty67.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --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).