From: Eshel Yaron Date: Sat, 29 Mar 2025 20:48:32 +0000 (+0100) Subject: scope.el: Fix some errors X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=df15a9c82da4bd726473bb0abffa7218b04f7c2f;p=emacs.git scope.el: Fix some errors --- diff --git a/lisp/emacs-lisp/scope.el b/lisp/emacs-lisp/scope.el index 983ee140b08..88cf178ff52 100644 --- a/lisp/emacs-lisp/scope.el +++ b/lisp/emacs-lisp/scope.el @@ -57,7 +57,7 @@ Optional argument LOCAL is a local context to extend." (defun scope-s (local sym) (let* ((beg (scope-sym-pos sym)) - (bare (bare-symbol sym)) + (bare (scope-sym-bare sym)) (name (symbol-name bare)) (len (length name)) (scope--local local)) @@ -81,12 +81,13 @@ Optional argument LOCAL is a local context to extend." (if bindings (let* ((binding (ensure-list (car bindings))) (sym (car binding)) - (bare (bare-symbol sym)) + (bare (scope-sym-bare sym)) (len (length (symbol-name bare))) (beg (scope-sym-pos sym))) (when beg (scope-report 'variable beg len beg)) (scope-1 local0 (cadr binding)) - (scope-let-1 local0 (scope-local-new bare beg local) + (scope-let-1 local0 + (if bare (scope-local-new bare beg local) local) (cdr bindings) body)) (scope-n local body))) @@ -251,7 +252,7 @@ Optional argument LOCAL is a local context to extend." (scope-report 'function beg (length (symbol-name bare)) beg)) (if (cdr exps) ;; def is (FUNC ARGLIST BODY...) - (scope-lambda local (car exps) (cdr exps)) + (scope-cl-lambda local (car exps) (cdr exps)) ;; def is (FUNC EXP) (scope-1 local (car exps))) (let ((scope-flet-alist (scope-local-new bare beg scope-flet-alist))) @@ -308,7 +309,7 @@ Optional argument LOCAL is a local context to extend." ((consp arg) (scope-1 local arg)))) (defun scope-declare-function (local fn _file arglist _fileonly) - (scope-defun local fn arglist nil)) + (scope-defun local fn (when (listp arglist) arglist) nil)) (defun scope-loop-for-and (local rest) (if (eq (scope-sym-bare (car rest)) 'and) @@ -389,6 +390,8 @@ Optional argument LOCAL is a local context to extend." (defun scope-loop-for (local0 local vars rest) (if vars + ;; FIXME: var need not be a symbol, see + ;; `cl-macs-loop-destructure-cons' test in cl-macs-tests.el. (let* ((var (car (ensure-list vars))) (bare (bare-symbol var)) (beg (scope-sym-pos var))) @@ -561,7 +564,7 @@ Optional argument LOCAL is a local context to extend." (if (consp regexp) (let* ((head (car regexp)) (bare (scope-sym-bare head))) - (when bare + (when (and bare (symbol-with-pos-p head)) (scope-report 'rx-construct (symbol-with-pos-pos head) (length (symbol-name bare)) (alist-get bare scope-rx-alist))) @@ -578,7 +581,8 @@ Optional argument LOCAL is a local context to extend." group submatch group-n submatch-n)) (scope-rx local (cdr regexp))))) - (when-let ((bare (scope-sym-bare regexp))) + (when-let (((symbol-with-pos-p regexp)) + (bare (scope-sym-bare regexp))) (scope-report 'rx-construct (symbol-with-pos-pos regexp) (length (symbol-name bare)) (alist-get bare scope-rx-alist))))) @@ -1276,7 +1280,7 @@ a (possibly empty) list of safe macros.") (put 'provide 'scope-analyzer #'scope--analyze-featurep) (put 'require 'scope-analyzer #'scope--analyze-featurep) -(scope-define-function-analyzer put-text-property (&optional _ _ prop val) +(scope-define-function-analyzer put-text-property (&optional _ _ prop val _) (when (memq (scope-sym-bare (scope--unqoute prop)) '(mouse-face face)) (when-let ((q (scope--unqoute val))) (scope-face q)))) @@ -1532,11 +1536,12 @@ a (possibly empty) list of safe macros.") (cond ((setq this (assq bare scope-flet-alist)) (scope-report - 'function (symbol-with-pos-pos f) (length (symbol-name bare)) this) + 'function (symbol-with-pos-pos f) (length (symbol-name bare)) (cdr this)) (scope-n local forms)) ((setq this (assq bare scope-macrolet-alist)) - (scope-report - 'macro (symbol-with-pos-pos f) (length (symbol-name bare)) this) + (when (symbol-with-pos-p f) + (scope-report + 'macro (symbol-with-pos-pos f) (length (symbol-name bare)) (cdr this))) ;; Local macros can be unsafe, so we do not expand them. ;; Hence we cannot interpret their arguments. )