Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc

From: João Távora <[email-masked]>
Date: Sat, 20 Jan 2024 21:12:22 +0000

On Sat, Jan 20, 2024 at 6:16 PM Eli Zaretskii <[email-masked]> wrote:
>
> > From: João Távora <[email-masked]>
> > Date: Sat, 20 Jan 2024 18:08:35 +0000
> > Cc: Eli Zaretskii <[email-masked]>, [email-masked]
> >
> > -(defun eldoc-minibuffer-message (format-string &rest args)
> > +(defvar eldoc--saved-mlf nil
> > +  "Saved `mode-line-format' used in `eldoc--minibuffer-message'.")
> > +(defun eldoc--minibuffer-message (format-string &rest args)
> >    "Display message specified by FORMAT-STRING and ARGS on the
> > mode-line as needed.
>
> Does this remove a function that existed before?  If so, please don't,
> since that function's name didn't include "--", so it was not an
> internal function.

The function eglot-minibuffer-message is a value for
eldoc-message-function and it's "external" indeed.  But not by
design rather by "status quo" -- i.e. because at the time it was
introduced, the '-- 'convention was not always observed.

The correct way to customize ElDoc's messaging outlet is to
set 'eldoc-message-function', the variable. That doesn't
require referencing the should-have-been-internal symbol.

> (I also find the tendency of using internal functions as values of
> variables that are clearly meant to be customized by modes to be
> undesirable.  They are not really internal functions.)

I see nothing wrong with it.

An internal symbol that designates a function means that:

1) you shouldn't call it, it's probably a bug if you do, and it
   unnecessarily constrains the development of the library.

2) you needn't refer to its value function value via (function <symbol>)
   or equivalent.

'eglot-minibuffer-message' verifies both.

1) The function is an alias to message except in certain situations
   where it will use the mode-line of a certain buffer chosen
   heuristically.  It is also a misnomer and the docstring

2) The recommended way to customize eldoc-message-function or
   other function-holding variables is not by 'setq' but rather
   'add-function'.  `setq` can be used if you intend to restore
   the old value.

But as you noted, because of this design mistake, I've noticed
a small number of modes do set it via 'setq'.  The correct way
would be to create an obsolete alias.  But if you don't want
to I won't insist, and we let this dirt persist.  There's
certainly much worse.

So Eshel, if you try my patch, remove the '--' from the
eldoc--minibuffer-message please.

João