(scope-define-symbol-type variable ()
:doc "Variable names."
:face 'elisp-free-variable
- :help (lambda (beg end def)
- (cond ((equal beg def) "Local variable definition")
- (def "Local variable")
- (t (elisp--help-echo beg end 'variable-documentation "Special 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"))
:completion (lambda ()
(let ((local-vars (elisp-local-variables)))
(lambda (sym) (or (elisp--shorthand-aware-boundp sym)
:doc "`condition-case' conditions."
:face 'elisp-condition
:help (lambda (beg end _def)
- (lambda (&rest _)
- (let ((msg (get (intern (buffer-substring beg end)) 'error-message)))
- (apply #'concat
- "`condition-case' condition"
- (when (and msg (not (string-empty-p msg)))
- `(": " ,msg))))))
+ (if-let ((sym (intern (buffer-substring-no-properties beg end))))
+ (lambda (&rest _)
+ (let ((msg (get sym 'error-message)))
+ (apply #'concat
+ "`condition-case' condition"
+ (when (and msg (not (string-empty-p msg)))
+ `(": " ,msg)))))
+ "`condition-case' condition"))
:completion (constantly (lambda (sym) (get sym 'error-conditions)))
:namespace 'condition)