]> git.eshelyaron.com Git - emacs.git/commitdiff
scope.el: Special handling for cl-letf
authorEshel Yaron <me@eshelyaron.com>
Tue, 18 Feb 2025 08:40:22 +0000 (09:40 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 18 Feb 2025 08:40:22 +0000 (09:40 +0100)
lisp/emacs-lisp/scope.el

index eb00cd1785951a8742d50051172c32311c83542d..87b073f0cac75ff4333517c7607a53c3e0f45486 100644 (file)
@@ -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))