]> git.eshelyaron.com Git - emacs.git/commitdiff
scope.el, elisp-mode.el: Support thing-at-point "things"
authorEshel Yaron <me@eshelyaron.com>
Wed, 12 Feb 2025 08:42:16 +0000 (09:42 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 12 Feb 2025 08:42:16 +0000 (09:42 +0100)
lisp/emacs-lisp/scope.el
lisp/progmodes/elisp-mode.el

index cdb374d990b8b663d0f7002b4aa98f5f7cfc959a..fc8a71e8bfeb160022fecf497195e45631681197 100644 (file)
@@ -1161,6 +1161,21 @@ 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 thing-at-point (thing &optional _)
+  (when-let ((quoted (scope--unqoute thing))) (scope-report-s quoted 'thing)))
+
+(dolist (sym '( forward-thing
+                beginning-of-thing
+                end-of-thing
+                bounds-of-thing-at-point))
+  (put sym 'scope-analyzer #'scope--analyze-thing-at-point))
+
+(scope-define-function-analyzer bounds-of-thing-at-mouse (_event thing)
+  (when-let ((quoted (scope--unqoute thing))) (scope-report-s quoted 'thing)))
+
+(scope-define-function-analyzer thing-at-mouse (_event thing &optional _)
+  (when-let ((quoted (scope--unqoute thing))) (scope-report-s quoted 'thing)))
+
 (scope-define-function-analyzer custom-declare-variable (sym _default _doc &rest args)
   (when-let ((quoted (scope--unqoute sym))) (scope-report-s quoted 'defvar))
   (while-let ((kw (car-safe args))
index 997c0cd9db637f8f96824168065e3c081d4cca7a..56002e475effbbd780f4c35abe7f01a7a45637f3 100644 (file)
@@ -455,6 +455,7 @@ happens in interactive invocations."
      (declaration   "Declaration")
      (rx-construct  "`rx' construct")
      (theme         "Theme")
+     (thing         "Thing (text object)")
      (slot          "Slot")
      (widget-type   "Widget type")
      (type          "Type")
@@ -488,6 +489,7 @@ happens in interactive invocations."
                   (declaration   'font-lock-variable-use-face)
                   (rx-construct  'elisp-rx)
                   (theme         'elisp-theme)
+                  (thing         'font-lock-type-face)
                   (slot          'font-lock-builtin-face)
                   (widget-type   'font-lock-type-face)
                   (type          'font-lock-type-face)
@@ -947,6 +949,14 @@ in `completion-at-point-functions' (which see)."
                             ((group) (lambda (sym) (get sym 'group-documentation)))
                             ((face) #'facep)
                             ((theme) #'custom-theme-p)
+                            ((thing) (lambda (sym)
+                                       (or
+                                        (assq sym (bound-and-true-p thing-at-point-provider-alist))
+                                        (assq sym (bound-and-true-p bounds-of-thing-at-point-provider-alist))
+                                        (get sym 'thing-at-point)
+                                        (get sym 'bounds-of-thing-at-point)
+                                        (get sym 'beginning-op)
+                                        (get sym 'end-op))))
                             ((nil) (lambda (sym)
                                      (let ((sym (intern-soft (symbol-name sym))))
                                        (or (boundp sym)