[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#55096: Eldoc showing elisp variable value beside docs
From: |
Štěpán Němec |
Subject: |
bug#55096: Eldoc showing elisp variable value beside docs |
Date: |
Mon, 25 Apr 2022 13:00:33 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
On Mon, 25 Apr 2022 10:09:39 +0200
Lars Ingebrigtsen wrote:
> emacsq <laszlomail@protonmail.com> writes:
>
>> Eldoc showing the docs in the minibuffer is quite useful, but I often
>> check elisp variable values too in the code, and it can be quite handy
>> if eldoc shows that too simply by putting cursor on the variable.
>
> This would only work for global values, and in that case, you can just
> `C-x C-e' the variable if you're interested in the value.
>
> So it seems like this would be of marginal utility. Anybody else got an
> opinion here?
FWIW, I've been running with some form of the following for many years,
and I find it extremely useful:
;; cf. `elisp-eldoc-var-docstring'
(defun my-elisp-eldoc-var-docstring-with-value (callback &rest _)
"Document variable at point.
Intended for `eldoc-documentation-functions' (which see)."
(when-let ((cs (elisp--current-symbol)))
(when (and (boundp cs)
;; nil and t are boundp!
(not (null cs))
(not (eq cs t)))
(funcall callback
(format "%.1250S %s"
(symbol-value cs)
(let* ((doc (custom-variable-documentation cs))
(more (- (length doc) 1000)))
(concat (propertize
(s-truncate 1000
(if (string= doc "nil")
"Undocumented."
doc)
"")
'face 'font-lock-doc-face)
(when (> more 0)
(format "[%sc more]" more)))))
:thing cs
:face 'font-lock-variable-name-face))))
It shows the current value, i.e. buffer-local for local variables, which
is what I want. (It also shows more of the doc string: I use multi-line
echo area.)
--
Štěpán