]> git.eshelyaron.com Git - emacs.git/commitdiff
scope.el: Handle oclosure--define
authorEshel Yaron <me@eshelyaron.com>
Mon, 9 Jun 2025 06:22:56 +0000 (08:22 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 9 Jun 2025 06:22:56 +0000 (08:22 +0200)
lisp/emacs-lisp/scope.el

index f56b75669b0bb3dbad80339370abe1411cb66606..bfd83935f349274f9e215cb2952d4fca8ba7ae4d 100644 (file)
   :imenu "Icon"
   :namespace 'icon)
 
+(scope-define-symbol-type oclosure ()
+  :doc "oclosure type names."
+  :face 'font-lock-type-face
+  :help (lambda (beg end _def)
+          (if-let ((sym (intern (buffer-substring-no-properties beg end))))
+              (lambda (&rest _)
+                (if-let ((doc (oclosure--class-docstring (get sym 'cl--class))))
+                    (format "OClosure type `%S'.\n\n%s" sym doc)
+                  "OClosure type"))
+            "OClosure type"))
+  :completion (constantly (lambda (sym)
+                            (oclosure--class-p (get sym 'cl--class))))
+  :namespace 'oclosure)
+
+(scope-define-symbol-type defoclosure ()
+  :doc "oclosure type definitions."
+  :face 'font-lock-type-face
+  :help (constantly "OClosure type definition")
+  :imenu "OClosure type"
+  :namespace 'oclosure)
+
 (defvar scope-counter nil)
 
 (defvar scope-local-functions nil)
@@ -1500,6 +1521,20 @@ a (possibly empty) list of safe macros.")
 (scope-define-function-analyzer defalias (sym _def &optional _docstring)
   (when-let ((quoted (scope--unqoute sym))) (scope-report-s quoted 'defun)))
 
+(scope-define-function-analyzer oclosure--define
+  (&optional name _docstring parent-names _slots &rest props)
+  (when-let ((quoted (scope--unqoute name))) (scope-report-s quoted 'defoclosure))
+  (dolist (parent parent-names)
+    (when-let ((quoted (scope--unqoute parent))) (scope-report-s quoted 'oclosure)))
+  (while-let ((kw (car-safe props))
+              (bkw (scope-sym-bare kw))
+              ((keywordp bkw)))
+    (scope-report-s kw 'constant)
+    (case bkw
+      (:predicate
+       (when-let ((q (scope--unqoute (cadr props)))) (scope-report-s q 'defun))))
+    (setq props (cddr props))))
+
 (scope-define-function-analyzer thing-at-point (thing &optional _)
   (when-let ((quoted (scope--unqoute thing))) (scope-report-s quoted 'thing)))