> I'm trying to use an advice around the function; the advice providing
> a binding of the symbol `read-minibuffer' to the definition of
> `my-read-minibuffer'. Like the following:

> (defadvice la-fonction
>   (around la-fonction-extended enable compile)
>   "Documentation"
>    (let (f1)
>      (fset 'f1 read-minibuffer)
>      (fset 'read-minibuffer my-read-minibuffer)
>      ad-do-it
>      (fset 'read-minibuffer f1)))

> Any comment? Is it silly? Is there a better way? Any idea?

The last fset will not be executed if the ad-do-it signals an error (or is
interrupted with C-g, ...).  To protect against such eventualities, you want
to use unwind-protect.

An alternative is to use (require 'cl) and then

   (defadvice la-fonction
     (around la-fonction-extended enable compile)
     "Documentation"
     (flet ((read-minibuffer my-read-minibuffer))
       ad-do-it))

it does the same as what you did (except it uses unwind-protect), tho.
In general, I don't think there's a better way.  I would argue that if you
need to use such an ugly hack, you should only be morally allowed to do that
after sending a patch that will make it unnecessary in the future.

I.e. please try and send a patch that makes this hack unnecessary.
You can then use this hack, knowing that it's only a temporary workaround
until your patch is accepted and/or in widespread use.


        Stefan
_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

Reply via email to