unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#55096: Eldoc showing elisp variable value beside docs
@ 2022-04-24 18:24 emacsq via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-04-25  8:09 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: emacsq via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-04-24 18:24 UTC (permalink / raw)
  To: 55096

[-- Attachment #1: Type: text/plain, Size: 676 bytes --]

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.

So for variables the value too can be shown after the docs. In case of primitive values it's quite simple, if there is a local value then it can show the local value first and then the global one.

In case of complex values the full value may be too big to display, but the beginning of it can still be shown, truncated after, say, 30 chars. It is still useful if, for example, a variable can be nil and also a list. Then you can see at a glance if it has a value set.

[-- Attachment #2: Type: text/html, Size: 1107 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#55096: Eldoc showing elisp variable value beside docs
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-04-25  8:09 UTC (permalink / raw)
  To: emacsq; +Cc: 55096

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?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#55096: Eldoc showing elisp variable value beside docs
  2022-04-25  8:09 ` Lars Ingebrigtsen
@ 2022-04-25 11:00   ` Štěpán Němec
  2022-05-24 12:50     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Štěpán Němec @ 2022-04-25 11:00 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55096, emacsq

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#55096: Eldoc showing elisp variable value beside docs
  2022-04-25 11:00   ` Štěpán Němec
@ 2022-05-24 12:50     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-24 12:50 UTC (permalink / raw)
  To: Štěpán Němec; +Cc: 55096, emacsq

Štěpán Němec <stepnem@gmail.com> writes:

>> 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:

Well, that means that there are at least two people who would like this,
so I've added Štěpán's function to Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-24 12:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-05-24 12:50     ` Lars Ingebrigtsen

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).