[Top][All Lists]

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

Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet,

From: Stefan Monnier
Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros.
Date: Tue, 04 Dec 2012 13:52:28 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> +;; `flet' and `labels' got obsolete since Emacs 24.3.
> +(defmacro gmm-flet (bindings &rest body)
> +  "Make temporary overriding function definitions.
> +
> +\(fn ((FUNC ARGLIST BODY...) ...) FORM...)"
> +  `(let (fn origs)
> +     (dolist (bind ',bindings)
> +       (setq fn (car bind))
> +       (push (cons fn (and (fboundp fn) (symbol-function fn))) origs)
> +       (fset fn (cons 'lambda (cdr bind))))
> +     (unwind-protect
> +      (progn ,@body)
> +       (dolist (orig origs)
> +      (if (cdr orig)
> +          (fset (car orig) (cdr orig))
> +        (fmakunbound (car orig)))))))
> +(put 'gmm-flet 'lisp-indent-function 1)

Please don't!

If you really can't stand the warning, then just do something like

   (defmacro gmm-flet (&rest r)
     (if (fboundp 'cl-flet) `(cl-flet ,@r) `(flet ,@r)))

After making sure that your uses of `flet' are compatible with `cl-flet'
and the other uses are changed to use something like (cl-)letf or
(better) defadvice.

Same for gmm-labels!


reply via email to

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