Subject: bug#62606: [PATCH] function to align mode-line elements to right

From: [email-masked]
Date: Fri, 09 Jun 2023 13:47:55 +0100

On 2023-06-06 12:24, Eli Zaretskii wrote:
> No, I was talking about the case where the R part becomes longer.

I see now. So you're worried about the difference between these two:

|L|-------M-----|--R--|
  X              Foo Bar

|L|-------M---|---R---|
  X            Foo Barrr

And how `Foo' moves left in the second case. I understand.

>> I modelled my function on
>> `tab-bar-format-align-right', which works in a very similar way.
> 
> IMNSHO, that mopdel is not the ideal one.

I'm not sure what you mean? If you're talking about what the function
/does/, isn't this just a matter of preference? You might not like using
it, but I /do/ like it. I wanted a function which does exactly what that
function does, but for the modeline. I find the way it displays
information perfectly natural. Clearly enough other people also do that
the tab-bar equivalent was worth building and using. If you're talking
about the internals, could you explain a bit more?

> Yes.  But with left alignment the beginning of the text never moves,
> only the end.  With right alignment, the beginning moves.  It's
> jarring, IMO.

Right, I see. But that's only true of the text as a whole isn't it?
Consider a modeline with two constructs, FOO and BAR: '(FOO " " BAR).
Both are left aligned. Say FOO prints "foo" and BAR prints "bar", so we
have:

foo bar

If FOO now prints something longer (e.g. "foooooooo", the beginning of 
the
BAR part will move, thus:

foo bar
     ----->
foooooooo bar

So with left aligned text, sometimes the beginning (of some piece of
information) moves as well). This happens for real if FOO is something
like the buffer name -- BAR will move whenever we switch to a buffer
with a name of a different length. I think if people who want
left-aligned text can put up with this, then people who want
right-aligned text will probably put up with the equivalent problem.

In fact, it was precisely /because/ of this kind of situation, that I
originally wanted to right-align some of my information, so that it
/wouldn't/ move when elements to the left of it changed length. By
right-aligning, I can completely control the space between them.

Overall, I can see that this isn't a feature you like, and probably not
one you would use either, but it's similar enough (in function and in
problems) to other stuff already in Emacs that it seems pretty
reasonable to me.

best,

Hugo