From: "Štěpán Němec" <stepnem@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 55096@debbugs.gnu.org, emacsq <laszlomail@protonmail.com>
Subject: bug#55096: Eldoc showing elisp variable value beside docs
Date: Mon, 25 Apr 2022 13:00:33 +0200 [thread overview]
Message-ID: <20220425130033+0200.658972-stepnem@gmail.com> (raw)
In-Reply-To: <87levt60u4.fsf@gnus.org> (Lars Ingebrigtsen's message of "Mon, 25 Apr 2022 10:09:39 +0200")
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
next prev parent reply other threads:[~2022-04-25 11:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-24 18:24 bug#55096: Eldoc showing elisp variable value beside docs emacsq via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-04-25 8:09 ` Lars Ingebrigtsen
2022-04-25 11:00 ` Štěpán Němec [this message]
2022-05-24 12:50 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220425130033+0200.658972-stepnem@gmail.com \
--to=stepnem@gmail.com \
--cc=55096@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=laszlomail@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).