Subject: bug#50989: 28.0.60; nobreak-char-display in Eldoc buffers

From: Augusto Stoffel <[email-masked]>
Date: Sun, 03 Oct 2021 13:39:33 +0200

On Sun,  3 Oct 2021 at 12:12, João Távora <[email-masked]> wrote:

> On Sun, Oct 3, 2021 at 12:07 PM Eli Zaretskii <[email-masked]> 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.

>From cfac0d542c751eef49b3482701d400aa2d2e38b4 Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <[email-masked]>
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