From 97a6b6138946e00f9ba2f089fe1564b896c3e24b Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Wed, 12 Feb 2025 09:42:16 +0100 Subject: [PATCH] scope.el, elisp-mode.el: Support thing-at-point "things" --- lisp/emacs-lisp/scope.el | 15 +++++++++++++++ lisp/progmodes/elisp-mode.el | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/lisp/emacs-lisp/scope.el b/lisp/emacs-lisp/scope.el index cdb374d990b..fc8a71e8bfe 100644 --- a/lisp/emacs-lisp/scope.el +++ b/lisp/emacs-lisp/scope.el @@ -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)) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 997c0cd9db6..56002e475ef 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -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) -- 2.39.5