]> git.eshelyaron.com Git - emacs.git/commitdiff
scope.el: Improve cl-loop analysis
authorEshel Yaron <me@eshelyaron.com>
Wed, 26 Feb 2025 18:50:28 +0000 (19:50 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 26 Feb 2025 18:50:28 +0000 (19:50 +0100)
lisp/emacs-lisp/scope.el

index 9c8c5a247482ac250cd0dd4bf22355ab68a1606f..7bbde581bbce4d53ba79814dd3208c154f559cea 100644 (file)
@@ -417,6 +417,8 @@ Optional argument LOCAL is a local context to extend."
   (scope-1 local form)
   (scope-loop local rest))
 
+(defvar scope-loop-into-vars nil)
+
 (defun scope-loop-collect (local expr rest)
   (scope-1 local expr)
   (let ((bw (scope-sym-bare (car rest)))
@@ -425,10 +427,15 @@ Optional argument LOCAL is a local context to extend."
         (let* ((var (car more))
                (bare (scope-sym-bare var))
                (beg (scope-sym-pos var)))
-          (when beg
-            (scope-report 'variable
-                          beg (length (symbol-name bare)) beg))
-          (scope-loop (scope-local-new bare beg local) (cdr more)))
+          (if (memq bare scope-loop-into-vars)
+              (progn
+                (scope-s local var)
+                (scope-loop local (cdr more)))
+            (when beg
+              (scope-report 'variable
+                            beg (length (symbol-name bare)) beg))
+            (let ((scope-loop-into-vars (cons bare scope-loop-into-vars)))
+              (scope-loop (scope-local-new bare beg local) (cdr more)))))
       (scope-loop local rest))))
 
 (defun scope-loop-with-and (local rest)
@@ -471,7 +478,11 @@ Optional argument LOCAL is a local context to extend."
        ((eq bare 'return)
         (scope-1 local (car rest))
         (scope-loop local (cdr rest))))
-    (scope-loop-do local next rest)))
+    (if (eq (scope-sym-bare (car-safe next)) 'return)
+        (progn
+          (scope-1 local (cadr next))
+          (scope-loop local (cdr rest)))
+      (scope-loop-do local next rest))))
 
 (defun scope-loop-initially (local next rest)
   (if (eq (scope-sym-bare next) 'do)
@@ -1276,7 +1287,7 @@ a (possibly empty) list of safe macros.")
 (scope-define-function-analyzer propertize (_string &rest props)
   (while props
     (cl-case (scope-sym-bare (scope--unqoute (car props)))
-      (face
+      ((face mouse-face)
        (when-let ((q (scope--unqoute (cadr props)))) (scope-face q))))
     (setq props (cddr props))))