From: Eshel Yaron Date: Mon, 27 Jan 2025 09:25:04 +0000 (+0100) Subject: scope.el: Initial 'cl-tagbody' support X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c117721c3470f801ece77224791e236eb18555b9;p=emacs.git scope.el: Initial 'cl-tagbody' support --- diff --git a/lisp/emacs-lisp/scope.el b/lisp/emacs-lisp/scope.el index 35f2bc5a15d..726459a200d 100644 --- a/lisp/emacs-lisp/scope.el +++ b/lisp/emacs-lisp/scope.el @@ -1328,6 +1328,37 @@ a (possibly empty) list of safe macros.") ;; Unsafe macro! (scope-rx l regexps)) +(scope-define-macro-analyzer cl-tagbody (l &rest body) + (let (labels statements) + (while body + (let ((head (pop body))) + (if (consp head) + (push head statements) + (push head labels)))) + (scope-cl-tagbody l (nreverse labels) (nreverse statements)))) + +(defvar scope-label-alist nil) + +(defun scope-cl-tagbody (l labels statements) + (if labels + (let* ((label (car labels)) + (bare (scope-sym-bare label))) + (when-let ((beg (scope-sym-pos label))) + (scope-report 'label beg (length (symbol-name bare)) beg)) + (let ((scope-label-alist + (if bare + (scope-local-new bare (scope-sym-pos label) scope-label-alist) + scope-label-alist))) + (scope-cl-tagbody l (cdr labels) statements))) + (scope-n l statements))) + +(scope-define-macro-analyzer go (_l label) + ;; Change to a local macro defintion induced by `cl-tagbody'. + (when-let ((bare (scope-sym-bare label)) + (pos (alist-get bare scope-label-alist)) + (beg (scope-sym-pos label))) + (scope-report 'label beg (length (symbol-name bare)) pos))) + (scope-define-macro-analyzer rx-define (l name &rest rest) (scope-rx-define l name rest))