Function: mh-flet

mh-flet is a macro defined in mh-acros.el.gz.

Signature

(mh-flet BINDINGS &rest BODY)

Documentation

Make temporary overriding function definitions.

That is, temporarily rebind the functions listed in BINDINGS and then execute BODY. BINDINGS is a list containing one or more lists of the form (FUNCNAME ARGLIST BODY...), similar to defun.

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-acros.el.gz
;; Emacs 24 made flet obsolete and suggested either cl-flet or
;; cl-letf. This macro is based upon gmm-flet from Gnus.
(defmacro mh-flet (bindings &rest body)
  "Make temporary overriding function definitions.
That is, temporarily rebind the functions listed in BINDINGS and then
execute BODY.  BINDINGS is a list containing one or more lists of the
form (FUNCNAME ARGLIST BODY...), similar to defun."
  (declare (indent 1) (debug ((&rest (sexp sexp &rest form)) &rest form)))
  (if (fboundp 'cl-letf)
      `(cl-letf ,(mapcar (lambda (binding)
                           `((symbol-function ',(car binding))
                             (lambda ,@(cdr binding))))
                         bindings)
         ,@body)
    `(flet ,bindings ,@body)))