[Top][All Lists]

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

Re: table.el

From: Tak Ota
Subject: Re: table.el
Date: Sat, 01 Dec 2001 21:31:53 -0800 (PST)

Sat, 1 Dec 2001 21:30:08 -0700 (MST): Richard Stallman <address@hidden> wrote:

> If we need to introduce this concept of wrappers, your design seems
> mostly good (though the comments people have made are good ideas too).
> But I want to make sure we really need to go that far.  Could you show
> me and explain one or two examples of what the wrappers are needed
> for?

The reason why I needed wrapper mechanism was that I was advised by
you not to use advice in table.el, and that was because
`describe-function' of those advised functions mislead novice users to
table.el where there is no real information about the original
functions.  I personally dislike this shortcoming of

The wrapper mechanism is mostly equivalent to around-advice, which can
add pre-processing and post-processing to an existing function.  The
difference between wrappers and advice is that advice can target any
existing functions while wrapper must have the wrapping mechanism
having been embedded in the original function.  Advantage of the
wrapper mechanism over advice is that it can modify the behavior of
the original function without changing the attribute of the original
function unlike advice does.  Also wrapper is effective to those byte
compiled callers but advice is not.

How table.el uses around-advice or wrapping is simply to perform
pre-processing and post-processing for some functions that are
executed within a table cell.  Let's take `kill-region' as an example.
When `kill-region' is executed, if beg and end are in a same table
cell it is natural to treat that region as a cell local region instead
of a buffer wide region.  In the table.el there is a hidden cache
buffer that always contains the current cell contents.  When the
advised `kill-region' is invoked, the pro-processing first determines
that if the region is cell local or not by testing both beg and end
belongs to the same cell.  If not the original `kill-region' is
executed.  Otherwise, the current buffer is temporarily switched to
the cell cache buffer and the beg and end are translated from the
original buffer's locations to the cache buffer's corresponding
locations.  Then the original `kill-region' is invoked in the cache
buffer.  When it is done the pre-processing kicks in and the content
of the cache buffer is reformatted by filling paragraphs and the
current buffer is restored.  At the end a timer is set so that the new
cache content is reflected to the original buffer eventually.


reply via email to

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