* bug#50989: 28.0.60; nobreak-char-display in Eldoc buffers
@ 2021-10-03 10:02 Augusto Stoffel
2021-10-03 10:34 ` João Távora
0 siblings, 1 reply; 8+ messages in thread
From: Augusto Stoffel @ 2021-10-03 10:02 UTC (permalink / raw)
To: 50989; +Cc: João Távora
Using the pylsp language server via Eglot, I sometimes get docstrings
with lots of non-breaking spaces in them. Those end up being
highlighted with the `nobreak-space' face in the Eldoc buffer, which is
very distracting.
I'm not sure this should be addressed in Eglot or in Eldoc. But the
following advice fixes things for me.
(advice-add 'eldoc--format-doc-buffer :after
(lambda (&rest _) "Don't display non-breaking spaces."
(with-current-buffer eldoc--doc-buffer
(setq-local nobreak-char-display nil))))
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#50989: 28.0.60; nobreak-char-display in Eldoc buffers
2021-10-03 10:02 bug#50989: 28.0.60; nobreak-char-display in Eldoc buffers Augusto Stoffel
@ 2021-10-03 10:34 ` João Távora
2021-10-03 11:07 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: João Távora @ 2021-10-03 10:34 UTC (permalink / raw)
To: Augusto Stoffel; +Cc: 50989
On Sun, Oct 3, 2021 at 11:03 AM Augusto Stoffel <arstoffel@gmail.com> wrote:
>
> Using the pylsp language server via Eglot, I sometimes get docstrings
> with lots of non-breaking spaces in them. Those end up being
> highlighted with the `nobreak-space' face in the Eldoc buffer, which is
> very distracting.
>
> I'm not sure this should be addressed in Eglot or in Eldoc. But the
> following advice fixes things for me.
>
> (advice-add 'eldoc--format-doc-buffer :after
> (lambda (&rest _) "Don't display non-breaking spaces."
> (with-current-buffer eldoc--doc-buffer
> (setq-local nobreak-char-display nil))))
I'd say put this in ElDoc directly. If someone then objects, we could make a
eldoc-no-break-char-display variable. Can you make a patch?
João
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#50989: 28.0.60; nobreak-char-display in Eldoc buffers
2021-10-03 10:34 ` João Távora
@ 2021-10-03 11:07 ` Eli Zaretskii
2021-10-03 11:12 ` João Távora
2021-10-05 21:16 ` Richard Stallman
0 siblings, 2 replies; 8+ messages in thread
From: Eli Zaretskii @ 2021-10-03 11:07 UTC (permalink / raw)
To: João Távora; +Cc: 50989, arstoffel
> From: João Távora <joaotavora@gmail.com>
> Date: Sun, 3 Oct 2021 11:34:32 +0100
> Cc: 50989@debbugs.gnu.org
>
> On Sun, Oct 3, 2021 at 11:03 AM Augusto Stoffel <arstoffel@gmail.com> wrote:
> >
> > Using the pylsp language server via Eglot, I sometimes get docstrings
> > with lots of non-breaking spaces in them. Those end up being
> > highlighted with the `nobreak-space' face in the Eldoc buffer, which is
> > very distracting.
> >
> > I'm not sure this should be addressed in Eglot or in Eldoc. But the
> > following advice fixes things for me.
> >
> > (advice-add 'eldoc--format-doc-buffer :after
> > (lambda (&rest _) "Don't display non-breaking spaces."
> > (with-current-buffer eldoc--doc-buffer
> > (setq-local nobreak-char-display nil))))
>
> I'd say put this in ElDoc directly. If someone then objects, we could make a
> eldoc-no-break-char-display variable. Can you make a patch?
IMNSHO, this doesn't make much sense. That face exists for a reason:
to signal to the users that some innocently-looking characters aren't
what they look like. What you suggest above is to sweep the problem
under the carpet. I think this is not TRT.
Why does the server return these NBSP characters? Would it make sense
to automatically convert them to spaces on input?
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#50989: 28.0.60; nobreak-char-display in Eldoc buffers
2021-10-03 11:07 ` Eli Zaretskii
@ 2021-10-03 11:12 ` João Távora
2021-10-03 11:25 ` Eli Zaretskii
2021-10-03 11:39 ` Augusto Stoffel
2021-10-05 21:16 ` Richard Stallman
1 sibling, 2 replies; 8+ messages in thread
From: João Távora @ 2021-10-03 11:12 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 50989, Augusto Stoffel
On Sun, Oct 3, 2021 at 12:07 PM Eli Zaretskii <eliz@gnu.org> wrote:
> IMNSHO, this doesn't make much sense. That face exists for a reason:
> to signal to the users that some innocently-looking characters aren't
> what they look like.
Eldoc's display facilities are only for displaying. Sure, you may want
to copy text away from there, but I'd say that's rare. So it wouldn't
be a problem
in practice, unless I'm missing something
> Why does the server return these NBSP characters? Would it make sense
> to automatically convert them to spaces on input?
That's also sweeping it under the rug. But I don't object either. Augusto, if
you agree, match a patch to Eglot (this is where I presume the "input"
Eli refers
to lives). Of course the real input is the server, but I'd rather not
go there, since
there are so many and all are out of our control.
João
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#50989: 28.0.60; nobreak-char-display in Eldoc buffers
2021-10-03 11:12 ` João Távora
@ 2021-10-03 11:25 ` Eli Zaretskii
2021-10-03 11:39 ` Augusto Stoffel
1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2021-10-03 11:25 UTC (permalink / raw)
To: João Távora; +Cc: 50989, arstoffel
> From: João Távora <joaotavora@gmail.com>
> Date: Sun, 3 Oct 2021 12:12:23 +0100
> Cc: Augusto Stoffel <arstoffel@gmail.com>, 50989@debbugs.gnu.org
>
> > Why does the server return these NBSP characters? Would it make sense
> > to automatically convert them to spaces on input?
>
> That's also sweeping it under the rug.
Well, we have no control on what the server does, so we cannot do
better. But I do wonder why they do it at all.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#50989: 28.0.60; nobreak-char-display in Eldoc buffers
2021-10-03 11:12 ` João Távora
2021-10-03 11:25 ` Eli Zaretskii
@ 2021-10-03 11:39 ` Augusto Stoffel
2021-10-05 9:13 ` Lars Ingebrigtsen
1 sibling, 1 reply; 8+ messages in thread
From: Augusto Stoffel @ 2021-10-03 11:39 UTC (permalink / raw)
To: João Távora; +Cc: 50989
[-- Attachment #1: Type: text/plain, Size: 1898 bytes --]
On Sun, 3 Oct 2021 at 12:12, João Távora <joaotavora@gmail.com> wrote:
> On Sun, Oct 3, 2021 at 12:07 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
>> IMNSHO, this doesn't make much sense. That face exists for a reason:
>> to signal to the users that some innocently-looking characters aren't
>> what they look like.
>
> Eldoc's display facilities are only for displaying. Sure, you may want
> to copy text away from there, but I'd say that's rare. So it wouldn't
> be a problem
> in practice, unless I'm missing something
I agree -- this is for display only, in which case NBSP and space are
supposed to be indistinguishable. With the attached patch, if you copy
the text from the Eldoc buffer to some other buffer, the NBSPs are still
there so they will be displayed as such.
>> Why does the server return these NBSP characters? Would it make sense
>> to automatically convert them to spaces on input?
I don't know for sure what the thinking is in any particular server, but
there are sensible reasons why one might do this. Suppose, for
instance, that the client editor decides to refill the text before
displaying it. Then it might be relevant to add NBSPs at strategic
places, and removing them would produce strange results.
> That's also sweeping it under the rug. But I don't object either. Augusto, if
> you agree, match a patch to Eglot (this is where I presume the "input"
> Eli refers
> to lives). Of course the real input is the server, but I'd rather not
> go there, since
> there are so many and all are out of our control.
I don't know how to do this on the Eglot side, or at least not in a
simple manner: Eldoc callbacks take a string, not a buffer, as argument,
and Eldoc buffers are reused whenever possible.
So I've attached a patch implementing the simplistic solution. Feel
free to ignore it if this seems unsuitable.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Disable-nobreak-char-display-in-Eldoc-buffers.patch --]
[-- Type: text/x-patch, Size: 914 bytes --]
From cfac0d542c751eef49b3482701d400aa2d2e38b4 Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
Date: Sun, 3 Oct 2021 13:11:26 +0200
Subject: [PATCH] Disable 'nobreak-char-display' in Eldoc buffers
* lisp/emacs-lisp/eldoc.el (eldoc--format-doc-buffer): Set
'nobreak-char-display' to nil in Eldoc buffers
---
lisp/emacs-lisp/eldoc.el | 1 +
1 file changed, 1 insertion(+)
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 21f262adc6..a1c3c3268f 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -477,6 +477,7 @@ eldoc--format-doc-buffer
(let ((inhibit-read-only t)
(things-reported-on))
(erase-buffer) (setq buffer-read-only t)
+ (setq-local nobreak-char-display nil)
(local-set-key "q" 'quit-window)
(cl-loop for (docs . rest) on docs
for (this-doc . plist) = docs
--
2.31.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* bug#50989: 28.0.60; nobreak-char-display in Eldoc buffers
2021-10-03 11:39 ` Augusto Stoffel
@ 2021-10-05 9:13 ` Lars Ingebrigtsen
0 siblings, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2021-10-05 9:13 UTC (permalink / raw)
To: Augusto Stoffel; +Cc: 50989, João Távora
Augusto Stoffel <arstoffel@gmail.com> writes:
>> Eldoc's display facilities are only for displaying. Sure, you may want
>> to copy text away from there, but I'd say that's rare. So it wouldn't
>> be a problem
>> in practice, unless I'm missing something
>
> I agree -- this is for display only, in which case NBSP and space are
> supposed to be indistinguishable. With the attached patch, if you copy
> the text from the Eldoc buffer to some other buffer, the NBSPs are still
> there so they will be displayed as such.
I can see arguments for both ways of doing this -- "cleaning up" the
string before display, and fixing the display (as your patch is doing).
I think the main argument here -- that eldoc buffers are for display
only, so nbsp should be displayed as normal space -- is compelling,
though, so I've applied your patch to Emacs 28.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#50989: 28.0.60; nobreak-char-display in Eldoc buffers
2021-10-03 11:07 ` Eli Zaretskii
2021-10-03 11:12 ` João Távora
@ 2021-10-05 21:16 ` Richard Stallman
1 sibling, 0 replies; 8+ messages in thread
From: Richard Stallman @ 2021-10-05 21:16 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 50989, arstoffel, joaotavora
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> IMNSHO, this doesn't make much sense. That face exists for a reason:
> to signal to the users that some innocently-looking characters aren't
> what they look like. What you suggest above is to sweep the problem
> under the carpet. I think this is not TRT.
That feature is useful for text that you're editing.
But I don't think it is useful in a help string which is displayed
only for you to read. So I think it is good to suppress it for
help strings generally.
The only exception I can imagine would be if a doc string displays an
example of buffer or file contents containing a non-breaking space.
In principle, it would be good to make an exception for that case.
But I think that exceptional case would be difficult to detect
reliably. Also, since doc strings generally don't include examples of
buffer or file contents, I think that case will never actually occur.
So I think we can get away with ignoring it.
It is ever worth doing, we could create a kind of quoting to force a
real NBSP into the displayed help string.
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-10-05 21:16 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-03 10:02 bug#50989: 28.0.60; nobreak-char-display in Eldoc buffers Augusto Stoffel
2021-10-03 10:34 ` João Távora
2021-10-03 11:07 ` Eli Zaretskii
2021-10-03 11:12 ` João Távora
2021-10-03 11:25 ` Eli Zaretskii
2021-10-03 11:39 ` Augusto Stoffel
2021-10-05 9:13 ` Lars Ingebrigtsen
2021-10-05 21:16 ` Richard Stallman
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).