emacs-devel
[Top][All Lists]
Advanced

[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 20:29:46 -0800 (PST)

I was trying to implement actual with-wrapper for each functions,
mostly in simple.el, which are currently advised from table.el.  Then
I encountered a problem that some of them are built-in functions
written in C.  Currently I have no idea how to write C code that
bounds a variable.  Could someone help me write `with-wrappers' macro
equivalent C code?

-Tak

Sat, 01 Dec 2001 10:12:13 -0800 (PST): Tak Ota <address@hidden> wrote:

> (defvar inhibit-wrappers nil
>   "Non-nil inhibits invoking wrappers")
> 
> (defmacro with-wrappers (wrapper-form &rest body)
>   "Invoke wrappers in WRAPPERS-VAR if present, otherwise execute forms in 
> BODY.
> WRAPPER-FORM looks like (WRAPPERS-VAR ARG...), where ARG... is the
> list of arguments passed to each wrapper in list stored in
> WRAPPERS-VAR.  Each wrapper must call the original function from
> within itself.  While calling each wrapper, WRAPPERS-VAR is bound to
> the cdr of the list, so that recursive invocations of `with-wrappers'
> on the same variable will result in each wrapper in the list being
> called.  Use `add-hook' and `remove-hook' for manipuation of
> WRAPPERS-VAR.  When `inhibit-wrappers' is non-nil wrapper invokation
> is inhibited.
> 
> An example usage of this is:
> 
>   (defvar kill-region-wrappers nil)
> 
>   (defun kill-region (beg end)
>     (with-wrappers (kill-region-wrappers beg end)
>       ...ordinary kill-region stuff...))"
> 
>   (let ((wrapper-var (car wrapper-form))
>         (wrapper (make-symbol "wrapper")))
>     `(if (and (not inhibit-wrappers) ,wrapper-var)
>          (let ((,wrapper (car ,wrapper-var))
>                (,wrapper-var (cdr ,wrapper-var)))
>            (funcall ,wrapper ,@(cdr wrapper-form)))
>        ,@body)))



reply via email to

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