emacs-devel
[Top][All Lists]
Advanced

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

Re: Where to put fix for #22317, mh-e: wrong usage of cl-flet


From: Stefan Monnier
Subject: Re: Where to put fix for #22317, mh-e: wrong usage of cl-flet
Date: Mon, 02 May 2016 00:49:17 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

> +(defmacro mh-flet (bindings &rest body)
> +  "Make temporary overriding function definitions.
> +This is an analogue of a dynamically scoped `let' that operates on
> +the function cell of FUNCs rather than their value cell.
> +
> +\(fn ((FUNC ARGLIST BODY...) ...) FORM...)"
> +  (if (fboundp 'cl-letf)
> +      `(cl-letf ,(mapcar (lambda (binding)
> +                           `((symbol-function ',(car binding))
> +                             (lambda ,@(cdr binding))))
> +                         bindings)
> +         ,@body)
> +    `(flet ,bindings ,@body)))

As long as you use (require 'cl), then I see no reason to stop using `flet'.
If you're annoyed by the warning, then add a `with-no-warnings'.
Or use `letf' unconditionally.

The other option is to stop using (require 'cl) and start using (require
'cl-lib) instead, in which case you'll want to always use cl-letf.
`cl-lib' is distributed in GNU ELPA and should work on XEmacs and Emacsā‰„22.

In neither of those 3 solutions do you need to switch between
2 different expansions.

> +(put 'mh-flet 'lisp-indent-function 1)
> +(put 'mh-flet 'edebug-form-spec
> +     '((&rest (sexp sexp &rest form)) &rest form))

I think even the oldest emacsen you support can handle

   (declare (indent 1) (debug ((&rest (sexp sexp &rest form)) &rest form)))

so I recommend you use that instead.


        Stefan




reply via email to

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