From 600846f5b62513c8774be81b455edf281f3a339f Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 18 Feb 2015 10:18:51 -0500 Subject: [PATCH] * cl-generic/cl-generic.el (cl-defmethod): Use cl-flet if available. --- packages/cl-generic/cl-generic.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/cl-generic/cl-generic.el b/packages/cl-generic/cl-generic.el index df09449ab..4b1a377ad 100644 --- a/packages/cl-generic/cl-generic.el +++ b/packages/cl-generic/cl-generic.el @@ -4,7 +4,7 @@ ;; Author: Stefan Monnier ;; vcomment: Emacs-25's version is 1.0 so this has to stay below. -;; Version: 0.1 +;; Version: 0.2 ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -101,15 +101,17 @@ ;; We could just alias `cl-call-next-method' to `call-next-method', ;; and that would work, but then files compiled with this cl-generic ;; wouldn't work in Emacs-25 any more. - ;; Also we use `labels' rather than one of cl-lib's macros, so as to - ;; be compatible with older emacsen (and ELPA's cl-lib emulation - ;; doesn't provide cl-flet and provides an incomplete cl-labels). + ;; Also we fallback on `labels' if `cl-flet' is not available + ;; (ELPA's cl-lib emulation doesn't provide cl-flet). + ;; We don't always use `labels' because that generates warnings + ;; in newer Emacsen where `cl-flet' is available. ,@(if qualifiers ;; Must be :before or :after, so can't call next-method. body - `((labels ((cl-call-next-method (&rest args) - (apply #'call-next-method args)) - (cl-next-method-p () (next-method-p))) + `((,(if (fboundp 'cl-flet) 'cl-flet 'labels) + ((cl-call-next-method (&rest args) + (apply #'call-next-method args)) + (cl-next-method-p () (next-method-p))) ,@body)))))))) (provide 'cl-generic) -- 2.39.2