From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Cc: mh-e-devel@lists.sourceforge.net
Subject: Re: Where to put fix for #22317, mh-e: wrong usage of cl-flet
Date: Mon, 02 May 2016 00:49:17 -0400 [thread overview]
Message-ID: <jwvy47tf526.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: 83602.1462155588@olgas.newt.com
> +(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
next prev parent reply other threads:[~2016-05-02 4:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-02 2:19 Where to put fix for #22317, mh-e: wrong usage of cl-flet Bill Wohler
2016-05-02 2:39 ` Eli Zaretskii
2016-05-02 4:49 ` Stefan Monnier [this message]
2016-05-31 0:04 ` Bill Wohler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvy47tf526.fsf-monnier+gmane.emacs.devel@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=mh-e-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.