[Top][All Lists]

[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: Bill Wohler
Subject: Re: Where to put fix for #22317, mh-e: wrong usage of cl-flet
Date: Mon, 30 May 2016 17:04:51 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> +(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.

I just committed Katsumi's version to the emacs-25 branch as it had been
well tested. I'd be interested in hearing his opinion on your
suggestions to improve the code.

Bill Wohler <address@hidden> aka <address@hidden>

reply via email to

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