diff options
author | Stefan Kangas <stefan@marxist.se> | 2022-08-06 20:33:50 +0200 |
---|---|---|
committer | Stefan Kangas <stefan@marxist.se> | 2022-08-06 20:33:50 +0200 |
commit | f8354d1935c8900a5b8dada7ba564cdd6dafdc93 (patch) | |
tree | bfec9d2edc2e02096f6a31ce769bc79ff643b66e /lisp/mh-e/mh-acros.el | |
parent | db2b5e784b2031f788af455f7056015bd15ce719 (diff) | |
download | emacs-f8354d1935c8900a5b8dada7ba564cdd6dafdc93.tar.gz |
Move mh-flet macro to mh-acros.el
* lisp/mh-e/mh-compat.el (mh-flet): Move from here...
* lisp/mh-e/mh-acros.el (mh-flet): ...to here.
Diffstat (limited to 'lisp/mh-e/mh-acros.el')
-rw-r--r-- | lisp/mh-e/mh-acros.el | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lisp/mh-e/mh-acros.el b/lisp/mh-e/mh-acros.el index 805b0820b03..31630b43ca6 100644 --- a/lisp/mh-e/mh-acros.el +++ b/lisp/mh-e/mh-acros.el @@ -269,6 +269,22 @@ MH-E functions." binders) (let* ,binders ,@body)))) +;; 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))) + (provide 'mh-acros) ;; Local Variables: |