GNU bug report logs - #62606
[PATCH] function to align mode-line elements to right

Previous Next

Package: emacs;

Reported by: hugo <at> heagren.com

Date: Sun, 2 Apr 2023 04:48:03 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: hugo <at> heagren.com
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 62606 <at> debbugs.gnu.org
Subject: bug#62606: [PATCH] function to align mode-line elements to right
Date: Mon, 05 Jun 2023 21:45:17 +0100
On 2023-05-06 15:39, Eli Zaretskii wrote:
> > > One possible issue with right alignment is that when the total size of
> > > the mode-line text changes (e.g., the mode lighter changes), the
> > > leftmost part of it will move horizontally, something that could be
> > > unpleasant and even annoying.
> >
> > This doesn't happen with my proposed setup (though I agree it would be
> > annoying if it did!). The user includes the symbol
> > `mode-line-format-right-align' in their mode line format. This is a
> > variable which holds a mode-line construct `(:> eval
> > (mode-line-format-right-align))'. So whenever the mode-line is reloaded
> > (and therefore, whenever the length could change), the space used to pad
> > the right-aligned part to the right is recalculated.
> 
> That recalculation is what I alluded to: the space will be different
> depending on the size of the mode-line text.

I confess I am very confused. Let's say we have a modeline like this,
with parts L (left-aligned), M (middle - displays as empty space) and R
(right-aligned):

|--L--|-------M-------|-R-|
Foo bar                 X

If L gets longer then:
- M will get shorter
- R will stay the same

So we get:
|--L-----|----M-------|-R-|
Foo barrrr              X

Is this what you're worried about? If so, I don't think it's much of a
cause for concern. I modelled my function on
`tab-bar-format-align-right', which works in a very similar way. It also
strikes me that something like this happens anyway already: if we have a
mode-line with just a left-aligned lighter, and the lighter gets longer 
(or
shorter), then the space between the end of the lighter and the edge of
the screen (i.e. M+R) gets smaller (or bigger). Isn't this to be 
expected?

If this isn't the effect you're worried about, could you explain in more
detail?

> > > Also, what happens if the mode-line text is longer than the window
> > > width. What are user expectations in that case, and does :align-to
> > > meet those expectations?
> >
> > Then the text overflows to the right.
> 
> I'm not sure everyone will agree with your expectations.

The only alternative I can think of is that the right-aligned part stay
visible, and the other text overflows 'behind' it. Personally I don't
think this would make much sense, but I can see that some people might
prefer it. I suppose the best thing to do would be to add an option to
control the behaviour, but I've had a look at the code and I have no
idea how to implement the other version---the current behaviour is what
happens by default and it just seemed right to me.

> > > This should use display-graphic-p, not window-system.
> >
> > Fixed.
> >
> > > Did you test this in a session which has both GUI and TTY frames?
> >
> > Yes, it behaves correctly (i.e. right-aligns in both, even when the
> > same buffer is simultaneously displayed in both).
> 
> And if then you delete all the GUI frames and only the TTY frames
> remain?

Same effect -- the right-aligned part is still right-aligned in the 
remaining
TTY frames.

Hope that helps.

Hugo




This bug report was last modified 1 year and 183 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.