]> git.eshelyaron.com Git - emacs.git/commitdiff
scope.el: Fix tooltip help for local variables
authorEshel Yaron <me@eshelyaron.com>
Wed, 11 Jun 2025 18:57:03 +0000 (20:57 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 11 Jun 2025 18:57:03 +0000 (20:57 +0200)
lisp/emacs-lisp/scope.el

index 78aee4faed09bb000c51d21a200938052fe032a8..fb9f25575975d973aaf28eb5dd6a8c286f6540ab 100644 (file)
 (scope-define-symbol-type variable ()
   :doc "Variable names."
   :face 'elisp-free-variable
-  :help (lambda (beg end _def)
-          (if-let ((sym (intern (buffer-substring-no-properties beg end))))
-              (lambda (&rest _)
-                (let ((val (if (boundp sym) (truncate-string-to-width (prin1-to-string (symbol-value sym)) 60 nil nil t) "#<unbound>")))
-                  (if-let ((doc (documentation-property sym 'variable-documentation t)))
-                      (format "Special variable `%S'.\n\nValue: %s\n\n%s" sym val doc)
-                    (format "Special variable `%S'.\n\nValue: %s" sym val))))
-            "Special variable"))
+  :help (lambda (beg end def)
+          (cond
+           ((equal beg def) "Local variable definition")
+           (def             "Local variable")
+           (t
+            (if-let ((sym (intern (buffer-substring-no-properties beg end))))
+                (lambda (&rest _)
+                  (let ((val (if (boundp sym) (truncate-string-to-width (prin1-to-string (symbol-value sym)) 60 nil nil t) "#<unbound>")))
+                    (if-let ((doc (documentation-property sym 'variable-documentation t)))
+                        (format "Special variable `%S'.\n\nValue: %s\n\n%s" sym val doc)
+                      (format "Special variable `%S'.\n\nValue: %s" sym val))))
+              "Special variable"))))
   :completion (lambda ()
                 (let ((local-vars (elisp-local-variables)))
                   (lambda (sym) (or (elisp--shorthand-aware-boundp sym)