diff options
| author | Eshel Yaron | 2025-10-15 19:03:24 +0200 |
|---|---|---|
| committer | Eshel Yaron | 2025-10-15 21:41:22 +0200 |
| commit | cb4d9efbd43e4b5657926b365a325165bdcf2c8b (patch) | |
| tree | cea2056eaac8943e02297c501904da2e4832fdf6 | |
| parent | f37a150a5fb3be1718fedc8fdf77d624edbc4a8a (diff) | |
| download | emacs-cb4d9efbd43e4b5657926b365a325165bdcf2c8b.tar.gz emacs-cb4d9efbd43e4b5657926b365a325165bdcf2c8b.zip | |
; elisp-scope.el: Rename some private symbols as such
Also add a few missing docstrings.
* lisp/emacs-lisp/elisp-scope.el (elisp-scope-symbol-role-p)
(elisp-scope-read-symbol-role, elisp-scope-special-variables)
(elisp-scope-let, elisp-scope-let*): Add docstring.
(elisp-scope-counter, elisp-scope-callback)
(elisp-scope-current-let-alist-form, elisp-scope-local-new)
(elisp-scope-sym-pos, elisp-scope-sym-bare)
(elisp-scope-report, elisp-scope-special-variable-p)
(elisp-scope-let-1, elisp-scope-variable)
(elisp-scope-binding, elisp-scope-symbol): Rename, replace
'elisp-scope-' prefix with 'elisp-scope--' to indicate that
these are private. Update all references.
| -rw-r--r-- | lisp/emacs-lisp/elisp-scope.el | 700 |
1 files changed, 363 insertions, 337 deletions
diff --git a/lisp/emacs-lisp/elisp-scope.el b/lisp/emacs-lisp/elisp-scope.el index 5230da17cc4..7f182bc73f0 100644 --- a/lisp/emacs-lisp/elisp-scope.el +++ b/lisp/emacs-lisp/elisp-scope.el | |||
| @@ -183,11 +183,14 @@ symbol role properties." | |||
| 183 | 183 | ||
| 184 | ;;;###autoload | 184 | ;;;###autoload |
| 185 | (defun elisp-scope-symbol-role-p (sym) | 185 | (defun elisp-scope-symbol-role-p (sym) |
| 186 | "Check whether a symbol SYM is the name of a \"symbol role\"." | ||
| 186 | (or (get sym 'elisp-scope-parent-roles) (get sym 'elisp-scope-role-properties))) | 187 | (or (get sym 'elisp-scope-parent-roles) (get sym 'elisp-scope-role-properties))) |
| 187 | 188 | ||
| 188 | (defvar elisp-scope-read-symbol-role-history nil) | 189 | (defvar elisp-scope-read-symbol-role-history nil) |
| 189 | 190 | ||
| 190 | (defun elisp-scope-read-symbol-role (prompt &optional default) | 191 | (defun elisp-scope-read-symbol-role (prompt &optional default) |
| 192 | "Prompt with PROMPT for a symbol role. | ||
| 193 | DEFAULT is the minibuffer default argument." | ||
| 191 | (completing-read | 194 | (completing-read |
| 192 | (format-prompt prompt default) | 195 | (format-prompt prompt default) |
| 193 | obarray #'elisp-scope-symbol-role-p 'confirm | 196 | obarray #'elisp-scope-symbol-role-p 'confirm |
| @@ -564,7 +567,7 @@ Interactively, prompt for ROLE." | |||
| 564 | :face 'elisp-completion-category-definition | 567 | :face 'elisp-completion-category-definition |
| 565 | :help "Completion category definition") | 568 | :help "Completion category definition") |
| 566 | 569 | ||
| 567 | (defvar elisp-scope-counter nil) | 570 | (defvar elisp-scope--counter nil) |
| 568 | 571 | ||
| 569 | (defvar elisp-scope-local-bindings nil | 572 | (defvar elisp-scope-local-bindings nil |
| 570 | "Alist of locally bound variables. | 573 | "Alist of locally bound variables. |
| @@ -579,97 +582,102 @@ is the buffer position in which BOUND is bound, such as a surrounding | |||
| 579 | "Output spec of the form currently analyzed, or nil if unknown. | 582 | "Output spec of the form currently analyzed, or nil if unknown. |
| 580 | See `elisp-scope-1' for possible values.") | 583 | See `elisp-scope-1' for possible values.") |
| 581 | 584 | ||
| 582 | (defvar elisp-scope-callback #'ignore) | 585 | (defvar elisp-scope--callback #'ignore |
| 586 | "Function to call to report information about each analyzed symbol.") | ||
| 583 | 587 | ||
| 584 | (defvar elisp-scope-current-let-alist-form nil) | 588 | (defvar elisp-scope--current-let-alist-form nil) |
| 585 | 589 | ||
| 586 | (defsubst elisp-scope-local-new (sym pos &optional local) | 590 | (defsubst elisp-scope--local-new (sym pos &optional local) |
| 587 | "Return new local context with SYM bound at POS. | 591 | "Return new local context with SYM bound at POS. |
| 588 | 592 | ||
| 589 | Optional argument LOCAL is a local context to extend." | 593 | Optional argument LOCAL is a local context to extend." |
| 590 | (cons (cons sym (or pos (cons 'gen (incf elisp-scope-counter)))) local)) | 594 | (cons (cons sym (or pos (cons 'gen (incf elisp-scope--counter)))) local)) |
| 591 | 595 | ||
| 592 | (defsubst elisp-scope-sym-pos (sym) | 596 | (defsubst elisp-scope--sym-pos (sym) |
| 593 | (when (symbol-with-pos-p sym) (symbol-with-pos-pos sym))) | 597 | (when (symbol-with-pos-p sym) (symbol-with-pos-pos sym))) |
| 594 | 598 | ||
| 595 | (defsubst elisp-scope-sym-bare (sym) | 599 | (defsubst elisp-scope--sym-bare (sym) |
| 596 | (cond | 600 | (cond |
| 597 | ((symbolp sym) sym) | 601 | ((symbolp sym) sym) |
| 598 | ((symbol-with-pos-p sym) (bare-symbol sym)))) | 602 | ((symbol-with-pos-p sym) (bare-symbol sym)))) |
| 599 | 603 | ||
| 600 | (defvar elisp-scope--quoted nil) | 604 | (defvar elisp-scope--quoted nil) |
| 601 | 605 | ||
| 602 | (defsubst elisp-scope-report (role beg len &optional id def) | 606 | (defsubst elisp-scope--report (role beg len &optional id def) |
| 603 | (funcall elisp-scope-callback role beg len id (or def (and (numberp id) id)))) | 607 | (funcall elisp-scope--callback role beg len id (or def (and (numberp id) id)))) |
| 604 | 608 | ||
| 605 | (defvar elisp-scope-special-variables nil) | 609 | (defvar elisp-scope-special-variables nil |
| 610 | "List of symbols that are special variables in the current analysis context.") | ||
| 606 | 611 | ||
| 607 | (defun elisp-scope-special-variable-p (sym) | 612 | (defun elisp-scope--special-variable-p (sym) |
| 613 | "Check whether SYM is a special variable in the current analysis context." | ||
| 608 | (or (memq sym elisp-scope-special-variables) (special-variable-p sym))) | 614 | (or (memq sym elisp-scope-special-variables) (special-variable-p sym))) |
| 609 | 615 | ||
| 610 | (defun elisp-scope-variable (sym beg len id) | 616 | (defun elisp-scope--variable (sym beg len id) |
| 611 | (elisp-scope-report | 617 | (elisp-scope--report |
| 612 | (if id (if (elisp-scope-special-variable-p sym) 'shadowed-variable 'bound-variable) 'free-variable) | 618 | (if id (if (elisp-scope--special-variable-p sym) 'shadowed-variable 'bound-variable) 'free-variable) |
| 613 | beg len id)) | 619 | beg len id)) |
| 614 | 620 | ||
| 615 | (defun elisp-scope-binding (sym beg len) | 621 | (defun elisp-scope--binding (sym beg len) |
| 616 | (elisp-scope-report | 622 | (elisp-scope--report |
| 617 | (if (elisp-scope-special-variable-p sym) 'shadowing-variable 'binding-variable) | 623 | (if (elisp-scope--special-variable-p sym) 'shadowing-variable 'binding-variable) |
| 618 | beg len beg)) | 624 | beg len beg)) |
| 619 | 625 | ||
| 620 | (defun elisp-scope-s (sym) | 626 | (defun elisp-scope--symbol (sym) |
| 621 | (let* ((beg (elisp-scope-sym-pos sym)) | 627 | (let* ((beg (elisp-scope--sym-pos sym)) |
| 622 | (bare (elisp-scope-sym-bare sym)) | 628 | (bare (elisp-scope--sym-bare sym)) |
| 623 | (name (symbol-name bare)) | 629 | (name (symbol-name bare)) |
| 624 | (len (length name))) | 630 | (len (length name))) |
| 625 | (when (and beg (not (booleanp bare))) | 631 | (when (and beg (not (booleanp bare))) |
| 626 | (cond | 632 | (cond |
| 627 | ((keywordp bare) (elisp-scope-report 'constant beg len)) | 633 | ((keywordp bare) (elisp-scope--report 'constant beg len)) |
| 628 | ((and elisp-scope-current-let-alist-form (= (aref name 0) ?.)) | 634 | ((and elisp-scope--current-let-alist-form (= (aref name 0) ?.)) |
| 629 | (if (and (length> name 1) (= (aref name 1) ?.)) | 635 | (if (and (length> name 1) (= (aref name 1) ?.)) |
| 630 | ;; Double dot escapes `let-alist'. | 636 | ;; Double dot escapes `let-alist'. |
| 631 | (let* ((unescaped (intern (substring name 1)))) | 637 | (let* ((unescaped (intern (substring name 1)))) |
| 632 | (elisp-scope-variable unescaped beg len (alist-get unescaped elisp-scope-local-bindings))) | 638 | (elisp-scope--variable unescaped beg len (alist-get unescaped elisp-scope-local-bindings))) |
| 633 | (elisp-scope-report 'bound-variable beg len | 639 | (elisp-scope--report 'bound-variable beg len |
| 634 | (list 'let-alist (car elisp-scope-current-let-alist-form) bare) | 640 | (list 'let-alist (car elisp-scope--current-let-alist-form) bare) |
| 635 | (cdr elisp-scope-current-let-alist-form)))) | 641 | (cdr elisp-scope--current-let-alist-form)))) |
| 636 | (t (elisp-scope-variable bare beg len (alist-get bare elisp-scope-local-bindings))))))) | 642 | (t (elisp-scope--variable bare beg len (alist-get bare elisp-scope-local-bindings))))))) |
| 637 | 643 | ||
| 638 | (defun elisp-scope-let-1 (local bindings body) | 644 | (defun elisp-scope--let-1 (local bindings body) |
| 639 | (if bindings | 645 | (if bindings |
| 640 | (let* ((binding (ensure-list (car bindings))) | 646 | (let* ((binding (ensure-list (car bindings))) |
| 641 | (sym (car binding)) | 647 | (sym (car binding)) |
| 642 | (bare (elisp-scope-sym-bare sym)) | 648 | (bare (elisp-scope--sym-bare sym)) |
| 643 | (len (length (symbol-name bare))) | 649 | (len (length (symbol-name bare))) |
| 644 | (beg (elisp-scope-sym-pos sym))) | 650 | (beg (elisp-scope--sym-pos sym))) |
| 645 | (when beg (elisp-scope-binding bare beg len)) | 651 | (when beg (elisp-scope--binding bare beg len)) |
| 646 | (elisp-scope-1 (cadr binding)) | 652 | (elisp-scope-1 (cadr binding)) |
| 647 | (elisp-scope-let-1 (if bare (elisp-scope-local-new bare beg local) local) | 653 | (elisp-scope--let-1 (if bare (elisp-scope--local-new bare beg local) local) |
| 648 | (cdr bindings) body)) | 654 | (cdr bindings) body)) |
| 649 | (let ((elisp-scope-local-bindings local)) | 655 | (let ((elisp-scope-local-bindings local)) |
| 650 | (elisp-scope-n body elisp-scope-output-spec)))) | 656 | (elisp-scope-n body elisp-scope-output-spec)))) |
| 651 | 657 | ||
| 652 | (defun elisp-scope-let (bindings body) | 658 | (defun elisp-scope-let (bindings body) |
| 653 | (elisp-scope-let-1 elisp-scope-local-bindings bindings body)) | 659 | "Analyze BINDINGS and BODY of a `let' form (let BINDINGS . BODY)." |
| 660 | (elisp-scope--let-1 elisp-scope-local-bindings bindings body)) | ||
| 654 | 661 | ||
| 655 | (defun elisp-scope-let* (bindings body) | 662 | (defun elisp-scope-let* (bindings body) |
| 663 | "Analyze BINDINGS and BODY of a `let*' form (let* BINDINGS . BODY)." | ||
| 656 | (if bindings | 664 | (if bindings |
| 657 | (let* ((binding (ensure-list (car bindings))) | 665 | (let* ((binding (ensure-list (car bindings))) |
| 658 | (sym (car binding)) | 666 | (sym (car binding)) |
| 659 | (bare (bare-symbol sym)) | 667 | (bare (bare-symbol sym)) |
| 660 | (len (length (symbol-name bare))) | 668 | (len (length (symbol-name bare))) |
| 661 | (beg (elisp-scope-sym-pos sym))) | 669 | (beg (elisp-scope--sym-pos sym))) |
| 662 | (when beg (elisp-scope-binding bare beg len)) | 670 | (when beg (elisp-scope--binding bare beg len)) |
| 663 | (elisp-scope-1 (cadr binding)) | 671 | (elisp-scope-1 (cadr binding)) |
| 664 | (let ((elisp-scope-local-bindings (elisp-scope-local-new bare beg elisp-scope-local-bindings))) | 672 | (let ((elisp-scope-local-bindings (elisp-scope--local-new bare beg elisp-scope-local-bindings))) |
| 665 | (elisp-scope-let* (cdr bindings) body))) | 673 | (elisp-scope-let* (cdr bindings) body))) |
| 666 | (elisp-scope-n body elisp-scope-output-spec))) | 674 | (elisp-scope-n body elisp-scope-output-spec))) |
| 667 | 675 | ||
| 668 | (defun elisp-scope-interactive (intr spec modes) | 676 | (defun elisp-scope-interactive (intr spec modes) |
| 669 | (when (symbol-with-pos-p intr) | 677 | (when (symbol-with-pos-p intr) |
| 670 | (elisp-scope-report 'special-form | 678 | (elisp-scope--report 'special-form |
| 671 | (symbol-with-pos-pos intr) | 679 | (symbol-with-pos-pos intr) |
| 672 | (length (symbol-name (elisp-scope-sym-bare intr))))) | 680 | (length (symbol-name (elisp-scope--sym-bare intr))))) |
| 673 | (elisp-scope-1 spec) | 681 | (elisp-scope-1 spec) |
| 674 | (mapc #'elisp-scope-major-mode-name modes)) | 682 | (mapc #'elisp-scope-major-mode-name modes)) |
| 675 | 683 | ||
| @@ -678,16 +686,16 @@ Optional argument LOCAL is a local context to extend." | |||
| 678 | (when (listp args) | 686 | (when (listp args) |
| 679 | (dolist (arg args) | 687 | (dolist (arg args) |
| 680 | (when-let* ((bare (bare-symbol arg)) | 688 | (when-let* ((bare (bare-symbol arg)) |
| 681 | (beg (elisp-scope-sym-pos arg))) | 689 | (beg (elisp-scope--sym-pos arg))) |
| 682 | (unless (memq bare '(&optional &rest)) | 690 | (unless (memq bare '(&optional &rest)) |
| 683 | (setq l (elisp-scope-local-new bare beg l)))))) | 691 | (setq l (elisp-scope--local-new bare beg l)))))) |
| 684 | ;; Handle docstring. | 692 | ;; Handle docstring. |
| 685 | (cond | 693 | (cond |
| 686 | ((and (consp (car body)) | 694 | ((and (consp (car body)) |
| 687 | (or (symbol-with-pos-p (caar body)) | 695 | (or (symbol-with-pos-p (caar body)) |
| 688 | (symbolp (caar body))) | 696 | (symbolp (caar body))) |
| 689 | (eq (bare-symbol (caar body)) :documentation)) | 697 | (eq (bare-symbol (caar body)) :documentation)) |
| 690 | (elisp-scope-s (caar body)) | 698 | (elisp-scope--symbol (caar body)) |
| 691 | (elisp-scope-1 (cadar body)) | 699 | (elisp-scope-1 (cadar body)) |
| 692 | (setq body (cdr body))) | 700 | (setq body (cdr body))) |
| 693 | ((stringp (car body)) (setq body (cdr body)))) | 701 | ((stringp (car body)) (setq body (cdr body)))) |
| @@ -698,24 +706,24 @@ Optional argument LOCAL is a local context to extend." | |||
| 698 | (symbolp decl))) | 706 | (symbolp decl))) |
| 699 | ((eq (bare-symbol decl) 'declare))) | 707 | ((eq (bare-symbol decl) 'declare))) |
| 700 | (when (symbol-with-pos-p decl) | 708 | (when (symbol-with-pos-p decl) |
| 701 | (elisp-scope-report 'macro | 709 | (elisp-scope--report 'macro |
| 702 | (symbol-with-pos-pos decl) | 710 | (symbol-with-pos-pos decl) |
| 703 | (length (symbol-name (bare-symbol decl))))) | 711 | (length (symbol-name (bare-symbol decl))))) |
| 704 | (dolist (spec (cdr form)) | 712 | (dolist (spec (cdr form)) |
| 705 | (when-let* ((head (car-safe spec)) | 713 | (when-let* ((head (car-safe spec)) |
| 706 | (bare (elisp-scope-sym-bare head))) | 714 | (bare (elisp-scope--sym-bare head))) |
| 707 | (when (symbol-with-pos-p head) | 715 | (when (symbol-with-pos-p head) |
| 708 | (elisp-scope-report 'function-property-declaration | 716 | (elisp-scope--report 'function-property-declaration |
| 709 | (symbol-with-pos-pos head) | 717 | (symbol-with-pos-pos head) |
| 710 | (length (symbol-name bare)))) | 718 | (length (symbol-name bare)))) |
| 711 | (cl-case bare | 719 | (cl-case bare |
| 712 | (completion (elisp-scope-sharpquote (cadr spec))) | 720 | (completion (elisp-scope-sharpquote (cadr spec))) |
| 713 | (interactive-only | 721 | (interactive-only |
| 714 | (when-let* ((bare (elisp-scope-sym-bare (cadr spec))) | 722 | (when-let* ((bare (elisp-scope--sym-bare (cadr spec))) |
| 715 | ((not (eq bare t)))) | 723 | ((not (eq bare t)))) |
| 716 | (elisp-scope-sharpquote (cadr spec)))) | 724 | (elisp-scope-sharpquote (cadr spec)))) |
| 717 | (obsolete | 725 | (obsolete |
| 718 | (when-let* ((bare (elisp-scope-sym-bare (cadr spec)))) | 726 | (when-let* ((bare (elisp-scope--sym-bare (cadr spec)))) |
| 719 | (elisp-scope-sharpquote (cadr spec)))) | 727 | (elisp-scope-sharpquote (cadr spec)))) |
| 720 | ((compiler-macro gv-expander gv-setter) | 728 | ((compiler-macro gv-expander gv-setter) |
| 721 | ;; Use the extended lexical environment `l'. | 729 | ;; Use the extended lexical environment `l'. |
| @@ -725,7 +733,7 @@ Optional argument LOCAL is a local context to extend." | |||
| 725 | (interactive-args | 733 | (interactive-args |
| 726 | (dolist (arg-form (cdr spec)) | 734 | (dolist (arg-form (cdr spec)) |
| 727 | (when-let* ((arg (car-safe arg-form))) | 735 | (when-let* ((arg (car-safe arg-form))) |
| 728 | (let ((elisp-scope-local-bindings l)) (elisp-scope-s arg)) | 736 | (let ((elisp-scope-local-bindings l)) (elisp-scope--symbol arg)) |
| 729 | (when (consp (cdr arg-form)) | 737 | (when (consp (cdr arg-form)) |
| 730 | (elisp-scope-1 (cadr arg-form))))))))) | 738 | (elisp-scope-1 (cadr arg-form))))))))) |
| 731 | (setq body (cdr body))) | 739 | (setq body (cdr body))) |
| @@ -746,19 +754,19 @@ Optional argument LOCAL is a local context to extend." | |||
| 746 | (len (length (symbol-name bare)))) | 754 | (len (length (symbol-name bare)))) |
| 747 | (when (and beg (not (eq bare '_))) | 755 | (when (and beg (not (eq bare '_))) |
| 748 | (if (memq bare '(&optional &rest)) | 756 | (if (memq bare '(&optional &rest)) |
| 749 | (elisp-scope-report 'ampersand beg len) | 757 | (elisp-scope--report 'ampersand beg len) |
| 750 | (elisp-scope-report 'binding-variable beg len beg))))))) | 758 | (elisp-scope--report 'binding-variable beg len beg))))))) |
| 751 | ;; Handle BODY. | 759 | ;; Handle BODY. |
| 752 | (let ((elisp-scope-local-bindings l)) (elisp-scope-n body outspec)))) | 760 | (let ((elisp-scope-local-bindings l)) (elisp-scope-n body outspec)))) |
| 753 | 761 | ||
| 754 | (defun elisp-scope-defun (name args body) | 762 | (defun elisp-scope-defun (name args body) |
| 755 | (when-let* ((beg (elisp-scope-sym-pos name)) | 763 | (when-let* ((beg (elisp-scope--sym-pos name)) |
| 756 | (bare (elisp-scope-sym-bare name))) | 764 | (bare (elisp-scope--sym-bare name))) |
| 757 | (elisp-scope-report | 765 | (elisp-scope--report |
| 758 | (let ((tmp body)) | 766 | (let ((tmp body)) |
| 759 | (when (stringp (car-safe tmp)) (pop tmp)) | 767 | (when (stringp (car-safe tmp)) (pop tmp)) |
| 760 | (when (eq 'declare (elisp-scope-sym-bare (car-safe (car-safe tmp)))) (pop tmp)) | 768 | (when (eq 'declare (elisp-scope--sym-bare (car-safe (car-safe tmp)))) (pop tmp)) |
| 761 | (if (eq 'interactive (elisp-scope-sym-bare (car-safe (car-safe tmp)))) | 769 | (if (eq 'interactive (elisp-scope--sym-bare (car-safe (car-safe tmp)))) |
| 762 | 'defcmd | 770 | 'defcmd |
| 763 | 'defun)) | 771 | 'defun)) |
| 764 | beg (length (symbol-name bare)))) | 772 | beg (length (symbol-name bare)))) |
| @@ -766,12 +774,14 @@ Optional argument LOCAL is a local context to extend." | |||
| 766 | 774 | ||
| 767 | (defun elisp-scope-setq (args) (elisp-scope-n args elisp-scope-output-spec)) | 775 | (defun elisp-scope-setq (args) (elisp-scope-n args elisp-scope-output-spec)) |
| 768 | 776 | ||
| 769 | (defvar elisp-scope-local-definitions nil) | 777 | (defvar elisp-scope-local-definitions nil |
| 778 | "Alist associating (local) analyzer functions to function/macro names.") | ||
| 770 | 779 | ||
| 771 | (defmacro elisp-scope-with-local-definition (sym def &rest body) | 780 | (defmacro elisp-scope-with-local-definition (sym af &rest body) |
| 781 | "Execute BODY with analyzer function AF associated to function/macro SYM." | ||
| 772 | (declare (indent 2) (debug t)) | 782 | (declare (indent 2) (debug t)) |
| 773 | `(let ((elisp-scope-local-definitions | 783 | `(let ((elisp-scope-local-definitions |
| 774 | (cons (cons ,sym ,def) elisp-scope-local-definitions))) | 784 | (cons (cons ,sym ,af) elisp-scope-local-definitions))) |
| 775 | ,@body)) | 785 | ,@body)) |
| 776 | 786 | ||
| 777 | (defun elisp-scope-flet (defs body outspec) | 787 | (defun elisp-scope-flet (defs body outspec) |
| @@ -779,18 +789,18 @@ Optional argument LOCAL is a local context to extend." | |||
| 779 | (let* ((def (car defs)) | 789 | (let* ((def (car defs)) |
| 780 | (func (car def)) | 790 | (func (car def)) |
| 781 | (exps (cdr def)) | 791 | (exps (cdr def)) |
| 782 | (beg (elisp-scope-sym-pos func)) | 792 | (beg (elisp-scope--sym-pos func)) |
| 783 | (bare (bare-symbol func)) | 793 | (bare (bare-symbol func)) |
| 784 | (len (length (symbol-name bare)))) | 794 | (len (length (symbol-name bare)))) |
| 785 | (when beg | 795 | (when beg |
| 786 | ;; TODO: Use a bespoke 'local-function-definition' role. | 796 | ;; TODO: Use a bespoke 'local-function-definition' role. |
| 787 | (elisp-scope-report 'function beg len beg)) | 797 | (elisp-scope--report 'function beg len beg)) |
| 788 | (if (cdr exps) | 798 | (if (cdr exps) |
| 789 | ;; def is (FUNC ARGLIST BODY...) | 799 | ;; def is (FUNC ARGLIST BODY...) |
| 790 | (elisp-scope-cl-lambda (car exps) (cdr exps)) | 800 | (elisp-scope-cl-lambda (car exps) (cdr exps)) |
| 791 | ;; def is (FUNC EXP) | 801 | ;; def is (FUNC EXP) |
| 792 | (elisp-scope-1 (car exps))) | 802 | (elisp-scope-1 (car exps))) |
| 793 | (let ((pos (or beg (cons 'gen (incf elisp-scope-counter))))) | 803 | (let ((pos (or beg (cons 'gen (incf elisp-scope--counter))))) |
| 794 | (elisp-scope-with-local-definition bare | 804 | (elisp-scope-with-local-definition bare |
| 795 | (elisp-scope--local-function-analyzer pos) | 805 | (elisp-scope--local-function-analyzer pos) |
| 796 | (elisp-scope-flet (cdr defs) body outspec)))) | 806 | (elisp-scope-flet (cdr defs) body outspec)))) |
| @@ -799,10 +809,10 @@ Optional argument LOCAL is a local context to extend." | |||
| 799 | (defun elisp-scope--local-function-analyzer (pos) | 809 | (defun elisp-scope--local-function-analyzer (pos) |
| 800 | (lambda (f &rest args) | 810 | (lambda (f &rest args) |
| 801 | (when (symbol-with-pos-p f) | 811 | (when (symbol-with-pos-p f) |
| 802 | (elisp-scope-report 'function | 812 | (elisp-scope--report 'function |
| 803 | (symbol-with-pos-pos f) | 813 | (symbol-with-pos-pos f) |
| 804 | (length (symbol-name (bare-symbol f))) | 814 | (length (symbol-name (bare-symbol f))) |
| 805 | pos)) | 815 | pos)) |
| 806 | (elisp-scope-n args))) | 816 | (elisp-scope-n args))) |
| 807 | 817 | ||
| 808 | (defun elisp-scope-labels (defs forms outspec) | 818 | (defun elisp-scope-labels (defs forms outspec) |
| @@ -811,12 +821,12 @@ Optional argument LOCAL is a local context to extend." | |||
| 811 | (func (car def)) | 821 | (func (car def)) |
| 812 | (args (cadr def)) | 822 | (args (cadr def)) |
| 813 | (body (cddr def)) | 823 | (body (cddr def)) |
| 814 | (beg (elisp-scope-sym-pos func)) | 824 | (beg (elisp-scope--sym-pos func)) |
| 815 | (bare (bare-symbol func)) | 825 | (bare (bare-symbol func)) |
| 816 | (len (length (symbol-name bare)))) | 826 | (len (length (symbol-name bare)))) |
| 817 | (when beg | 827 | (when beg |
| 818 | (elisp-scope-report 'function beg len beg)) | 828 | (elisp-scope--report 'function beg len beg)) |
| 819 | (let ((pos (or beg (cons 'gen (incf elisp-scope-counter))))) | 829 | (let ((pos (or beg (cons 'gen (incf elisp-scope--counter))))) |
| 820 | (elisp-scope-with-local-definition bare | 830 | (elisp-scope-with-local-definition bare |
| 821 | (elisp-scope--local-function-analyzer pos) | 831 | (elisp-scope--local-function-analyzer pos) |
| 822 | (elisp-scope-lambda args body) | 832 | (elisp-scope-lambda args body) |
| @@ -827,19 +837,19 @@ Optional argument LOCAL is a local context to extend." | |||
| 827 | 837 | ||
| 828 | (defun elisp-scope-block (name body) | 838 | (defun elisp-scope-block (name body) |
| 829 | (if name | 839 | (if name |
| 830 | (let* ((beg (elisp-scope-sym-pos name)) | 840 | (let* ((beg (elisp-scope--sym-pos name)) |
| 831 | (bare (bare-symbol name))) | 841 | (bare (bare-symbol name))) |
| 832 | (when beg | 842 | (when beg |
| 833 | (elisp-scope-report 'block beg (length (symbol-name bare)) beg)) | 843 | (elisp-scope--report 'block beg (length (symbol-name bare)) beg)) |
| 834 | (let ((elisp-scope-block-alist (elisp-scope-local-new bare beg elisp-scope-block-alist))) | 844 | (let ((elisp-scope-block-alist (elisp-scope--local-new bare beg elisp-scope-block-alist))) |
| 835 | (elisp-scope-n body))) | 845 | (elisp-scope-n body))) |
| 836 | (elisp-scope-n body))) | 846 | (elisp-scope-n body))) |
| 837 | 847 | ||
| 838 | (defun elisp-scope-return-from (name result) | 848 | (defun elisp-scope-return-from (name result) |
| 839 | (when-let* ((bare (and (symbol-with-pos-p name) (bare-symbol name))) | 849 | (when-let* ((bare (and (symbol-with-pos-p name) (bare-symbol name))) |
| 840 | (pos (alist-get bare elisp-scope-block-alist))) | 850 | (pos (alist-get bare elisp-scope-block-alist))) |
| 841 | (elisp-scope-report 'block | 851 | (elisp-scope--report 'block |
| 842 | (symbol-with-pos-pos name) (length (symbol-name bare)) pos)) | 852 | (symbol-with-pos-pos name) (length (symbol-name bare)) pos)) |
| 843 | (elisp-scope-1 result)) | 853 | (elisp-scope-1 result)) |
| 844 | 854 | ||
| 845 | (defvar elisp-scope-assume-func nil) | 855 | (defvar elisp-scope-assume-func nil) |
| @@ -857,7 +867,7 @@ Optional argument LOCAL is a local context to extend." | |||
| 857 | ((consp arg) (elisp-scope-1 arg)))) | 867 | ((consp arg) (elisp-scope-1 arg)))) |
| 858 | 868 | ||
| 859 | (defun elisp-scope-loop-for-and (rest) | 869 | (defun elisp-scope-loop-for-and (rest) |
| 860 | (if (eq (elisp-scope-sym-bare (car rest)) 'and) | 870 | (if (eq (elisp-scope--sym-bare (car rest)) 'and) |
| 861 | (elisp-scope-loop-for elisp-scope-local-bindings (cadr rest) (cddr rest)) | 871 | (elisp-scope-loop-for elisp-scope-local-bindings (cadr rest) (cddr rest)) |
| 862 | (elisp-scope-loop rest))) | 872 | (elisp-scope-loop rest))) |
| 863 | 873 | ||
| @@ -868,7 +878,7 @@ Optional argument LOCAL is a local context to extend." | |||
| 868 | 878 | ||
| 869 | (defun elisp-scope-loop-for-to (local expr rest) | 879 | (defun elisp-scope-loop-for-to (local expr rest) |
| 870 | (elisp-scope-1 expr) | 880 | (elisp-scope-1 expr) |
| 871 | (when-let* ((bare (elisp-scope-sym-bare (car rest))) | 881 | (when-let* ((bare (elisp-scope--sym-bare (car rest))) |
| 872 | (more (cdr rest))) | 882 | (more (cdr rest))) |
| 873 | (cond | 883 | (cond |
| 874 | ((eq bare 'by) | 884 | ((eq bare 'by) |
| @@ -878,7 +888,7 @@ Optional argument LOCAL is a local context to extend." | |||
| 878 | 888 | ||
| 879 | (defun elisp-scope-loop-for-from (local expr rest) | 889 | (defun elisp-scope-loop-for-from (local expr rest) |
| 880 | (elisp-scope-1 expr) | 890 | (elisp-scope-1 expr) |
| 881 | (when-let* ((bare (elisp-scope-sym-bare (car rest))) | 891 | (when-let* ((bare (elisp-scope--sym-bare (car rest))) |
| 882 | (more (cdr rest))) | 892 | (more (cdr rest))) |
| 883 | (cond | 893 | (cond |
| 884 | ((memq bare '(to upto downto below above)) | 894 | ((memq bare '(to upto downto below above)) |
| @@ -890,7 +900,7 @@ Optional argument LOCAL is a local context to extend." | |||
| 890 | 900 | ||
| 891 | (defun elisp-scope-loop-for-= (local expr rest) | 901 | (defun elisp-scope-loop-for-= (local expr rest) |
| 892 | (elisp-scope-1 expr) | 902 | (elisp-scope-1 expr) |
| 893 | (when-let* ((bare (elisp-scope-sym-bare (car rest))) | 903 | (when-let* ((bare (elisp-scope--sym-bare (car rest))) |
| 894 | (more (cdr rest))) | 904 | (more (cdr rest))) |
| 895 | (cond | 905 | (cond |
| 896 | ((eq bare 'then) | 906 | ((eq bare 'then) |
| @@ -900,15 +910,15 @@ Optional argument LOCAL is a local context to extend." | |||
| 900 | 910 | ||
| 901 | (defun elisp-scope-loop-for-being-the-hash-keys-of-using (form rest) | 911 | (defun elisp-scope-loop-for-being-the-hash-keys-of-using (form rest) |
| 902 | (let* ((var (cadr form)) | 912 | (let* ((var (cadr form)) |
| 903 | (bare (elisp-scope-sym-bare var)) | 913 | (bare (elisp-scope--sym-bare var)) |
| 904 | (beg (elisp-scope-sym-pos var))) | 914 | (beg (elisp-scope--sym-pos var))) |
| 905 | (when beg (elisp-scope-binding bare beg (length (symbol-name bare)))) | 915 | (when beg (elisp-scope--binding bare beg (length (symbol-name bare)))) |
| 906 | (let ((elisp-scope-local-bindings (elisp-scope-local-new bare beg elisp-scope-local-bindings))) | 916 | (let ((elisp-scope-local-bindings (elisp-scope--local-new bare beg elisp-scope-local-bindings))) |
| 907 | (elisp-scope-loop-for-and rest)))) | 917 | (elisp-scope-loop-for-and rest)))) |
| 908 | 918 | ||
| 909 | (defun elisp-scope-loop-for-being-the-hash-keys-of (local expr rest) | 919 | (defun elisp-scope-loop-for-being-the-hash-keys-of (local expr rest) |
| 910 | (elisp-scope-1 expr) | 920 | (elisp-scope-1 expr) |
| 911 | (when-let* ((bare (elisp-scope-sym-bare (car rest))) | 921 | (when-let* ((bare (elisp-scope--sym-bare (car rest))) |
| 912 | (more (cdr rest))) | 922 | (more (cdr rest))) |
| 913 | (let ((elisp-scope-local-bindings local)) | 923 | (let ((elisp-scope-local-bindings local)) |
| 914 | (cond | 924 | (cond |
| @@ -917,13 +927,13 @@ Optional argument LOCAL is a local context to extend." | |||
| 917 | (t (elisp-scope-loop-for-and rest)))))) | 927 | (t (elisp-scope-loop-for-and rest)))))) |
| 918 | 928 | ||
| 919 | (defun elisp-scope-loop-for-being-the-hash-keys (local word rest) | 929 | (defun elisp-scope-loop-for-being-the-hash-keys (local word rest) |
| 920 | (when-let* ((bare (elisp-scope-sym-bare word))) | 930 | (when-let* ((bare (elisp-scope--sym-bare word))) |
| 921 | (cond | 931 | (cond |
| 922 | ((eq bare 'of) | 932 | ((eq bare 'of) |
| 923 | (elisp-scope-loop-for-being-the-hash-keys-of local (car rest) (cdr rest)))))) | 933 | (elisp-scope-loop-for-being-the-hash-keys-of local (car rest) (cdr rest)))))) |
| 924 | 934 | ||
| 925 | (defun elisp-scope-loop-for-being-the (local word rest) | 935 | (defun elisp-scope-loop-for-being-the (local word rest) |
| 926 | (when-let* ((bare (elisp-scope-sym-bare word))) | 936 | (when-let* ((bare (elisp-scope--sym-bare word))) |
| 927 | (cond | 937 | (cond |
| 928 | ((memq bare '(buffer buffers)) | 938 | ((memq bare '(buffer buffers)) |
| 929 | (let ((elisp-scope-local-bindings local)) | 939 | (let ((elisp-scope-local-bindings local)) |
| @@ -937,7 +947,7 @@ Optional argument LOCAL is a local context to extend." | |||
| 937 | (defun elisp-scope-loop-for-being (local next rest) | 947 | (defun elisp-scope-loop-for-being (local next rest) |
| 938 | (elisp-scope-loop-for-being-the | 948 | (elisp-scope-loop-for-being-the |
| 939 | local (car rest) | 949 | local (car rest) |
| 940 | (if (memq (elisp-scope-sym-bare next) '(the each)) (cdr rest) rest))) | 950 | (if (memq (elisp-scope--sym-bare next) '(the each)) (cdr rest) rest))) |
| 941 | 951 | ||
| 942 | (defun elisp-scope-loop-for (local vars rest) | 952 | (defun elisp-scope-loop-for (local vars rest) |
| 943 | (if vars | 953 | (if vars |
| @@ -945,10 +955,10 @@ Optional argument LOCAL is a local context to extend." | |||
| 945 | ;; `cl-macs-loop-destructure-cons' test in cl-macs-tests.el. | 955 | ;; `cl-macs-loop-destructure-cons' test in cl-macs-tests.el. |
| 946 | (let* ((var (car (ensure-list vars))) | 956 | (let* ((var (car (ensure-list vars))) |
| 947 | (bare (bare-symbol var)) | 957 | (bare (bare-symbol var)) |
| 948 | (beg (elisp-scope-sym-pos var))) | 958 | (beg (elisp-scope--sym-pos var))) |
| 949 | (when beg (elisp-scope-binding bare beg (length (symbol-name bare)))) | 959 | (when beg (elisp-scope--binding bare beg (length (symbol-name bare)))) |
| 950 | (elisp-scope-loop-for (elisp-scope-local-new bare beg local) (cdr-safe vars) rest)) | 960 | (elisp-scope-loop-for (elisp-scope--local-new bare beg local) (cdr-safe vars) rest)) |
| 951 | (when-let* ((bare (elisp-scope-sym-bare (car rest))) | 961 | (when-let* ((bare (elisp-scope--sym-bare (car rest))) |
| 952 | (more (cdr rest))) | 962 | (more (cdr rest))) |
| 953 | (cond | 963 | (cond |
| 954 | ((memq bare '(from upfrom downfrom)) | 964 | ((memq bare '(from upfrom downfrom)) |
| @@ -972,34 +982,34 @@ Optional argument LOCAL is a local context to extend." | |||
| 972 | 982 | ||
| 973 | (defun elisp-scope-loop-collect (expr rest) | 983 | (defun elisp-scope-loop-collect (expr rest) |
| 974 | (elisp-scope-1 expr) | 984 | (elisp-scope-1 expr) |
| 975 | (let ((bw (elisp-scope-sym-bare (car rest))) | 985 | (let ((bw (elisp-scope--sym-bare (car rest))) |
| 976 | (more (cdr rest))) | 986 | (more (cdr rest))) |
| 977 | (if (eq bw 'into) | 987 | (if (eq bw 'into) |
| 978 | (let* ((var (car more)) | 988 | (let* ((var (car more)) |
| 979 | (bare (elisp-scope-sym-bare var)) | 989 | (bare (elisp-scope--sym-bare var)) |
| 980 | (beg (elisp-scope-sym-pos var))) | 990 | (beg (elisp-scope--sym-pos var))) |
| 981 | (if (memq bare elisp-scope-loop-into-vars) | 991 | (if (memq bare elisp-scope-loop-into-vars) |
| 982 | (progn | 992 | (progn |
| 983 | (elisp-scope-s var) | 993 | (elisp-scope--symbol var) |
| 984 | (elisp-scope-loop (cdr more))) | 994 | (elisp-scope-loop (cdr more))) |
| 985 | (when beg (elisp-scope-binding bare beg (length (symbol-name bare)))) | 995 | (when beg (elisp-scope--binding bare beg (length (symbol-name bare)))) |
| 986 | (let ((elisp-scope-loop-into-vars (cons bare elisp-scope-loop-into-vars)) | 996 | (let ((elisp-scope-loop-into-vars (cons bare elisp-scope-loop-into-vars)) |
| 987 | (elisp-scope-local-bindings (elisp-scope-local-new bare beg elisp-scope-local-bindings))) | 997 | (elisp-scope-local-bindings (elisp-scope--local-new bare beg elisp-scope-local-bindings))) |
| 988 | (elisp-scope-loop (cdr more))))) | 998 | (elisp-scope-loop (cdr more))))) |
| 989 | (elisp-scope-loop rest)))) | 999 | (elisp-scope-loop rest)))) |
| 990 | 1000 | ||
| 991 | (defun elisp-scope-loop-with-and (rest) | 1001 | (defun elisp-scope-loop-with-and (rest) |
| 992 | (if (eq (elisp-scope-sym-bare (car rest)) 'and) | 1002 | (if (eq (elisp-scope--sym-bare (car rest)) 'and) |
| 993 | (elisp-scope-loop-with (cadr rest) (cddr rest)) | 1003 | (elisp-scope-loop-with (cadr rest) (cddr rest)) |
| 994 | (elisp-scope-loop rest))) | 1004 | (elisp-scope-loop rest))) |
| 995 | 1005 | ||
| 996 | (defun elisp-scope-loop-with (var rest) | 1006 | (defun elisp-scope-loop-with (var rest) |
| 997 | (let* ((bare (elisp-scope-sym-bare var)) | 1007 | (let* ((bare (elisp-scope--sym-bare var)) |
| 998 | (beg (symbol-with-pos-pos var)) | 1008 | (beg (symbol-with-pos-pos var)) |
| 999 | (l (elisp-scope-local-new bare beg elisp-scope-local-bindings)) | 1009 | (l (elisp-scope--local-new bare beg elisp-scope-local-bindings)) |
| 1000 | (eql (car rest))) | 1010 | (eql (car rest))) |
| 1001 | (when beg (elisp-scope-binding bare beg (length (symbol-name bare)))) | 1011 | (when beg (elisp-scope--binding bare beg (length (symbol-name bare)))) |
| 1002 | (if (eq (elisp-scope-sym-bare eql) '=) | 1012 | (if (eq (elisp-scope--sym-bare eql) '=) |
| 1003 | (let* ((val (cadr rest)) (more (cddr rest))) | 1013 | (let* ((val (cadr rest)) (more (cddr rest))) |
| 1004 | (elisp-scope-1 val) | 1014 | (elisp-scope-1 val) |
| 1005 | (let ((elisp-scope-local-bindings l)) | 1015 | (let ((elisp-scope-local-bindings l)) |
| @@ -1014,29 +1024,29 @@ Optional argument LOCAL is a local context to extend." | |||
| 1014 | (elisp-scope-loop rest))) | 1024 | (elisp-scope-loop rest))) |
| 1015 | 1025 | ||
| 1016 | (defun elisp-scope-loop-named (name rest) | 1026 | (defun elisp-scope-loop-named (name rest) |
| 1017 | (let* ((beg (elisp-scope-sym-pos name)) | 1027 | (let* ((beg (elisp-scope--sym-pos name)) |
| 1018 | (bare (elisp-scope-sym-bare name))) | 1028 | (bare (elisp-scope--sym-bare name))) |
| 1019 | (when beg | 1029 | (when beg |
| 1020 | (elisp-scope-report 'block beg (length (symbol-name bare)) beg)) | 1030 | (elisp-scope--report 'block beg (length (symbol-name bare)) beg)) |
| 1021 | (let ((elisp-scope-block-alist (elisp-scope-local-new bare beg elisp-scope-block-alist))) | 1031 | (let ((elisp-scope-block-alist (elisp-scope--local-new bare beg elisp-scope-block-alist))) |
| 1022 | (elisp-scope-loop rest)))) | 1032 | (elisp-scope-loop rest)))) |
| 1023 | 1033 | ||
| 1024 | (defun elisp-scope-loop-finally (next rest) | 1034 | (defun elisp-scope-loop-finally (next rest) |
| 1025 | (if-let* ((bare (elisp-scope-sym-bare next))) | 1035 | (if-let* ((bare (elisp-scope--sym-bare next))) |
| 1026 | (cond | 1036 | (cond |
| 1027 | ((eq bare 'do) | 1037 | ((eq bare 'do) |
| 1028 | (elisp-scope-loop-do (car rest) (cdr rest))) | 1038 | (elisp-scope-loop-do (car rest) (cdr rest))) |
| 1029 | ((eq bare 'return) | 1039 | ((eq bare 'return) |
| 1030 | (elisp-scope-1 (car rest)) | 1040 | (elisp-scope-1 (car rest)) |
| 1031 | (elisp-scope-loop (cdr rest)))) | 1041 | (elisp-scope-loop (cdr rest)))) |
| 1032 | (if (eq (elisp-scope-sym-bare (car-safe next)) 'return) | 1042 | (if (eq (elisp-scope--sym-bare (car-safe next)) 'return) |
| 1033 | (progn | 1043 | (progn |
| 1034 | (elisp-scope-1 (cadr next)) | 1044 | (elisp-scope-1 (cadr next)) |
| 1035 | (elisp-scope-loop (cdr rest))) | 1045 | (elisp-scope-loop (cdr rest))) |
| 1036 | (elisp-scope-loop-do next rest)))) | 1046 | (elisp-scope-loop-do next rest)))) |
| 1037 | 1047 | ||
| 1038 | (defun elisp-scope-loop-initially (next rest) | 1048 | (defun elisp-scope-loop-initially (next rest) |
| 1039 | (if (eq (elisp-scope-sym-bare next) 'do) | 1049 | (if (eq (elisp-scope--sym-bare next) 'do) |
| 1040 | (elisp-scope-loop-do (car rest) (cdr rest)) | 1050 | (elisp-scope-loop-do (car rest) (cdr rest)) |
| 1041 | (elisp-scope-loop-do next rest))) | 1051 | (elisp-scope-loop-do next rest))) |
| 1042 | 1052 | ||
| @@ -1047,7 +1057,7 @@ Optional argument LOCAL is a local context to extend." | |||
| 1047 | (let ((elisp-scope-loop-if-depth (1+ elisp-scope-loop-if-depth)) | 1057 | (let ((elisp-scope-loop-if-depth (1+ elisp-scope-loop-if-depth)) |
| 1048 | (elisp-scope-local-bindings | 1058 | (elisp-scope-local-bindings |
| 1049 | ;; `if' binds `it'. | 1059 | ;; `if' binds `it'. |
| 1050 | (elisp-scope-local-new 'it (elisp-scope-sym-pos keyword) elisp-scope-local-bindings))) | 1060 | (elisp-scope--local-new 'it (elisp-scope--sym-pos keyword) elisp-scope-local-bindings))) |
| 1051 | (elisp-scope-loop rest))) | 1061 | (elisp-scope-loop rest))) |
| 1052 | 1062 | ||
| 1053 | (defun elisp-scope-loop-end (rest) | 1063 | (defun elisp-scope-loop-end (rest) |
| @@ -1061,7 +1071,7 @@ Optional argument LOCAL is a local context to extend." | |||
| 1061 | (defun elisp-scope-loop (forms) | 1071 | (defun elisp-scope-loop (forms) |
| 1062 | (when forms | 1072 | (when forms |
| 1063 | (let* ((kw (car forms)) | 1073 | (let* ((kw (car forms)) |
| 1064 | (bare (elisp-scope-sym-bare kw)) | 1074 | (bare (elisp-scope--sym-bare kw)) |
| 1065 | (rest (cdr forms))) | 1075 | (rest (cdr forms))) |
| 1066 | (cond | 1076 | (cond |
| 1067 | ((memq bare '(for as)) | 1077 | ((memq bare '(for as)) |
| @@ -1082,22 +1092,22 @@ Optional argument LOCAL is a local context to extend." | |||
| 1082 | ((memq bare '(and else)) (elisp-scope-loop-and rest)))))) | 1092 | ((memq bare '(and else)) (elisp-scope-loop-and rest)))))) |
| 1083 | 1093 | ||
| 1084 | (defun elisp-scope-named-let (name bindings body &optional outspec) | 1094 | (defun elisp-scope-named-let (name bindings body &optional outspec) |
| 1085 | (let ((bare (elisp-scope-sym-bare name)) | 1095 | (let ((bare (elisp-scope--sym-bare name)) |
| 1086 | (beg (elisp-scope-sym-pos name))) | 1096 | (beg (elisp-scope--sym-pos name))) |
| 1087 | (when beg | 1097 | (when beg |
| 1088 | (elisp-scope-report 'function beg (length (symbol-name bare)) beg)) | 1098 | (elisp-scope--report 'function beg (length (symbol-name bare)) beg)) |
| 1089 | (dolist (binding bindings) | 1099 | (dolist (binding bindings) |
| 1090 | (let* ((sym (car (ensure-list binding))) | 1100 | (let* ((sym (car (ensure-list binding))) |
| 1091 | (beg (symbol-with-pos-pos sym)) | 1101 | (beg (symbol-with-pos-pos sym)) |
| 1092 | (bare (bare-symbol sym))) | 1102 | (bare (bare-symbol sym))) |
| 1093 | (when beg (elisp-scope-binding bare beg (length (symbol-name bare)))) | 1103 | (when beg (elisp-scope--binding bare beg (length (symbol-name bare)))) |
| 1094 | (elisp-scope-1 (cadr binding)))) | 1104 | (elisp-scope-1 (cadr binding)))) |
| 1095 | (let ((l elisp-scope-local-bindings)) | 1105 | (let ((l elisp-scope-local-bindings)) |
| 1096 | (dolist (binding bindings) | 1106 | (dolist (binding bindings) |
| 1097 | (when-let* ((sym (car (ensure-list binding))) | 1107 | (when-let* ((sym (car (ensure-list binding))) |
| 1098 | (bare (elisp-scope-sym-bare sym))) | 1108 | (bare (elisp-scope--sym-bare sym))) |
| 1099 | (setq l (elisp-scope-local-new bare (elisp-scope-sym-pos sym) l)))) | 1109 | (setq l (elisp-scope--local-new bare (elisp-scope--sym-pos sym) l)))) |
| 1100 | (let ((pos (or beg (cons 'gen (incf elisp-scope-counter))))) | 1110 | (let ((pos (or beg (cons 'gen (incf elisp-scope--counter))))) |
| 1101 | (elisp-scope-with-local-definition bare | 1111 | (elisp-scope-with-local-definition bare |
| 1102 | (elisp-scope--local-function-analyzer pos) | 1112 | (elisp-scope--local-function-analyzer pos) |
| 1103 | (let ((elisp-scope-local-bindings l)) (elisp-scope-n body outspec))))))) | 1113 | (let ((elisp-scope-local-bindings l)) (elisp-scope-n body outspec))))))) |
| @@ -1110,11 +1120,11 @@ Optional argument LOCAL is a local context to extend." | |||
| 1110 | (defun elisp-scope-rx-1 (regexp) | 1120 | (defun elisp-scope-rx-1 (regexp) |
| 1111 | (if (consp regexp) | 1121 | (if (consp regexp) |
| 1112 | (let* ((head (car regexp)) | 1122 | (let* ((head (car regexp)) |
| 1113 | (bare (elisp-scope-sym-bare head))) | 1123 | (bare (elisp-scope--sym-bare head))) |
| 1114 | (when (and bare (symbol-with-pos-p head)) | 1124 | (when (and bare (symbol-with-pos-p head)) |
| 1115 | (elisp-scope-report 'rx-construct | 1125 | (elisp-scope--report 'rx-construct |
| 1116 | (symbol-with-pos-pos head) (length (symbol-name bare)) | 1126 | (symbol-with-pos-pos head) (length (symbol-name bare)) |
| 1117 | (alist-get bare elisp-scope-rx-alist))) | 1127 | (alist-get bare elisp-scope-rx-alist))) |
| 1118 | (cond | 1128 | (cond |
| 1119 | ((memq bare '(literal regex regexp eval)) | 1129 | ((memq bare '(literal regex regexp eval)) |
| 1120 | (elisp-scope-1 (cadr regexp))) | 1130 | (elisp-scope-1 (cadr regexp))) |
| @@ -1129,15 +1139,15 @@ Optional argument LOCAL is a local context to extend." | |||
| 1129 | group-n submatch-n)) | 1139 | group-n submatch-n)) |
| 1130 | (elisp-scope-rx (cdr regexp))))) | 1140 | (elisp-scope-rx (cdr regexp))))) |
| 1131 | (when-let* (((symbol-with-pos-p regexp)) | 1141 | (when-let* (((symbol-with-pos-p regexp)) |
| 1132 | (bare (elisp-scope-sym-bare regexp))) | 1142 | (bare (elisp-scope--sym-bare regexp))) |
| 1133 | (elisp-scope-report 'rx-construct | 1143 | (elisp-scope--report 'rx-construct |
| 1134 | (symbol-with-pos-pos regexp) (length (symbol-name bare)) | 1144 | (symbol-with-pos-pos regexp) (length (symbol-name bare)) |
| 1135 | (alist-get bare elisp-scope-rx-alist))))) | 1145 | (alist-get bare elisp-scope-rx-alist))))) |
| 1136 | 1146 | ||
| 1137 | (defun elisp-scope-rx-define (name rest) | 1147 | (defun elisp-scope-rx-define (name rest) |
| 1138 | (when-let* ((bare (elisp-scope-sym-bare name))) | 1148 | (when-let* ((bare (elisp-scope--sym-bare name))) |
| 1139 | (elisp-scope-report 'rx-construct | 1149 | (elisp-scope--report 'rx-construct |
| 1140 | (symbol-with-pos-pos name) (length (symbol-name bare)) nil)) | 1150 | (symbol-with-pos-pos name) (length (symbol-name bare)) nil)) |
| 1141 | (if (not (cdr rest)) | 1151 | (if (not (cdr rest)) |
| 1142 | (elisp-scope-rx-1 (car rest)) | 1152 | (elisp-scope-rx-1 (car rest)) |
| 1143 | (let ((l elisp-scope-rx-alist) | 1153 | (let ((l elisp-scope-rx-alist) |
| @@ -1150,23 +1160,23 @@ Optional argument LOCAL is a local context to extend." | |||
| 1150 | (len (length (symbol-name bare)))) | 1160 | (len (length (symbol-name bare)))) |
| 1151 | (when beg | 1161 | (when beg |
| 1152 | (if (memq (bare-symbol arg) '(&optional &rest _)) | 1162 | (if (memq (bare-symbol arg) '(&optional &rest _)) |
| 1153 | (elisp-scope-report 'ampersand beg len) | 1163 | (elisp-scope--report 'ampersand beg len) |
| 1154 | (elisp-scope-report 'rx-construct beg len beg)))))) | 1164 | (elisp-scope--report 'rx-construct beg len beg)))))) |
| 1155 | (dolist (arg args) | 1165 | (dolist (arg args) |
| 1156 | (when-let* ((bare (bare-symbol arg)) | 1166 | (when-let* ((bare (bare-symbol arg)) |
| 1157 | (beg (elisp-scope-sym-pos arg))) | 1167 | (beg (elisp-scope--sym-pos arg))) |
| 1158 | (unless (memq bare '(&optional &rest)) | 1168 | (unless (memq bare '(&optional &rest)) |
| 1159 | (setq l (elisp-scope-local-new bare beg l))))) | 1169 | (setq l (elisp-scope--local-new bare beg l))))) |
| 1160 | (let ((elisp-scope-rx-alist l)) | 1170 | (let ((elisp-scope-rx-alist l)) |
| 1161 | (elisp-scope-rx-1 rx))))) | 1171 | (elisp-scope-rx-1 rx))))) |
| 1162 | 1172 | ||
| 1163 | (defun elisp-scope-rx-let (bindings body) | 1173 | (defun elisp-scope-rx-let (bindings body) |
| 1164 | (if-let* ((binding (car bindings))) | 1174 | (if-let* ((binding (car bindings))) |
| 1165 | (let ((name (car binding)) (rest (cdr binding))) | 1175 | (let ((name (car binding)) (rest (cdr binding))) |
| 1166 | (when-let* ((bare (elisp-scope-sym-bare name)) | 1176 | (when-let* ((bare (elisp-scope--sym-bare name)) |
| 1167 | (beg (symbol-with-pos-pos name))) | 1177 | (beg (symbol-with-pos-pos name))) |
| 1168 | (elisp-scope-report 'rx-construct | 1178 | (elisp-scope--report 'rx-construct |
| 1169 | beg (length (symbol-name bare)) beg)) | 1179 | beg (length (symbol-name bare)) beg)) |
| 1170 | (if (cdr rest) | 1180 | (if (cdr rest) |
| 1171 | (let ((l elisp-scope-rx-alist) | 1181 | (let ((l elisp-scope-rx-alist) |
| 1172 | (args (car rest)) | 1182 | (args (car rest)) |
| @@ -1178,67 +1188,67 @@ Optional argument LOCAL is a local context to extend." | |||
| 1178 | (len (length (symbol-name bare)))) | 1188 | (len (length (symbol-name bare)))) |
| 1179 | (when beg | 1189 | (when beg |
| 1180 | (if (memq (bare-symbol arg) '(&optional &rest _)) | 1190 | (if (memq (bare-symbol arg) '(&optional &rest _)) |
| 1181 | (elisp-scope-report 'ampersand beg len) | 1191 | (elisp-scope--report 'ampersand beg len) |
| 1182 | (elisp-scope-report 'rx-construct beg len beg)))))) | 1192 | (elisp-scope--report 'rx-construct beg len beg)))))) |
| 1183 | (dolist (arg args) | 1193 | (dolist (arg args) |
| 1184 | (when-let* ((bare (bare-symbol arg)) | 1194 | (when-let* ((bare (bare-symbol arg)) |
| 1185 | (beg (elisp-scope-sym-pos arg))) | 1195 | (beg (elisp-scope--sym-pos arg))) |
| 1186 | (unless (memq bare '(&optional &rest)) | 1196 | (unless (memq bare '(&optional &rest)) |
| 1187 | (setq l (elisp-scope-local-new bare beg l))))) | 1197 | (setq l (elisp-scope--local-new bare beg l))))) |
| 1188 | (let ((elisp-scope-rx-alist l)) | 1198 | (let ((elisp-scope-rx-alist l)) |
| 1189 | (elisp-scope-rx-1 rx)) | 1199 | (elisp-scope-rx-1 rx)) |
| 1190 | (let ((elisp-scope-rx-alist (elisp-scope-local-new (elisp-scope-sym-bare name) | 1200 | (let ((elisp-scope-rx-alist (elisp-scope--local-new (elisp-scope--sym-bare name) |
| 1191 | (elisp-scope-sym-pos name) | 1201 | (elisp-scope--sym-pos name) |
| 1192 | elisp-scope-rx-alist))) | 1202 | elisp-scope-rx-alist))) |
| 1193 | (elisp-scope-rx-let (cdr bindings) body))) | 1203 | (elisp-scope-rx-let (cdr bindings) body))) |
| 1194 | (elisp-scope-rx-1 (car rest)) | 1204 | (elisp-scope-rx-1 (car rest)) |
| 1195 | (let ((elisp-scope-rx-alist (elisp-scope-local-new (elisp-scope-sym-bare name) | 1205 | (let ((elisp-scope-rx-alist (elisp-scope--local-new (elisp-scope--sym-bare name) |
| 1196 | (elisp-scope-sym-pos name) | 1206 | (elisp-scope--sym-pos name) |
| 1197 | elisp-scope-rx-alist))) | 1207 | elisp-scope-rx-alist))) |
| 1198 | (elisp-scope-rx-let (cdr bindings) body)))) | 1208 | (elisp-scope-rx-let (cdr bindings) body)))) |
| 1199 | (elisp-scope-n body))) | 1209 | (elisp-scope-n body))) |
| 1200 | 1210 | ||
| 1201 | (defun elisp-scope-gv-define-expander (name handler) | 1211 | (defun elisp-scope-gv-define-expander (name handler) |
| 1202 | (when-let* ((beg (elisp-scope-sym-pos name)) (bare (elisp-scope-sym-bare name))) | 1212 | (when-let* ((beg (elisp-scope--sym-pos name)) (bare (elisp-scope--sym-bare name))) |
| 1203 | (elisp-scope-report 'defun beg (length (symbol-name bare)))) | 1213 | (elisp-scope--report 'defun beg (length (symbol-name bare)))) |
| 1204 | (elisp-scope-1 handler)) | 1214 | (elisp-scope-1 handler)) |
| 1205 | 1215 | ||
| 1206 | (defun elisp-scope-gv-define-simple-setter (name setter rest) | 1216 | (defun elisp-scope-gv-define-simple-setter (name setter rest) |
| 1207 | (when-let* ((beg (elisp-scope-sym-pos name)) (bare (elisp-scope-sym-bare name))) | 1217 | (when-let* ((beg (elisp-scope--sym-pos name)) (bare (elisp-scope--sym-bare name))) |
| 1208 | (elisp-scope-report 'defun beg (length (symbol-name bare)))) | 1218 | (elisp-scope--report 'defun beg (length (symbol-name bare)))) |
| 1209 | (when-let* ((beg (elisp-scope-sym-pos setter)) (bare (elisp-scope-sym-bare setter))) | 1219 | (when-let* ((beg (elisp-scope--sym-pos setter)) (bare (elisp-scope--sym-bare setter))) |
| 1210 | (elisp-scope-report 'function beg (length (symbol-name bare)))) | 1220 | (elisp-scope--report 'function beg (length (symbol-name bare)))) |
| 1211 | (elisp-scope-n rest)) | 1221 | (elisp-scope-n rest)) |
| 1212 | 1222 | ||
| 1213 | (defun elisp-scope-face (face) | 1223 | (defun elisp-scope-face (face) |
| 1214 | (if (or (elisp-scope-sym-bare face) | 1224 | (if (or (elisp-scope--sym-bare face) |
| 1215 | (keywordp (elisp-scope-sym-bare (car-safe face)))) | 1225 | (keywordp (elisp-scope--sym-bare (car-safe face)))) |
| 1216 | (elisp-scope-face-1 face) | 1226 | (elisp-scope-face-1 face) |
| 1217 | (mapc #'elisp-scope-face-1 face))) | 1227 | (mapc #'elisp-scope-face-1 face))) |
| 1218 | 1228 | ||
| 1219 | (defun elisp-scope-face-1 (face) | 1229 | (defun elisp-scope-face-1 (face) |
| 1220 | (cond | 1230 | (cond |
| 1221 | ((symbol-with-pos-p face) | 1231 | ((symbol-with-pos-p face) |
| 1222 | (when-let* ((beg (elisp-scope-sym-pos face)) (bare (elisp-scope-sym-bare face))) | 1232 | (when-let* ((beg (elisp-scope--sym-pos face)) (bare (elisp-scope--sym-bare face))) |
| 1223 | (elisp-scope-report 'face beg (length (symbol-name bare))))) | 1233 | (elisp-scope--report 'face beg (length (symbol-name bare))))) |
| 1224 | ((keywordp (elisp-scope-sym-bare (car-safe face))) | 1234 | ((keywordp (elisp-scope--sym-bare (car-safe face))) |
| 1225 | (let ((l face)) | 1235 | (let ((l face)) |
| 1226 | (while l | 1236 | (while l |
| 1227 | (let ((kw (car l)) | 1237 | (let ((kw (car l)) |
| 1228 | (vl (cadr l))) | 1238 | (vl (cadr l))) |
| 1229 | (setq l (cddr l)) | 1239 | (setq l (cddr l)) |
| 1230 | (when-let* ((bare (elisp-scope-sym-bare kw)) | 1240 | (when-let* ((bare (elisp-scope--sym-bare kw)) |
| 1231 | ((keywordp bare))) | 1241 | ((keywordp bare))) |
| 1232 | (when-let* ((beg (elisp-scope-sym-pos kw)) | 1242 | (when-let* ((beg (elisp-scope--sym-pos kw)) |
| 1233 | (len (length (symbol-name bare)))) | 1243 | (len (length (symbol-name bare)))) |
| 1234 | (elisp-scope-report 'constant beg len)) | 1244 | (elisp-scope--report 'constant beg len)) |
| 1235 | (when (eq bare :inherit) | 1245 | (when (eq bare :inherit) |
| 1236 | (when-let* ((beg (elisp-scope-sym-pos vl)) (fbare (elisp-scope-sym-bare vl))) | 1246 | (when-let* ((beg (elisp-scope--sym-pos vl)) (fbare (elisp-scope--sym-bare vl))) |
| 1237 | (elisp-scope-report 'face beg (length (symbol-name fbare)))))))))))) | 1247 | (elisp-scope--report 'face beg (length (symbol-name fbare)))))))))))) |
| 1238 | 1248 | ||
| 1239 | (defun elisp-scope-deftype (name args body) | 1249 | (defun elisp-scope-deftype (name args body) |
| 1240 | (when-let* ((beg (elisp-scope-sym-pos name)) (bare (elisp-scope-sym-bare name))) | 1250 | (when-let* ((beg (elisp-scope--sym-pos name)) (bare (elisp-scope--sym-bare name))) |
| 1241 | (elisp-scope-report 'deftype beg (length (symbol-name bare)))) | 1251 | (elisp-scope--report 'deftype beg (length (symbol-name bare)))) |
| 1242 | (elisp-scope-lambda args body)) | 1252 | (elisp-scope-lambda args body)) |
| 1243 | 1253 | ||
| 1244 | (defun elisp-scope-defmethod-1 (local args body) | 1254 | (defun elisp-scope-defmethod-1 (local args body) |
| @@ -1249,55 +1259,55 @@ Optional argument LOCAL is a local context to extend." | |||
| 1249 | (let* ((var (car arg)) | 1259 | (let* ((var (car arg)) |
| 1250 | (spec (cadr arg))) | 1260 | (spec (cadr arg))) |
| 1251 | (cond | 1261 | (cond |
| 1252 | ((setq bare (elisp-scope-sym-bare var)) | 1262 | ((setq bare (elisp-scope--sym-bare var)) |
| 1253 | (when-let* ((beg (elisp-scope-sym-pos var)) | 1263 | (when-let* ((beg (elisp-scope--sym-pos var)) |
| 1254 | (len (length (symbol-name bare)))) | 1264 | (len (length (symbol-name bare)))) |
| 1255 | (elisp-scope-binding bare beg len)) | 1265 | (elisp-scope--binding bare beg len)) |
| 1256 | (cond | 1266 | (cond |
| 1257 | ((consp spec) | 1267 | ((consp spec) |
| 1258 | (let ((head (car spec)) (form (cadr spec))) | 1268 | (let ((head (car spec)) (form (cadr spec))) |
| 1259 | (and (eq 'eql (elisp-scope-sym-bare head)) | 1269 | (and (eq 'eql (elisp-scope--sym-bare head)) |
| 1260 | (not (or (symbolp form) (symbol-with-pos-p form))) | 1270 | (not (or (symbolp form) (symbol-with-pos-p form))) |
| 1261 | (elisp-scope-1 form)))) | 1271 | (elisp-scope-1 form)))) |
| 1262 | ((symbol-with-pos-p spec) | 1272 | ((symbol-with-pos-p spec) |
| 1263 | (when-let* ((beg (symbol-with-pos-pos spec)) | 1273 | (when-let* ((beg (symbol-with-pos-pos spec)) |
| 1264 | (bare (bare-symbol spec)) | 1274 | (bare (bare-symbol spec)) |
| 1265 | (len (length (symbol-name bare)))) | 1275 | (len (length (symbol-name bare)))) |
| 1266 | (elisp-scope-report 'type beg len)))) | 1276 | (elisp-scope--report 'type beg len)))) |
| 1267 | (elisp-scope-defmethod-1 (elisp-scope-local-new bare (elisp-scope-sym-pos var) local) | 1277 | (elisp-scope-defmethod-1 (elisp-scope--local-new bare (elisp-scope--sym-pos var) local) |
| 1268 | (cdr args) body))))) | 1278 | (cdr args) body))))) |
| 1269 | ((setq bare (elisp-scope-sym-bare arg)) | 1279 | ((setq bare (elisp-scope--sym-bare arg)) |
| 1270 | (cond | 1280 | (cond |
| 1271 | ((memq bare '(&optional &rest &body _)) | 1281 | ((memq bare '(&optional &rest &body _)) |
| 1272 | (when-let* ((beg (elisp-scope-sym-pos arg))) | 1282 | (when-let* ((beg (elisp-scope--sym-pos arg))) |
| 1273 | (elisp-scope-report 'ampersand beg (length (symbol-name bare)))) | 1283 | (elisp-scope--report 'ampersand beg (length (symbol-name bare)))) |
| 1274 | (elisp-scope-defmethod-1 local (cdr args) body)) | 1284 | (elisp-scope-defmethod-1 local (cdr args) body)) |
| 1275 | ((eq bare '&context) | 1285 | ((eq bare '&context) |
| 1276 | (let* ((expr-type (cadr args)) | 1286 | (let* ((expr-type (cadr args)) |
| 1277 | (expr (car expr-type)) | 1287 | (expr (car expr-type)) |
| 1278 | (spec (cadr expr-type)) | 1288 | (spec (cadr expr-type)) |
| 1279 | (more (cddr args))) | 1289 | (more (cddr args))) |
| 1280 | (when-let* ((beg (elisp-scope-sym-pos arg))) | 1290 | (when-let* ((beg (elisp-scope--sym-pos arg))) |
| 1281 | (elisp-scope-report 'ampersand beg (length (symbol-name bare)))) | 1291 | (elisp-scope--report 'ampersand beg (length (symbol-name bare)))) |
| 1282 | (elisp-scope-1 expr) | 1292 | (elisp-scope-1 expr) |
| 1283 | (cond | 1293 | (cond |
| 1284 | ((consp spec) | 1294 | ((consp spec) |
| 1285 | (let ((head (car spec)) (form (cadr spec))) | 1295 | (let ((head (car spec)) (form (cadr spec))) |
| 1286 | (and (eq 'eql (elisp-scope-sym-bare head)) | 1296 | (and (eq 'eql (elisp-scope--sym-bare head)) |
| 1287 | (not (or (symbolp form) (symbol-with-pos-p form))) | 1297 | (not (or (symbolp form) (symbol-with-pos-p form))) |
| 1288 | (elisp-scope-1 form)))) | 1298 | (elisp-scope-1 form)))) |
| 1289 | ((symbol-with-pos-p spec) | 1299 | ((symbol-with-pos-p spec) |
| 1290 | (when-let* ((beg (symbol-with-pos-pos spec)) | 1300 | (when-let* ((beg (symbol-with-pos-pos spec)) |
| 1291 | (bare (bare-symbol spec)) | 1301 | (bare (bare-symbol spec)) |
| 1292 | (len (length (symbol-name bare)))) | 1302 | (len (length (symbol-name bare)))) |
| 1293 | (elisp-scope-report 'type beg len beg)))) | 1303 | (elisp-scope--report 'type beg len beg)))) |
| 1294 | (elisp-scope-defmethod-1 local more body))) | 1304 | (elisp-scope-defmethod-1 local more body))) |
| 1295 | (t | 1305 | (t |
| 1296 | (when-let* ((beg (elisp-scope-sym-pos arg)) | 1306 | (when-let* ((beg (elisp-scope--sym-pos arg)) |
| 1297 | (len (length (symbol-name bare)))) | 1307 | (len (length (symbol-name bare)))) |
| 1298 | (elisp-scope-binding bare beg len)) | 1308 | (elisp-scope--binding bare beg len)) |
| 1299 | (elisp-scope-defmethod-1 (elisp-scope-local-new bare (elisp-scope-sym-pos arg) local) | 1309 | (elisp-scope-defmethod-1 (elisp-scope--local-new bare (elisp-scope--sym-pos arg) local) |
| 1300 | (cdr args) body)))))) | 1310 | (cdr args) body)))))) |
| 1301 | (let ((elisp-scope-local-bindings local)) | 1311 | (let ((elisp-scope-local-bindings local)) |
| 1302 | (elisp-scope-n body)))) | 1312 | (elisp-scope-n body)))) |
| 1303 | 1313 | ||
| @@ -1312,24 +1322,24 @@ Optional argument LOCAL is a local context to extend." | |||
| 1312 | ;; (if (stringp (cadr rest)) (cddr rest) (cdr rest)))) | 1322 | ;; (if (stringp (cadr rest)) (cddr rest) (cdr rest)))) |
| 1313 | 1323 | ||
| 1314 | (defun elisp-scope-defmethod (name rest) | 1324 | (defun elisp-scope-defmethod (name rest) |
| 1315 | (when-let* ((beg (elisp-scope-sym-pos name)) (bare (elisp-scope-sym-bare name))) | 1325 | (when-let* ((beg (elisp-scope--sym-pos name)) (bare (elisp-scope--sym-bare name))) |
| 1316 | (elisp-scope-report 'defun beg (length (symbol-name bare)))) | 1326 | (elisp-scope--report 'defun beg (length (symbol-name bare)))) |
| 1317 | ;; [EXTRA] | 1327 | ;; [EXTRA] |
| 1318 | (when (eq (elisp-scope-sym-bare (car rest)) :extra) | 1328 | (when (eq (elisp-scope--sym-bare (car rest)) :extra) |
| 1319 | (elisp-scope-s (car rest)) | 1329 | (elisp-scope--symbol (car rest)) |
| 1320 | (setq rest (cddr rest))) | 1330 | (setq rest (cddr rest))) |
| 1321 | ;; [QUALIFIER] | 1331 | ;; [QUALIFIER] |
| 1322 | (when (keywordp (elisp-scope-sym-bare (car rest))) | 1332 | (when (keywordp (elisp-scope--sym-bare (car rest))) |
| 1323 | (elisp-scope-s (car rest)) | 1333 | (elisp-scope--symbol (car rest)) |
| 1324 | (setq rest (cdr rest))) | 1334 | (setq rest (cdr rest))) |
| 1325 | ;; ARGUMENTS | 1335 | ;; ARGUMENTS |
| 1326 | (elisp-scope-defmethod-1 elisp-scope-local-bindings (car rest) (cdr rest))) | 1336 | (elisp-scope-defmethod-1 elisp-scope-local-bindings (car rest) (cdr rest))) |
| 1327 | 1337 | ||
| 1328 | (defun elisp-scope-cl-defun (name arglist body) | 1338 | (defun elisp-scope-cl-defun (name arglist body) |
| 1329 | (let ((beg (elisp-scope-sym-pos name)) | 1339 | (let ((beg (elisp-scope--sym-pos name)) |
| 1330 | (bare (elisp-scope-sym-bare name))) | 1340 | (bare (elisp-scope--sym-bare name))) |
| 1331 | (when beg (elisp-scope-report 'defun beg (length (symbol-name bare)))) | 1341 | (when beg (elisp-scope--report 'defun beg (length (symbol-name bare)))) |
| 1332 | (let ((elisp-scope-block-alist (elisp-scope-local-new bare beg elisp-scope-block-alist))) | 1342 | (let ((elisp-scope-block-alist (elisp-scope--local-new bare beg elisp-scope-block-alist))) |
| 1333 | (elisp-scope-cl-lambda arglist body)))) | 1343 | (elisp-scope-cl-lambda arglist body)))) |
| 1334 | 1344 | ||
| 1335 | (defun elisp-scope-cl-lambda (arglist body) | 1345 | (defun elisp-scope-cl-lambda (arglist body) |
| @@ -1342,11 +1352,11 @@ Optional argument LOCAL is a local context to extend." | |||
| 1342 | (let ((head (car arglist))) | 1352 | (let ((head (car arglist))) |
| 1343 | (if (consp head) | 1353 | (if (consp head) |
| 1344 | (elisp-scope-cl-lambda-1 head (cons (cdr arglist) more) body) | 1354 | (elisp-scope-cl-lambda-1 head (cons (cdr arglist) more) body) |
| 1345 | (let ((bare (elisp-scope-sym-bare head))) | 1355 | (let ((bare (elisp-scope--sym-bare head))) |
| 1346 | (if (memq bare '(&optional &rest &body &key &aux &whole &cl-defs &cl-quote)) | 1356 | (if (memq bare '(&optional &rest &body &key &aux &whole &cl-defs &cl-quote)) |
| 1347 | (progn | 1357 | (progn |
| 1348 | (when-let* ((beg (elisp-scope-sym-pos head))) | 1358 | (when-let* ((beg (elisp-scope--sym-pos head))) |
| 1349 | (elisp-scope-report 'ampersand beg (length (symbol-name bare)))) | 1359 | (elisp-scope--report 'ampersand beg (length (symbol-name bare)))) |
| 1350 | (cl-case bare | 1360 | (cl-case bare |
| 1351 | (&optional (elisp-scope-cl-lambda-optional (cadr arglist) (cddr arglist) more body)) | 1361 | (&optional (elisp-scope-cl-lambda-optional (cadr arglist) (cddr arglist) more body)) |
| 1352 | (&cl-defs (elisp-scope-cl-lambda-defs (cadr arglist) (cddr arglist) more body)) | 1362 | (&cl-defs (elisp-scope-cl-lambda-defs (cadr arglist) (cddr arglist) more body)) |
| @@ -1354,9 +1364,11 @@ Optional argument LOCAL is a local context to extend." | |||
| 1354 | (&key (elisp-scope-cl-lambda-key (cadr arglist) (cddr arglist) more body)) | 1364 | (&key (elisp-scope-cl-lambda-key (cadr arglist) (cddr arglist) more body)) |
| 1355 | (&aux (elisp-scope-cl-lambda-aux (cadr arglist) (cddr arglist) more body)) | 1365 | (&aux (elisp-scope-cl-lambda-aux (cadr arglist) (cddr arglist) more body)) |
| 1356 | (&whole (elisp-scope-cl-lambda-1 (cdr arglist) more body)))) | 1366 | (&whole (elisp-scope-cl-lambda-1 (cdr arglist) more body)))) |
| 1357 | (when-let* ((beg (elisp-scope-sym-pos head))) | 1367 | (when-let* ((beg (elisp-scope--sym-pos head))) |
| 1358 | (elisp-scope-binding bare beg (length (symbol-name bare)))) | 1368 | (elisp-scope--binding bare beg (length (symbol-name bare)))) |
| 1359 | (let ((elisp-scope-local-bindings (elisp-scope-local-new bare (elisp-scope-sym-pos head) elisp-scope-local-bindings))) | 1369 | (let ((elisp-scope-local-bindings |
| 1370 | (elisp-scope--local-new bare (elisp-scope--sym-pos head) | ||
| 1371 | elisp-scope-local-bindings))) | ||
| 1360 | (elisp-scope-cl-lambda-1 (cdr arglist) more body)))))) | 1372 | (elisp-scope-cl-lambda-1 (cdr arglist) more body)))))) |
| 1361 | (elisp-scope-cl-lambda-1 (list '&rest arglist) more body))) | 1373 | (elisp-scope-cl-lambda-1 (list '&rest arglist) more body))) |
| 1362 | (more (elisp-scope-cl-lambda-1 (car more) (cdr more) body)) | 1374 | (more (elisp-scope-cl-lambda-1 (car more) (cdr more) body)) |
| @@ -1380,25 +1392,25 @@ Optional argument LOCAL is a local context to extend." | |||
| 1380 | (if (consp var) | 1392 | (if (consp var) |
| 1381 | (let ((elisp-scope-local-bindings l)) | 1393 | (let ((elisp-scope-local-bindings l)) |
| 1382 | (elisp-scope-cl-lambda-1 var (cons (append (when svar (list svar)) | 1394 | (elisp-scope-cl-lambda-1 var (cons (append (when svar (list svar)) |
| 1383 | (cons '&optional arglist)) | 1395 | (cons '&optional arglist)) |
| 1384 | more) | 1396 | more) |
| 1385 | body)) | 1397 | body)) |
| 1386 | (when-let* ((bare (elisp-scope-sym-bare svar))) | 1398 | (when-let* ((bare (elisp-scope--sym-bare svar))) |
| 1387 | (when-let* ((beg (elisp-scope-sym-pos svar))) | 1399 | (when-let* ((beg (elisp-scope--sym-pos svar))) |
| 1388 | (elisp-scope-binding bare beg (length (symbol-name bare)))) | 1400 | (elisp-scope--binding bare beg (length (symbol-name bare)))) |
| 1389 | (setq l (elisp-scope-local-new bare (elisp-scope-sym-pos svar) l))) | 1401 | (setq l (elisp-scope--local-new bare (elisp-scope--sym-pos svar) l))) |
| 1390 | (when-let* ((bare (elisp-scope-sym-bare var))) | 1402 | (when-let* ((bare (elisp-scope--sym-bare var))) |
| 1391 | (when-let* ((beg (elisp-scope-sym-pos var))) | 1403 | (when-let* ((beg (elisp-scope--sym-pos var))) |
| 1392 | (elisp-scope-binding bare beg (length (symbol-name bare)))) | 1404 | (elisp-scope--binding bare beg (length (symbol-name bare)))) |
| 1393 | (setq l (elisp-scope-local-new bare (elisp-scope-sym-pos var) l))) | 1405 | (setq l (elisp-scope--local-new bare (elisp-scope--sym-pos var) l))) |
| 1394 | (cond | 1406 | (cond |
| 1395 | (arglist | 1407 | (arglist |
| 1396 | (let ((head (car arglist))) | 1408 | (let ((head (car arglist))) |
| 1397 | (if-let* ((bare (elisp-scope-sym-bare head)) | 1409 | (if-let* ((bare (elisp-scope--sym-bare head)) |
| 1398 | ((memq bare '(&rest &body &key &aux)))) | 1410 | ((memq bare '(&rest &body &key &aux)))) |
| 1399 | (progn | 1411 | (progn |
| 1400 | (when-let* ((beg (elisp-scope-sym-pos head))) | 1412 | (when-let* ((beg (elisp-scope--sym-pos head))) |
| 1401 | (elisp-scope-report 'ampersand beg (length (symbol-name bare)))) | 1413 | (elisp-scope--report 'ampersand beg (length (symbol-name bare)))) |
| 1402 | (cl-case bare | 1414 | (cl-case bare |
| 1403 | ((&rest &body) | 1415 | ((&rest &body) |
| 1404 | (let ((elisp-scope-local-bindings l)) | 1416 | (let ((elisp-scope-local-bindings l)) |
| @@ -1418,18 +1430,18 @@ Optional argument LOCAL is a local context to extend." | |||
| 1418 | (let* ((l elisp-scope-local-bindings)) | 1430 | (let* ((l elisp-scope-local-bindings)) |
| 1419 | (if (consp var) | 1431 | (if (consp var) |
| 1420 | (elisp-scope-cl-lambda-1 var (cons arglist more) body) | 1432 | (elisp-scope-cl-lambda-1 var (cons arglist more) body) |
| 1421 | (when-let* ((bare (elisp-scope-sym-bare var))) | 1433 | (when-let* ((bare (elisp-scope--sym-bare var))) |
| 1422 | (when-let* ((beg (elisp-scope-sym-pos var))) | 1434 | (when-let* ((beg (elisp-scope--sym-pos var))) |
| 1423 | (elisp-scope-binding bare beg (length (symbol-name bare)))) | 1435 | (elisp-scope--binding bare beg (length (symbol-name bare)))) |
| 1424 | (setq l (elisp-scope-local-new bare (elisp-scope-sym-pos var) l))) | 1436 | (setq l (elisp-scope--local-new bare (elisp-scope--sym-pos var) l))) |
| 1425 | (cond | 1437 | (cond |
| 1426 | (arglist | 1438 | (arglist |
| 1427 | (let ((head (car arglist))) | 1439 | (let ((head (car arglist))) |
| 1428 | (if-let* ((bare (elisp-scope-sym-bare head)) | 1440 | (if-let* ((bare (elisp-scope--sym-bare head)) |
| 1429 | ((memq bare '(&key &aux)))) | 1441 | ((memq bare '(&key &aux)))) |
| 1430 | (progn | 1442 | (progn |
| 1431 | (when-let* ((beg (elisp-scope-sym-pos head))) | 1443 | (when-let* ((beg (elisp-scope--sym-pos head))) |
| 1432 | (elisp-scope-report 'ampersand beg (length (symbol-name bare)))) | 1444 | (elisp-scope--report 'ampersand beg (length (symbol-name bare)))) |
| 1433 | (cl-case bare | 1445 | (cl-case bare |
| 1434 | (&key | 1446 | (&key |
| 1435 | (let ((elisp-scope-local-bindings l)) | 1447 | (let ((elisp-scope-local-bindings l)) |
| @@ -1457,33 +1469,33 @@ Optional argument LOCAL is a local context to extend." | |||
| 1457 | (not (cddr var)) | 1469 | (not (cddr var)) |
| 1458 | ;; VAR is (KEYWORD VAR) | 1470 | ;; VAR is (KEYWORD VAR) |
| 1459 | (setq var (cadr var))) | 1471 | (setq var (cadr var))) |
| 1460 | (when-let* ((bare (elisp-scope-sym-bare kw)) | 1472 | (when-let* ((bare (elisp-scope--sym-bare kw)) |
| 1461 | ((keywordp bare))) | 1473 | ((keywordp bare))) |
| 1462 | (when-let* ((beg (elisp-scope-sym-pos kw))) | 1474 | (when-let* ((beg (elisp-scope--sym-pos kw))) |
| 1463 | (elisp-scope-report 'constant beg (length (symbol-name bare)))) | 1475 | (elisp-scope--report 'constant beg (length (symbol-name bare)))) |
| 1464 | (setq l (elisp-scope-local-new bare (elisp-scope-sym-pos svar) l))) | 1476 | (setq l (elisp-scope--local-new bare (elisp-scope--sym-pos svar) l))) |
| 1465 | (if (consp var) | 1477 | (if (consp var) |
| 1466 | (let ((elisp-scope-local-bindings l)) | 1478 | (let ((elisp-scope-local-bindings l)) |
| 1467 | (elisp-scope-cl-lambda-1 var (cons (append (when svar (list svar)) | 1479 | (elisp-scope-cl-lambda-1 var (cons (append (when svar (list svar)) |
| 1468 | (cons '&key arglist)) | 1480 | (cons '&key arglist)) |
| 1469 | more) | 1481 | more) |
| 1470 | body)) | 1482 | body)) |
| 1471 | (when-let* ((bare (elisp-scope-sym-bare svar))) | 1483 | (when-let* ((bare (elisp-scope--sym-bare svar))) |
| 1472 | (when-let* ((beg (elisp-scope-sym-pos svar))) | 1484 | (when-let* ((beg (elisp-scope--sym-pos svar))) |
| 1473 | (elisp-scope-binding bare beg (length (symbol-name bare)))) | 1485 | (elisp-scope--binding bare beg (length (symbol-name bare)))) |
| 1474 | (setq l (elisp-scope-local-new bare (elisp-scope-sym-pos svar) l))) | 1486 | (setq l (elisp-scope--local-new bare (elisp-scope--sym-pos svar) l))) |
| 1475 | (when-let* ((bare (elisp-scope-sym-bare var))) | 1487 | (when-let* ((bare (elisp-scope--sym-bare var))) |
| 1476 | (when-let* ((beg (elisp-scope-sym-pos var))) | 1488 | (when-let* ((beg (elisp-scope--sym-pos var))) |
| 1477 | (elisp-scope-binding bare beg (length (symbol-name bare)))) | 1489 | (elisp-scope--binding bare beg (length (symbol-name bare)))) |
| 1478 | (setq l (elisp-scope-local-new bare (elisp-scope-sym-pos var) l))) | 1490 | (setq l (elisp-scope--local-new bare (elisp-scope--sym-pos var) l))) |
| 1479 | (cond | 1491 | (cond |
| 1480 | (arglist | 1492 | (arglist |
| 1481 | (let ((head (car arglist))) | 1493 | (let ((head (car arglist))) |
| 1482 | (if-let* ((bare (elisp-scope-sym-bare head)) | 1494 | (if-let* ((bare (elisp-scope--sym-bare head)) |
| 1483 | ((memq bare '(&aux &allow-other-keys)))) | 1495 | ((memq bare '(&aux &allow-other-keys)))) |
| 1484 | (progn | 1496 | (progn |
| 1485 | (when-let* ((beg (elisp-scope-sym-pos head))) | 1497 | (when-let* ((beg (elisp-scope--sym-pos head))) |
| 1486 | (elisp-scope-report 'ampersand beg (length (symbol-name bare)))) | 1498 | (elisp-scope--report 'ampersand beg (length (symbol-name bare)))) |
| 1487 | (cl-case bare | 1499 | (cl-case bare |
| 1488 | (&aux | 1500 | (&aux |
| 1489 | (let ((elisp-scope-local-bindings l)) | 1501 | (let ((elisp-scope-local-bindings l)) |
| @@ -1507,10 +1519,10 @@ Optional argument LOCAL is a local context to extend." | |||
| 1507 | (if (consp var) | 1519 | (if (consp var) |
| 1508 | (let ((elisp-scope-local-bindings l)) | 1520 | (let ((elisp-scope-local-bindings l)) |
| 1509 | (elisp-scope-cl-lambda-1 var (cons arglist more) body)) | 1521 | (elisp-scope-cl-lambda-1 var (cons arglist more) body)) |
| 1510 | (when-let* ((bare (elisp-scope-sym-bare var))) | 1522 | (when-let* ((bare (elisp-scope--sym-bare var))) |
| 1511 | (when-let* ((beg (elisp-scope-sym-pos var))) | 1523 | (when-let* ((beg (elisp-scope--sym-pos var))) |
| 1512 | (elisp-scope-binding bare beg (length (symbol-name bare)))) | 1524 | (elisp-scope--binding bare beg (length (symbol-name bare)))) |
| 1513 | (setq l (elisp-scope-local-new bare (elisp-scope-sym-pos var) l))) | 1525 | (setq l (elisp-scope--local-new bare (elisp-scope--sym-pos var) l))) |
| 1514 | (let ((elisp-scope-local-bindings l)) | 1526 | (let ((elisp-scope-local-bindings l)) |
| 1515 | (cond | 1527 | (cond |
| 1516 | (arglist (elisp-scope-cl-lambda-aux (car arglist) (cdr arglist) more body)) | 1528 | (arglist (elisp-scope-cl-lambda-aux (car arglist) (cdr arglist) more body)) |
| @@ -1523,26 +1535,26 @@ Optional argument LOCAL is a local context to extend." | |||
| 1523 | (arglist (cadr b)) | 1535 | (arglist (cadr b)) |
| 1524 | (mbody (cddr b))) | 1536 | (mbody (cddr b))) |
| 1525 | (elisp-scope-cl-lambda arglist mbody) | 1537 | (elisp-scope-cl-lambda arglist mbody) |
| 1526 | (when-let* ((bare (elisp-scope-sym-bare name)) | 1538 | (when-let* ((bare (elisp-scope--sym-bare name)) |
| 1527 | (len (length (symbol-name bare)))) | 1539 | (len (length (symbol-name bare)))) |
| 1528 | (let ((beg (elisp-scope-sym-pos name))) | 1540 | (let ((beg (elisp-scope--sym-pos name))) |
| 1529 | ;; TODO: Use a bespoke 'local-macro-definition' role. | 1541 | ;; TODO: Use a bespoke 'local-macro-definition' role. |
| 1530 | (when beg (elisp-scope-report 'macro beg len beg)) | 1542 | (when beg (elisp-scope--report 'macro beg len beg)) |
| 1531 | (let ((pos (or beg (cons 'gen (incf elisp-scope-counter))))) | 1543 | (let ((pos (or beg (cons 'gen (incf elisp-scope--counter))))) |
| 1532 | (elisp-scope-with-local-definition bare | 1544 | (elisp-scope-with-local-definition bare |
| 1533 | (lambda (f &rest _) | 1545 | (lambda (f &rest _) |
| 1534 | (when (symbol-with-pos-p f) | 1546 | (when (symbol-with-pos-p f) |
| 1535 | (elisp-scope-report 'macro (symbol-with-pos-pos f) len pos))) | 1547 | (elisp-scope--report 'macro (symbol-with-pos-pos f) len pos))) |
| 1536 | (elisp-scope-cl-macrolet (cdr bindings) body outspec)))))) | 1548 | (elisp-scope-cl-macrolet (cdr bindings) body outspec)))))) |
| 1537 | (elisp-scope-n body outspec))) | 1549 | (elisp-scope-n body outspec))) |
| 1538 | 1550 | ||
| 1539 | (defun elisp-scope-define-minor-mode (mode _doc body) | 1551 | (defun elisp-scope-define-minor-mode (mode _doc body) |
| 1540 | (let ((explicit-var nil) (command t)) | 1552 | (let ((explicit-var nil) (command t)) |
| 1541 | (while-let ((kw (car-safe body)) | 1553 | (while-let ((kw (car-safe body)) |
| 1542 | (bkw (elisp-scope-sym-bare kw)) | 1554 | (bkw (elisp-scope--sym-bare kw)) |
| 1543 | ((keywordp bkw))) | 1555 | ((keywordp bkw))) |
| 1544 | (when-let* ((beg (elisp-scope-sym-pos kw))) | 1556 | (when-let* ((beg (elisp-scope--sym-pos kw))) |
| 1545 | (elisp-scope-report 'constant beg (length (symbol-name bkw)))) | 1557 | (elisp-scope--report 'constant beg (length (symbol-name bkw)))) |
| 1546 | (cl-case bkw | 1558 | (cl-case bkw |
| 1547 | ((:init-value :keymap :after-hook :initialize) | 1559 | ((:init-value :keymap :after-hook :initialize) |
| 1548 | (elisp-scope-1 (cadr body))) | 1560 | (elisp-scope-1 (cadr body))) |
| @@ -1566,30 +1578,30 @@ Optional argument LOCAL is a local context to extend." | |||
| 1566 | (elisp-scope-global-minor-mode-predicate (cadr body))) | 1578 | (elisp-scope-global-minor-mode-predicate (cadr body))) |
| 1567 | ((:on :off) | 1579 | ((:on :off) |
| 1568 | (let ((obod (cdr body))) | 1580 | (let ((obod (cdr body))) |
| 1569 | (while (and obod (not (keywordp (elisp-scope-sym-bare (car obod))))) | 1581 | (while (and obod (not (keywordp (elisp-scope--sym-bare (car obod))))) |
| 1570 | (elisp-scope-1 (pop obod))) | 1582 | (elisp-scope-1 (pop obod))) |
| 1571 | (setq body (cons bkw (cons nil obod)))))) | 1583 | (setq body (cons bkw (cons nil obod)))))) |
| 1572 | (setq body (cddr body))) | 1584 | (setq body (cddr body))) |
| 1573 | (when-let* ((bare (elisp-scope-sym-bare mode)) (beg (elisp-scope-sym-pos mode)) | 1585 | (when-let* ((bare (elisp-scope--sym-bare mode)) (beg (elisp-scope--sym-pos mode)) |
| 1574 | (typ (if command 'defcmd 'defun))) | 1586 | (typ (if command 'defcmd 'defun))) |
| 1575 | (elisp-scope-report typ beg (length (symbol-name bare))) | 1587 | (elisp-scope--report typ beg (length (symbol-name bare))) |
| 1576 | (unless explicit-var | 1588 | (unless explicit-var |
| 1577 | (elisp-scope-report 'defvar beg (length (symbol-name bare))))) | 1589 | (elisp-scope--report 'defvar beg (length (symbol-name bare))))) |
| 1578 | (elisp-scope-n body))) | 1590 | (elisp-scope-n body))) |
| 1579 | 1591 | ||
| 1580 | (defun elisp-scope-global-minor-mode-predicate (pred) | 1592 | (defun elisp-scope-global-minor-mode-predicate (pred) |
| 1581 | (if (consp pred) | 1593 | (if (consp pred) |
| 1582 | (if (eq 'not (elisp-scope-sym-bare (car pred))) | 1594 | (if (eq 'not (elisp-scope--sym-bare (car pred))) |
| 1583 | (mapc #'elisp-scope-global-minor-mode-predicate (cdr pred)) | 1595 | (mapc #'elisp-scope-global-minor-mode-predicate (cdr pred)) |
| 1584 | (mapc #'elisp-scope-global-minor-mode-predicate pred)) | 1596 | (mapc #'elisp-scope-global-minor-mode-predicate pred)) |
| 1585 | (elisp-scope-major-mode-name pred))) | 1597 | (elisp-scope-major-mode-name pred))) |
| 1586 | 1598 | ||
| 1587 | (defun elisp-scope-major-mode-name (mode) | 1599 | (defun elisp-scope-major-mode-name (mode) |
| 1588 | (when-let* ((beg (elisp-scope-sym-pos mode)) | 1600 | (when-let* ((beg (elisp-scope--sym-pos mode)) |
| 1589 | (bare (bare-symbol mode)) | 1601 | (bare (bare-symbol mode)) |
| 1590 | ((not (booleanp bare))) | 1602 | ((not (booleanp bare))) |
| 1591 | (len (length (symbol-name bare)))) | 1603 | (len (length (symbol-name bare)))) |
| 1592 | (elisp-scope-report 'major-mode beg len))) | 1604 | (elisp-scope--report 'major-mode beg len))) |
| 1593 | 1605 | ||
| 1594 | (defun elisp-scope-mode-line-construct (format) | 1606 | (defun elisp-scope-mode-line-construct (format) |
| 1595 | (elisp-scope-mode-line-construct-1 format)) | 1607 | (elisp-scope-mode-line-construct-1 format)) |
| @@ -1597,16 +1609,16 @@ Optional argument LOCAL is a local context to extend." | |||
| 1597 | (defun elisp-scope-mode-line-construct-1 (format) | 1609 | (defun elisp-scope-mode-line-construct-1 (format) |
| 1598 | (cond | 1610 | (cond |
| 1599 | ((symbol-with-pos-p format) | 1611 | ((symbol-with-pos-p format) |
| 1600 | (elisp-scope-report 'free-variable | 1612 | (elisp-scope--report 'free-variable |
| 1601 | (symbol-with-pos-pos format) | 1613 | (symbol-with-pos-pos format) |
| 1602 | (length (symbol-name (bare-symbol format))))) | 1614 | (length (symbol-name (bare-symbol format))))) |
| 1603 | ((consp format) | 1615 | ((consp format) |
| 1604 | (let ((head (car format))) | 1616 | (let ((head (car format))) |
| 1605 | (cond | 1617 | (cond |
| 1606 | ((or (stringp head) (consp head) (integerp head)) | 1618 | ((or (stringp head) (consp head) (integerp head)) |
| 1607 | (mapc #'elisp-scope-mode-line-construct-1 format)) | 1619 | (mapc #'elisp-scope-mode-line-construct-1 format)) |
| 1608 | ((or (symbolp head) (symbol-with-pos-p head)) | 1620 | ((or (symbolp head) (symbol-with-pos-p head)) |
| 1609 | (elisp-scope-s head) | 1621 | (elisp-scope--symbol head) |
| 1610 | (cl-case (bare-symbol head) | 1622 | (cl-case (bare-symbol head) |
| 1611 | (:eval | 1623 | (:eval |
| 1612 | (elisp-scope-1 (cadr format))) | 1624 | (elisp-scope-1 (cadr format))) |
| @@ -1656,6 +1668,8 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 1656 | (defvar warning-minimum-log-level) | 1668 | (defvar warning-minimum-log-level) |
| 1657 | 1669 | ||
| 1658 | (defmacro elisp-scope-define-analyzer (fsym args &rest body) | 1670 | (defmacro elisp-scope-define-analyzer (fsym args &rest body) |
| 1671 | "Define an analyzer function for function/macro FSYM. | ||
| 1672 | ARGS is the arguments list of the analyzer function, and BODY is its body." | ||
| 1659 | (declare (indent defun)) | 1673 | (declare (indent defun)) |
| 1660 | (let ((analyzer (intern (concat "elisp-scope--analyze-" (symbol-name fsym))))) | 1674 | (let ((analyzer (intern (concat "elisp-scope--analyze-" (symbol-name fsym))))) |
| 1661 | `(progn | 1675 | `(progn |
| @@ -1672,10 +1686,18 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 1672 | (apply #',helper args))))) | 1686 | (apply #',helper args))))) |
| 1673 | 1687 | ||
| 1674 | (defmacro elisp-scope-define-function-analyzer (fsym args &rest body) | 1688 | (defmacro elisp-scope-define-function-analyzer (fsym args &rest body) |
| 1689 | "Define an analyzer function for function FSYM. | ||
| 1690 | The analyzer function analyzes occurrences of FSYM as a function call, | ||
| 1691 | and it analyzes the arguments in calls to FSYM by executing BODY with | ||
| 1692 | ARGS bound to the analyzed arguments." | ||
| 1675 | (declare (indent defun)) | 1693 | (declare (indent defun)) |
| 1676 | `(elisp-scope--define-function-analyzer ,fsym ,args function ,@body)) | 1694 | `(elisp-scope--define-function-analyzer ,fsym ,args function ,@body)) |
| 1677 | 1695 | ||
| 1678 | (defmacro elisp-scope-define-macro-analyzer (fsym args &rest body) | 1696 | (defmacro elisp-scope-define-macro-analyzer (fsym args &rest body) |
| 1697 | "Define an analyzer function for macro FSYM. | ||
| 1698 | The analyzer function analyzes occurrences of FSYM as a macro call, and | ||
| 1699 | it analyzes the arguments in calls to FSYM by executing BODY with ARGS | ||
| 1700 | bound to the analyzed arguments." | ||
| 1679 | (declare (indent defun)) | 1701 | (declare (indent defun)) |
| 1680 | (let ((helper (intern (concat "elisp-scope--analyze-" (symbol-name fsym) "-1")))) | 1702 | (let ((helper (intern (concat "elisp-scope--analyze-" (symbol-name fsym) "-1")))) |
| 1681 | `(progn | 1703 | `(progn |
| @@ -1685,6 +1707,10 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 1685 | (apply #',helper args))))) | 1707 | (apply #',helper args))))) |
| 1686 | 1708 | ||
| 1687 | (defmacro elisp-scope-define-special-form-analyzer (fsym args &rest body) | 1709 | (defmacro elisp-scope-define-special-form-analyzer (fsym args &rest body) |
| 1710 | "Define an analyzer function for special form FSYM. | ||
| 1711 | The analyzer function analyzes occurrences of FSYM as a special form, | ||
| 1712 | and it analyzes the arguments in calls to FSYM by executing BODY with | ||
| 1713 | ARGS bound to the analyzed arguments." | ||
| 1688 | (declare (indent defun)) | 1714 | (declare (indent defun)) |
| 1689 | (let ((helper (intern (concat "elisp-scope--analyze-" (symbol-name fsym) "-1")))) | 1715 | (let ((helper (intern (concat "elisp-scope--analyze-" (symbol-name fsym) "-1")))) |
| 1690 | `(progn | 1716 | `(progn |
| @@ -1694,7 +1720,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 1694 | (apply #',helper args))))) | 1720 | (apply #',helper args))))) |
| 1695 | 1721 | ||
| 1696 | (defun elisp-scope--unquote (form) | 1722 | (defun elisp-scope--unquote (form) |
| 1697 | (when (memq (elisp-scope-sym-bare (car-safe form)) '(quote function \`)) | 1723 | (when (memq (elisp-scope--sym-bare (car-safe form)) '(quote function \`)) |
| 1698 | (cadr form))) | 1724 | (cadr form))) |
| 1699 | 1725 | ||
| 1700 | (elisp-scope-define-analyzer with-suppressed-warnings (f warnings &rest body) | 1726 | (elisp-scope-define-analyzer with-suppressed-warnings (f warnings &rest body) |
| @@ -1736,7 +1762,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 1736 | (cons (symbol . slot) . | 1762 | (cons (symbol . slot) . |
| 1737 | (plist (:type . cl-type)))))) | 1763 | (plist (:type . cl-type)))))) |
| 1738 | (while-let ((kw (car-safe props)) | 1764 | (while-let ((kw (car-safe props)) |
| 1739 | (bkw (elisp-scope-sym-bare kw)) | 1765 | (bkw (elisp-scope--sym-bare kw)) |
| 1740 | ((keywordp bkw))) | 1766 | ((keywordp bkw))) |
| 1741 | (elisp-scope-report-s kw 'constant) | 1767 | (elisp-scope-report-s kw 'constant) |
| 1742 | (elisp-scope-1 (cadr props) (when (eq bkw :predicate) '(symbol . defun))) | 1768 | (elisp-scope-1 (cadr props) (when (eq bkw :predicate) '(symbol . defun))) |
| @@ -1863,7 +1889,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 1863 | (elisp-scope-1 default) | 1889 | (elisp-scope-1 default) |
| 1864 | (elisp-scope-1 doc) | 1890 | (elisp-scope-1 doc) |
| 1865 | (while-let ((kw (car-safe args)) | 1891 | (while-let ((kw (car-safe args)) |
| 1866 | (bkw (elisp-scope-sym-bare kw)) | 1892 | (bkw (elisp-scope--sym-bare kw)) |
| 1867 | ((keywordp bkw))) | 1893 | ((keywordp bkw))) |
| 1868 | (elisp-scope-report-s kw 'constant) | 1894 | (elisp-scope-report-s kw 'constant) |
| 1869 | (elisp-scope-1 (cadr args) | 1895 | (elisp-scope-1 (cadr args) |
| @@ -1878,7 +1904,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 1878 | (elisp-scope-1 members) | 1904 | (elisp-scope-1 members) |
| 1879 | (elisp-scope-1 doc '(symbol . defgroup)) | 1905 | (elisp-scope-1 doc '(symbol . defgroup)) |
| 1880 | (while-let ((kw (car-safe args)) | 1906 | (while-let ((kw (car-safe args)) |
| 1881 | (bkw (elisp-scope-sym-bare kw)) | 1907 | (bkw (elisp-scope--sym-bare kw)) |
| 1882 | ((keywordp bkw))) | 1908 | ((keywordp bkw))) |
| 1883 | (elisp-scope-report-s kw 'constant) | 1909 | (elisp-scope-report-s kw 'constant) |
| 1884 | (elisp-scope-1 (cadr args) (when (eq bkw :group) '(symbol . group))) | 1910 | (elisp-scope-1 (cadr args) (when (eq bkw :group) '(symbol . group))) |
| @@ -1893,7 +1919,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 1893 | (elisp-scope-1 spec)) | 1919 | (elisp-scope-1 spec)) |
| 1894 | (elisp-scope-1 doc) | 1920 | (elisp-scope-1 doc) |
| 1895 | (while-let ((kw (car-safe args)) | 1921 | (while-let ((kw (car-safe args)) |
| 1896 | (bkw (elisp-scope-sym-bare kw)) | 1922 | (bkw (elisp-scope--sym-bare kw)) |
| 1897 | ((keywordp bkw))) | 1923 | ((keywordp bkw))) |
| 1898 | (elisp-scope-report-s kw 'constant) | 1924 | (elisp-scope-report-s kw 'constant) |
| 1899 | (elisp-scope-1 (cadr args) (when (eq bkw :group) '(symbol . group))) | 1925 | (elisp-scope-1 (cadr args) (when (eq bkw :group) '(symbol . group))) |
| @@ -1935,8 +1961,8 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 1935 | (elisp-scope-1 ov) | 1961 | (elisp-scope-1 ov) |
| 1936 | (elisp-scope-1 prop) ;TODO: Recognize overlay props. | 1962 | (elisp-scope-1 prop) ;TODO: Recognize overlay props. |
| 1937 | (if-let* ((q (elisp-scope--unquote prop)) | 1963 | (if-let* ((q (elisp-scope--unquote prop)) |
| 1938 | ((eq (elisp-scope-sym-bare q) 'face)) | 1964 | ((eq (elisp-scope--sym-bare q) 'face)) |
| 1939 | (face (elisp-scope--unquote val))) | 1965 | (face (elisp-scope--unquote val))) |
| 1940 | ;; TODO: Use `elisp-scope-1' with an appropriate outspec. | 1966 | ;; TODO: Use `elisp-scope-1' with an appropriate outspec. |
| 1941 | (elisp-scope-face face) | 1967 | (elisp-scope-face face) |
| 1942 | (elisp-scope-1 val))) | 1968 | (elisp-scope-1 val))) |
| @@ -2001,9 +2027,9 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2001 | (elisp-scope-1 beg) | 2027 | (elisp-scope-1 beg) |
| 2002 | (elisp-scope-1 end) | 2028 | (elisp-scope-1 end) |
| 2003 | (elisp-scope-1 prop) | 2029 | (elisp-scope-1 prop) |
| 2004 | (if-let* (((memq (elisp-scope-sym-bare (elisp-scope--unquote prop)) | 2030 | (if-let* (((memq (elisp-scope--sym-bare (elisp-scope--unquote prop)) |
| 2005 | '(mouse-face face))) | 2031 | '(mouse-face face))) |
| 2006 | (q (elisp-scope--unquote val))) | 2032 | (q (elisp-scope--unquote val))) |
| 2007 | ;; TODO: Use `elisp-scope-1' with an appropriate outspec. | 2033 | ;; TODO: Use `elisp-scope-1' with an appropriate outspec. |
| 2008 | (elisp-scope-face q) | 2034 | (elisp-scope-face q) |
| 2009 | (elisp-scope-1 val)) | 2035 | (elisp-scope-1 val)) |
| @@ -2015,7 +2041,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2015 | (elisp-scope-1 string) | 2041 | (elisp-scope-1 string) |
| 2016 | (while props | 2042 | (while props |
| 2017 | (elisp-scope-1 (car props)) | 2043 | (elisp-scope-1 (car props)) |
| 2018 | (cl-case (elisp-scope-sym-bare (elisp-scope--unquote (car props))) | 2044 | (cl-case (elisp-scope--sym-bare (elisp-scope--unquote (car props))) |
| 2019 | ((face mouse-face) | 2045 | ((face mouse-face) |
| 2020 | (if-let* ((q (elisp-scope--unquote (cadr props)))) | 2046 | (if-let* ((q (elisp-scope--unquote (cadr props)))) |
| 2021 | ;; TODO: Use `elisp-scope-1' with an appropriate outspec. | 2047 | ;; TODO: Use `elisp-scope-1' with an appropriate outspec. |
| @@ -2031,18 +2057,18 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2031 | (elisp-scope-1 superclasses '(repeat . (symbol . type))) | 2057 | (elisp-scope-1 superclasses '(repeat . (symbol . type))) |
| 2032 | (elisp-scope-1 slots | 2058 | (elisp-scope-1 slots |
| 2033 | '(repeat | 2059 | '(repeat |
| 2034 | cons | 2060 | cons |
| 2035 | (symbol . slot) | 2061 | (symbol . slot) |
| 2036 | plist | 2062 | plist |
| 2037 | (:initform . code) | 2063 | (:initform . code) |
| 2038 | (:initarg . (symbol . constant)) | 2064 | (:initarg . (symbol . constant)) |
| 2039 | (:accessor . (symbol . defun)) | 2065 | (:accessor . (symbol . defun)) |
| 2040 | (:allocation . code) | 2066 | (:allocation . code) |
| 2041 | (:writer . (symbol . function)) | 2067 | (:writer . (symbol . function)) |
| 2042 | (:reader . (symbol . function)) | 2068 | (:reader . (symbol . function)) |
| 2043 | (:type . cl-type) | 2069 | (:type . cl-type) |
| 2044 | ;; TODO: add (:custom . custom-type) | 2070 | ;; TODO: add (:custom . custom-type) |
| 2045 | )) | 2071 | )) |
| 2046 | (elisp-scope-1 options)) | 2072 | (elisp-scope-1 options)) |
| 2047 | 2073 | ||
| 2048 | (elisp-scope-define-function-analyzer cl-struct-define | 2074 | (elisp-scope-define-function-analyzer cl-struct-define |
| @@ -2062,7 +2088,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2062 | (elisp-scope-1 class '(symbol . widget-type)) | 2088 | (elisp-scope-1 class '(symbol . widget-type)) |
| 2063 | (elisp-scope-1 doc) | 2089 | (elisp-scope-1 doc) |
| 2064 | (while-let ((kw (car-safe args)) | 2090 | (while-let ((kw (car-safe args)) |
| 2065 | (bkw (elisp-scope-sym-bare kw)) | 2091 | (bkw (elisp-scope--sym-bare kw)) |
| 2066 | ((keywordp bkw))) | 2092 | ((keywordp bkw))) |
| 2067 | (elisp-scope-report-s kw 'constant) | 2093 | (elisp-scope-report-s kw 'constant) |
| 2068 | (elisp-scope-1 (cadr args) | 2094 | (elisp-scope-1 (cadr args) |
| @@ -2138,7 +2164,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2138 | (if-let* ((q (elisp-scope--unquote kws))) | 2164 | (if-let* ((q (elisp-scope--unquote kws))) |
| 2139 | (progn | 2165 | (progn |
| 2140 | (while-let ((kw (car-safe q)) | 2166 | (while-let ((kw (car-safe q)) |
| 2141 | (bkw (elisp-scope-sym-bare kw)) | 2167 | (bkw (elisp-scope--sym-bare kw)) |
| 2142 | ((keywordp bkw))) | 2168 | ((keywordp bkw))) |
| 2143 | (elisp-scope-report-s kw 'constant) | 2169 | (elisp-scope-report-s kw 'constant) |
| 2144 | (elisp-scope-1 (cadr q) (when (eq bkw :group) '(symbol . group))) | 2170 | (elisp-scope-1 (cadr q) (when (eq bkw :group) '(symbol . group))) |
| @@ -2169,7 +2195,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2169 | (defun elisp-scope--easy-menu-do-define-menu (menu) | 2195 | (defun elisp-scope--easy-menu-do-define-menu (menu) |
| 2170 | (let ((items (cdr menu))) | 2196 | (let ((items (cdr menu))) |
| 2171 | (while-let ((kw (car-safe items)) | 2197 | (while-let ((kw (car-safe items)) |
| 2172 | (bkw (elisp-scope-sym-bare kw)) | 2198 | (bkw (elisp-scope--sym-bare kw)) |
| 2173 | ((keywordp bkw))) | 2199 | ((keywordp bkw))) |
| 2174 | (elisp-scope-report-s kw 'constant) | 2200 | (elisp-scope-report-s kw 'constant) |
| 2175 | (cl-case bkw | 2201 | (cl-case bkw |
| @@ -2184,7 +2210,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2184 | (let ((it (cddr (append item nil)))) | 2210 | (let ((it (cddr (append item nil)))) |
| 2185 | (elisp-scope-1 (car it)) | 2211 | (elisp-scope-1 (car it)) |
| 2186 | (while-let ((kw (car-safe it)) | 2212 | (while-let ((kw (car-safe it)) |
| 2187 | (bkw (elisp-scope-sym-bare kw)) | 2213 | (bkw (elisp-scope--sym-bare kw)) |
| 2188 | ((keywordp bkw))) | 2214 | ((keywordp bkw))) |
| 2189 | (elisp-scope-report-s kw 'constant) | 2215 | (elisp-scope-report-s kw 'constant) |
| 2190 | (cl-case bkw | 2216 | (cl-case bkw |
| @@ -2207,11 +2233,11 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2207 | (if-let* ((q (elisp-scope--unquote def))) | 2233 | (if-let* ((q (elisp-scope--unquote def))) |
| 2208 | ;; TODO: Use `elisp-scope-1' with an appropriate outspec. | 2234 | ;; TODO: Use `elisp-scope-1' with an appropriate outspec. |
| 2209 | (cond | 2235 | (cond |
| 2210 | ((eq (elisp-scope-sym-bare (car-safe q)) 'menu-item) | 2236 | ((eq (elisp-scope--sym-bare (car-safe q)) 'menu-item) |
| 2211 | (let ((fn (caddr q)) (it (cdddr q))) | 2237 | (let ((fn (caddr q)) (it (cdddr q))) |
| 2212 | (elisp-scope-sharpquote fn) | 2238 | (elisp-scope-sharpquote fn) |
| 2213 | (while-let ((kw (car-safe it)) | 2239 | (while-let ((kw (car-safe it)) |
| 2214 | (bkw (elisp-scope-sym-bare kw)) | 2240 | (bkw (elisp-scope--sym-bare kw)) |
| 2215 | ((keywordp bkw))) | 2241 | ((keywordp bkw))) |
| 2216 | (elisp-scope-report-s kw 'constant) | 2242 | (elisp-scope-report-s kw 'constant) |
| 2217 | (cl-case bkw | 2243 | (cl-case bkw |
| @@ -2244,13 +2270,13 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2244 | binding)) | 2270 | binding)) |
| 2245 | (form (when (consp binding) | 2271 | (form (when (consp binding) |
| 2246 | (if (cdr binding) (cadr binding) (car binding)))) | 2272 | (if (cdr binding) (cadr binding) (car binding)))) |
| 2247 | (bare (elisp-scope-sym-bare sym)) | 2273 | (bare (elisp-scope--sym-bare sym)) |
| 2248 | (len (length (symbol-name bare))) | 2274 | (len (length (symbol-name bare))) |
| 2249 | (beg (elisp-scope-sym-pos sym))) | 2275 | (beg (elisp-scope--sym-pos sym))) |
| 2250 | (when beg (elisp-scope-binding bare beg len)) | 2276 | (when beg (elisp-scope--binding bare beg len)) |
| 2251 | (when form (elisp-scope-1 form)) | 2277 | (when form (elisp-scope-1 form)) |
| 2252 | (let ((elisp-scope-local-bindings | 2278 | (let ((elisp-scope-local-bindings |
| 2253 | (elisp-scope-local-new bare beg elisp-scope-local-bindings))) | 2279 | (elisp-scope--local-new bare beg elisp-scope-local-bindings))) |
| 2254 | (elisp-scope-if-let (cdr bindings) then else outspec))) | 2280 | (elisp-scope-if-let (cdr bindings) then else outspec))) |
| 2255 | (elisp-scope-1 then outspec) | 2281 | (elisp-scope-1 then outspec) |
| 2256 | (elisp-scope-n else outspec))) | 2282 | (elisp-scope-n else outspec))) |
| @@ -2266,7 +2292,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2266 | (elisp-scope-mode-line-construct name) | 2292 | (elisp-scope-mode-line-construct name) |
| 2267 | (when (stringp (car body)) (pop body)) | 2293 | (when (stringp (car body)) (pop body)) |
| 2268 | (while-let ((kw (car-safe body)) | 2294 | (while-let ((kw (car-safe body)) |
| 2269 | (bkw (elisp-scope-sym-bare kw)) | 2295 | (bkw (elisp-scope--sym-bare kw)) |
| 2270 | ((keywordp bkw))) | 2296 | ((keywordp bkw))) |
| 2271 | (elisp-scope-report-s kw 'constant) | 2297 | (elisp-scope-report-s kw 'constant) |
| 2272 | (cl-case bkw | 2298 | (cl-case bkw |
| @@ -2282,13 +2308,13 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2282 | (if bindings | 2308 | (if bindings |
| 2283 | (let* ((binding (ensure-list (car bindings))) | 2309 | (let* ((binding (ensure-list (car bindings))) |
| 2284 | (sym (car binding)) | 2310 | (sym (car binding)) |
| 2285 | (bare (elisp-scope-sym-bare sym)) | 2311 | (bare (elisp-scope--sym-bare sym)) |
| 2286 | (len (length (symbol-name bare))) | 2312 | (len (length (symbol-name bare))) |
| 2287 | (beg (elisp-scope-sym-pos sym))) | 2313 | (beg (elisp-scope--sym-pos sym))) |
| 2288 | (when beg (elisp-scope-binding bare beg len)) | 2314 | (when beg (elisp-scope--binding bare beg len)) |
| 2289 | (elisp-scope-1 (cadr binding)) | 2315 | (elisp-scope-1 (cadr binding)) |
| 2290 | (elisp-scope-oclosure-lambda-1 | 2316 | (elisp-scope-oclosure-lambda-1 |
| 2291 | (if bare (elisp-scope-local-new bare beg local) local) | 2317 | (if bare (elisp-scope--local-new bare beg local) local) |
| 2292 | (cdr bindings) args body)) | 2318 | (cdr bindings) args body)) |
| 2293 | (let ((elisp-scope-local-bindings local)) | 2319 | (let ((elisp-scope-local-bindings local)) |
| 2294 | (elisp-scope-lambda args body)))) | 2320 | (elisp-scope-lambda args body)))) |
| @@ -2352,22 +2378,22 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2352 | (defun elisp-scope-cl-tagbody (labels statements) | 2378 | (defun elisp-scope-cl-tagbody (labels statements) |
| 2353 | (if labels | 2379 | (if labels |
| 2354 | (let* ((label (car labels)) | 2380 | (let* ((label (car labels)) |
| 2355 | (bare (elisp-scope-sym-bare label))) | 2381 | (bare (elisp-scope--sym-bare label))) |
| 2356 | (when-let* ((beg (elisp-scope-sym-pos label))) | 2382 | (when-let* ((beg (elisp-scope--sym-pos label))) |
| 2357 | (elisp-scope-report 'label beg (length (symbol-name bare)) beg)) | 2383 | (elisp-scope--report 'label beg (length (symbol-name bare)) beg)) |
| 2358 | (let ((elisp-scope-label-alist | 2384 | (let ((elisp-scope-label-alist |
| 2359 | (if bare | 2385 | (if bare |
| 2360 | (elisp-scope-local-new bare (elisp-scope-sym-pos label) elisp-scope-label-alist) | 2386 | (elisp-scope--local-new bare (elisp-scope--sym-pos label) elisp-scope-label-alist) |
| 2361 | elisp-scope-label-alist))) | 2387 | elisp-scope-label-alist))) |
| 2362 | (elisp-scope-cl-tagbody (cdr labels) statements))) | 2388 | (elisp-scope-cl-tagbody (cdr labels) statements))) |
| 2363 | (elisp-scope-n statements))) | 2389 | (elisp-scope-n statements))) |
| 2364 | 2390 | ||
| 2365 | (elisp-scope-define-macro-analyzer go (label) | 2391 | (elisp-scope-define-macro-analyzer go (label) |
| 2366 | ;; TODO: Change to a local macro defintion induced by `cl-tagbody'. | 2392 | ;; TODO: Change to a local macro defintion induced by `cl-tagbody'. |
| 2367 | (when-let* ((bare (elisp-scope-sym-bare label)) | 2393 | (when-let* ((bare (elisp-scope--sym-bare label)) |
| 2368 | (pos (alist-get bare elisp-scope-label-alist)) | 2394 | (pos (alist-get bare elisp-scope-label-alist)) |
| 2369 | (beg (elisp-scope-sym-pos label))) | 2395 | (beg (elisp-scope--sym-pos label))) |
| 2370 | (elisp-scope-report 'label beg (length (symbol-name bare)) pos))) | 2396 | (elisp-scope--report 'label beg (length (symbol-name bare)) pos))) |
| 2371 | 2397 | ||
| 2372 | (elisp-scope-define-macro-analyzer rx-define (name &rest rest) | 2398 | (elisp-scope-define-macro-analyzer rx-define (name &rest rest) |
| 2373 | (elisp-scope-rx-define name rest)) | 2399 | (elisp-scope-rx-define name rest)) |
| @@ -2395,8 +2421,8 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2395 | ;; Unsafe macro! | 2421 | ;; Unsafe macro! |
| 2396 | (let* ((bare (bare-symbol backend)) | 2422 | (let* ((bare (bare-symbol backend)) |
| 2397 | (len (length (symbol-name bare))) | 2423 | (len (length (symbol-name bare))) |
| 2398 | (beg (elisp-scope-sym-pos backend))) | 2424 | (beg (elisp-scope--sym-pos backend))) |
| 2399 | (when beg (elisp-scope-report 'nnoo-backend beg len)))) | 2425 | (when beg (elisp-scope--report 'nnoo-backend beg len)))) |
| 2400 | 2426 | ||
| 2401 | (elisp-scope-define-macro-analyzer gv-define-expander (name handler) | 2427 | (elisp-scope-define-macro-analyzer gv-define-expander (name handler) |
| 2402 | (elisp-scope-gv-define-expander name handler)) | 2428 | (elisp-scope-gv-define-expander name handler)) |
| @@ -2433,7 +2459,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2433 | (elisp-scope-report-s name 'symbol-role-definition) | 2459 | (elisp-scope-report-s name 'symbol-role-definition) |
| 2434 | (dolist (parent parents) (elisp-scope-report-s parent 'symbol-role)) | 2460 | (dolist (parent parents) (elisp-scope-report-s parent 'symbol-role)) |
| 2435 | (while-let ((kw (car-safe props)) | 2461 | (while-let ((kw (car-safe props)) |
| 2436 | (bkw (elisp-scope-sym-bare kw)) | 2462 | (bkw (elisp-scope--sym-bare kw)) |
| 2437 | ((keywordp bkw))) | 2463 | ((keywordp bkw))) |
| 2438 | (elisp-scope-report-s kw 'constant) | 2464 | (elisp-scope-report-s kw 'constant) |
| 2439 | (cl-case bkw | 2465 | (cl-case bkw |
| @@ -2450,9 +2476,9 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2450 | (if (or (symbol-with-pos-p place) (symbolp place)) | 2476 | (if (or (symbol-with-pos-p place) (symbolp place)) |
| 2451 | (let* ((bare (bare-symbol place)) | 2477 | (let* ((bare (bare-symbol place)) |
| 2452 | (len (length (symbol-name bare))) | 2478 | (len (length (symbol-name bare))) |
| 2453 | (beg (elisp-scope-sym-pos place))) | 2479 | (beg (elisp-scope--sym-pos place))) |
| 2454 | (when beg (elisp-scope-binding bare beg len)) | 2480 | (when beg (elisp-scope--binding bare beg len)) |
| 2455 | (setq l (elisp-scope-local-new bare beg l))) | 2481 | (setq l (elisp-scope--local-new bare beg l))) |
| 2456 | (elisp-scope-1 place)) | 2482 | (elisp-scope-1 place)) |
| 2457 | (elisp-scope-1 (cadr binding)))) | 2483 | (elisp-scope-1 (cadr binding)))) |
| 2458 | (let ((elisp-scope-local-bindings l)) (elisp-scope-n body elisp-scope-output-spec)))) | 2484 | (let ((elisp-scope-local-bindings l)) (elisp-scope-n body elisp-scope-output-spec)))) |
| @@ -2501,21 +2527,21 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2501 | (elisp-scope-1 sequence) | 2527 | (elisp-scope-1 sequence) |
| 2502 | (let ((l elisp-scope-local-bindings)) | 2528 | (let ((l elisp-scope-local-bindings)) |
| 2503 | (dolist (arg args) | 2529 | (dolist (arg args) |
| 2504 | (let* ((bare (elisp-scope-sym-bare arg)) | 2530 | (let* ((bare (elisp-scope--sym-bare arg)) |
| 2505 | (len (length (symbol-name bare))) | 2531 | (len (length (symbol-name bare))) |
| 2506 | (beg (elisp-scope-sym-pos arg))) | 2532 | (beg (elisp-scope--sym-pos arg))) |
| 2507 | (if (eq bare '&rest) | 2533 | (if (eq bare '&rest) |
| 2508 | (elisp-scope-report 'ampersand beg len) | 2534 | (elisp-scope--report 'ampersand beg len) |
| 2509 | (when beg (elisp-scope-binding bare beg len)) | 2535 | (when beg (elisp-scope--binding bare beg len)) |
| 2510 | (setq l (elisp-scope-local-new bare beg l))))) | 2536 | (setq l (elisp-scope--local-new bare beg l))))) |
| 2511 | (let ((elisp-scope-local-bindings l)) (elisp-scope-n body)))) | 2537 | (let ((elisp-scope-local-bindings l)) (elisp-scope-n body)))) |
| 2512 | 2538 | ||
| 2513 | (elisp-scope-define-analyzer let-alist (f alist &rest body) | 2539 | (elisp-scope-define-analyzer let-alist (f alist &rest body) |
| 2514 | (elisp-scope-report-s f 'macro) | 2540 | (elisp-scope-report-s f 'macro) |
| 2515 | (elisp-scope-1 alist) | 2541 | (elisp-scope-1 alist) |
| 2516 | (let ((elisp-scope-current-let-alist-form | 2542 | (let ((elisp-scope--current-let-alist-form |
| 2517 | (cons (or (elisp-scope-sym-pos f) (cons 'gen (incf elisp-scope-counter))) | 2543 | (cons (or (elisp-scope--sym-pos f) (cons 'gen (incf elisp-scope--counter))) |
| 2518 | (elisp-scope-sym-pos f)))) | 2544 | (elisp-scope--sym-pos f)))) |
| 2519 | (elisp-scope-n body))) | 2545 | (elisp-scope-n body))) |
| 2520 | 2546 | ||
| 2521 | (elisp-scope-define-macro-analyzer define-obsolete-face-alias (&optional obs cur when) | 2547 | (elisp-scope-define-macro-analyzer define-obsolete-face-alias (&optional obs cur when) |
| @@ -2573,18 +2599,18 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2573 | (elisp-scope-define-special-form-analyzer condition-case (var bodyform &rest handlers) | 2599 | (elisp-scope-define-special-form-analyzer condition-case (var bodyform &rest handlers) |
| 2574 | (let* ((bare (bare-symbol var)) | 2600 | (let* ((bare (bare-symbol var)) |
| 2575 | (beg (when (symbol-with-pos-p var) (symbol-with-pos-pos var))) | 2601 | (beg (when (symbol-with-pos-p var) (symbol-with-pos-pos var))) |
| 2576 | (l (elisp-scope-local-new bare beg elisp-scope-local-bindings))) | 2602 | (l (elisp-scope--local-new bare beg elisp-scope-local-bindings))) |
| 2577 | (when beg (elisp-scope-binding bare beg (length (symbol-name bare)))) | 2603 | (when beg (elisp-scope--binding bare beg (length (symbol-name bare)))) |
| 2578 | (elisp-scope-1 bodyform elisp-scope-output-spec) | 2604 | (elisp-scope-1 bodyform elisp-scope-output-spec) |
| 2579 | (dolist (handler handlers) | 2605 | (dolist (handler handlers) |
| 2580 | (dolist (cond-name (ensure-list (car-safe handler))) | 2606 | (dolist (cond-name (ensure-list (car-safe handler))) |
| 2581 | (when-let* ((cbeg (elisp-scope-sym-pos cond-name)) | 2607 | (when-let* ((cbeg (elisp-scope--sym-pos cond-name)) |
| 2582 | (cbare (elisp-scope-sym-bare cond-name)) | 2608 | (cbare (elisp-scope--sym-bare cond-name)) |
| 2583 | (clen (length (symbol-name cbare)))) | 2609 | (clen (length (symbol-name cbare)))) |
| 2584 | (cond | 2610 | (cond |
| 2585 | ((booleanp cbare)) | 2611 | ((booleanp cbare)) |
| 2586 | ((keywordp cbare) (elisp-scope-report 'constant cbeg clen)) | 2612 | ((keywordp cbare) (elisp-scope--report 'constant cbeg clen)) |
| 2587 | (t (elisp-scope-report 'condition cbeg clen))))) | 2613 | (t (elisp-scope--report 'condition cbeg clen))))) |
| 2588 | (let ((elisp-scope-local-bindings l)) | 2614 | (let ((elisp-scope-local-bindings l)) |
| 2589 | (elisp-scope-n (cdr handler) elisp-scope-output-spec))))) | 2615 | (elisp-scope-n (cdr handler) elisp-scope-output-spec))))) |
| 2590 | 2616 | ||
| @@ -2622,7 +2648,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2622 | 2648 | ||
| 2623 | (cl-defmethod elisp-scope--handle-quoted ((_spec (eql 'code)) arg) | 2649 | (cl-defmethod elisp-scope--handle-quoted ((_spec (eql 'code)) arg) |
| 2624 | (let ((elisp-scope-local-bindings nil) | 2650 | (let ((elisp-scope-local-bindings nil) |
| 2625 | (elisp-scope-current-let-alist-form nil) | 2651 | (elisp-scope--current-let-alist-form nil) |
| 2626 | (elisp-scope-local-definitions nil) | 2652 | (elisp-scope-local-definitions nil) |
| 2627 | (elisp-scope-block-alist nil) | 2653 | (elisp-scope-block-alist nil) |
| 2628 | (elisp-scope-label-alist nil) | 2654 | (elisp-scope-label-alist nil) |
| @@ -2740,7 +2766,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2740 | (let ((res nil) (go t)) | 2766 | (let ((res nil) (go t)) |
| 2741 | (while (and arg go) | 2767 | (while (and arg go) |
| 2742 | (let* ((key (car arg)) | 2768 | (let* ((key (car arg)) |
| 2743 | (bkw (elisp-scope-sym-bare key)) | 2769 | (bkw (elisp-scope--sym-bare key)) |
| 2744 | (val (cadr arg))) | 2770 | (val (cadr arg))) |
| 2745 | (push (if (keywordp bkw) '(symbol . constant) t) res) | 2771 | (push (if (keywordp bkw) '(symbol . constant) t) res) |
| 2746 | (push (setq go (elisp-scope--match-spec-to-arg (alist-get bkw (cdr spec) t) val)) res)) | 2772 | (push (setq go (elisp-scope--match-spec-to-arg (alist-get bkw (cdr spec) t) val)) res)) |
| @@ -2764,7 +2790,7 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2764 | (res nil) | 2790 | (res nil) |
| 2765 | (go t) | 2791 | (go t) |
| 2766 | bkw) | 2792 | bkw) |
| 2767 | (while (and go (keywordp (setq bkw (elisp-scope-sym-bare (car arg))))) | 2793 | (while (and go (keywordp (setq bkw (elisp-scope--sym-bare (car arg))))) |
| 2768 | (push '(symbol . constant) res) | 2794 | (push '(symbol . constant) res) |
| 2769 | (setq go (elisp-scope--match-spec-to-arg (alist-get bkw val-spec-alist t) (cadr arg))) | 2795 | (setq go (elisp-scope--match-spec-to-arg (alist-get bkw val-spec-alist t) (cadr arg))) |
| 2770 | (push go res) | 2796 | (push go res) |
| @@ -2802,8 +2828,8 @@ property, or if the current buffer is trusted (see `trusted-content-p')." | |||
| 2802 | "Report that symbol SYM has role ROLE. | 2828 | "Report that symbol SYM has role ROLE. |
| 2803 | 2829 | ||
| 2804 | If SYM is not a symbol with position information, do nothing." | 2830 | If SYM is not a symbol with position information, do nothing." |
| 2805 | (when-let* ((beg (elisp-scope-sym-pos sym)) (bare (bare-symbol sym))) | 2831 | (when-let* ((beg (elisp-scope--sym-pos sym)) (bare (bare-symbol sym))) |
| 2806 | (elisp-scope-report role beg (length (symbol-name bare))))) | 2832 | (elisp-scope--report role beg (length (symbol-name bare))))) |
| 2807 | 2833 | ||
| 2808 | (defvar-local elisp-scope-buffer-file-name nil) | 2834 | (defvar-local elisp-scope-buffer-file-name nil) |
| 2809 | 2835 | ||
| @@ -2858,7 +2884,7 @@ See also `elisp-scope-analyze-form' for an details about how subforms | |||
| 2858 | are analyzed." | 2884 | are analyzed." |
| 2859 | (cond | 2885 | (cond |
| 2860 | ((consp form) | 2886 | ((consp form) |
| 2861 | (let* ((f (car form)) (bare (elisp-scope-sym-bare f)) | 2887 | (let* ((f (car form)) (bare (elisp-scope--sym-bare f)) |
| 2862 | (forms (cdr form)) (this nil)) | 2888 | (forms (cdr form)) (this nil)) |
| 2863 | (when bare | 2889 | (when bare |
| 2864 | (cond | 2890 | (cond |
| @@ -2883,7 +2909,7 @@ are analyzed." | |||
| 2883 | (t | 2909 | (t |
| 2884 | (elisp-scope-report-s f 'unknown) | 2910 | (elisp-scope-report-s f 'unknown) |
| 2885 | (when elisp-scope-assume-func (elisp-scope-n forms))))))) | 2911 | (when elisp-scope-assume-func (elisp-scope-n forms))))))) |
| 2886 | ((symbol-with-pos-p form) (elisp-scope-s form)))) | 2912 | ((symbol-with-pos-p form) (elisp-scope--symbol form)))) |
| 2887 | 2913 | ||
| 2888 | (defun elisp-scope-n (forms &optional outspec) | 2914 | (defun elisp-scope-n (forms &optional outspec) |
| 2889 | "Analyze FORMS as evaluated forms. | 2915 | "Analyze FORMS as evaluated forms. |
| @@ -2937,8 +2963,8 @@ for the `identity' function: | |||
| 2937 | (lambda (fsym arg) | 2963 | (lambda (fsym arg) |
| 2938 | (elisp-scope-report-s fsym \\='function) | 2964 | (elisp-scope-report-s fsym \\='function) |
| 2939 | (elisp-scope-1 arg elisp-scope-output-spec))" | 2965 | (elisp-scope-1 arg elisp-scope-output-spec))" |
| 2940 | (let ((elisp-scope-counter 0) | 2966 | (let ((elisp-scope--counter 0) |
| 2941 | (elisp-scope-callback callback) | 2967 | (elisp-scope--callback callback) |
| 2942 | (read-symbol-shorthands nil) | 2968 | (read-symbol-shorthands nil) |
| 2943 | (max-lisp-eval-depth 32768)) | 2969 | (max-lisp-eval-depth 32768)) |
| 2944 | (elisp-scope-1 (read-positioning-symbols (or stream (current-buffer)))))) | 2970 | (elisp-scope-1 (read-positioning-symbols (or stream (current-buffer)))))) |