From c2adb89a954a29dd6ad1b561dbb04a12a312be64 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Tue, 18 Feb 2025 09:40:22 +0100 Subject: [PATCH] scope.el: Special handling for cl-letf --- lisp/emacs-lisp/scope.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lisp/emacs-lisp/scope.el b/lisp/emacs-lisp/scope.el index eb00cd17859..87b073f0cac 100644 --- a/lisp/emacs-lisp/scope.el +++ b/lisp/emacs-lisp/scope.el @@ -1437,6 +1437,20 @@ a (possibly empty) list of safe macros.") (put 'defmacro 'scope-analyzer #'scope--analyze-defun) (put 'ert-deftest 'scope-analyzer #'scope--analyze-defun) +(scope-define-macro-analyzer cl-letf (l bindings &rest body) + (let ((l0 l)) + (dolist (binding bindings) + (let ((place (car binding))) + (if (or (symbol-with-pos-p place) (symbolp place)) + (let* ((bare (bare-symbol place)) + (len (length (symbol-name bare))) + (beg (scope-sym-pos place))) + (when beg (scope-report 'variable beg len beg)) + (setq l (scope-local-new bare beg l))) + (scope-1 l0 place)) + (scope-1 l0 (cadr binding)))) + (scope-n l body))) + (scope-define-macro-analyzer setf (l &rest args) (scope-n l args)) -- 2.39.5